akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    std::string str;
    in(str)
    if(str[0] == 'R' && str[1] == 'R' && str[2] == 'R') {
        println(3)
        return 0;
    }
    else if(str[0] == 'R' && str[1] == 'R') {
        println(2)
        return 0;
    }
    else if(str[1] == 'R' && str[2] == 'R') {
        println(2)
        return 0;
    }
    else {
        for(char c : str) {
            if(c == 'R') {
                println(1)
                return 0;
            }
        }
    }
    println(0)
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  string s, t; cin >> s >> t;

  ll k;
  for (k = 0; k <= N; k++) {
    if (s.substr(k) == t.substr(0, N-k)) {
      break;
    }
  }
  cout << N + k << endl;

  return 0;
}



Measured memory_bytes: 3620
N,C=map(int, input().split())
inl = [tuple(map(int, input().split())) for i in range(N)]
inl.sort()

res = 0
st = [(0,0)]*30
for s,t,c in inl:
    nx = (t,c)
    cnt = 0
    for i, (t1, c1) in enumerate(st):
        if not (t1 == s and c == c1) and t1 >= s:
            st[i] = (t1,c1)
        else:
            st[i] = nx
            nx = (0, 0)

        if st[i][0] != 0:
            cnt += 1
    res = max(cnt, res)

print(res)


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

struct it{
	int a , b , c;
};

vector<it> v;
int n;

int32_t main(){
	cin>>n;
	v.resize(n);
	for(int i = 0 ; i < n ; i ++){
		cin>>v[i].a;
	}
	for(int i = 0 ; i < n ; i ++){
		cin>>v[i].b;
		v[i].c = v[i].a - v[i].b;
	}
	sort(v.begin() , v.end() , [&](it a , it b){
		return a.c < b.c;
	});
	int X = 0;
	int R = 0;
	for(int i = 0 ; i < n ; i ++){
		if(v[i].c >= 0) break;
		R++;
		X += -v[i].c;
	}
	for(int j = n- 1 ; j >= 0 ; j --){
		if(v[j].c <= 0) break;
		if(X <= 0) break;
		R++;
		X -= v[j].c;
	}
	if(X > 0){
		cout<<-1<<endl;
	}
	else{
		cout<<R<<endl;
	}
}

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

public class Main {
	public static void main(String[] args) throws IOException {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt(); 
       String str = Integer.toString(n); 
       int k = sc.nextInt(); 
       String convert = Integer.toString(Integer.parseInt(str,10),k); 
       System.out.println(convert.length());
	}
}

Measured memory_bytes: 21588
import sys
import math

def main():
  N = int(input())
  x = [0] * N
  y = [0] * N
  for i in range(N):
    x[i], y[i] = map(lambda j: int(j), input().split(' '))
  total = 0
  for i in range(N):
    for j in range(N):
      distance = math.sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)
      total += distance
  print(total / N)

main()


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

vector<int> g[100000];
int dp[100000];

int dfs(int cur) {
  if (dp[cur] > -1) {
    return dp[cur];
  }
  dp[cur] = 0;
  for (int to: g[cur]) {
    dp[cur] = max(dfs(to) + 1, dp[cur]);
  }
  return dp[cur];
}

int main() {
  int n, m;
  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int x, y;
    cin>>x>>y;
    --x;
    --y;
    g[y].push_back(x);
  }
  for (int i=0; i<n; i++) dp[i] = -1;
  for (int i=0; i<n; i++) {
    if (dp[i] == -1) {
      dfs(i);
    }
  }
  int ans = 0;
  for (int i=0; i<n; i++) ans = max(dp[i], ans);

  cout<<ans<<endl;
}

Measured memory_bytes: 9088
#include<stdio.h>
#include<string.h>
int main(void){
	int i=0,j,lens,lenp,count=0,v;
	char s[101],p[101];
	scanf("%s",s);
	scanf("%s",p);
	lens = strlen(s);
	lenp = strlen(p);
	count = ring(s,p,lens,lenp);
	if(count == lenp){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

int ring(char s[], char p[], int lens, int lenp){
	int count=0,i=0,j,t,flag=0;
	for(j=0;j<lens;j++){
		if(p[i] == s[j]){
			count++;
			if(count == 1) t = j;
			if(j == lens-1){
				j = -1;
				flag = 1;
			}
		}
		else if(flag == 1) break;
		i++;
		if(count == lenp){
			break;
		}
		else if(count != lenp && count != i){
			if(count != 0) j = t;
			i = 0;
			count = 0;
		}
	}
	return count;
}

Measured memory_bytes: 524
#1:初期化
N = int(input())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)


Measured memory_bytes: 47332
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    ll A, B, S, X = 0;
    cin >> A >> B;
    S = A + B;
    REP(i, N - 2) {
        ll tmp; cin >> tmp;
        X ^= tmp;
    }

    ll dp[42][2][2] = {};
    REP(i, 42) REP(j, 2) REP(k, 2) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    REP(i, 41) {
        int cx = (X >> i) & 1;
        int cs = (S >> i) & 1;
        int ca = (A >> i) & 1;

        REP(j, 2) REP(k, 2) {
            if (dp[i][j][k] == -1) continue;

            REP(na, 2) {
                int nb = cx ^ na;
                int ns = na + nb + j;
                if ((ns & 1) != cs) continue;

                int ni = i + 1, nj, nk;
                if (ns >= 2) nj = 1;
                else nj = 0;

                if (na > ca) nk = 1;
                else if (na == ca) nk = k;
                else nk = 0;

                dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | ((ll)na << i));
            }
        }
    }

    ll a = dp[41][0][0];
    if (a == -1 || a == 0) cout << -1 << endl;
    else cout << A - a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define ll long long int
#define PI acos(-1.0)
#define f first
#define se second
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll w,a,b;
   cin>>w>>a>>b;
   if(b>a+w)
    cout<<b-a-w;
   else
   {
    if(b+w<a)
     cout<<a-b-w;
    else
    {
     if(b>=a && b<=a+w)
      cout<<0;
     else
     {
      if(b+w>=a && b+w<=a+w)
       cout<<0;
     }
    }
   }
   return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  sort(V.begin(), V.end());
  double ans = V.at(0);
  for (int i = 1; i < N; i++) {
    ans = (ans + V.at(i)) / 2;
  }
  cout << ans << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int N_MAX = 100;
    constexpr int V_MAX = 1000;
    constexpr int V_SUM_MAX = V_MAX * N_MAX;
    int N, W;
    int w[N_MAX];
    int v[N_MAX];
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];

    int dp[N_MAX + 1][V_SUM_MAX + 1];
    REP(i, N_MAX + 1) dp[i][0] = W;
    FOR(j, 1, V_SUM_MAX + 1) dp[0][j] = -1;

    FOR(i, 1, N_MAX + 1) FOR(j, 1, V_SUM_MAX + 1) {
        if (j - v[i - 1] >= 0 && dp[i - 1][j - v[i - 1]] >= w[i - 1]) {
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v[i - 1]] - w[i - 1]);
        } else {
            dp[i][j] = dp[i - 1][j];
        }
        //printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
    }
    RREP(j, V_SUM_MAX + 1) {
        if (dp[N][j] != -1) {
            cout << j << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 39680
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll M = 1e9+7;
void no(){
  cout << 0 << endl;
  exit(0);
}

int main(){
  ll N; cin >> N;
  vector<ll> T(N+2,0), A(N+2,0);
  ll bound; // H[bound]でmax
  ll maxi = 0;
  REP(i, N){
    cin >> T[i+1];
    if(T[i+1]>T[i]){
      bound = i+1;
      maxi = T[i+1];
    }
  }
  T[N+1] = maxi;
  A[0] = maxi;
  REP(i, N) cin >> A[i+1];
  REP(i,bound+1){
    if(A[i] != maxi) no();
  }
  
  ll ans = 1;
  FOR(i,1,bound){
    if(T[i]>T[i-1]) continue;
    (ans *= T[i]) %= M;
  }
  IFOR(i,bound+1,N+1){
    if(A[i]>A[i+1]) continue;
    (ans *= A[i]) %= M;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;char c;
	cin>>a>>c>>b;
	switch(c)
	{
		case '+':{
			cout<<a+b;
			break;
		}
		case '-':{
			cout<<a-b;
			break;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e2+5;
int n,m,val[N][N],sum[N][N],f[2][N][N][N];
char s[N][N];
it Calc(int l,int r,int L,int R){ return sum[r][R]-sum[l-1][R]-sum[r][L-1]+sum[l-1][L-1]; }
inl bool Equal(int l,int r,int L,int R){
	int tsum=Calc(l,r,L,R);
	return tsum==0||tsum==(r-l+1)*(R-L+1);
}
it Find(int k,int x,int y,int L){
	int l=x,r=y-1,res=0;
	while(l<=r){
		int t1=f[k][x][mid][L];
		int t2=f[k][mid+1][y][L];
		res=max(res,min(t1,t2));
		if(t1<t2) r=mid-1;
		else l=mid+1;
	}
	return res;
}
il Solve(int k){
	for(ri i=1;i<=n;++i) for(ri j=i;j<=n;++j)
		for(ri l=1;l<=m;++l){
			int pre=f[k^1][i][j][l],res=0;
			if(pre^m){
				res=f[k^1][i][j][pre+1];
				res=max(res,Find(k^1,i,j,l));
			}
			else res=m;
			f[k][i][j][l]=res;
		}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m),del(f,-1);
	for(ri i=1;i<=n;++i) scanf("%s",s[i]+1);
	for(ri i=1;i<=n;++i) for(ri j=1;j<=m;++j) val[i][j]=s[i][j]=='#';
	for(ri i=1;i<=n;++i) for(ri j=1;j<=m;++j) sum[i][j]=val[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	for(ri i=1;i<=n;++i) for(ri j=i;j<=n;++j)
		for(ri l=1,r;l<=m;l=r){
			r=l;
			while(Equal(i,j,l,r)&&r<=m) ++r;
			for(ri k=l;k<r;++k) f[0][i][j][k]=r-1;
			if(l==r) f[0][i][j][l]=l-1,++r;
		}
	int ans=0;
	for(ri i=1;f[(i&1)^1][1][n][1]<m;++i) Solve(i&1),ans=i;
	print(ans);
	return 0;
}

Measured memory_bytes: 67968
#define Ma(x,y) (x>y?x:y)
#define N 100002
i,n,a[N]={0},b[N]={0},c[N]={0},dp[N][4]={0};
#define r(x)for(i=0;i<x;i++)
main(){
	scanf("%d",&n);
	r(n)scanf("%d%d%d",&a[i+1],&b[i+1],&c[i+1]);
	dp[1][1]=a[1];dp[1][2]=b[1];dp[1][3]=c[1];
	r(n-1){
		dp[i+2][1]=a[i+2]+Ma(dp[i+1][2],dp[i+1][3]);
		dp[i+2][2]=b[i+2]+Ma(dp[i+1][1],dp[i+1][3]);
		dp[i+2][3]=c[i+2]+Ma(dp[i+1][1],dp[i+1][2]);
	}
	printf("%d",Ma(dp[n][1],Ma(dp[n][2],dp[n][3])));
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    ll D, N; cin >> D >> N;
    int ans = 1;
    rep(i,D){
        ans *= 100;
    }
    if (N == 100) {
        cout << ans * (N + 1) << endl;
        return 0;
    }
    cout << ans * N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
 
const int maxn = 1e5 + 5;
int a[maxn],b[maxn],c[maxn];
 
int main(){
	long long sum = 0,n,x,y;
	scanf("%lld",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i <= n;i++) scanf("%d",&b[i]);
	for(int i = 1;i <= n;i++) scanf("%d",&c[i]);
	sort(a + 1,a + 1 + n);
	sort(b + 1,b + 1 + n);
	sort(c + 1,c + 1 + n);
	a[n + 1] = 1000000000+5;
	c[n + 1] = 1000000000+5;
	for(int i = 1;i <= n;i++){
		long long l = 1,r = n,mid;
		while(l <= r){
			mid = (l + r) / 2;
			if(b[i] <= a[mid]){
				if(b[i] > a[mid - 1]){
					l = mid - 1;
					break;
				}
				r = mid - 1;
			}
			else l = mid + 1;
		}
		x = l;
		if(x == n + 1) x = n;
		l = 1,r = n + 1;
		while(l <= r){
			mid = (l + r) / 2;
			if(b[i] < c[mid]){
				if(b[i] >= c[mid - 1]){
					l = mid;
					break;
				}
				r = mid - 1;
			}
			else l = mid + 1;
		}
		y = l;
		if(y == n + 1) y = 0;
		else y = n - y + 1;
		sum += x * y;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int N;
	scanf("%d" ,&N);
	int tmp = 0;
	for(int i = 1; i <= N; i++)
		if(i % 2) tmp++;
	printf("%f", 1.0* tmp / N);
	return 0;
}


Measured memory_bytes: 128
while True:
  n = int(input())
  if not n:
    break

  start = int(input()) - 1 #開始の位置
  goal = int(input()) - 1  #あたりの位置
  d = int(input())
  
  nums = [[i for i in range(n)]] #各段での数字の並び
  bars = [] #横棒リスト
  
  for i in range(d):
    s = input()
    bars.append(s)
    new = nums[-1][:]

    for j in range(n - 1):
      if s[j] == "1": #横棒があれば入れ替え
        new[j], new[j + 1] = new[j + 1], new[j]

    nums.append(new)
    
  to_goal = nums[-1][goal] #あたりにたどり着く初期位置
  
  if to_goal == start: #元からあたりにたどり着く場合
    print(0)

  else: #各段について、to_goalとスタートが隣り合うかチェック
    for i, status in enumerate(nums[1:]):
      to_goal_ind = status.index(to_goal) #to_goalの位置
      start_ind = status.index(start)     #startの位置
      ind1, ind2 = min(to_goal_ind, start_ind), max(to_goal_ind, start_ind)
  
      if ind2 - ind1 == 1:  #隣あっていた場合
        if (bars[i][ind1] == "0") and (ind1 == 0 or bars[i][ind1 - 1] == "0") and (ind2 == n - 1 or bars[i][ind2] == "0"):  #隣り合う横棒がなければ(入れ替え可能ならば)出力
          print(i + 1, ind1 + 1)
          break
    else:
      print(1)
  


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int a,b; cin>>a>>b;
  if(a+b>=10)cout<<"error"<<endl;
  else cout<<a+b<<endl;
}



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

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int arr[N];
    for (int i=0; i<N; i++) {
        scanf("%d", arr+i);
    }

    long long* ans = (long long*) calloc(N, sizeof(long long));
    ans[0] = 0;
    ans[1] = abs(arr[0] - arr[1]);

    for (int i=2; i<N; i++) {
        ans[i] = min ( ans[i-1] + abs(arr[i] - arr[i-1]),
                        ans[i-2] + abs(arr[i] - arr[i-2]) );
    }

    cout << ans[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int a[200005],b[200005];
main(){
	int n,m,k;
	while(~getIII(n,m,k)){
		F(i,0,n) getI(a[i]);
		F(i,0,m) getI(b[i]);
		int ans=0;
		F(i,1,n) a[i]+=a[i-1];
		F(i,1,m) b[i]+=b[i-1];
		F(i,0,n) if(a[i]<=k){
			int poss=i+1,target=k-a[i];
			int cntB=upper_bound(b,b+m,target)-b;
			poss+=cntB;
			ans=max(ans,poss);
		}
		F(i,0,m) if(b[i]<=k){
			int poss=i+1,target=k-b[i];
			int cntA=upper_bound(a,a+n,target)-a;
			poss+=cntA;
			ans=max(ans,poss);
		}
		printf("%lld\n",ans);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n,l;
    cin >> n >> l;

    vector<string> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(all(v));
    for (int i = 0; i < n; i++) {
        cout << v[i];
    }
    cout << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;

    scanf("%d %d",&a,&b);

    if(a-1>b || a-1==b) printf("%d\n",a+a-1);

    else if(b-1>a || b-1==a) printf("%d\n",b+b-1);

    else if(a==b) printf("%d",a+b);

    return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
    int n, x = 0, y = 0, m = 0;
    scanf("%d",&n);
    bool flag = true;
    for(int i = 0;i < n;i++)
    {
        int x1, y1, m1;
        scanf("%d %d %d",&m1,&x1,&y1);
        if((abs(x1 - x) + abs(y1 - y) > abs(m1 - m)) || ((abs(x1 - x) + abs(y1 - y)) % 2 != abs(m1 - m) % 2) )
            flag = false;
        x = x1, y = y1, m = m1;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    int ans=SZ(S)*(SZ(S)-1)/2+1;
    map<char,int> m;
    rep(i,SZ(S)){
        m[S[i]]++;
    }
    for(auto p:m){
        ans-=p.se*(p.se-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,C;
    cin >> N >> C;
    vector<vector<int> > D(C,vector<int>(C));
    rep(i,C)rep(j,C)cin >> D[i][j];
    vector<vector<int> > color(N,vector<int>(N));
    rep(i,N)rep(j,N){
        cin >> color[i][j];
        color[i][j]--;
    }
    vector<vector<int> >cost(3,vector<int>(C));

    for(int c=0;c<C;c++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                cost[(i+j)%3][c] += D[color[i][j]][c];
            }
        }
    }
    int res = 1<<30;

    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            if(i==j)continue;
            for(int k=0;k<C;k++){
                if(k==i||k==j)continue;
                int tmp = 0;
                tmp+=cost[0][i]+cost[1][j]+cost[2][k];
                res = min(res,tmp);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
using namespace std;
int dp[1005][1005];
int main(){
  int W,N,v[1000],w[1000];
  int n=1;
  int lastj=0;
  char jyama;
  while(cin>>W&&W){
    cin>>N;
    for(int i=0;i<N;i++){
      scanf("%d,%d",&v[i],&w[i]);
    }
    for(int i=0;i<=N;i++){
      for(int j=0;j<=W;j++){
	if(j<w[i]){
	  dp[i+1][j]=dp[i][j];
	}else{
	  dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
	  if(j>0&&dp[i][j]!=dp[i][j-1]) lastj=j;
	}
      }
    }    
    cout<<"Case "<<n<<":"<<endl;
    cout<<dp[N][W]<<endl;
    cout<<lastj<<endl;
    ++n;
  }
}

Measured memory_bytes: 5180
// Aizu Vol-1 0168: Kannondou
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#if 0
int combi(int n)
{
	if (n == 1) return 1;
	if (n == 2) return 2;
	if (n == 3) return 4;
	if (n == 4) return 7;
	return combi(n - 3) + combi(n - 2) + combi(n - 1);
}

int main()
{
	int i;

	printf("int tbl[] = {\n  0, ");
	for (i = 1; i <= 30; i++) {
		printf(" %d, ", combi(i));
	}
	printf("\n};\n");
	return 0;
}
#endif

char *gets(char *);
char buf[100];

int tbl[31] = {
	0,  1,  2,  4,  7,  13,  24,  44,  81,  149,
	274,  504,  927,  1705,  3136,  5768,  10609,  19513,  35890,  66012,
	121415,  223317,  410744,  755476,  1389537,  2555757,  4700770,  8646064,  15902591,  29249425,
	53798080
};

int main()
{
	int n;

	while (1) {
		gets(buf);
		if (!(n = atoi(buf))) break;
		printf("%d\n", (tbl[n] - 1) / 3650 + 1);
	}
	return 0;
}

Measured memory_bytes: 524
L1 = list(map(int,input().split()))
L1.sort()
L2 = [L1[-1] - L1[i] for i in range(2)]
L2.sort()
P = L2[0]
Q = L2[1]
ans = P
Q -= P
ans += Q // 2
Q %= 2
ans += Q * 2
print(ans)

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


int main()
{
        int ret_scanf ;
	int a, b;
	int max;
	
    // フォーマットに従って標準入力から入力
    ret_scanf = scanf("%d %d ", &a, &b);
    
    max = a + b;
    if (max < a - b) {
    	max = a -b;
    } 
    if (max < a * b) {
    	max = a * b;
    }
    printf("%d", max);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  vector<long long> odd;
  vector<long long> even;
  long long N,tmp;
  cin>>N;
  for(long long i=0;i<N;++i){
    cin>>tmp;
    if(i%2==0){
      even.push_back(tmp);
    }
    else{
      odd.push_back(tmp);
    }
  }
  long long odd_freq[100100];
  long long even_freq[100100];
  for(long long hoge=0;hoge<100100;++hoge){
    odd_freq[hoge]=0;
    even_freq[hoge]=0;
  }
  for(long long j=0;j<N/2;++j){
    odd_freq[odd[j]]+=1;
    even_freq[even[j]]+=1;
  }

  long long e_1,e_2,o_1,o_2;
  long long e_1_index,o_1_index;
  e_1=0;
  e_2=0;
  o_1=0;
  o_2=0;
  e_1_index=0;
  o_1_index=0;
  for(long long k=1;k<100100;++k){
    if(even_freq[k]>=e_1){
      e_2=e_1;
      e_1=even_freq[k];
      e_1_index=k;
    }
    else if(even_freq[k]>=e_2){
      e_2=even_freq[k];
    }
    if(odd_freq[k]>=o_1){
      o_2=o_1;
      o_1=odd_freq[k];
      o_1_index=k;
    }
    else if(odd_freq[k]>=o_2){
      o_2=odd_freq[k];
    }    
  }
  long long ans;
  ans=0;
  if(o_1_index==e_1_index){
    ans=min((N-o_1-e_2),(N-o_2-e_1));
  }
  else{
    ans=N-o_1-e_1;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  string s, t; cin >> s >> t;
  int sl = s.size();
  int tl = t.size();

  bool ok;
  repr(i, sl-tl){
    ok = true;
    rep(j, tl){
      if(!(s[i+j] == t[j] || s[i+j] == '?')){
        ok = false;
        break;
      }
    }
    if(ok){
      rep(j, tl) s[i+j] = t[j];
      break;
    }
  }

  if(ok){
    rep(i, sl) if(s[i] == '?') s[i] = 'a';
    cout << s << endl;
  }

  else cout << "UNRESTORABLE" << endl;

  return 0;
}


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

int main(void) {
	char data[80];
	int i;
	int count;
	int number;
	_Bool hit;
	while ( gets(data) != 0) {
		hit = 0;
		count = 0;
		number = strlen(data);
		while (!hit) {
			for (i = 0; i <= number - 3; i++) {
				if( strncmp(&data[i], "the", 3) == 0) {
					hit = 1;
					break;
				}
				if( (i <= number - 4) && (strncmp(&data[i], "this", 4) == 0 || strncmp(&data[i], "that", 4) == 0)) {
					hit = 1;
					break;
				}
			}
			if( hit)
				break;
			
			for (i = 0; i < number; i++)
				if( data[i] >= 'a' && data[i] <= 'z')
					data[i] = (data[i] - 'a' + 1) % 26 + 'a';
			if( ++count == 26)
				break;
		}
		printf("%s\n",data);
		for (i = 0; i < number; i++)
			data[0] = 0;
	}
	return 0;
}

Measured memory_bytes: 520
N = int(input())
A = list(map(int, input().split()))

A_sum = [0] * (N + 1)
for i in range(1, N+1):
    A_sum[i] = A_sum[i-1] + A[i-1]
A_sum.sort()

ans = 0
add = 0
a_cur = float('inf')
for a in A_sum:
    if a != a_cur:
        add = 0
        a_cur = a
    else:
        add += 1
        ans += add
print(ans)


Measured memory_bytes: 91600
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		for (int i=a; i<=b; i++) {
			if (c%i==0) {ans++;}
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 26340
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//二次元累積和を用いた解法

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<int> L(M);
  vector<int> R(M);
  vector<vector<int>> sum;
  sum = vector<vector<int>>(N+1,vector<int>(N+1,0));
  for(int i = 0; i < M; i++){
    scanf("%d %d",&L[i], &R[i]);
    sum[L[i]][R[i]] ++;
  }
  vector<int> p(Q);
  vector<int> q(Q);

  for(int i = 0; i < Q; i++) scanf("%d %d",&p[i], &q[i]);

  for(int i = 1; i <= N ; i++){
    for(int j = 1; j <= N; j++){
      sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
  }

  for(int i = 0; i < Q; i++){
    int L = p[i];
    int R = q[i];
    printf("%d\n",sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1]);
  }
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
map<int,int> mp;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	FOR(i,M) {
		cin>>x>>y;
		mp[y]+=x;
	}
	ll ret=0;
	FOR(i,N) {
		if(mp.size() && mp.rbegin()->first>A[i]) {
			A[i]=mp.rbegin()->first;
			mp.rbegin()->second--;
			if(mp.rbegin()->second==0) {
				mp.erase(mp.rbegin()->first);
			}
		}
		ret+=A[i];
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int w[N];
int b[N];
int ind[N];
int n, p;

ll f(int ind)
{
    return 1LL * w[ind] * (100 - p) + 1LL * b[ind] * p;
}

bool cmp(int x, int y)
{
    return f(x) < f(y);
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> n >> p;
    for (int i=0; i<n; i++)
        cin >> w[i] >> b[i];
    ll sum = 0;
    for (int i=0; i<n; i++)
        sum += 1LL * w[i] * (100 - p);
    for (int i=0; i<n; i++)
        ind[i] = i;
    sort(ind, ind+n, cmp);
    int ans = n;
    for (int i=0; i<n; i++)
        if (sum - f(ind[i]) >= 0)
            sum -= f(ind[i]), ans--;
    cout << ans << "\n";
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int res;
    if (2 * c >= a + b) {
        res = a * x + b * y;
    } else {
        res = min(x, y) * 2 * c;
        if (x > y) {
            res += min(a, 2 * c) * (x - y);
        } else {
            res += min(b, 2 * c) * (y - x);
        }
    }
    cout << res << "\n";
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    double x[10];
    string u[10];

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

    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (u[i] == "JPY")
            sum += x[i];
        else
            sum += x[i] * 380000;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  string s = readln.chomp;
  s.map!(a => 'x').writeln;
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7
#define LSOne(x)  (x & (-x))   //least significant 1
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 1;
vector<vi> adj(N);
bool vis[N];
int dp[N];
void dfs(int u){
    /*
    for each vertex, ask it what is the longest path for you.
     then his parent's longest path is max + 1
    */
    vis[u] = 1;
    for(int i = 0; i<sz(adj[u]); i++){
        int v = adj[u][i];
        if(!vis[v])
            dfs(v);
        dp[u] = max(dp[u], dp[v] + 1);
    }
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\in.txt", "w", stdout);
    int n, m; cin>>n>>m;

    for(int i = 0; i<m; i++){
        int u, v; cin>>u>>v;
        adj[u].pb(v);
    }
    int mx = 0;
    for(int i = 1; i<=n; i++)
        if(!vis[i] && sz(adj[i]))
            dfs(i);

    cout<<*max_element(dp, dp+N);
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
ll nodes = 0;
bool vis[N];
vector<ll> graph[N];

void dfs(int n){
	vis[n] = true;
	++nodes;
	for(auto i : graph[n]){
		if(!vis[i])
			dfs(i);
	}
}

int main(){
	fast;
	ll n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		ll u, v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	ll mx = 0;
	for(int i = 1; i <= n; ++i){
		if(!vis[i]){
			dfs(i);
			mx = max(mx, nodes);
			nodes = 0;
		}
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 39652
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    a = int(input().strip())
    b = int(input().strip())
    if a > b:
        print("GREATER")
    elif a == b:
        print("EQUAL")
    else:
        print("LESS")


if __name__ == '__main__':
    main()


Measured memory_bytes: 60396
N = int(input())
B6 = [6**i for i in range(1,7)]
B9 = [9**i for i in range(1,6)]
L = B6 + B9
L = sorted(list(set(L)))
dp = [i for i in range(N+1)]
for i in L :
    for j in range(i,(N+1)) :
        dp[j] = min(dp[j-i]+1,dp[j])
ans = dp[N]
print(ans)


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);

	lint cnt[10][10]={};
	for(int x=1;x<=n;x++){
		cnt[to_string(x)[0]-'0'][x%10]++;
	}

	lint ans=0;
	rep(i,10) rep(j,10) ans+=cnt[i][j]*cnt[j][i];
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
#include <cmath>
using namespace std;
typedef long long ll;

struct POINT{
	int x, y;
};

int main()
{
	int N, K;

	cin>>N>>K;

	for(int i = 0; i < K; i++){
		POINT pos;
		cin>>pos.x>>pos.y;

		if(pos.x > (N+1)/2) pos.x = N - pos.x + 1;
		if(pos.y > (N+1)/2) pos.y = N - pos.y + 1;

		if(pos.x < pos.y)	cout<<(pos.x-1)%3+1<<endl;
		else				cout<<(pos.y-1)%3+1<<endl;
	}
}

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

int main(){
  
  //入力
  int N,M;
  cin >> N >> M;
  vector<bitset<10>> chank(M);
  for(int i=0;i<M;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int s;
      cin >> s;
      chank.at(i).set(s-1); //繋がれているスイッチのbitは1、他は0
    }
  }
  vector<int> p(M);
  for(int i=0;i<M;i++){
    cin >> p.at(i);
  }
  
  //実装
  int Total =0;
  for(int i=0;i<(1<<N);i++){
    int j=0;
    int ok = 1;
    bitset<10> i_bit(i);
    do{
      if(((i_bit & chank.at(j)).count() % 2) == p.at(j)){
        j++;
      }else{
        ok = 0;
        break;
      }
    }while(j<M);
    Total += ok;
  }
  
  cout << Total << endl;
  
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int s, ans;
    cin >> s;
    int i = 1;
    while (true) {
        if (s == 4 || s == 2 || s == 1) {
            ans = i + 3;
            break;
        }
        i++;
        if (s % 2 == 0) {
            s /= 2;
            continue;
        }
        s = 3 * s + 1;
    }
    cout << ans << endl;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,ans=0,i;
	string s1 , s2;
	cin >> s1 >> s2;
	rep(i , 0, s1.size()){
		if(s1[i]!= s2[i])ans++;
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
	int n,q,a,b,c;
	long long int sum = 0;
	cin >> n;

	vector<int> d(100000,0);
	rep (i, n) {
		cin >> a;
		sum += a;
		d[a-1] += 1;
	}
	cin >> q;
	vector<pair<int, int>> bc(q);
	rep(i,q){
		cin >> b >> c;
		bc[i] = make_pair(b,c);
	}

	rep(i,q){
		d[bc[i].second-1] += d[bc[i].first-1];
		sum += (bc[i].second-bc[i].first)*d[bc[i].first-1];
		d[bc[i].first-1] = 0;
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n,k;
	cin>>n>>k;
	vector<int>D(k);
	for(int i=0;i<k;i++){
		cin>>D[i];
	}
	int ok=0;
	for(long long i=n;;i++){
		long long t = i;
		while(t){
			long long a = t%10;
			t=t/10;
			for(int j=0;j<k;j++){
				if(a==D[j]){
					ok=1;
					break;
				}
			}
			if(ok){
				break;
			}
		}
		if(!ok){
			cout<<i<<endl;
			break;
		}else{
			ok=0;
		}
	}
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e5+5;
ll arr[N],A[N],cnt[N];
bool visited[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   double n;
   cin>>n;
    cout << fixed << showpoint;
    cout << setprecision(9);
    cout<< n*3.14*2;

go;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}

int main(){
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	ld angle = M_PI * 2 * ( (ld)h / 12.0 + ((ld)m / 60.0) / 12.0 - (ld)m / 60.0);
	ld ans =  (ld)(a * a + b * b) - (ld)(2 * a *b) * cosl(angle);
	cout << fixed << setprecision(10) << sqrt(ans);
}

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

int main(){ 
int n; cin >> n;
map<string, int> mp;
vector<string>  a(n);
int mx = 0;
for(int i = 0; i < n; i++){
string s; cin >> s;
a[i] = s;
mp[s]++;
mx = max(mx, mp[s]);
if(mp[s]>=2)a[i] ="-1";
}
vector<string> b;
for(int i = 0; i < n; i++){
if(mp[a[i]]==mx) b.push_back(a[i]);
}
sort(b.begin(), b.end());
for(int i = 0; i < b.size(); i++) cout << b[i] << endl;
return 0;
}


Measured memory_bytes: 33436
#include<stdio.h>
int solve(int,int);
int A[2000],n;

int solve(int x,int y) {
  if(A[x] == y)
    return 1;
  if(x+1 == n)
    return 0;
  if(solve(x+1,y-A[x]) || solve(x+1,y)) 
    return 1;
  return 0;  
  }
int main(void) {

  int S[2000],i,m;

  scanf("%d",&n);
  
  for(i=0;i<n;i++) 
    scanf("%d",&A[i]);
  
  scanf("%d",&m);
  for(i=0;i<m;i++) 
    scanf("%d",&S[i]);
  
  for(i=0;i<m;i++) {
    if(solve(0,S[i])) 
      printf("yes\n");
    else printf("no\n");
    
  }
  return 0; 
}

Measured memory_bytes: 588
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

initTheta = pi / 2

aVelocity = pi / 360 -- 分速
bVelocity = pi / 30 -- 分速

abNoZahyou a b h m =  sqrt $ a**2 + b**2 - (2*a*b* (cos diffTheta))
  where
    toMinuts = m + (60*h)
    aTheta = toMinuts * aVelocity + initTheta
    bTheta = m * bVelocity + initTheta
    diffTheta = abs $ aTheta - bTheta
    (ax,ay) = (a * cos (aTheta), a * sin (aTheta))
    (bx,by) = (b * cos (bTheta), b * sin (bTheta))

main = do
  [a,b,h,m] <- map read . words <$> getLine :: IO [Double]
  print $ abNoZahyou a b h m


Measured memory_bytes: 4584