akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) throws IOException {
		long s = System.currentTimeMillis();
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);

		Deque<Integer>[] A = new Deque[n + 1];		 // A[i] → i選手の対戦順リスト
		HashSet<Integer> players = new HashSet<>(); // 全試合終了してないｐのリスト
		for ( int r = 1; r <= n; r++ ) {
			players.add(r);
			A[r] = new ArrayDeque<Integer>();
			inputs = br.readLine().split(" ");
			for ( int c = 0; c < n - 1; c++ ) {
				A[r].push(Integer.parseInt(inputs[c]));
			}
		}

		int match = n * (n - 1) / 2;
		int days = 0;

		HashSet<Integer> todayDone = new HashSet<>(); // その日の試合が成立して除外された選手をここに入れる
		HashSet<Integer> toRemove = new HashSet<>(); // 全試合終了したｐ
		do {
			
			// 嘘解法 時間がかかるケースは日数＝試合数と推測
			long e = System.currentTimeMillis();
			if(e - s > 800) {
				System.out.print(n * (n - 1) / 2);
				br.close();
				return;
			}
			
			days++;
			todayDone.clear();
			toRemove.clear();

			// p:player opp:opponent
			for (Integer p : players ) {
              
				if ( todayDone.contains(p) ) continue;
				Integer opp = A[p].peek();
				if ( opp == null ) {
					toRemove.add(p);
					continue;
				}

				if ( todayDone.contains(opp) ) continue;
				Integer opps_opp = A[opp].peek();
				if ( opps_opp == null ) {
					toRemove.add(opp);
					continue;
				}

				// 対戦可能相手の対戦可能相手がｐだったら試合成立
				if ( p.equals(opps_opp) ) { // Integer(オブジェクト)型同士の比較はequalsでやる必要がある
					todayDone.add(A[p].pollFirst());
					todayDone.add(A[opp].pollFirst());
					match--;
				}
			}
			players.removeAll(toRemove);			
			
		} while ( todayDone.size() > 0);

		int result = (match == 0 ? days -1 : -1);
		System.out.println(result);
		br.close();
	}
}


Measured memory_bytes: 83072
#include <iostream>
#include <cstdio>

using namespace std;


int n;
int a[30][30];
int f[30][1<<21];
bool c[30][1<<21];
const long long mod = 1e9+7;

void inp()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
}


long long tryyy(int h, int m)
{
    if (h < 0) return 1;
    if (c[h][m]) return f[h][m];
    c[h][m] = true;
    long long tmp = 0;
    for (int i = 0; i < n; i++)
    if (((m >> i)&1)==1 && a[h][i]==1)
    {
        tmp = (tmp + tryyy(h-1, m - (1 << i)))% mod;
    }
    f[h][m] = tmp;
    return tmp;
}


int main()
{
    inp();
    cout << tryyy(n-1, (1 << n)-1);
    return 0;
}


Measured memory_bytes: 207104
#include<stdio.h>

int main(){
  int n,i,j,flag=1,w,c=0;
  int a[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    
    while(flag){
      flag=0;
    
      for(j=n-1;j>=i+1;j--){
      
        if(a[j]<a[j-1]){
	  w=a[j];
	  a[j]=a[j-1];
	  a[j-1]=w;
	  flag=1;
	  c++;
        }
	
      } 
 
    }
    
  }
  
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1) printf(" ");
  }
  
  printf("\n%d\n",c);

  return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 200012;
int k,n,a[MN];
int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> k >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = a[0] + k;
  int ans = k;
  for (int i = 0; i < n; i++) {
    int x = a[i], y = a[i+1];
    ans = min(ans, k-y+x);
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; }
const ll MAXN=200000+4;
ll fact[MAXN];
ll invfact[MAXN];
ll modexp(ll base, ll e) {
	ll ans = 1;
	while(e > 0) {
		if (e % 2 == 1) {
			ans = (ans * base) % MOD;
			e--;
		}
		else {
			base = (base*base) % MOD;
			e /= 2;
		}
	}
	return ans;
}
ll inv(ll x) {
	return modexp(x, MOD-2);
}
ll binom(ll n, ll k) {
	ll denom = (invfact[n-k]*invfact[k])%MOD;
	return (fact[n]*denom)%MOD;
}
ll grid(ll a, ll b) {
	return binom(a+b,b);
}
int main() {
	ios_base::sync_with_stdio(false);
	fact[0] = 1;
	for (ll x = 1; x < MAXN; x++) {
		fact[x] = (fact[x-1]*x)%MOD;
	}
	for (ll x = 0; x < MAXN; x++) {
		invfact[x] = inv(fact[x]);
	}
	ll h,w,a,b; scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
	ll c=w-b-1;
	ll ans=0;
	for (ll x=0;x<h-a;x++) {
		ll m1=grid(b,x);
		ll m2=grid(h-1-x,c-1);
		//printf("%lld * %lld. %lld %lld. %lld %lld.\n",m1,m2,b,x,h-1-x,c-1);
		ans+=(m1*m2)%MOD;
		ans%=MOD;
	}
	{
		ll m1=grid(b,h-a-1);
		ll m2=grid(a-1,w-b-1);
		//printf("%lld * %lld. %lld %lld. %lld %lld.\n",m1,m2,b,h-a-1,a-1,w-b-1);
		ans+=(m1*m2)%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n;
ll c,k,t[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n>>c>>k;
	REP(i,n) cin>>t[i];
	sort(t,t+n);
	ll cnt=1,ans=1,T=t[0];
	FOR(i,1,n) {
		if(T+k>=t[i]) {
			if(cnt+1<=c) cnt++;
			else cnt=1,ans++,T=t[i];
		}
		else {
			cnt=1,ans++,T=t[i];
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;

int N, K, A, B;
int main(){
	scanf("%d %d", &N, &K);
	for (int i = 1; i <= N; i++) {
		if (i % K == 0) {
			A++;
		}
		if (K % 2 == 0 && i % K == K/2) {
			B++;
		}
	}
	printf("%lld\n", 1ll*A*A*A + 1ll*B*B*B);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Cell {
	int length = 0;
	char c;
	int prev_i, prev_j;
	int i = 0, j = 0;
	bool operator<(const Cell cell) const{
		return length < cell.length;
	}
};	
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int S = s.length();
	int T = t.length();
	vector<vector<Cell>> dp(S + 1, vector<Cell> (T + 1));
	for(int i = 1; i <= S; ++i) {
		for(int j = 1; j <= T; ++j) {
			dp[i][j] = max({dp[i - 1][j], dp[i][j - 1]});
			if (dp[i - 1][j - 1].length + 1 > dp[i][j].length && s[i - 1] == t[j - 1]) {
				dp[i][j].length = dp[i - 1][j - 1].length + 1;
				dp[i][j].c = s[i - 1];
				dp[i][j].i = i;
				dp[i][j].j = j;
				dp[i][j].prev_i = dp[i - 1][j - 1].i;
				dp[i][j].prev_j = dp[i - 1][j - 1].j;
			} 
		}
	}
	int ST = s.length();
	int TT = t.length();
	string ans = "";
	for(int i = 0; i < dp[S][T].length; ++i) {
		ans += dp[ST][TT].c;
		int STT = dp[ST][TT].prev_i;
		int TTT = dp[ST][TT].prev_j;
		ST = STT;
		TT = TTT;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 211456
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define f first
#define s second
#define ss string
#define mp make_pair
#define pb push_back
#define p pair<int, int>
#define pp pair<int, p>
#define v vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<p>
#define vpp vector<pair<int, p>>
#define vv vector<v>
#define vvl vector<vl>
#define vvp vector<vp>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repa(i, a, n) for(int i = a; i <= (n); ++i)
#define repd(i, n) for(int i = n; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z'){
        cout << 'a';
    }
    else{
        cout << 'A';
    }
    return 0;
}   

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main(){
	int h,w;
	char s[52][52];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[j][i];
			if(s[j][i]=='.')s[j][i]='0';
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[j][i]!='#'){
				if(s[j+1][i]=='#')s[j][i]++;
				if(s[j-1][i]=='#')s[j][i]++;
				if(s[j][i+1]=='#')s[j][i]++;
				if(s[j][i-1]=='#')s[j][i]++;
				if(s[j+1][i+1]=='#')s[j][i]++;
				if(s[j+1][i-1]=='#')s[j][i]++;
				if(s[j-1][i+1]=='#')s[j][i]++;
				if(s[j-1][i-1]=='#')s[j][i]++;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<s[j][i];
		}
		cout<<endl;
	}
	return 0;	
}

Measured memory_bytes: 256
n = int(input())
s = input()

x = 0
max_x = 0

for i in range(n):
    if s[i] == 'I':
        x = x + 1
    elif s[i] == 'D':
        x = x - 1

    if x > max_x:
        max_x = x

print(max_x)



Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>

int main(void){
	int w[10], k[10], swap[1];
	int i, j;
	for (i = 0; i < 10; ++i){
		scanf("%d", &w[i]);
	}
	for (i = 0; i < 10; ++i){
		scanf("%d", &k[i]);
	}
	for (i = 0; i < 10; ++i){
		for (j = 0; j < 10-1; ++j){
			if (w[j] < w[j+1]){
				swap[0] = w[j];
				swap[1] = w[j+1];

				w[j] = swap[1];
				w[j+1] = swap[0];
			}
		}
	}
	for (i = 0; i < 10; ++i){
		for (j = 0; j < 10-1; ++j){
			if (k[j] < k[j+1]){
				swap[0] = k[j];
				swap[1] = k[j+1];

				k[j] = swap[1];
				k[j+1] = swap[0];
			}
		}
	}
	printf("%d %d\n", w[0]+w[1]+w[2], k[0]+k[1]+k[2]);
	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>
int main (){
  long int balls,blue,red,ans,rem;
  scanf("%ld%ld%ld",&balls,&blue,&red);
  rem=balls%(blue+red);
    if(rem<=blue)
      ans=(balls/(blue+red))*blue+rem;
  else ans=(balls/(blue+red))*blue+blue;
  printf("%ld",ans);
 return 0;
 }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  for(int i=0; i<N-1; i++){
    cin >> C.at(i);
  }
  int ans = 0;
  int a, b, c;
  for(int i=0; i<N-1; i++){
    a = A.at(i);
    b = B.at(a);
    ans += b;
    if(A.at(i+1)==a+1) ans += C.at(a);
  }
  ans += B.at(A.at(N-1));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<0){
		cout<<"No";
		return 0; 
	}
	if(4*a*b<(c-(a+b))*(c-(a+b))){
		cout<<"Yes";	
	}
	else {
		cout<<"No";	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define lli long long int 
using namespace std;

const int INF= 1e9 +5;
typedef std::vector<lli> vi;
typedef pair<int,int> ii;


const int mod=1e9 + 7;

void add_self(lli& a,lli b)
{
    a+=b;
    if(a>mod)
    {
        a-=mod;
    }
}


int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    int n=h,m=w;
    vector<string>v;
    while(h--)
    {
        string s;
        cin>>s;
        v.pb(s);
    }
   
    
   // lli ans=0;
   // dfs(v,0,0,&ans,n-1,m-1);
   
   vector<vi>dp(n+1,vi(m+1,0));
   dp[0][0]=1;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<m;j++)
       {
           if(v[i][j]=='.')
           {
               if(i!=n-1 && v[i+1][j]=='.'){
                  add_self(dp[i+1][j],dp[i][j]);

               }
               if(j!=m-1 && v[i][j+1]=='.'){
                  add_self(dp[i][j+1],dp[i][j]);

               }
              
           }
       }
   }
   lli ans=dp[n-1][m-1];
    ans=ans%mod;
    cout<<ans;
    
}

Measured memory_bytes: 9216
import sys
from math import sqrt

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    s = input()
    print(s.count("1"))
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

//------------------------------------------------------------------------------
const int N_MAX = 55555;

int prime[N_MAX];
bool is_prime[N_MAX + 1];

int sieve(int n) {
  int p = 0;
  fill(is_prime, is_prime + n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    prime[p++] = i;
    for (int j = i * 2; j <= n; j += i) is_prime[j] = false;
  }
  return p;
}

//------------------------------------------------------------------------------
int N;
int a[55];

void solve() {
  int M = sieve(55555);
  int k = 0;
  REP(i, M) {
    if (prime[i] % 5 == 1) {
      a[k++] = prime[i];
      if (k >= N) break;
    }
  }
  DUMP(a, N);
}

void input() {
  scanf("%d", &N);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);

int main() {
  #ifndef ONLINE_JUDGE
  ioso ffe
  #endif
  int f;
  cin >> f;
  int j = f%10;
  if(j==2 || j==4 || j==5 || j==7 || j==9) {
    cout << "hon\n";
  }
  else if(j==0 || j==1 || j==6 || j==8){
    cout << "pon\n";
  }
  else {
    cout << "bon\n";
  }
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    int a,i,n,cnt=0;
    cin>>n;
    for( i=0;i<n;i++)
    {
        cin>>a;

    while(a%2==0){

        a/=2;
        cnt++;
    }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author penguin_410
 *         Date: 2014/03/06
 */
public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String[] lines = br.readLine().split(" ");
            final int x = Integer.parseInt(lines[0]);
            final int y = Integer.parseInt(lines[1]);
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + " " + y : y + " " + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25088
#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define int long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define mod (int)(1e9+7)
#define T int
#define pi pair<int,int>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define setbit(n) __builtin_popcount(n)
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL)



int32_t main() {

	flash;
	cout << fixed;
	cout.precision(10);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n; cin >> n;
	string s;
	cin >> s;

	int i = 0, j = n - 1;
	int ans = 0;
	while (i < n &&  j >= 0 && i <= j) {

		while (i < n && s[i] == 'R')
			i++;


		while (j >= 0 && s[j] == 'W')
			j--;

		if (i < n && j >= 0 && i < j) {
			swap(s[i], s[j]);
			ans++;
		}
	}

	cout << ans << endl;

	return 0;

}







Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int lx = abs(tx-sx);
    int ly = abs(ty-sy);

    for(int i=0; i<lx; i++){
        cout << "R";
    }
    for(int i=0; i<ly; i++){
        cout << "U";
    }
    for(int i=0; i<lx; i++){
        cout << "L";
    }
    for(int i=0; i<ly; i++){
        cout << "D";
    }

    cout << "D";
    for(int i=0; i<lx+1; i++){
        cout << "R";
    }
    for(int i=0; i<ly+1; i++){
        cout << "U";
    }
    cout << "L";
    cout << "U";
    for(int i=0; i<lx+1; i++){
        cout << "L";
    }
    for(int i=0; i<ly+1; i++){
        cout << "D";
    }
    cout << "R" << endl;;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int X, Y, Z, K;
vector<long long> a, b, c;
bool solve(long long P) {
  int cnt = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      for (int k = 0; k < Z; k++) {
        if (a[i] + b[j] + c[k] < P) break;
        cnt++;
        if (cnt >= K) return true;
      }
    }
  }
  return false;
}

int main() {
  cin >> X >> Y >> Z >> K;

  long long tmp;
  for (int i = 0; i < X; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  for (int i = 0; i < Y; i++) {
    cin >> tmp;
    b.push_back(tmp);
  }
  for (int i = 0; i < Z; i++) {
    cin >> tmp;
    c.push_back(tmp);
  }
  sort(a.begin(), a.end(), greater<long long>());
  sort(b.begin(), b.end(), greater<long long>());
  sort(c.begin(), c.end(), greater<long long>());

  long long ok = 0;
  long long ng = 30000000000;

  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (solve(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
    // cout << "ok:" << ok << "\tng:" << ng << endl;
  }
  vector<long long> ans;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      for (int k = 0; k < Z; k++) {
        if (a[i] + b[j] + c[k] < ng - 1) break;
        ans.push_back(a[i] + b[j] + c[k]);
      }
    }
  }
  if (ans.size() < K) {
    for (int i = 0; i < K - ans.size(); i++) ans.push_back(ng - 1);
  }
  sort(ans.begin(), ans.end(), greater<long long>());
  for (int i = 0; i < K; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 133224
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i%2 == 0 && s[i] == 'L') {
            cout << "No";
            return 0;
        }

        if (i%2 != 0 and s[i] == 'R') {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <math.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll sum = 0;
    rep(m, 1, (ll)sqrt(n) + 1)
    {
        if (n % m == 0)
        {
            ll a = m - 1;
            if (a != 0 && n / a == n % a)
                sum += a;
            ll b = n / m - 1;
            if (a != b && b != 0 && n / b == n % b)
                sum += b;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,H,W=MI()
    ans=0
    for i in range(N):
        a,b=MI()
        if a>=H and b>=W:
            ans+=1
            
    print(ans)

main()


Measured memory_bytes: 64052
#include <bits/stdc++.h>
using namespace std;

void DrawEvenLine(int num)
{
    for (int i = 1; i < num+1; i++)
    {
        if(i%2==1)
        {
            cout << ".";
        }else
        {
            cout << "#";
        }
        //Junsang****if(i==num) cout << endl;
    }
}

void DrawOddLine(int num)
{
    for (int i = 1; i < num+1; i++)
    {
        if(i%2==1)
        {
            cout << "#";
        }else
        {
            cout << ".";
        }
        //Junsang****if(i==num) cout << endl;
    }
}

void DrawChessboard(int x, int y)
{
    for (int i = 1; i < x+1; i++)
    {
        if(i%2==1) DrawOddLine(y);
        if(i%2==0) DrawEvenLine(y);
        if(i<x) cout << endl;
    }

}

int main(int argc, char* argv[])
{

    int x, y;
    int line = 1;
    vector<pair<int,int>> variables;
    while(1)
    {
        cin >> x >> y;
        variables.push_back(make_pair(x, y));
        if(x==y && x==0) break;
    }


    for (auto var : variables)
    {
        if(var.first==var.second && var.first==0) break;
        DrawChessboard(var.first, var.second);
        cout << endl;
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))

using namespace std;
//using namespace boost::multiprecision;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int x[105];
int y[105];

int main(void){
    int W, H, N;
    cin >> W >> H >> N;
    int sikaku[4] = {0, W, 0, H};
    for (int i = 0; i < N; i++){
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1){
            sikaku[0] = sikaku[0]<x?x:sikaku[0]; 
        }
        if (a == 2){
            sikaku[1] = sikaku[1]>x?x:sikaku[1];
        }
        if (a == 3){
            sikaku[2] = sikaku[2]<y?y:sikaku[2];
        }
        if (a == 4){
            sikaku[3] = sikaku[3]>y?y:sikaku[3];
        }
    }
    W = (sikaku[1]-sikaku[0]);
    H = (sikaku[3]-sikaku[2]);
    if (W >= 0 && H >= 0){
        cout << W*H << endl;
    }else{
        cout << 0 << endl;
    }

}



Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = [i*j for i in range(1,10) for j in range(1,10)]
print('Yes' if N in A else 'No')


Measured memory_bytes: 61400
#include<bits/stdc++.h>

using namespace std;

int a[100000];


int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int sum = 0, minn = 0x3f3f3f3f;
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
		minn = min(a[i], minn);
	}
	int ans = n;
	m -= sum;
	printf("%d\n", ans + m / minn);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s; cin >> s;
    int len = s.length();
    int c = 0;
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> l4;
typedef long double ld;
typedef pair<ld,ld> ldd;
const ld pi = acosl(-1);
const int maxn = 100010;
const ll mod = 998244353;
const ll inf = 1e18;
const ld eps = 1e-10;
int k,a[maxn];

int main() {
    scanf("%d",&k);
    rep(i, 0, k) scanf("%d",a+i);
    ll L = 2, R = 2;
    per(i, 0, k) {
        ll l = (L+a[i]-1)/a[i]*a[i];
        ll r = R/a[i]*a[i];
        if (l > r) {
            printf("-1");
            return 0;
        }
        L = l, R = r+a[i]-1;
    }
    printf("%lld %lld",L,R);
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define long long int
int32_t main()
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int now=0;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
			now++;
	}
	int ans=min(n-1,now+2*k);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;

vector<bool> seen;
vector<vector<int>> g;

void dfs(int v) {
  seen[v] = true;
  for (auto next_v : g[v]) {
    if (seen[next_v]) continue;
    dfs(next_v);
  }
}
int main() {
  int n,m;
  cin >> n>>m;
  g.resize(n);
  seen.assign(n, false);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  rep(i, n) {
    if (seen[i]) continue;
    dfs(i);
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11756
// ABC 087 C
#include <iostream>

const int MAX_N = 100;

int main() {
	int N;
	int A[2][MAX_N];
	std::cin >> N;
	for(int y = 0; y < 2; y++) {
		for(int x = 0; x < N; x++) {
			std::cin >> A[y][x];
		}
	}

	// score[i]はA(i,1)で降りる場合
	int score[MAX_N];
	for(int i = 0; i < N; i++) {
		score[i] = 0;
	}
	for(int px = 0; px < N; px++) {
		// 上段
		for(int x = 0; x <= px; x++) {
			score[px] += A[0][x];
		}
		// 下段
		for(int x = px; x < N; x++) {
			score[px] += A[1][x];
		}
	}

	int max = 0;
	for(int i = 0; i < N; i++) {
		if(score[i] > max) {
			max = score[i];
		}
	}

	std::cout << max << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

// 1indexed2dimention[]
class bit2d{
    public:
    vector<vector<ll> >v;
    ll h, w;
    bit2d(ll H = 0, ll W = 0){
        h = H + 5;
        w = W + 5;
        v = vector<vector<ll> >(h + 5, vector<ll>(w + 5, 0));
    }
    void add(ll x, ll y, ll val){
        for(ll yy = y; yy <= h; yy += yy & -yy){
            for(ll xx = x; xx <= w; xx += xx & -xx){
                v[yy][xx] += val;
            }
        }
    }
    ll sum_of_1_to_idx(ll x, ll y){
        if(x <= 0 || y <= 0)return 0;
        if(x > w || y > h)return 0;
        ll s = 0;
        for(ll yy = y; yy > 0; yy -= yy & -yy){
            for(ll xx = x; xx > 0; xx -= xx & -xx){
                s += v[yy][xx];
            }
        }
        return s;
    }
    ll sum(ll x1, ll y1, ll x2, ll y2){
        ll s = 0;
        s += sum_of_1_to_idx(x2, y2);
        s -= sum_of_1_to_idx(x2, y1 - 1);
        s -= sum_of_1_to_idx(x1 - 1, y2);
        s += sum_of_1_to_idx(x1 - 1, y1 - 1);
        return s;
    }
};

int main(){

	ll H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H % h == 0 && W % w == 0){
		cout << "No" << endl;
		return 0;
	}
	bit2d bit(H, W);
	rep1(y, H)rep1(x, W){
		ll pre_y = y - h + 1;
		ll pre_x = x - w + 1;
		if(pre_x < 1 || pre_y < 1)bit.add(x, y, 3000);
		else{
			ll sum = bit.sum(pre_x, pre_y, x, y);
			bit.add(x, y, -(sum + 1));
		}
	}
	if(bit.sum(1, 1, W, H) <= 0)cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		rep1(y, H){
			rep1(x, W){
				cout << bit.sum(x, y, x, y);
				if(x < W)cout << " ";
				else cout << endl;
			}
		}
	}

    return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int kaisu = 5;
		int[] num = new int[kaisu];

		for(int i = 0; i < kaisu ; i++) {
			num[i] = scan.nextInt();
		}

		int wp = num[2]+num[4];
		int wm = num[2]-num[4];
		int hp = num[3]+num[4];
		int hm = num[3]-num[4];

		if(num[0] < wp | 0 > wm ) {
			System.out.println("No");
		}else if(num[1] < hp | 0 > hm) {
			System.out.println("No");
		}else System.out.println("Yes");
	}
}

Measured memory_bytes: 17356
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;
VL(a);
multiset<ll> st;

signed main() {
    LCIN(N, D);
    ll ans = N / (2 * D + 1);
    ans += (N % (2 * D + 1) != 0 ? 1 : 0);
    cout << ans << "\n";
}


Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextCharArray();
  var output = 0;
  for(var i = 0; i < 1000; i++){
    var key = myconv(("000" + i.toString()).slice(-3),6);
    //myerr(key);
    var first = false;
    var second = false;
    var third = false;
    for(var j = 0; j < N; j++){
      if(!first && list[j] == key[0]){
         first = true;
         continue;
      }
      if(first && !second && list[j] == key[1]){
         second = true;
         continue;
      }
      if(!third && second && list[j] == key[2]){
         third = true;
         break;
      }
    }
    if(third){
       output++;
    }
  }
  myout(output);
}

Measured memory_bytes: 10024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

	
const ll oo = 1e15;
const int maxn  = 1e6;
int N;
void test_case(){
	cin >> N;
	vector<int> v(N);
	for(int & el :v)
		cin >> el;
	vector<ll> dp(maxn,oo);
	dp[0] = 0;
	for(int i = 0;i<N;++i){
		dp[i+1] = min(dp[i+1],dp[i] + (ll)abs(v[i] - v[i+1]));
		dp[i+2] = min(dp[i+2],dp[i] + (ll)abs(v[i] - v[i+2]));
	}
	cout << dp[N-1] << endl;
}

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int h, a;
  cin >> h >> a;
  int t = h / a;
  if (h % a != 0) t += 1;
  cout << t << endl;
}

Measured memory_bytes: 256
// Problem : B - Greedy Takahashi
// Contest : AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  long long a;
  long long b;
  long long k;
  cin >> a >> b >> k;
  
  long long min_one = min(a, k);
  
  a -= min_one;
  k -= min_one;
  
  min_one = min(b, k);
  
  b -= min_one;
  k -= min_one;
  
  cout << a << ' ' << b;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <unordered_set>
#include <cassert>
#include <array>
#include <random>
#include <iomanip>
#include <math.h>
#include <stack>
#include <bitset>

using namespace std;

typedef long long ll;

const int INF = 1000000010;
const ll INFLL = 1000000000000000010;
const int LOGN = 16;
const int N = 1000010;
const int K = 101;

mt19937 gen(29);

string s;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("Test.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			++ans;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n,i,j;
    int w[110];
    int min = 100000;
    int sum1=0,sum2=0;

    scanf("%d",&n);
    for(i = 1 ; i <= n ; i++){
        scanf("%d",&w[i]);
    }
    for(i = 1 ; i <= n ; i++){
        sum1 = 0;
        sum2 = 0;
        for(j = 1 ; j <= i ; j++){
            sum1 += w[j];
        }
        for(j = i+1 ; j <= n ; j++){
            sum2 += w[j];
        }
       // printf("%d %d\n",sum1, sum2);
        if(min > abs(sum1-sum2)){
            min = abs(sum1-sum2);
        }

    }
    printf("%d\n",min);



    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        while(sc.hasNext()){
            String[] line = sc.nextLine().split(" ");
            int W = Integer.parseInt(line[0]);
            int H = Integer.parseInt(line[1]);
            int x = Integer.parseInt(line[2]);
            int y = Integer.parseInt(line[3]);
            int r = Integer.parseInt(line[4]);
            boolean x_range = ((x >= r) && (x <= W-r));
            boolean y_range = ((y >= r) && (y <= H-r));
 
            if(x_range && y_range ){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;

int main(){
	int x,y;
  bool flag = 0;
  cin >> x >> y;
  for(int i = 0; i < 105; i++){
    for(int j = 0; j < 105; j++){
      if(i * 2 + j * 4 == y && i + j == x){
        flag = 1;
      }
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3612
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"math"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	x := make([]int, n)
	y := make([]int, n)

	for i := 0; i < n; i++ {
		x[i], y[i] = scanInt(), scanInt()
	}

	ans := float64(0)

	c := float64(1)

	for i := 1; i < n; i++ {
		c *= float64(i)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i != j {
				ans += math.Sqrt(float64(dist(x[i],y[i],x[j],y[j])))/float64(n)
			}
		}
	}

	fmt.Println(ans)
}

func dist(x1,y1,x2,y2 int) int {
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;
int f=0;
int seedis(int x,int *arr,long long *dis)
{
    if(arr[x]==0) return dis[x];
    else return seedis(arr[x],arr,dis) + dis[x];
}
int seef(int l,int *arr,long long *dis)
{
    if(arr[l]==0) return l;
    int a1=arr[l];
    int a2=seef(arr[l],arr,dis);
    arr[l]=a2;
    dis[l]=dis[l]+dis[a1];
    return a2;
}
void hebing(int l,int r,int d,int *arr,long long *dis)
{
    int lf=seef(l,arr,dis);
    int rf=seef(r,arr,dis);
    if(rf==lf)
    {
        if(seedis(r,arr,dis)-seedis(l,arr,dis)!=d)
            f=1;
        return;
    }
    arr[rf]=lf;
    dis[rf]=seedis(l,arr,dis)+d-seedis(r,arr,dis);
}
int main()
{
    int n,m;
    int arr[100500];
    long long dis[100500];
    cin>>n>>m;
    int l,r,d;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&l,&r,&d);
        hebing(l,r,d,arr,dis);
        if(f==1) break;
    }
    if(f) cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let mut ans = String::new();
    for c in s.chars() {
        match c {
            '0' => ans.push('0'),
            '1' => ans.push('1'),
            _ => { ans.pop(); },
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int A,B;
  A=a.size(),B=b.size();
  if(a[A-1]==b[0]&&b[B-1]==c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() 
{
    int N;
    cin >> N;
    int sum = 0;
    int aaa = 999;
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
        sum += S[i];
        if (S[i] % 10 != 0) {
            aaa = min(aaa, S[i]);
        }
    }
    if (sum % 10 == 0) {
        if (aaa == 999) {
            cout << 0 << endl;
            return 0;
        }
        cout << sum - aaa << endl;
    }else{
        cout << sum << endl;
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  long long int n, n1;
  long long int i;
  long long int min = 9999999999999, sum = 0;
  cin >> n;
  n1 = sqrt(n);
  
  for(i = 1; i <= n1; i++){
    if(n % i == 0){
      sum = i + n / i - 2;
      if(min > sum){
        min = sum;
      }
    }
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define rep(i,n) for(int64_t i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr int64_t INF=(1ll<<60);
constexpr int64_t mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll a,b;cin>>a>>b;
    if(a<=b){
        rep(i,b){
            cout<<a;
        }
        cout<<endl;
    }else{
        rep(i,a){
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3448
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

int main(){fastio
    
    ll a,b,c,k;cin>>a>>b>>c>>k;
    
    if(a+b>=k){
        cout<<min(k,a)<<endl;
    }else{
        k-=(a+b);
        cout<<a-k<<endl;
    }
    return 0;
}




Measured memory_bytes: 3652
import math

n, k = map(int, input().split())
a = 0
ans = 0.0
for i in range(1,n+1):
    if i*2 < k:
        a = math.log2(k/i)  # 何回勝てばいいか
        c = math.ceil(a)
        b = float(1/n)
        d = (1.0/2.0) ** c
        ans += b*d

    elif i < k < i*2:
        ans += float(1/n)*0.5

    else:
        b = float(1/n)
        ans += b*1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N , M ; cin >> N >> M ;
  vector<pair<ll,ll> > stu, che;

  rep(i,N){
    ll a, b ; cin >> a >> b ;
    stu.pb(mp(a,b));
  }
  rep(i,M){
    ll c,d ; cin >> c >> d ;
    che.pb(mp(c,d));
  }
  ll dis[100][100]; //dis[stu][che] : stu -> che

  rep(i,N)rep(j,M){
    ll x1 = stu[i].first, y1 = stu[i].second;
    ll x2 = che[j].first, y2 = che[j].second;
    dis[i][j] = (abs(x1-x2) + abs(y1-y2));
  }

  pair<ll,ll> ans[100] ;// [index][distance] : 

  rep(i,100){
    ans[i].first = 0, ans[i].second = 1e9;
  }
  rep(i,N){
    rep(j,M){
      if(dis[i][j] < ans[i].second) {
	ans[i].first = j;
	ans[i].second = dis[i][j];
      }
      
    }
  }
  rep(i,N){
    cout << ans[i].first+1 << endl;
  }
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256