akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
  int A,B;
  cin >> A >> B;
  
  if(A<=B*2)cout << 0 << endl;
  else cout << A-B*2 << endl;
  
}


Measured memory_bytes: 256
/*
	0102:Matrix-like Computation
*/
#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int n;
		int mat[11][11];
		
		cin >> n;
		
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				cin >> mat[i][j];
			}
		}
		
		//縦の合計の処理
		for(int i = 0; i < n; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += mat[i][j];
			}
			
			mat[i][n] = sum;
		}
		
		//横の合計の処理
		for(int i = 0; i < n; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += mat[j][i];
			}
			
			mat[n][i] = sum;
		}
		
		//合計の合計
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += mat[n][i];
		}
		mat[n][n] = sum;
		
		for(int i = 0; i <= n; i++) {
			for(int j = 0; j <= n; j++) {
				printf("%5d", mat[i][j]);
			}
			putchar('\n');
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> dict = new HashSet<String>();
        for(int i = 0;i<n;i++){
            String s = sc.next();
            String str = sc.next();
            if(s.equals("insert")) {
                dict.add(str);
            }
            else if(dict.contains(str)){
                System.out.println("yes");
            }
            else {
                System.out.println("no");
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 253008
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll count[4] = {};
  rep(i,0,3){
    int a,b;
    cin >> a >> b;
    count[a-1]++;
    count[b-1]++; 
  }
  ll ok=0;
  ll ng=0;
  rep(i,0,4){
    if(count[i] == 2) ok++;
    if(count[i] == 0 || count[i] > 2) ng++;
  }
  
  if(ng > 0) print("NO");
  else if(ok == 2) print("YES");
  else print("NO");
  
}


Measured memory_bytes: 256
import sys

N = int(input())
L = list(map(int, input().split()))

n = L[0]
while True:
    if len(L) <= 0:
        break

    if L[0] - n < -1:
        print("No")
        sys.exit()

    n = max(n, L[0])
    L.pop(0)

print("Yes")


Measured memory_bytes: 14252
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

    private void solve(FastScanner sc) {
        long x = sc.nextLong();
        long d = x / 11;
        long r = x % 11;
        long ans = d * 2;
        if (r >= 7) ans += 2;
        else if (r != 0) ans++;
        System.out.println(ans);
    }

    /*
     * template
     */

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

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int bufLen = 0;

        private boolean hasNextByte() {
            if (ptr < bufLen) {
                return true;
            } else {
                ptr = 0;
                try {
                    bufLen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (bufLen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

int main(){
	int n,ans=INT_MAX;
	string s;
  	cin >> n >> s;
  	int a[n+1];
  	a[0] = 0;
  	for (int i=0;i<n;i++){
      	cin >> s[i];
    	if(s[i]=='W') a[i+1]=a[i]+1;
      	else a[i+1]=a[i];
    }
  	for (int i=0;i<n;i++){
      	int k=a[i]+n-i-1-(a[n]-a[i+1]);
      	ans=min(k,ans); 
    }
  	cout << ans <<endl;
}

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

int main(){
  int64_t N,M,K;
  cin >> N >> M >> K;
  vector<int64_t> suma(N+1,0),sumb(M+1,0);
  int64_t A,B;
  for(int i=1;i<=N;i++){
    cin >> A;
    suma.at(i)=suma.at(i-1)+A;
  }
  for(int i=1;i<=M;i++){
    cin >> B;
    sumb.at(i)=sumb.at(i-1)+B;
  }
  int64_t ans=0;
  int bs=M;
  for(int64_t i=0;i<=N;i++){
    if(suma.at(i)>K){
      break;
    }
    int64_t j=bs;
    for(j=bs;j>=0;j--){
      if(sumb.at(j)<=K-suma.at(i)){
        break;
      }
    }
    ans=max(ans,i+j);
    bs=j;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb std::ios::sync_with_stdio(false)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
/*** TEMPLATE CODE STARTS HERE ***/
ll a,b,c;
int main()
{
//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
    cin>>a>>b>>c;
    ll ans=0ll;
    ans+=b;
    ans+=min(b,c);
    c-=min(b,c);
    ans+=min(c,a);
    c-=min(c,a);
    if(c>=1)
    {
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


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

typedef long long ll;
using namespace std;

int n; 
int r[5005];
int p[5005];

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

	
		cin >> n;
		
		memset(r,0,sizeof(r));
		for (int i = 0;i < n;i++){
			cin >> r[i];
		}
		int ans = INT_MAX;

		if(n == 3){
			ans = r[0] + r[1] + r[2];
			ans += max(0,r[1] - r[0] - r[2]);
		}else{

		for (int i = 0;i <= r[1];i++){
			for (int j = 0;j <= r[n-2];j++){
				memcpy(p,r,sizeof(r));
				int sum = 0;
				int a = p[1]-i; int b = p[n-2]-j;
				if(i < p[1] - p[0] || j < p[n-2]-p[n-1]) continue;		
				sum += p[0] + a;
				sum += p[n-1] + b;
				p[1] -= a; p[n-2] -= b;
				for (int k = 1;k < n-1;k++){
					sum += 2*p[k];
					p[k+1] = max(0,p[k+1]-p[k]);
				}
				ans = min(sum,ans);
			}
		}

		for (int i = 0;i <= r[1];i++){
			for (int j = 0;j <= r[n-2];j++){
				memcpy(p,r,sizeof(r));
				int sum = 0;
				if(i < p[1] - p[0] || j < p[n-2]-p[n-1]) continue;
				int a = p[1]-i; int b = p[n-2]-j;				
				sum += p[0] + a;
				sum += p[n-1] + b;
				p[1] -= a; p[n-2] -= b;
				for (int k = n-2;k > 0;k--){
					sum += 2*p[k];
					p[k+1] = max(0,p[k+1]-p[k]);
				}
				ans = min(sum,ans);
			}
		}
		}

		cout << ans << endl;

	

	return 0;

}




Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int main(void){
  int N,Q;
  cin >> N >> Q;
  int ans[N]={};
  pair<int,int> line[N-1],point[Q];
  rep(i,N-1) cin >> line[i].first >> line[i].second;
  rep(i,Q) cin >> point[i].first >> point[i].second;
  rep(i,Q) ans[point[i].first-1]+=point[i].second;
  sort(line,line+N-1);
  rep(i,N-1) ans[line[i].second-1]+=ans[line[i].first-1];
  rep(i,N) cout << ans[i] <<" ";
}

Measured memory_bytes: 6272
#include <stdio.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int foo[5005];
int goo[5005];
int main()
{
    int n,m;
    long long s=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&foo[i]);
        s+=foo[i];
    }
    if(s<m)
    {
        printf("%d\n",n);
        return 0;
    }
    int h=0;
    sort(foo,foo+n,greater<int>());
    for(int i=0;i<n;i++)
    {
        if(foo[i]>=m)
        {
            h++;
            continue;
        }
        int c=0;
        for(int j=0;j<n;j++)
        {
            if(i!=j)
            {
                goo[c++]=foo[j];
            }
        }
        long long sum=0;
        for(int j=0;j<c;j++)
        {
            sum+=goo[j];
            if(sum>=m)
            {
                sum-=goo[j];
            }
        }
        if(sum+foo[i]>=m)
        {
            h++;
        }
    }
    printf("%d\n",n-h);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int cnt[26] = {};
    for (int i = 0; i < N; i++)
    {
        string str;
        cin >> str;
        cnt[str[0] - 'A']++;
    }

    int mul[] = {cnt['M' - 'A'], cnt['A' - 'A'], cnt['R' - 'A'], cnt['C' - 'A'], cnt['H' - 'A']};
    long long sum = 0;
    for (int i = 0; i < 1 << 5; i++)
    {
        int bits = 0;
        for (int j = 0; j < 5; j++)
        {
            if ((i >> j) & 1)
            {
                bits++;
            }
        }
        if (bits != 3)
        {
            continue;
        }
        long long s = 1;
        for (int j = 0; j < 5; j++)
        {
            if ((i >> j) & 1)
            {
                s *= mul[j];
            }
        }
        sum += s;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define MOD 1000000007
#define MAXN 100005
#define lint long long
using namespace std;

struct ii {
	int a, b;
	bool operator < (ii o) const {
		return tie(a, b) < tie(o.a, o.b);
	}
};

int TC, N, M, K, Q, x, y, z, cnt, mnm, mks, ptr, ans;
string s;

int mod(lint n) { return (n%MOD + MOD)%MOD; }

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	ios::sync_with_stdio(0);
	
	cin>>s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ',') s[i] = ' ';
	}
	cout<<s<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char s[100005];
    scanf("%s", s);
    int slen = strlen(s);
    int zero = 0, one = 0;
    for(int i = 0; i < slen; ++i)
    {
        if(s[i] == '0')
            zero++;
        else if(s[i] == '1')
            one++;
    }
    printf("%d\n", min(zero, one)*2);
    return 0;
}


Measured memory_bytes: 384
import scala.io.Source.stdin

object Main extends App {
  println {
    stdin.getLines.map{ s=>
      s.foldLeft(List(0)){ (x,y) =>
        if(y.asDigit>=10 || y.asDigit < 0)
          {if(x.head>0) 0::x else x }
        else (x.head*10+y.asDigit)::x.tail
      }.sum
    }.sum
  }
}

Measured memory_bytes: 43796
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;

bool check(int i) { return n / i == n % i; }

signed main() {
  cin >> n;
  int ans = 0ll;
  for (int i = 1ll; i * i <= n; i++) {
    if (n % i == 0ll) {
      int m = n / i - 1ll;
      if (m != 0 && n / m == n % m) ans += m;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  string s;
  cin>>s;
  int n=s.length();
  if(n==2){
    cout<<(s[0]==s[1]?"1 2":"-1 -1")<<endl;
    return 0;
  }
  fr(i,n-2){
    if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i+2]==s[i]){cout<<i+1<<" "<<i+3<<endl;return 0;}
  }
  cout<<"-1 -1"<<endl;
}

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

void solve(int n, vector<int>h, int k){
  vector<ll>dp(n, INF);
  dp[0] = 0;
  for (int i=0; i<n; i++){
    for (int j=1; (j<=k && i+j<n); j++){
      dp[i+j] = min(
        dp[i+j],
        dp[i] + abs( h[i] - h[i+j] )
      );
    }
  }
  cout << dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  solve(n,h,k);
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(A) A.begin(), A.end()
#define SZ(A) (ll)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e6;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
    bool ok = true;
    cin >> n;
    int a[n];
    map <int, int> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (p.find(a[i]) != p.end()) ok = false;
        p[a[i]] = 1;
    }
    if (!ok) cout << "NO\n";
    else cout << "YES\n";
 	return 0;
}

Measured memory_bytes: 10368
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
import itertools
p = list(itertools.permutations(range(N),N))
#print(p)
ans = 0
for i in p:
    num = 0
    for j in range(N-1):
        num += ((l[i[j+1]][0]-l[i[j]][0])**2+(l[i[j+1]][1]-l[i[j]][1])**2)**0.5
    #print(num)
    ans += num
print(ans/len(p))

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

using namespace std;

int main(){
	int N, M, X, Y; cin >> N >> M >> X >> Y;
	int x[N], y[M];
	for(int i = 0; i < N; ++i) cin >> x[i];
	for(int i = 0; i < M; ++i) cin >> y[i];
	bool ans;
	for(int Z = X + 1; Z <= Y; ++Z){
		ans = true;
		if(!(X < Z && Z <= Y)){
			ans = false;
		}
		for(int i = 0; i < N; ++i){
			if(!(x[i] < Z)){
				ans = false;
			}
		}
		for(int i = 0; i < M; ++i){
			if(!(y[i] >= Z)){
				ans = false;
			}
		}
		if(ans) break;
	}
	
	cout << (ans ? "No War" : "War") << endl;
}

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

int main(void){
  int n;
  cin>>n;
  int sum=0;
  int tmp=n;
  for(int i=0;i<10;i++){
    // cout<<tmp<<endl;
    sum += tmp%10;
    tmp = tmp/10;
  }
  // cout<<sum<<endl;
  if (n%sum==0){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define inf 1e18
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 1000
// <<fixed << setprecision(9)

void err()
{
	cout<<"NO\n";
	exit(0);
}

int main()
{
	int n,i,k,j;
	boost;
	
	cin>>n>>k;
	int dp[n],ht[n];
	rep(i,0,n){
		cin>>ht[i];
		dp[i]=1e9;
	}
	
	dp[0]=0;
	int mn;
	rep(i,0,n-1)
	{
		rep(j,1,k+1)
		{
			mn=1e9;
			if(n>i+j)
			{
				dp[j+i]=min(dp[j+i],dp[i] + abs(ht[j+i]-ht[i]));	
			}
			
		}
	}
	cout<<dp[n-1];
	
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {

			String s = sc.next();
			if(s.length() == 1) {
				System.out.println(0);
				return;
			}
			char[] c1 = s.substring(0, s.length() / 2).toCharArray();
			int half = 0;
			if(s.length() % 2 == 0) {
				half = s.length() / 2;
			} else {
				half = s.length() / 2 + 1;
			}
			char[] c2 = s.substring(half).toCharArray();
			char[] c3 = new char[c1.length];
			for(int i = 0 ; i < c1.length ; i++) {
				c3[c1.length - 1 -i] = c1[i];
			}
			char[] c4 = new char[c2.length];
			for(int i = 0 ; i < c2.length ; i++) {
				c4[c2.length - 1 -i] = c2[i];
			}
			int ans1 = 0;
			for(int i = 0 ; i < c1.length ; i++) {
				if(c2[i] != c3[i]) {
					ans1++;
				}
			}
			int ans2 = 0;
			for(int i = 0 ; i < c2.length ; i++) {
				if(c1[i] != c4[i]) {
					ans2++;
				}
			}
			System.out.println(Math.min(ans1, ans2));
		}

	}

}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
class union_find{
  private:
    ll N; //要素数
    ll ER = 1e18; // x,yが同じ集合にない時の重みの差(場合によって編集)
    vll par; // iの親
    vll rank; // 木の深さ
    vll siz; // iの属する集合の要素数
    vll weig; // iの重さ
    
  public:
    // 要素の初期化
    union_find(ll n){
      N = n;
      par.resize(N); rank.resize(N);
      siz.resize(N); weig.resize(N);
      for(ll i=0;i<N;i++){
        par[i] = i; rank[i] = 0;
        siz[i] = 1; weig[i] = 0;
      }
    }

    // 木の根を求める
    ll root(ll x){
      if(par[x] == x) return x;
      else{
        ll r = root(par[x]);
        weig[x] += weig[par[x]];
        return par[x] = r;
      }
    }

    // 根まで辿って根に対する重みを得る
    ll weight(ll x){
      root(x);
      return weig[x];
    }

    // 木の併合(rank基準) (wはxとyの重みの差 w = w(y) - w(x))
    void unite(ll x, ll y, ll w = 0){
      w += (weight(x) - weight(y));
      x = root(x);
      y = root(y);
      if(x == y) return;

      if(rank[x] < rank[y]){
        par[x] = y;
        siz[y] += siz[x];
        w *= -1;
        weig[x] = w;
      }
      else{
        par[y] = x;
        siz[x] += siz[y];
        weig[y] = w;
        if(rank[x] == rank[y]) rank[x]++;
      }
    }
    // yとxの重みの差 w(y) - w(x)を返す
    ll diff(ll x, ll y){
      if(same(x,y)) return weight(y) - weight(x);
      else return ER; // 同じ集合にない時、ERを返す。
    }

    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y){
      return root(x) == root(y);
    }

    // xが木の根であるかどうか
    bool is_root(ll x){
      return x == root(x);
    }

    // xの属する集合の要素数
    ll size(ll x){
      return siz[root(x)];
    }

    // 全体でいくつ集合があるか
    ll cnt(){
      ll res = 0;
      for(ll i=0;i<N;i++) if(i == root(i)) res++;
      return res;
    }
};
//-----------------------------------------

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, m;
  cin >> n >> m;
  union_find tree(n);
  REP(i,m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    tree.unite(a, b);
  }
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ans = max(ans, tree.size(i));
  }

  cout << ans << endl;

    
    
  return 0;
}



Measured memory_bytes: 9524
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <ctime>
#include <sstream>
#include <fstream>
#include <bitset>
#include <iomanip>
#include <assert.h>

using namespace std;
typedef long long LL;
typedef long double LD;

#define PII pair<int, int>
#define sz(X) ((int)((X).size()))

template<class T> T abs(T x){return x < 0 ? -x : x;}

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

const int maxn = 31, maxs = 100000;
int d[maxn][maxn][4][maxn][maxn], ans[maxn][maxn];
bool b[maxn][maxn];
bool g[maxn][maxn][4];
int x[maxs], y[maxs], s[maxs];
int n, m;

void bfs(int tx, int ty, int tk){
	int l = 1, r = 1;
	x[l] = n; y[r] = m;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			d[tx][ty][tk][i][j] = -1;
	d[tx][ty][tk][n][m] = 0;
	while (l <= r){
		for (int k = 0; k < 4; ++k)
			if (g[x[l]][y[l]][k]){
				int u = x[l] + dx[k], v = y[l] + dy[k];
				if (u == 0 || v == 0 || u > n || v > m) continue;
				if (d[tx][ty][tk][u][v] != -1) continue;
				d[tx][ty][tk][u][v] = d[tx][ty][tk][x[l]][y[l]] + 1;
				x[++r] = u;
				y[r] = v;
			}
		++l;
	}
}

void spfa(){
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j){
			b[i][j] = false;
			ans[i][j] = -1;
		}
	int l = 1, r = 1;
	b[1][1] = true;
	ans[1][1] = 0;
	x[l] = 1; y[l] = 1; s[l] = 0;
	while (l <= r){
		int i = x[l], j = y[l];
		for (int k = 0; k < 4; ++k)
			if (g[i][j][k]){
				int u = i + dx[k], v = j + dy[k];
				if (d[i][j][k][i][j] == -1) continue;
				int tmp = max(ans[i][j], s[l] + d[i][j][k][i][j]);
				if (ans[u][v] == -1 || tmp < ans[u][v]){
					ans[u][v] = tmp;
					if (!b[u][v]){
						b[u][v] = true;
						x[++r] = u;
						y[r] = v;
						s[r] = s[l] + 1;
					}
				}
			}
		b[i][j] = false;
		++l;
	}
	printf("%d\n", ans[n][m]);
}

int main(){
	while (scanf("%d%d", &n, &m)){
		if (n == 0) break;
		memset(g, false, sizeof(g));
		for (int i = 1; i <= n; ++i){

			for (int j = 1; j <= m - 1; ++j){
				int x;
				scanf("%d", &x);
				if (x == 0){
					g[i][j][0] = true;
					g[i][j + 1][1] = true;
				}
			}

			if (i != n){
				for (int j = 1; j <= m; ++j){
					int x;
					scanf("%d", &x);
					if (x == 0){
						g[i][j][2] = true;
						g[i + 1][j][3] = true;
					}
				}
			}
		}

		bool ok = true;
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j)
				for (int k = 0; k < 4; ++k)
					if (g[i][j][k]){
						int t, u = i + dx[k], v = j + dy[k];
						if (k <= 1) t = 1 - k; else t = 5 - k;
						g[i][j][k] = false;
						g[u][v][t] = false;
						bfs(i, j, k);
						if (d[i][j][k][1][1] == -1){
							ok = false;
						}
						g[i][j][k] = true;
						g[u][v][t] = true;
					}
		if (!ok){
			puts("-1");
			continue;
		}
		spfa();

	}
	return 0;
}

Measured memory_bytes: 15156
N = int(input())

list_6_9 = [1]

tmp = 6
while tmp < 100000:
  list_6_9.append(tmp)
  tmp *= 6

tmp = 9
while tmp < 100000:
  list_6_9.append(tmp)
  tmp *= 9


cnt_draw_list = [100000] * (N+1)
cnt_draw_list[0] = 0


## ループして引き落とし回数を更新していく
for n in range(1,N+1):
  for draw_cash in list_6_9:
    tmp = n - draw_cash
    if tmp >= 0:
      cnt_draw_list[n] = min(cnt_draw_list[n],cnt_draw_list[tmp] + 1)


print(cnt_draw_list[N])


Measured memory_bytes: 3828
#include<iostream>

using namespace std;

int f(int x){
	return x*x;
}

int main(void){
	int d;
	while(cin>>d){
		int ans=0;
		for(int i=1;d*i<600;i++){
			ans+=f(d*i)*d;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main(void){
	char  w[101];
	char c='a';
	int i=0,j=0,b=0;

	scanf("%s",w);
	i=strlen(w);
for (j= 0; j< 26; ++j)
{b=0;i=strlen(w)-1;
	while(i>=0){
		if (w[i]==c)
		{
			b++;
		}
		i--;
		
	}
	if (b!=0&&b%2!=0)
	{
		printf("No\n");
		return 0;	
	}
	c++;
}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	char a[5];
	int i,j,cnt=0;
	scanf("%s",a);
	for(i=0;i<4;i++){
		for(j=i+1;j<4;j++){
			if(a[i]==a[j]) cnt++;
		}
	}
	if(cnt == 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
priority_queue<i_i> leaves;
vector<int> children[102000];
int ans = 0;
int parent[102000];

void dfs(int now, int depth){
    if(children[now].size() == 0){
        i_i in = {depth, now};
        leaves.push(in);
        return;
    }
    for(int i = 0; i < children[now].size(); i++){
        dfs(children[now][i], depth + 1);
    }
    return;
}

int main() {
    //cout.precision(10);
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> parent[i];
    }
    if(parent[1] != 1){
        parent[1] = 1;
        ans++;
    }
    if(k >= (n - 1)){
        cout << ans << endl;
        return 0;
    }
    for(int i = 2; i <= n; i++){
        children[parent[i]].push_back(i);
    }
    dfs(1, 0);
    while(!leaves.empty()){
        i_i out = leaves.top();
        leaves.pop();
        //cout << out.first << endl;
        if(out.first <= k){
            break;
        }
        int now = out.second;
        for(int i = 1; i < k; i++){
            int next = parent[now];
            parent[now] = 1;
            now = next;
            //now = parent[now];
            if(now == 1){
                break;
            }
        }
        if(parent[now] == 1){
            continue;
        }
        ans++;
        i_i in = {out.first - k, parent[now]};
        parent[now] = 1;
        if(in.first <= k){
            continue;
        }
        leaves.push(in);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12416
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));
$arraySum = [0 => 1];
$ans = 0;

$total = 0;

for ($i = 0; $i < $N; $i++) {
    $total += $A[$i];
    $arraySum[$total]++;
}

foreach ($arraySum as $key => $num) {
    $ans += $num * ($num - 1) / 2;
}

echo $ans . PHP_EOL;


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

#define task "C"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next nextalscjaowjico
#define prev prevoua0wucckjsl
#define y1 y1kscj9u20cjeijc
#define left leftljascjljl
#define right rightsocjolkjl
#define y0 y0cqu3jioajc

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
int a, b;
int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
#else
    //freopen(task".in","r",stdin);
    //freopen(task".out","w",stdout);
#endif
    cin >> a >> b;
    int l = (a * 25 + 1) / 2;
    int l1 = (b * 10);
    int r = ((a + 1) * 25) / 2;
    int r1 = (b + 1) * 10;
    //DB(l);
    //DB(l1);
    //DB(r);
    //DB(r1);
    if (max(l, l1) >= min(r, r1)) cout << -1;
    else cout << max(l, l1);
    return 0;
}


Measured memory_bytes: 256
/*input
400

*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+100;
typedef long long int lld;
typedef long long ll;

#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

pair<ll,ll> intersection(ll a,ll b,ll c,ll d) {
    // Error(a,b,c,d);
    if(b<c or d<a) return make_pair(-1,-1);
    return make_pair(max(a,c),min(b,d));
}


vector<ll> V;
ll Array[lim], C[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    cin>>n;
    cout<<10-(n/200)<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  
  int ans = 0;

  rep(i, N) {
    int l, r;
    cin >> l >> r;
    
    ans += r - l + 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: i32,
        q: i32,
        abcd: [(usize, usize, i32, i32); q],
    }
    let mut ga = vec!{0; n};
    let ans = dfs(&abcd, &mut ga, 1, m, 0);
    println!("{}", ans);
}

fn dfs(abcd: &Vec<(usize, usize, i32, i32)>, ga: &mut Vec<i32>, lower: i32, m: i32, i: usize) -> i32 {
    if ga.len() == i {
        // 長さnまで到達したら終了，得点計算
        let mut score = 0;
        for &(a, b, c, d) in abcd {
            // 配列アクセスのため0スタートに合わせる
            if ga[b - 1] - ga[a - 1] == c {
                score += d;
            }
        }
        return score;
    }
    let mut ans = 0;
    // 最後の桁を"1つ前の値" ~ 最大値mまで変化させる
    for lastnum in lower..=m {
        ga[i] = lastnum;
        let t = dfs(abcd, ga, lastnum, m, i + 1);
        ans = if ans > t { ans } else { t };
    }
    ans
}

Measured memory_bytes: 2136
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;



main(){
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    int ce = 0;
    for (int i = 0; i < n; i++){
            if (s[i] == 'B') ce++;
            else ans += ce;
    }
    cout << ans;




}


Measured memory_bytes: 640
def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    dp = [0]*(N+1)
    dp[0] = 1000
    for i in range(1, N+1):
        for j in range(0, i-1):
            # j日目に買ってi日目に売る
            dp[i] = max(dp[i], dp[j]//A[j] * A[i-1] + dp[j] % A[j])
        dp[i] = max(dp[i], dp[i-1])

    print(dp[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 64792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum == x) {
    cout << N << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  ll ans = 0;
  ll subs = 0;
  for (int i = 0; i < N; i++) {
    subs += a[i];
    if (subs <= x) {
      ans = i + 1;
    }
  }
  if (ans == N) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll n=110000,k,i,j;
    cin>>k;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for(j=k;; j++)
    {
        if(prime[j])
        {

            cout<<j<<endl;
            break;
        }
    }

    return 0;
}





Measured memory_bytes: 3668
#include <iostream>
#include <queue>
#include <climits>
using namespace std;

class P{
public:
  int i,j,dir, cost;
  P(){};
  P( int I,int J, int d, int c ){
    i=I; j=J; dir=d; cost=c;
  }
  bool operator<(const P &p) const{
    return cost > p.cost; // queue 用に greater で定義
  }
};


int di[4] = { 0,1,0,-1 };
int dj[4] = { 1,0,-1,0 };

int main(){
  int o[30][30]; // マスに割り当てられた命令
  int c[4];      // 命令を与えた時のコスト
  int cost[30][30][4];
  int w,h;
  priority_queue<P> qu;
  P p;

  while( cin>>w>>h && (w||h) ){
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ ){
	cin >> o[i][j];
	for( int k=0;k<4;k++ )
	  cost[i][j][k]=INT_MAX;
      }
    for( int i=0;i<4;i++ )
      cin >> c[i];

    while( !qu.empty() ) qu.pop();
    qu.push( P(0,0,0,0) );

    int ans=0;
    while( !qu.empty() ){
      p=qu.top(); qu.pop(); // cost が最小のものを取り出す

      if( (p.i==h-1) && (p.j==w-1) ){
	//	cout << "***"<<endl;
	ans=p.cost;
	break;
      }
      if( (p.i<0) || (p.i>=h) ) continue;
      if( (p.j<0) || (p.j>=w) ) continue;

      
      if( cost[p.i][p.j][p.dir] <= p.cost ) continue;
      cost[p.i][p.j][p.dir] = p.cost;

      /*
      cout << p.i << "," << p.j << " "<<p.cost << endl;
      cout << "size="<<qu.size() << endl;
      if( qu.size()>10 )break;
      */

      for( int i=0;i<4;i++ ){ // 直進・右・反転・左　への移動
	int nextD = (i+p.dir)%4;;
	int ni=p.i+di[nextD], nj=p.j+dj[nextD];
	if( i==o[p.i][p.j] )	  qu.push( P(ni,nj,nextD,p.cost) );
	else                 	  qu.push( P(ni,nj,nextD,p.cost+c[i]) );
      }
      
    }
    cout << ans << endl;

    /*
    for( int k=0;k<4;k++ ){
      cout << "k="<<k<<endl;
      for( int i=0;i<h;i++ ){
	for( int j=0;j<w;j++ )
	  cout << cost[i][j][k] << "\t";
	cout << endl;
      }
    }
    */
  }
  return 0;
}

Measured memory_bytes: 0
def read_input():
    n, t_span = map(int, input().split())
    tlist = list(map(int, input().split()))

    return n, t_span, tlist


def submit():
    n, t_span, tlist = read_input()

    times = []
    for t in tlist:
        times.append([t, t + t_span])

    result = times[:1]
    for t in times[1:]:
        # 時間に重複があれば上書き
        if result[-1][1] > t[0]:
            result[-1][1] = t[1]

        else:
            result.append(t)

    acc = 0
    for t in result:
        acc += t[1] - t[0]

    print(acc)

if __name__ == '__main__':
    submit()

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

int compare(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main (void)
{
    int n;
    int x[200000], s[200000];
    int i, j;

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

    qsort(s, n, sizeof(int), compare);

    for(i = 0; i < n; ++i){
        if(s[n / 2] <= x[i]) printf("%d\n", s[n / 2 - 1]); else printf("%d\n", s[n / 2]);
    }
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main() {
	while (true) {
		int N;
		vector<pair<int, int> > s;
		pair<int, int> p;
		cin >> N;
		if (N == 0) {
			break;
		}
		p.first = p.second = 0;
		s.push_back(p);
		for (int i = 1; i < N; i++) {
			int dx[] = {-1, 0, 1, 0};
			int dy[] = {0, -1, 0, 1};
			int n, d;
			cin >> n >> d;
			int x = s[n].first + dx[d];
			int y = s[n].second + dy[d];
			p.first = x;
			p.second = y;
			s.push_back(p);
		}
		int xsize, ysize;
		int xmax = INT_MIN;
		int xmin = INT_MAX;
		int ymax = INT_MIN;
		int ymin = INT_MAX;
		for (int i = 0; i < N; i++) {
			//cout << s[i].first << " " << s[i].second << endl;
			xmax = max(xmax, s[i].first);
			xmin = min(xmin, s[i].first);
			ymax = max(ymax, s[i].second);
			ymin = min(ymin, s[i].second);
		}
		xsize = xmax - xmin + 1;
		ysize = ymax - ymin + 1;
		cout << xsize << " " << ysize << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
while True:
    x=input().split(" ")
    a=int(x[0])
    op=x[1]
    b=int(x[2])
    if(op == '+'):
        print(a + b)
    elif(op == '-'):
        print(a - b)
    elif(op == '*'):
        print(a * b)
    elif(op == '/'):
        print(a // b)
    elif(op == '?'):
        break


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

#define MAXN 123123
#define INF 0x3f3f3f3f3f3f3f3f

long long int n, w, weight[102], value[102], memo[102][MAXN];

long long int knap(int i, int carry){
    if(carry>w) return -INF;
    if(i==n) return 0;
    if(memo[i][carry]!=-1) return memo[i][carry];

    return memo[i][carry] = max(knap(i+1, carry), knap(i+1, carry+weight[i])+value[i]);
}

int main(){
    cin >> n >> w;

    for(int i=0;i<n;i++){
        cin >> weight[i] >> value[i];
    }

    memset(memo, -1, sizeof memo);

    cout << knap(0, 0) << endl;
}


Measured memory_bytes: 98304
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
    int n,i;
    int x[100],y[100];
    double dxy1=0,dxy2=0,dxy3=0,dxy8=0;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++) scanf("%d",&x[i]);
    for(i = 0;i < n;i++) scanf("%d",&y[i]);
    
    for(i = 0;i < n;i++){
        dxy1 += abs(x[i]-y[i]);
        dxy2 += pow(fabs((double)x[i]-y[i]),2.0);
        dxy3 += pow(fabs((double)x[i]-y[i]),3.0);
        if(dxy8 < abs(x[i]-y[i])) dxy8 = abs(x[i]-y[i]);
    }
    
    dxy2 = pow(dxy2,1.0/2);
    dxy3 = pow(dxy3,1.0/3);
    
    printf("%lf\n%lf\n%lf\n%lf\n",dxy1,dxy2,dxy3,dxy8);
}



Measured memory_bytes: 1972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static long maxK(int[] weights, int[] values, int W){
        long[] dp = new long[W+1];
        for (int i = 0; i < weights.length; i++) {
            for (int weight = W - weights[i]; weight >= 0; weight--) {
                dp[weight+ weights[i]] = Math.max(dp[weight + weights[i]], dp[weight] + values[i]);
            }
        }
        return max(dp);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());
        int[] weights = new int[N];
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(reader.readLine());
            weights[i] = Integer.parseInt(st.nextToken());
            values[i] = Integer.parseInt(st.nextToken());
        }
        System.out.println(maxK(weights, values, W));
    }

    private static long max(long[] a){
        long max = 0;
        for (int i = 0; i < a.length; i++) {
            if (a[i] > max){
                max = a[i];
            }
        }
        return max;
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<list>

using namespace std;

int main()
{
	int N;
	vector<int> b;
	list<int> ans;
	int max_num = 0;

	cin >> N;

	for(int i=0;i<N;i++)
	{
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
		max_num = max(tmp,max_num);
	}

	bool flag;
	for(int i=0;i<N;i++)
	{	
		flag = false;
		for(int j = max_num;j > 0;j--)
		{
			if(j > b.size())continue;

			if(b[j-1] == j)
			{
				flag = true;
				ans.push_front(b[j-1]);
				b.erase(b.begin()+j-1);
				break;
			}
		}

		if(!flag)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	for(auto i : ans)
	{
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1010


int solve(){
  int n, sum_r = 0, max_r = 0, sum_w = 0;
  int r[SIZE], w[SIZE];

  pair<int,int> book[SIZE];

  scanf("%d" , &n);
  if(n == 0) return 0;

  for(int i=0;i<n;i++){
    scanf("%d%d", r+i, w+i);
    sum_r += r[i];
    sum_w += w[i];
    max_r = max(max_r, r[i]);
  }
  
  if(max_r*2 > sum_r){
    bool dp[1001] = {};

    dp[0] = true;
    bool f = false;
    for(int i=0;i<n;i++){
      if(r[i]==max_r && !f){f=true; continue;}
      for(int j=max_r-w[i];j>=0;j--){
        dp[j+w[i]] |= dp[j];
      }
    }

    for(int i=max_r-(sum_r-max_r);i>=0;i--){
      if(dp[i]){
        printf("%d\n", max_r * 2 + sum_w-i);
        break;
      }
    }
    
  }else{
    printf("%d\n",sum_r + sum_w);
  }
  

  return 1;
}

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



Measured memory_bytes: 3152
count={}
for s in raw_input().rstrip().split():
	if not count.has_key(s):
		count[s]=[len(s),0]
	count[s][1]+=1

long,mode=max([x[0] for x in count.values()]),max([x[1] for x in count.values()])
for k,v in count.items():
	if v[0]==long:
		long=k
	if v[1]==mode:
		mode=k

print mode,long

Measured memory_bytes: 4220
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if(a > b){
            System.out.println("a > b");
        } else if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        }
        
    }
}


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

int main(){
    string SA, SB, SC;
    cin >> SA >> SB >> SC;

    char trash = SA[0];
    string winner;

    while(true){

        if(trash == 'a'){

            if(SA.size() == 0){
                winner = "A";
                break;
            }
            else{
                trash = SA[0];
                SA.erase(0, 1);
            }
        }

        if(trash == 'b'){

            if(SB.size() == 0){
                winner = "B";
                break;
            }
            else{
                trash = SB[0];
                SB.erase(0, 1);
            }
        }

        if(trash == 'c'){

            if(SC.size() == 0){
                winner = "C";
                break;
            }
            else{
                trash = SC[0];
                SC.erase(0, 1);
            }
        } 

    }
    cout << winner << endl;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

type Card = (String,Int)

main = do
  n <- readLn
  ss <- replicateM n getLine
  mapM_ (putStrLn . toString) . solve . map (toCards . words) $ ss

toString :: Card -> String
toString (t,n) = t ++ " " ++ show n

toCards :: [String] -> Card
toCards [t,n] = (t,read n) 

thirteenS :: String -> [String]
thirteenS = replicate 13

makeCards :: [(String,Int)]
makeCards = zip (concat [thirteenS "S",thirteenS "H",thirteenS "C",thirteenS "D"]) (concat . replicate 4 $ [1..13])
solve :: [Card] -> [Card]
solve cards = makeCards \\ cards

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

int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

int main() {
  int n;cin>>n;
  int heap[n+1];



  for(int i = 1; i < n+1; i++) {
    cin >> heap[i];
  }

  for(int i = 1; i < n+1; i ++) {
    cout << "node " << i << ": ";
    cout << "key = " << heap[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << heap[parent(i)] << ", ";
    if (left(i) <= n) cout << "left key = " << heap[left(i)] << ", ";
    if (right(i) <= n) cout << "right key = " << heap[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3088