akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int N;
    int* monsters;
    char* buffer;
    if (scanf("%d ", &N) != EOF) {
        buffer = malloc(sizeof(char)*N*11+1);
        monsters = malloc(sizeof(int)*N);
        if (fgets(buffer, N*11+1, stdin) != NULL) {
            monsters[0] = atoi(strtok(buffer, " "));
            for (int i = 1; i < N; i++) {
                monsters[i] = atoi(strtok(NULL, " "));
            }
        } else {
            free(buffer);
            free(monsters);
            fprintf(stderr, "[x] fgets() error.\n");
            return 1;
        }
    } else {
        fprintf(stderr, "[x] scanf() error.\n");
        return 1;
    }
    int end;
    int min_index;
    while (1) {
        end = 1;
        for (int i = 0; i < N; i++) {
            if (monsters[i] != 0) {
                min_index = i;
                break;
            }
        }
        for (int i = 0; i < N; i++) {
            if (monsters[i] != 0 && monsters[i] < monsters[min_index]) {
                min_index = i;
            }
        }
        for (int i = 0; i < N; i++) {
            if (i != min_index && monsters[i] != 0) {
                monsters[i] = monsters[i] % monsters[min_index];
                end = 0;
            }
        }
        if (end) break;
    }
    printf("%d", monsters[min_index]);
    free(buffer);
    free(monsters);
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
	string a, b, c;
	cin >> a >> b >> c;

	cout << char(toupper(a[0])) << char(toupper(b[0])) << char(toupper(c[0])) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		for(int i=0;i<n;i++){
			int x=s.nextInt();
			System.out.println("Case "+(i+1)+":");
			for(int j=0;j<10;j++){
				x*=x;
				String str=String.format("%08d",x);
				x=Integer.parseInt(str.substring(2, 6));
				System.out.println(x);
			}
		}
	}
	

}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;



int main(){
	
	int n;
	while(1){
		cin>>n;
		if(n==0)return 0;
		string h[100]={};
		string w[100]={};
		int m=0;
		for(int i=0;i<n;i++){
			string g;
			cin>>g;
			h[i]+=g[0];
			for(int j=1;j<g.size();j++){
				if(g[j-1]=='a'||g[j-1]=='i'||g[j-1]=='u'||g[j-1]=='e'||g[j-1]=='o')h[i]+=g[j];

			}
			int y=h[i].size();
			m=max(m,y);
			w[i]+=g[0];
		}
		int x=1;bool f=0,F=0;
		while(1){
		
		set<string>r;
		for(int i=0;i<n;i++){

			r.insert(w[i]);
			if(x<h[i].size())w[i]+=h[i][x];
			//else f=1;
		}
		
		if(r.size()==n){F=1;break;}
		//if(f)break;
		x++;
		
		if(x>m){f=1;break;}
		}
		if(F)cout<<x<<endl;
		else cout<<"-1"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a[4][N],b[N],c[N],A,B;
void M(int x,int *a){ while(x<=n) a[x]^=1,x+=(x&(-x));}
int Q(int x,int *a){ int s=0; while(x) s^=a[x],x-=(x&(-x)); return s;}
void GG(){ printf("No"); exit(0);}
int main()
{
	int i,p;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[1][i]);
	for(i=1;i<=n;i++) scanf("%d",&a[2][i]);
	for(i=1;i<=n;i++) scanf("%d",&a[3][i]);
	for(i=1;i<=n;i++){
		p=(a[1][i]-1)/3;
		if((a[2][i]-1)/3!=p) GG();
		if((a[3][i]-1)/3!=p) GG();
		if((a[1][i]-1)%3==1) GG();
		if((a[3][i]-1)%3==1) GG();
		if(i&1) b[(a[1][i]+2)/3]=1;
		if((a[1][i]-1)%3==2){
			if(i&1) A^=1; else B^=1;
		  }
	  }
	for(i=1;i<=n;i++) if((i&1)&&!b[i]) GG();
	memset(b,0,sizeof(b));
	for(i=1;i<=n;i++){
		p=(a[1][i]+2)/3;
		if(i&1) B^=Q(n-p+1,b),M(n-p+1,b);
		else A^=Q(n-p+1,c),M(n-p+1,c);
	  }
	if(A+B==0) printf("Yes");
	else printf("No");
	return 0;
}


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

const ll mod = 1e9+7;

ll find_ans(ll n,ll b){
    if(n/b==0){
        return n;
    }
    return n%b + find_ans(n/b,b);
}

int main() {

    ll n;
    cin>>n;
    ll s;
    cin>>s;
    // cout<<1<<" ";
    for(ll i=2;i*i<=n;i++){
        if(find_ans(n,i)==s){
            cout<<i<<endl;
            return 0;
        }
    }
    
    // Case when b>sqrt(n)
    // Now b must be one of the divisors of (n-s)   
    ll c=n-s;
    if(n<s){
        cout<<-1<<endl;
        return 0;
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    ll ans=1e18;
    for(ll i=1;i*i<=c;i++){
        if(c%i==0){
            bool flag=false;
            if(i!=1)
                if(find_ans(n,i)==s){
                    ans=min(ans,i);
                    flag=true;
                }
            if(find_ans(n,c/i + 1)==s){
                ans=min(ans,c/i + 1);
            }
        }
    }
    
    if(ans==1e18){
        cout<<-1<<endl;
    }
    else{
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 256
import math
import sys

sys.setrecursionlimit(10 ** 7)


x, y = map(int, input().split())
mod = 10 ** 9 + 7

fac = [1]
caf = [1]


def pow(n, p):
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod


n = (x + y) // 3 + 10

for i in range(1, n):
    fac.append((fac[i - 1] * i) % mod)
    caf.append(pow(fac[i], mod - 2))


def ncr(n, r):
    if n < r or r < 0:
        return 0
    return (fac[n] * caf[r] * caf[n - r]) % mod


if (x + y) % 3 != 0:
    print(0)
else:
    n = (x + y) // 3
    r = (2 * x - y) // 3
    print(ncr(n, r))



Measured memory_bytes: 121820
N = int(input())
AB = []
answer = "Yes"
time = 0
for i in range(N):
    x = list(map(int, input().split()))
    AB.append(x)
AB = sorted(AB,key=lambda x:x[1])
for i in range(N):
    time += AB[i][0]
    if(time > AB[i][1]):
        answer = "No"
        break
print(answer)

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	string s;
	h >> s;
	lli temp = 0;
	fit(it, s)
		temp = temp + (*it - '0');
	g << (temp % 9 == 0 ? "Yes" : "No");

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 3768
a, b = map(int, input().split())

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z

lcm = a * b / gcd(a, b)
print(int(lcm))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#define ll long long
using namespace std;
map<int,ll>mp;
char s[200010];
int main()
{
    scanf("%s",s);
    ll l=strlen(s);
    for(int i=0;i<l;i++)
        mp[s[i]-'a']++;
    ll ans=(l-1)*l/2;
    for(int i=0;i<=25;i++)
    {
        if(mp[i])
            ans-=(mp[i]-1)*mp[i]/2;
    }
    printf("%lld\n",ans+1);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
        char s[4];

        scanf("%s",s);

        if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) printf("Yes\n");
        else if(s[0]==s[2] && s[2]!=s[1] && s[1]==s[3]) printf("Yes\n");
        else if(s[0]==s[3] && s[3]!=s[1] && s[1]==s[2]) printf("Yes\n");
        else printf("No\n");
        return 0;
}


Measured memory_bytes: 128
a = []

def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1, 10):
    dfs(i)
a = sorted(a)
k = int(input())
print(a[k-1])

Measured memory_bytes: 8512
n, m = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(m)]
cnt = [0]*(n+1)
IDs = {}
for p, y in sorted(L, key = lambda x: x[1]):
    cnt[p] += 1
    
    # Yをkey, IDがvalueとなるように辞書型で格納.
    IDs[y] = '%06d%06d' % (p, cnt[p])
for _, y in L:
    print(IDs[y])

Measured memory_bytes: 32952
A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]

for i in range(0,N):
    for j in range(9):
        if B[i] ==  A[j]:
            A[j] = 0

if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or  A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0 :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
[N,K] = list(map(int,input().split()))
h = []
for i in range(N):
    h.append(int(input()))

h.sort(reverse=True) 

out = 10**9

L = 0
R = K-1
while R<=N-1:
    D = h[L]-h[R]
    if out > D:
        out = D
    L+=1
    R+=1
print(out)

Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define fin ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{fin;
  int n,i;
  cin>>n;
  int a[n],dp[n];
  memset(dp,0,n);
  for(i=0;i<n;i++)
    cin>>a[i];
  dp[n-1]=0;
  dp[n-2]=abs(a[n-1]-a[n-2]);
  for(i=n-3;i>=0;i--)
    dp[i]=min(dp[i+1]+abs(a[i+1]-a[i]),dp[i+2]+abs(a[i+2]-a[i]));
  cout<<dp[0]<<"\n";
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    int sum = accumulate(ALL(A), 0);
    double min = (double)sum / (4*M);

    int select = count_if(ALL(A), [min](int i) { return i >= min; });
    if (select >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    int L;
    cin >> L;
    int next[N][20];
    rep(i, N){
        next[i][0] = upper_bound(all(x), x[i]+L)-x.begin()-1;
    }
    rep(j, 19){
        rep(i, N){
            next[i][j+1] = next[next[i][j]][j];
        }
    }
    int Q;
    cin >> Q;
    while(Q--){
        int u, v; cin >> u >> v; u--, v--;
        if(u > v) swap(u, v);
        int ans = 1;
        rep3(j, 19, 0){
            if(next[u][j] < v) u = next[u][j], ans += (1<<j); 
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 11432
import java.util.*;
public class Main { 
	public static int[] list;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			list = new int[10];
			for(int j = 0; j < 10; j++) {
				list[j] = stdIn.nextInt();
			}
			if(solv(0,0,0)) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	
	public static boolean solv(int lastL, int lastR, int c) {
		if(c == 10) return true;
		int a = list[c];
		if(lastL < a && solv(a,lastR,c+1)) {
			return true;
		}
		if(lastR < a && solv(lastL,a,c+1)) {
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 18152
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

#define GOAL 10
#define START 0
#define WALL -1

class State{
public:
  int x,y;
  int cost;
  bool left;

  State(){}
  State(int _x,int _y,int _cost,bool _left){
    x = _x;
    y = _y;
    cost = _cost;
    left = _left;
  }

  bool operator<(const State &st)const{
    return cost > st.cost;
  }
};

int w,h;
int t[62][62];

int dx[2][9] = {
  {1,1,1,1,1,2,2,2,3},
  {-1,-1,-1,-1,-1,-2,-2,-2,-3}
};

int dy[2][9] = {
  {-2,-1,0,1,2,-1,0,1,0},
  {-2,-1,0,1,2,-1,0,1,0},
};


int main(){
  while(cin>>w>>h,w||h){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        char ch;
        cin>>ch;

        if(ch == 'T'){
          t[i][j] = GOAL;
        }
        else if(ch == 'S'){
          t[i][j] = START;
        }
        else if(ch == 'X'){
          t[i][j] = WALL;
        }
        else{
          t[i][j] = ch - '0';
        }
      }
    }

    priority_queue<State> open;
    bool closed[62][62][2];
    memset(closed,0,sizeof(closed));

    for(int i=0;i<w;i++){
      if(t[h-1][i] == START){
        open.push(State(i,h-1,0,true));
        open.push(State(i,h-1,0,false));
      }
    }

    bool goal = false;

    while(!open.empty()){
      State st = open.top(); open.pop();
      if(closed[st.x][st.y][st.left]) continue;
      closed[st.x][st.y][st.left] = true;

      if(t[st.y][st.x] == GOAL){
        cout<<st.cost-GOAL<<endl;
        goal = true;
        break;
      }

      for(int i=0;i<9;i++){
        int nx = st.x + dx[st.left][i];
        int ny = st.y + dy[st.left][i];

        if(0 <= nx && nx < w && 0 <= ny && ny < h && t[ny][nx] != WALL){
          open.push(State(nx,ny,st.cost+t[ny][nx],!st.left));
        }
      }
    }
    if(!goal) cout<<"-1\n";
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
long long x, y;

int main(){
	scanf("%lld", &x);
	long long n = 2 * x; 
	for(int i = 1; i <= 1e5; i++)
		if(i * (i + 1) >= n){
			y = i;
			break;
		}
	printf("%lld", y);
}

		

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		while(true){
			int n = sc.nextInt();
			if(n==0){
				break;
			}
			int[] num = new int[26];
			String y = sc.nextLine();
			String x = sc.nextLine();
			String[] s = x.split("[\\s]+");
			for(int i=0;i<n;i++){
				// vote
				num[(int)s[i].charAt(0)-(int)'A']++;
				
				// max search
				int max = 0;
				int now = 0;
				for(int j=0;j<26;j++){
					if(max<num[j]){
						max = num[j];
						now = j;
					}
				}

				// judge
				boolean judge = true;
				for(int j=0;j<26;j++){
					if(now == j){
						continue;
					}
					if(max<=num[j]+n-i-1){
						judge = false;
						break;
					}
				}

				// output
				if(judge){
					System.out.println(alphabet.charAt(now)+" "+(i+1));
					break;
				}
				else if(i==n-1){
					System.out.println("TIE");
				}
			}
		}
	}
}

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

int main() {
	int num, in, min = 2147483647, max = -2147483647;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> in;
		if (max < in - min) max = in - min;
		if (min > in) min = in;
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a=0,b=0,k=0;cin>>a>>b>>k;
    int c=1;
    while(c<=k){
        if(c%2==1)
        {
            a=a/2;
            b=b+a;
        }
        else{
            b=b/2;
            a=a+b;
        }
        c++;
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

D=min(A+B,2*C)

price=min(X,Y)*D

Z=max(X,Y)-min(X,Y)

if X>Y:
   price+=Z*min(A,2*C)
elif X<Y:
   price+=Z*min(B,2*C)

print(price)

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

int main() {
    string s;
    cin >> s;
    ll a[4];
    for (int i = 0; i < 4; i++){
        a[i] = s[i] - '0';
    }

    for (int bit = 0; bit < (1 << 3); bit++){
        ll hoge = a[0];
        for (int i = 0; i < 3; i++){
            if(bit & (1<<i)){
                hoge += a[i + 1];
            }
            else
            {
                hoge -= a[i + 1];
            }
        }
        if(hoge == 7){
          for (int i = 0; i < 4; i++){
            cout << a[i];
            if(i !=3){
              if (bit & (1 << i)) cout << "+";
              else cout << "-";
            }
          }
          cout << "=7" << endl;
          return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) { os << p.first << " " << p.second; return os; }

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N = 5;
	int r = 0;
	vector<int>v(N); rep(i, 0, N) { cin >> v[i]; chmax(r, (10 - v[i] % 10) % 10); v[i] += (10 - v[i] % 10) % 10; }
	dump(v);
	cout << accumulate(all(v), 0ll)-r << endl;

	return 0;
}


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

int main()
{
	int n,i,a[100001],b[100001],c[100001],dp[100001][4];cin>>n;
	
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	dp[n][1]=a[n];
	dp[n][2]=b[n];
	dp[n][3]=c[n];
	
	for(i=n-1;i>=1;i--)
	{
		
		dp[i][1]=max(dp[i+1][2],dp[i+1][3])+a[i];
		dp[i][2]=max(dp[i+1][1],dp[i+1][3])+b[i];
		dp[i][3]=max(dp[i+1][1],dp[i+1][2])+c[i];
	}
	
	cout<<max(max(dp[1][1],dp[1][2]),dp[1][3]);
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  i64 ans  = 0;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    int l, r; cin >> l >> r;
    ans += (r-l) + 1;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


int a[30][30];
int h,w;

vector<string> v;

bool inside(int a, int b){
	return 0<=a&&a<h&&0<=b&&b<w;
}


void dfs(pii p){
	int dd[]={0,1,0,-1,0};
	if(a[p.F][p.S]) return;
	a[p.F][p.S]=1;
	rep(i,4){
		pii np=p;
		np.F+=dd[i];
		np.S+=dd[i+1];
		if(inside(np.F,np.S)){
			if(v[np.F][np.S]=='#') continue;
			dfs(np);
		}
	}
}

void mainmain(){
	while(cin>>w>>h,w||h){
		v=vector<string>(h);
		rep(i,h) cin>>v[i];
		pii p;
		rep(i,h){
			rep(j,w){
				if(v[i][j]=='@'){
					p=mkp(i,j);
				}
			}
		}
		rep(i,30) rep(j,30) a[i][j]=0;
		dfs(p);
		int ans = 0;
		rep(i,30){
			rep(j,30){
				ans += a[i][j];
			}
		}
		cout<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3056
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, X, Y; cin >> N >> K >> X >> Y;
    int ans;
    for(int i=0;i<K && i<N ;i++){
        ans += X;
    }
    for(int i=K;i<N;i++){
        ans += Y;
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n,m;
	cin >> n >> m;
	int si,sj;
	cin >> si >> sj;
	int ei,ej;
	cin >> ei >> ej;
	int ans=0;
	si--;
	sj--;
	ei--;
	ej--;
	vector<string> v(n);
	for(int i=0;i<n;++i)
	cin >> v[i];
	set<array<int,3>> s;
	s.insert({0,si,sj});
	vector<vector<int>> vis(n,vector<int>(m,-1));
	vis[si][sj]=0;
	while(!s.empty())
	{
		auto it=s.begin();
		array<int,3> a=*it;
		int i=a[1];
		int j=a[2];
		int val=a[0];
		s.erase(it);
		if(vis[i][j]==val)
		{
			if(i>0 && v[i-1][j]!='#')
			{
				if(vis[i-1][j]==-1 || vis[i-1][j]>val)
				{	
					s.insert({val,i-1,j});
					vis[i-1][j]=val;
				}
			}
			if(j>0 && v[i][j-1]!='#')
			{
				if(vis[i][j-1]==-1 || vis[i][j-1]>val)
				{	
					s.insert({val,i,j-1});
					vis[i][j-1]=val;
				}
			}
			if(i<n-1 && v[i+1][j]!='#')
			{
				if(vis[i+1][j]==-1 || vis[i+1][j]>val)
				{	
					s.insert({val,i+1,j});
					vis[i+1][j]=val;
				}
			}
			if(j<m-1 && v[i][j+1]!='#')
			{
				if(vis[i][j+1]==-1 || vis[i][j+1]>val)
				{	
					s.insert({val,i,j+1});
					vis[i][j+1]=val;
				}
			}
			for(int x=-2;x<=2;++x)
			{
				for(int y=-2;y<=2;++y)
				{
				if(i+x>=0 && j+y>=0 && i+x<=n-1 && j+y<=m-1 && v[i+x][j+y]!='#')
				{
					
					 
					if(vis[i+x][j+y]==-1 || vis[i+x][j+y]>val+1)
					{	
						//cout << i+x << " " << j+y << endl;
						s.insert({val+1,i+x,j+y});
						vis[i+x][j+y]=val+1;
					}
				}
				}
			}
		}
	}
	cout << vis[ei][ej] << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  
  int s3 = s % 10;
  int s2 = ((s % 100) -s2)/10;
  int s1 = (s - s3 - s2)/100;
    
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Inf = 1e9+7;
const int Mod = 1e9+7;

int main ()
{
	string x;
	cin >> x;
	for (int i = 0 ; i < x.size(); i++) {
		if (x[i]==',')cout <<" ";
		else cout << x[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: f64,
        pos: [[f64; 2]; n],
    }

    let mut ans = 0;
    for i in 0 .. n {
        let x = pos[i][0];
        let y = pos[i][1];
        let dist = (x * x + y * y).sqrt();
        if dist <= d { ans += 1};
    }

    println!("{}", ans);

}


Measured memory_bytes: 15776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int k2 = k * 2;
		int[][] count = new int[4 * k + 1][4 * k + 1];

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (sc.next().equals("W")) {
				y += k;//全てblackに
			}
			x %= k2;
			y %= k2;
			//二次元imos 重みの加算
			count[x][y]++;
			count[x][y + k]--;
			count[x + k][y]--;
			count[x + k][y + k]++;
			count[x + k][y + k]++;
			count[x + k][y + k + k]--;
			count[x + k + k][y + k]--;
			count[x + k + k][y + k + k]++;
		}
		//横方向への累積和
		final int H = count.length;
		final int W = count[0].length;
		for (int y = 0; y < H; y++) {
			for (int x = 1; x < W; x++) {
				count[y][x] += count[y][x - 1];
			}
		}
		//縦方向への累積和
		for (int y = 1; y < H; y++) {
			for (int x = 0; x < W; x++) {
				count[y][x] += count[y - 1][x];
			}
		}
		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(y < k2 && x < k2) continue;
				count[y % k2][x % k2] += count[y][x];
			}
		}
		long ans = 0L;
		for (int y = 0; y < k2; y++) {
			for (int x = 0; x < k2; x++) {
				ans = Math.max(ans, count[y][x]);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 161456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  vector<int>A(N);
  vector<long double>sum(N+K);
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum[i]+=A[i]+1;
    sum[i+K]-=A[i]+1;
  }
  for(int i=1;i<N+K;i++)sum[i]+=sum[i-1];
  sort(sum.begin(),sum.end());
  cout<<fixed<<setprecision(10)<<sum[N+K-1]/2<<endl;
}

Measured memory_bytes: 10156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1002;
const ll MOD = 1000000007;
const int iNF = 0x3f3f3f3f;
/*
s = 0
row = [1, n]
col = [n+1, n+m]
t = n+m+1
*/

int n, m, head[MAXN*2], s, t;
struct Edge {
    int t, flow, cap, nxt;
} edge[MAXN * MAXN * 2];
int edge_cnt;

void add_edge (int f, int T, int cap) {
    edge[edge_cnt++] = {T, 0, cap, head[f]};
    head[f] = edge_cnt - 1;
    edge[edge_cnt++] = {f, 0, 0, head[T]};
    head[T] = edge_cnt - 1;
}

int lev[MAXN*2];
int dfs (int nd, int lim) {
    if (nd == t || lim == 0) {
        return lim;
    }

    for (int i=head[nd]; i!=-1; i=edge[i].nxt) {
        int x = edge[i].t;
        if (lev[x] == lev[nd]+1 && edge[i].cap > edge[i].flow) {
            int df = 0;
            if (df = dfs(x, min(lim, edge[i].cap - edge[i].flow))) {
                edge[i].flow += df;
                edge[i^1].flow -= df;
                return df;
            }
        }
    }

    return 0;
}

bool bfs () {
    memset(lev, -1, (n+m+2) * sizeof(int));
    lev[s] = true;
    queue<int> que;
    que.emplace(s);

    while (SZ(que)) {
        int cur = que.front();
        que.pop();

        for (int i=head[cur]; i!=-1; i=edge[i].nxt) {
            int x = edge[i].t;
            if (lev[x] == -1 && edge[i].cap > edge[i].flow) {
                lev[x] = lev[cur] + 1;
                que.emplace(x);
            }
        }
    }

    return lev[t] != -1;
}

int dinic (int x, int y) {
    s = x, t = y;
    int ret = 0;
    while (bfs()) {
        int df = 0;
        while (df = dfs(s, iNF)) {
            ret += df;
        }
    }
    return ret;
}

/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    memset(head, -1, (n+m+2) * sizeof(int));

    REP1 (i, n) {
        REP1 (j, m) {
            char c;
            cin >> c;
            if (c == 'o') {
                add_edge(i, n+j, 1);
                add_edge(n+j, i, 1);
            } else if (c == 'S') {
                add_edge(0, i, iNF);
                add_edge(0, n+j, iNF);
            } else if (c == 'T') {
                add_edge(i, n+m+1, iNF);
                add_edge(n+j, n+m+1, iNF);
            } else {
                assert(c == '.');
            }
        }
    }

    int ans = dinic(0, n+m+1);
    cout << (ans >= iNF ? -1 : ans) << endl;

    return 0;
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace IntModulo
{
	const int mod = 1e9 + 7;

	inline int add(int x, int y, int m = mod)
	{
		if (x + y < m)
			return x + y;
		return x + y - m;
	}

	inline int sub(int x, int y, int m = mod)
	{
		if (x >= y)
			return x - y;
		return x - y + m;
	}

	inline int mult(int x, int y, int m = mod)
	{
		return x * (LL) y % m;
	}

	inline int power(int x, LL y, int m = mod)
	{
		int r = 1;
		while(y)
		{
			if (y & 1)
				r = mult(r, x, m);
			x = mult(x, x, m);
			y >>= 1;
		}
		
		return r;
	}
	
	inline int inverse(int x, int m = mod)
	{
		return power(x, m - 2, m);
	}

	inline void ADD(int& x, int y, int m = mod){
		x += y;
		if (x >= m) x -= m;
	}

	inline void SUB(int& x, int y, int m = mod){
		x -= y;
		if (x < 0) x += m;
	}

	inline void MULT(int& x, int y, int m = mod){
		x = (x * (LL) y) % m;
	}
};

using namespace IntModulo;

const int N = 1 << 12;
int dp[N / 3][N];

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	dp[0][0] = 1;
	int ans = 0;
	FOR(i, 1, n / 3 + 1){
		FOR(j, 0, n + 1) if (dp[i - 1][j]){
			FOR(k, 3, n - j + 1){
				ADD(dp[i][j + k], dp[i - 1][j]);
			}
		}		
		ADD(ans, dp[i][n]);
	}
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;	
	return 0;
}


Measured memory_bytes: 9828
INF=pow(10,16)

A,B,Q=[int(x) for x in str(input()).split()]
s=[-INF]+[int(input()) for x in range(A)]+[INF]
t=[-INF]+[int(input()) for x in range(B)]+[INF]

for i in range(Q):
  temp=int(input())
  start1=0
  end1=A+1
  while start1!=end1-1:
    mid=(start1+end1)//2
    if s[mid]>=temp:
      end1=mid
    else:
      start1=mid
  
  start2=0
  end2=B+1
  while start2!=end2-1:
    mid=(start2+end2)//2
    if t[mid]>=temp:
      end2=mid
    else:
      start2=mid



  mi=INF
  for i in [s[end1-1],s[end1]]:
    for j in [t[end2-1],t[end2]]:
      mi=min(mi,abs(temp-i)+abs(i-j))
      mi=min(mi,abs(temp-j)+abs(i-j))
  print(mi)






Measured memory_bytes: 79064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        double taxRate = 1.08d;
        int a = (int) (n / taxRate);
        
        String result = ((int) (a * taxRate) == n)
            ? String.valueOf(a)
            : (int)((a + 1) * taxRate) == n
                ? String.valueOf(a+1)
                : ":(";
        System.out.println(result);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) 
	{
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans;
	return 0;
}


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

priority_queue <int,vector<int>,greater<int> > q;
double s[55];

int main(){
	int n; 
	cin >> n;
	double x, y, z;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		
	
	}
	sort(s,s+n);
	double p = s[0];
	for(int i = 1; i < n; i++){
		p = (p+s[i])/2;
	}
	printf("%.7lf", p);

	

	return 0;
}


Measured memory_bytes: 256
//atcoder
#include<cstdio>
const int N = 1e5+5;
int h[N];
//最右能到的位置
int right[N];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&h[i]);
    int ans = 0;
    for(int i = n; i >= 1; i--){
        if(i==n || h[i+1]>h[i]) right[i] = i;
        else right[i] = right[i+1];
        int len = right[i] - i;
        if(len>ans) ans = len;
    }
    printf("%d\n",ans);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
      for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) return;
      par[rx] = ry;
  }

  bool same(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
  }
};

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

  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    uf.unite(a,b);
  }

  vi group(n);

  rep(i,n){
    group[uf.root(i)]++;
  }

  int ret = 0;
  rep(i,n){
    ret = max(ret,group[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 11116
from collections import deque

N,M = map(int,input().split())
G = [[] for _ in range(N+1)]
dist = [-1] * (N+1)
pre = [1] * (N+1)
dist[0:2] = [0,0]
q = deque()

for i in range(M):
    A,B = map(int,input().split())
    G[A].append(B)
    G[B].append(A)
#print(G)    
q.append(1)
while q:
    v = q.popleft()
    for i in G[v]:
        if dist[i] != -1:
            continue
        dist[i] = pre[v] + 1
        pre[i] = v
        q.append(i)
print("Yes")
for i in range(2,N+1):
    print(pre[i])

Measured memory_bytes: 37576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool t[2010][2010];
int n,h,w,z[2010][4];
vector<int> X,Y;
void DFS(int y,int x){
	if(x<0||y<0||x>=w||y>=h)return;
	if(t[y][x])return;
	t[y][x]=true;
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	for(int i=0;i<4;i++){
		int xx=x+dx[i],yy=y+dy[i];
		DFS(yy,xx);
	}
}
int main(){
	while(cin>>w>>h&&w+h){
	cin>>n;
	X.clear();Y.clear();
	for(int i=0;i<n;i++){
		for(int j=0;j<4;j++)cin>>z[i][j];
		X.push_back(z[i][0]),X.push_back(z[i][2]);
		Y.push_back(z[i][1]),Y.push_back(z[i][3]);
	}
	X.push_back(0),X.push_back(w),Y.push_back(0),Y.push_back(h);
	sort(X.begin(),X.end());sort(Y.begin(),Y.end());
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			z[i][j*2+0]=lower_bound(X.begin(),X.end(),z[i][j*2+0])-X.begin();
			z[i][j*2+1]=lower_bound(Y.begin(),Y.end(),z[i][j*2+1])-Y.begin();
		}
	}
	w=lower_bound(X.begin(),X.end(),w)-X.begin();
	h=lower_bound(Y.begin(),Y.end(),h)-Y.begin();
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			t[i][j]=false;
		}
	}
	for(int k=0;k<n;k++){
		for(int i=z[k][0];i<z[k][2];i++){
			for(int j=z[k][1];j<z[k][3];j++){
				t[j][i]=true;
			}
		}
	}
	int cnt=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(t[i][j]==false){
				DFS(i,j);
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;}
	return 0;
}

Measured memory_bytes: 12572
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long M = sc.nextLong();
        long ans = 0;
        for (long i = 1; i <= (int) Math.sqrt(M); i++) {
            if (M % i == 0 && M / i >= N) {
                ans = Math.max(i, ans);
            }
            if (M % i == 0 && M / (M / i) >= N) {
                ans = Math.max(M / i, ans);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;
int main()
{
    int n;
    cin>>n;
    int r=n%1000;
    if(r>0)
    cout<<1000-r;
    else
    {
        cout<<0;
    }
    
}

Measured memory_bytes: 3632
from sys import stdin


def get_result(data):
    N = data[0]
    q, mod = divmod(N, 500)
    q_5, _ = divmod(mod, 5)
    return q * 1000 + q_5 * 5


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

//どう辺をはって、最短経路問題を考えるか
void solve() {
	int n, m; cin >> n >> m;
    vector<P> pairs;
    rep(i, n) {
        pairs.pb(P(i, -1)); //別の点を作る
    }
    int p[200200], q[200200], c[200200];
    rep(i, m) {
        cin >> p[i] >> q[i] >> c[i];
        --p[i]; --q[i];
        pairs.pb(P(p[i], c[i]));
        pairs.pb(P(q[i], c[i]));
    }

    sort(all(pairs));
    pairs.erase(unique(all(pairs)), pairs.end());
    int sz = pairs.size();
    map<P, int> mp; //逆引き
    rep(i, sz) {
        mp[pairs[i]] = i;
    }

    vector<vector<P>> g(sz);
    //駅での乗り換え
    rep(i, sz) {
        if(pairs[i].sc == -1) continue;
        int station = pairs[i].fr;
        int out = mp[P(station, -1)];
        g[i].pb(P(out, 0));
        g[out].pb(P(i, 1)); //別に余分に辺を張る分には構わない
    }
    //路線間の移動
    rep(i, m) {
        int s = mp[P(p[i], c[i])], t = mp[P(q[i], c[i])];
        g[s].pb(P(t, 0));
        g[t].pb(P(s, 0));
    }
    int start = mp[P(0, -1)], goal = mp[P(n - 1, -1)];
    vector<int> dist(sz, INF);
    deque<int> deq;
    deq.push_back(start);
    dist[start] = 0;
    while(deq.size()) {
        int x = deq.front(); deq.pop_front();
        for(auto& y: g[x]) {
            int to = y.fr, cost = y.sc;
            if(dist[x] + cost < dist[to]) { //01BFSでは、暫定より短いものが得られたなら更新
            //1のみちを考えた後に、0のみちがでてきたときも更新しないといけない
                if(cost == 0) {
                    dist[to] = dist[x];
                    deq.push_front(to);
                } else {
                    dist[to] = dist[x] + 1;
                    deq.push_back(to);
                }
            }
        }
    }
    cout << (dist[goal] == INF ? -1 : dist[goal]) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using f64 = double;
using f128 = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;

using StrView = string_view;

auto solve(i64 const X) -> void {
  for (i64 i = -200; i < 200; ++i) {
    for (i64 j = -200; j < 200; ++j) {
      i64 A5 = i * i * i * i * i;
      i64 B5 = j * j * j * j * j;
      if (A5 - B5 == X) {
        cout << i << " " << j << "\n";
        return;
      }
    }
  }
}

auto main() -> int {
  i64 X;
  scanf("%" SCNd64, &X);
  solve(X);
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    vector<int> ans(N, 1);
    for(int i=0; i<N-1; i++) if(S[i] == 'R' && S[i+1] == 'R'){
        ans[i+2] += ans[i];
        ans[i] = 0;
    }
    for(int i=N-1; i>0; i--) if(S[i] == 'L' && S[i-1] == 'L'){
        ans[i-2] += ans[i];
        ans[i] = 0;
    }
    for(int i=0; i<N; i++) cout << ans[i] << " \n"[i==N-1];
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
#ABC130C
import sys


tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

a=[]
for i in range(0,n):
	a.append(1)

#print(a)

for i in range(0,m):
	tmp = int(input())
	a[tmp]=0

#print(a)


for i in range(2,n):
	a[i]=a[i]*(a[i-1]+a[i-2])


if(n==1):
	print(1)
else:
	print((a[n-1]+a[n-2])% 1000000007)




Measured memory_bytes: 462744