akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,D,X;
	cin>>N>>D>>X;
	fx(N){
		int a;
		cin>>a;
		int i=0;
		while(1+a*i<=D){
			X++;
			i++;
		}
		
	}
	ce(X)

}

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

#define ll long long
#define ull unsigned long long

#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >

#define pb push_back

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

bool chkbit(ll n, ll k)
{
    return n & (1LL << k);
}

int main()
{
    fast;

    ll n;

    cin >> n;

    vll a(n);

    for(int i = 0; i < n; i++) cin >> a[i];

    ll ans = 0;

    for(ll i = 0; i < 61; i++){
        ll cnt = 0;

        for(auto x : a) cnt += chkbit(x, i);

        ll tmp1 = (cnt * (n - cnt)) % mod;
        ll tmp2 = (1LL << i) % mod;
        ll tmp3 = (tmp1 * tmp2) % mod;
        ans += tmp3;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}



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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 == 0) {
            continue;
        }

        int count = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) {
                ++count;
            }
        }

        if (count == 8) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,char>mp;
int main(){
  char a,ans;
  cin>>a;
  if(a=='A'){
    ans='T';
  }
  else if(a=='T'){
    ans='A';
  }
  else if(a=='G'){
    ans='C';
  }
  else{
    ans='G';
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ULL>
#define vll vector<LL>
#define mod 1000000007

int main(void){
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<


using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

double a,b,x;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>a>>b>>x;
	double ar= a*a*b;
	double adh = ar/2;
	if(x>=adh){
		double adda = ar - x;
		adda*=2;
		double cali = adda / (a*a*a);
		double res = atan(cali);
		res*=180;
		res/=PI;
		cout<<fixed<<std::setprecision(10)<<res<<endl;
		return 0; 
	}
	double bali = a*b*b;
	double cali = bali / (2*x);
	double res = atan(cali);
	res*=180;
	res/=PI;
	cout<<fixed<<std::setprecision(10)<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	xs := x2 - x1
	ys := y2 - y1
	x3 := x2 - ys
	y3 := y2 + xs
	x4 := x1 - ys
	y4 := y1 + xs
	fmt.Printf("%d %d %d %d", x3, y3, x4, y4)

}


Measured memory_bytes: 512
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if (X < Y)&(max(x) < min(y))&(max(x) < Y)&(X < min(y)):
    print("No War")
else:
    print("War")

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{   
   int n,x,q,a,b,c,ans=0;cin>>n;mii m;
   for(int i=0;i<n;i++)
   {
     cin >> x;
     m[x]++;
     ans+=x;
   }
   cin >> q;
   while(q--)
   {
     cin >> b >> c;
     a=m[b];
     ans-=(a*b);
     m[b]=0;
     m[c]+=a;
     ans+=a*c;
     cout << ans << endl;
   }
   
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 9536
N, K, Q = map(int, input().split())
As = list(map(int, input().split()))

ans = 10 ** 9
for Y in sorted(As)[:N - Q - K + 2]:
    cands = []
    cs = []
    for A in As + [0]: # 最終要素は番兵
        if A < Y:
            if len(cs) >= K:
                cands += sorted(cs)[:len(cs) - K + 1]
            cs = []
        else:
            cs += [A]

    if len(cands) < Q: continue
    X = sorted(cands)[Q - 1]

    ans = min(ans, X - Y)

print(ans)


Measured memory_bytes: 3316
<?php
$s = trim(fgets(STDIN));

$f = true;

if ($s[0] !== 'A') {
    $f = false;
}

$C = 0;
$ss = ' ABDEFGHIJKLMNOPQRSTUVWXYZ';
for ($i = 2; $i < strlen($s); $i++) {
    if (strpos($ss, $s[$i]) > 0) {
        $f = false;
    }

    if ($i >= 2 && $i < strlen($s) - 1 && $s[$i] === 'C') {
        $C++;
    }
}
$sss = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (strpos($sss, $s[1])) {
    $f = false;
}
if ($C !== 1) {
    $f = false;
}
if ($s[strlen($s) - 1] === 'C') {
    $f = false;
}

if ($f) {
    echo 'AC' . PHP_EOL;
} else {
    echo 'WA' . PHP_EOL;
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
 
// #define fisier 1
 
using namespace std;
 
typedef long long ll;
 
int n, v[200002];
deque<pair<int, int> >d;
bool chk(int mx)
{
    d.clear();
    for(int i = 1; i <= n; ++i)
    {
        if(v[i] > v[i-1])
            d.pb({v[i] - v[i-1], 1});
        else
        {
            int sum = v[i-1];
            while(sum >= v[i])
            {
                pair<int, int> x = d.back();
                if(sum - x.fi >= v[i])
                {
                    sum -= x.fi;
                    d.pop_back();
                }
                else
                {
                    int dif = sum - v[i];
                    x.fi -= dif;
                    d.pop_back();
                    if(x.fi)
                        d.pb(x);
                    sum = v[i];
                    break;
                }
            }
            while(!d.empty())
            {
                pair<int, int> x = d.back();
                if(x.se == mx)
                {
                    sum -= x.fi;
                    d.pop_back();
                }
                else
                {
                    --x.fi;
                    d.pop_back();
                    if(x.fi)
                        d.pb(x);
                    d.pb({1, x.se + 1});
                    if(v[i] - sum)
                        d.pb({v[i] - sum, 1});
                    break;
                }
            }
            if(d.empty())
                return 0;
        }
    }
    return 1;
}
int main()
{
 
   // ifstream cin("a.in");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    int st = 1;
    int dr = n;
    int ans = n;
    while(st <= dr)
    {
        int mid = (st + dr) / 2;
        if(chk(mid))
            ans = mid, dr = mid - 1;
        else
            st = mid + 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int n,m; cin>>n>>m;
    vector<int> x;
    rep(i,m) {int y; cin>>y; x.push_back(y);}
    sort(all(x));
    if (n >= m){
        cout<<0<<endl; return 0;
    }else{
        vector<int> y;
        rep(i,m-1) y.push_back(x[i+1]-x[i]);
        sort(all(y), greater<int>());
        int sum = x[m-1]-x[0];
        rep(i, n-1) sum-=y[i];
        cout<<sum<<endl; return 0;
    }
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n;
    cin >> n;
    int x;
    int min=1e6,cnt=0;
    F(i,0,n){
        cin >> x;
        if(min>x){
            ++cnt;
            min=x;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product

H, W, K = map(int, input().split())
ary = []
for y in range(H):
    ary.append(input())

case = 0
for yb in range(1<<H):
    for xb in range(1<<W):
        nb = 0
        for y in range(H):
            for x in range(W):
                if ((not ((yb >> y) & 1) and ((xb >> x) & 1))) and ary[y][x] == '#':
                    nb += 1
        if nb == K:
            case += 1

print(case)


Measured memory_bytes: 9068
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mx 100000000
int md=1e9+7;
int __gcd(int a, int b) {if(b==0) return a; return __gcd(b, a%b);}
int poww(int a, int b) {int res=1;while(b) {if(b&1){res*=a;res%=md;}a*=a;a%=md;b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=0;i<n;i++) cin>>arr[i];}
void vinp(vector<int> v,int n){for(int i=0;i<n;i++){int a;cin>>a;v.push_back(a);}}
map<int, int> mapp;
set<int> s;vector<int> v;
bool prime[mx];

void seive(int n) 
{ 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; }}} 
void fun()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}



signed main()
{  fun();
	int a,b;
	char ch;
	cin>>a>>ch>>b;
	if(ch=='+')
	{
		cout<<a+b;
	}
	else
	{
		cout<<a-b;
	}
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import copy

N = int(input())
A = [int(input()) for i in range(N)]

Amax = max(A)
TMP = copy.deepcopy(A)
TMP.remove(Amax)
Amax2 = max(TMP)

for i in range(N):
        if A[i] == Amax:
                print(Amax2)
        else:
                print(Amax)
                

Measured memory_bytes: 96984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<pair<string, int>> card;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    bool flag = true;
    for(int j = 0; j < card.size(); j++){
      if(card.at(j).first == s){
        card.at(j).second++;
        flag = false;
        break;
      }
    }
    if(flag)
      card.push_back(make_pair(s,1));
  }
  int m; cin >> m;
  for(int i = 0; i < m; i++){
    string s; cin >> s;
    bool flag = true;
    for(int j = 0; j < card.size(); j++){
      if(card.at(j).first == s){
        card.at(j).second--;
        flag = false;
        break;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < card.size(); i++){
    ans = max(ans,card.at(i).second);
  }
  cout << ans;
}
      

Measured memory_bytes: 3628
#include<stdio.h>

void swap(int *a , int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main () {
	int sticks[31];
	int stickNum , rootNum;
	int rootFrom , rootTo;
	int i;

	scanf("%d" , &stickNum);
	for(i = 1; i <= stickNum; i++) {
		sticks[i] = i;
	}

	scanf("%d" , &rootNum);
	for(i = 0; i < rootNum; i++) {
		scanf("%d,%d" , &rootFrom , &rootTo);
		swap(&sticks[rootFrom] , &sticks[rootTo]);
	}

	for(i = 1; i <= stickNum; i++) {
		printf("%d\n" , sticks[i]);
	}

	return 0;
}

Measured memory_bytes: 596
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   long long int n;
   while(cin>>n)
   {
     int kk=(int)(sqrt(n));
     long long int result=kk*kk;
     cout<<result<<endl;       
   }
   return 0;
 }
 

        

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int keta(int n)
{
	int cnt = 1;
	while (n > 9)
	{
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main()
{
	int n;
	scanf("%d", &n);
	// printf ("%d\n", keta(n));
	int i = 1;
	int cnt = 0;
	while (i <= n)
	{
		if (keta(i) % 2)
			cnt++;
		i++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define MAX 10000
using namespace std;
int main() {
    int conp[101];
    int a = 0;
    int b = 0;
    int n = 0;
    int ans = 0;
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i) {
        cin >> conp[i];
    }
    sort(conp,conp+n);
    for (int j = 0; j < n; j++) {
        if(conp[j] <= a){
            for (int i = 0; i < n; ++i) {
                if(conp[i] <= b && conp[i] > a){
                    for (int k = 0; k < n; ++k) {
                        if(conp[k] > b && conp[k] < 21){
                            ans++;
                            conp[j] = MAX;
                            conp[i] = MAX;
                            conp[k] = MAX;
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef pair<int,int> P;

int main(){
	int w,h;
	while(cin>>w>>h,w,h){
		char board[114][514];
		int pass[114][514];
		
		int xs,ys,xg,yg;
		cin>>xs>>ys>>xg>>yg;
		
		for(int i=0;i<=110;i++){
		for(int j=0;j<=110;j++){pass[i][j]=INF;
			board[i][j]='#';
			}}
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			char a;
			int b,c,d;
			cin>>a>>b>>c>>d;
			
			if(b==0){
				for(int j=0;j<2;j++)
				for(int k=0;k<4;k++)board[d+j][c+k]=a;
				}
			else{
				for(int j=0;j<2;j++)
				for(int k=0;k<4;k++)board[d+k][c+j]=a;
				}	
			}
		
		queue<P>Q;
		Q.push(P(ys,xs));
		pass[ys][xs]=0;
		
		while(Q.size()){
			P p=Q.front();
			Q.pop();
			
			if(p.first==yg&&p.second==xg)break;
			
			int dir[2][4]={{1,0,-1,0},{0,1,0,-1}};
			for(int i=0;i<4;i++){
				int ny=p.first+dir[0][i];
				int nx=p.second+dir[1][i];
				
				if(0<=ny&&ny<=h&&0<=nx&&nx<=w&&board[ny][nx]==board[ys][xs]&&pass[ny][nx]==INF){
					Q.push(P(ny,nx));
					pass[ny][nx]=pass[p.first][p.second]+1;
					}
				}
			}
		
		if(pass[yg][xg]!=INF)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
		
		}
		return 0;
	}

Measured memory_bytes: 3304
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()




int main() {
	ll x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	};
	public static void main(String[] __){
		int a=s.nextInt(),b=s.nextInt(),c=s.nextInt();
		
		if(a==b&&b==c&&a%2==0) {
			System.out.println(-1);
			return;
		}
		
		for(int i=0;i<10000000;i++) {
			if(a%2+b%2+c%2>0) {
				System.out.println(i);
				return;
			}
			final int ba=b/2+c/2;
			final int bb=c/2+a/2;
			final int bc=a/2+b/2;
			a=ba;
			b=bb;
			c=bc;
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b) {
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if(a<b){a=b;return true;}
	return false;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=1e9+7;
constexpr int inf=3e18;


int N,M;
vector<int>G[100005];
vector<int>G2[300005];
bool used[100005];
vector<int>xx;
void dfs(int x){
	used[x]=true;
	for(int i:G[x])if(!used[i]){
		dfs(i);
	}
	xx.push_back(x);
}
int bfs(){
	queue<P>que;
	int dis[300005];
	fill(dis,dis+300000,inf);
	dis[0]=0;que.push({0,0});
	while(!que.empty()){
		P p=que.front();que.pop();
		if(dis[p.second]<p.first)continue;
		for(int i:G2[p.second]){
			if(dis[i]==inf){
				dis[i]=p.first+1;
				que.push({dis[i],i});
			}
		}
	}
	return dis[N-1];
}
vector<P>edge[1000005];
signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b,c;cin>>a>>b>>c;a--;b--;c--;
		edge[c].push_back({a,b});
	}
	int now=100000;
	rep(i,1000000){
		for(P j:edge[i]){
			G[j.first].push_back(j.second);
			G[j.second].push_back(j.first);
		}
		for(P j:edge[i]){
			if(!used[j.first]){
				dfs(j.first);
				for(int k:xx){
					G2[now].push_back(k);
					G2[k].push_back(now);
				}
				now++;
				xx.clear();
			}
			if(!used[j.second]){
				dfs(j.second);
				for(int k:xx){
					G2[now].push_back(k);
					G2[k].push_back(now);
				}
				now++;
				xx.clear();
			}
		}
		for(P j:edge[i]){
			used[j.first]=false;
			used[j.second]=false;
			G[j.first].clear();
			G[j.second].clear();
		}
	}
	int ans=bfs();
	cout<<(ans==inf?-1:ans/2)<<endl;
}


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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define inf 1000*1000*1000+5
const ll mod=998244353;


void solve()
{
	string str;
	cin>>str;
	if(str[2]==str[3]&&str[4]==str[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return;
}
int main()
{
	solve();
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define vpii vector<pair<int,int>>

using namespace std;

int n,m;

main()
{
        cin>>n;

        vpii v;
        rep(i,n)
        {
                int a,b;
                cin>>a>>b;
                v.push_back(make_pair(b,a));
        }

        sort(ALL(v));


        for(auto it : v)
        {
                m+=it.second;
                if(it.first<m)
                {
                        cout<<"No"<<endl;
                        return 0;
                }
        }

        cout<<"Yes"<<endl;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  double ans=0;
  while(n--) {
    double x,y;
    cin >> x >> y;
    ans=max(ans,y/x);
  }
  printf("%.10f\n",ans*m);
  return 0;
}


Measured memory_bytes: 3272
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, total = 0, mx = 0;
	scanf("%d", &n);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		total += j;
		mx = max(mx, j);
	}
	printf("%d\n", total - mx / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef int Read ; // Here to change the type of numbers
inline Read Readin() {
	Read K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline Read Min( Read A , Read B ) { return A < B ? A : B ; }
inline Read Max( Read A , Read B ) { return A > B ? A : B ; }
inline Read Abs( Read A ) { return A < 0 ? -A : A ; }

int main() {
	long long S ;
	int Ans = 1000000 ;
	scanf( "%lld" , &S ) ;
	while( S >= 1000 ) {
		Ans = Min( Abs( S % 1000 - 753 ) , Ans ) ;
		S /= 10 ;
	}
	Ans = Min( Abs( S - 753 ) , Ans ) ;
	printf( "%d\n" , Ans ) ;
	return 0 ;
	
}

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

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

using namespace std;
using lint=long long;

lint dfs(string s,lint sum){
	int n=s.length();
	if(n==0) return sum;
	lint res=0;
	rep(i,n) res+=dfs(s.substr(i+1),sum+stoll(s.substr(0,i+1)));
	return res;
}

int main(){
	string s; cin>>s;
	cout<<dfs(s,0)<<'\n';
	return 0;
}


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

int main() {
    long M,N;
    cin >> M >> N;
    if (M==1 && N == 1){
        cout << 1 << endl;
    }else if(M== 1){
        cout << N - 2 << endl;
    }else if(N == 1){
        cout << M - 2 << endl;
    }else{
        cout << (M-2)*(N-2) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b,c;
    cin >> a;
    if(65 <=a && a<=90){
        cout << "1";
    }
    else if(97<=a && a<=122){
        cout << "2";
    }
    else{
        cout << "0";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a>b) {
            System.out.println("a > b");
        }else if(a<b) {
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26192
import sys
sys.setrecursionlimit(int(1e6))

N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

H.sort()
n = len(H) - K
if n > 0:
    ans = sum(H[:n])
else:
    ans = 0
print(ans)


Measured memory_bytes: 26024
# -*- coding: utf-8 -*-

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, K = map(int, input().split())

for i in range(1, K+1):

    ans = cmb(N-K+1, i, mod) * cmb(K-1, i-1, mod) % mod

    print(ans)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

long long gcd(long long c, long long d) {
  if (c < d) swap(c, d);

  while (d > 0LL) {
    long long r = c % d;
    c = d;
    d = r;
  }

  return c;
}


int main() {
  long long A, B, C, D, CD, x, y;
  cin >> A >> B >> C >> D;
  CD = C * D / gcd(C, D);

  long long ac, bc, ad, bd, acd, bcd;

  ac = A / C;
  if (A % C == 0) ac--;
  ad = A / D;
  if (A % D == 0) ad--;
  acd = A / CD;
  if (A % CD == 0) acd--;

  bc = B / C;
  bd = B / D;
  bcd = B / CD;

  long long ans;

  ans = B - A + 1 - (bc-ac) - (bd-ad) + (bcd-acd);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> S(4,true);
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    char houkou = s.at(i);
    switch (houkou){
      case 'N': S.at(0) = false;
        		break;
      case 'W': S.at(1) = false;
        		break;
      case 'S': S.at(2) = false;
        		break;
      case 'E': S.at(3) = false;
        		break;
    }
  }
  if((S.at(0) == S.at(2)) and (S.at(1) == S.at(3)))
    cout << "Yes" << endl;
  else
 	cout << "No" << endl;
      
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

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

			String s = sc.next();
			String a[] = new String[4];

			for (int i = 0; i < 4; i++) {
				a[i] = s.substring(i, i + 1);
			}
			
			Arrays.sort(a);
			if (a[0].equals(a[1]) && a[2].equals(a[3]) && !(a[1].equals(a[2]))) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		}

	}

}

Measured memory_bytes: 21716
r,c = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(r)]

for ai in a:
  print(*ai,end=' ')
  print(sum(ai))
for j in range(c):
  print(sum([a[i][j] for i in range(r)]),end=' ')
print(sum([sum(ai)for ai in a]))


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer buffer = new StringTokenizer(br.readLine());
			int sec = Integer.parseInt(buffer.nextToken());
			
			int h = sec / 3600;
			int m = sec % 3600 / 60;
			int s = sec % 60;
			
			System.out.printf("%d:%d:%d\n",h,m,s);
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int d[10][10];

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

    for(int i=1; i<=n; ++i) {
        string s;
        s = to_string(i);
        ++d[s[0] - '0'][s[s.size()-1] - '0'];
    }

    ll ans = 0;
    for(int i=1; i<10; ++i) {
        for(int k=1; k<10; ++k) {
            if (i!=k) {
                ans += (d[i][k] * d[k][i]);
            } else {
                ans += d[i][k] * d[i][k];
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun Int.isOdd() = this % 2 == 1
    fun Int.isEven() = this % 2 == 0

    val s = readLine()!!.toCharArray()
    println(
        if (s.filterIndexed { index, c -> index.isEven() }
                .all{ it != 'L' }
            &&
            s.filterIndexed { index, c -> index.isOdd() }
                .all { it != 'R' }
        ) {
            "Yes"
        } else {
            "No"
        }
    )
}

Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    ll max = 0;
    repl(i, 1, n + 1) {
        sum += (ll) i;
        if(sum >= n) {
            max = i;
            break;
        }
    }
    ll r = sum - (ll) n;
    repl(i, 1, max + 1) {
        if(i != r) {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[][] way = new int[N][N];
		scn.nextLine();
		for (int j = 0; j < N; j++) {
			char[] ss = scn.nextLine().toCharArray();
			for(int i = 0;i < N;i++) {
				way[j][i] = (ss[i] == 48)?0:1;
			}
		}

		int ans = -1;

		for (int n = 0; n < N; n++) {

			int[] group = new int[N];
			boolean can = true;
			HashSet<Integer> the = new HashSet<Integer>();
			HashSet<Integer> next = new HashSet<Integer>();

			int now_g = 0;
			next.add(n);
			while (!next.isEmpty()) {
				the = new HashSet<Integer>();
				now_g++;
				for(int j:next) {
					the.add(j);
					group[j] = now_g;
				}
				next = new HashSet<Integer>();
				for (int j : the) {
					for (int i = 0; i < N; i++) {
						if (way[j][i] != 1)
							continue;
						if(group[i] != 0) {
							if(group[i] == now_g-1) {

								continue;
							}else {
								can = false;
								break;
							}
						}
						next.add(i);
					}
					if(!can)break;
				}
			}

			if(can)ans = Math.max(now_g, ans);
		}
		System.out.println((ans < 2)?-1:ans);

	}

}


Measured memory_bytes: 43228
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
char S[1000001];

bool f(int X) {
  int rem = X;
  int s_i = 0, s_io = 0, s_ioi = 0;
  rep(i, N) {
    if (S[i] == 'I') {
      if (rem > 0) {
        rem--;
        s_i++;
      }
      else {
        if (s_io > 0) s_ioi++, s_io--;
      }
    }
    else if (S[i] == 'O') {
      if (s_i > 0) s_io++, s_i--;
    }
    else {
      // J
      if (s_io > 0) s_ioi++, s_io--;
    }
  }
  return s_ioi >= X;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  cin >> S;
  reverse(S, S+N);
  int lo = 0, hi = N;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) lo = mid;
    else hi = mid;
  }
  cout << lo << "\n";
  return 0;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int dp[110005];

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

	rep(i, 110005) dp[i] = INF;
	dp[0] = 0;

	for(int i = 0;i < n;i++) {
		chmin(dp[i+1], dp[i] + abs(h[i] - h[i + 1]));
		chmin(dp[i+2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1152
N,M = map(int, input().split())
ID = [ list(map(int,input().split())) + [i] for i in range(M)]

ID.sort()
town = 0

for i in range(M):
    if ID[i][0] != town:
        town = ID[i][0]
        count = 1
        ID[i].append("0"*(6-len(str(town)))+str(town)+"0"*(6-len(str(count)))+str(count))
    else:
        count += 1
        ID[i].append("0"*(6-len(str(town)))+str(town)+"0"*(6-len(str(count)))+str(count))
        
ID.sort(key=lambda x:x[2])

for i in range(M):
    print(ID[i][3])

Measured memory_bytes: 35008
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toLong()}
    val p = TreeMap<Long, Long>()

    for (i in 1..M) {
        val (b, c) = readLine()!!.split(" ").map{it.toInt()}
        p[c.toLong()] = (p[c.toLong()] ?: 0L) + b
    }
    for (i in A.indices) {
        p[A[i]] = (p[A[i]] ?: 0L) + 1
    }

    var res = 0L
    var cnt = 0L
    while (cnt < N) {
        val e = p.pollLastEntry()
        val num = Math.min(N - cnt, e.value)
        res += e.key * num
        cnt += num
    }

    println(res)
}


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

enum {A, B, C, ACT_NUM};

constexpr int MAX_N = 1e5;

int act[MAX_N][ACT_NUM];
int dp[MAX_N][ACT_NUM];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i)
    cin >> act[i][A] >> act[i][B] >> act[i][C];

  dp[0][A] = act[0][A];
  dp[0][B] = act[0][B];
  dp[0][C] = act[0][C];

  for (int i{1}; i < N; ++i) {
    chmax(dp[i][A], dp[i-1][B] + act[i][A]);
    chmax(dp[i][A], dp[i-1][C] + act[i][A]);
    chmax(dp[i][B], dp[i-1][C] + act[i][B]);
    chmax(dp[i][B], dp[i-1][A] + act[i][B]);
    chmax(dp[i][C], dp[i-1][A] + act[i][C]);
    chmax(dp[i][C], dp[i-1][B] + act[i][C]);
  }

  cout << max(max(dp[N-1][A], dp[N-1][B]), dp[N-1][C]) << endl;

  return 0;
}


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

int stack[500];
int idx = 0;

int pop() {
    return stack[--idx];
}

void push(int n) {
    stack[idx++] = n;
}

int main (void) {
    int n, i;
    char s[100];

    int a, b;

    while (scanf("%s", s) != EOF) {

        switch (s[0]) {
            case '+':
                push(pop() + pop());
                break;
            case '-':
                a = pop();
                b = pop();
                //printf("%d %d\n", a, b);
                push(-1 * a + b);
                break;
            case '*':
                push(pop() * pop());
                break;
            default:
                push(atoi(s));
                break;
        }
    }

    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll x;
    ll now = 100;
    ll ans = 0;

    std::cin >> x;

    while(now < x) {
        now += static_cast<double>(now) * 0.01;
        ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> L( M );
	set<int> LL;
	for( int i = 0; i < N; i++ ) {
		int K;
		cin >> K;
		for( int j = 0; j < K; j++ ) {
			int l;
			cin >> l;
			l--;
			L[l].push_back( i );
			if( L[l].size() ) LL.insert( l );
		}
	}

	UnionFind uf( N );
	for( auto it = LL.begin(); it != LL.end(); it++ ) {
		int i = *it;
		int a;
		for( int j = 0; j < L[i].size(); j++ ) {
			if( j == 0 ) {
				a = L[i][j];
			}
			else {
				uf.unionSet( a, L[i][j] );
			}
		}
	}
	string ans = "YES";
	if( uf.size( 0 ) != N ) {
		ans = "NO";
	}

	cout << ans << endl;
}

Measured memory_bytes: 7552
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int MOD = (int)1e9 + 7;
int cnt[87];
LL pw[87];

LL add(LL a, LL b) {
   return (a + b) % MOD;
}

LL mul(LL a, LL b) {
   return (a * b) % MOD;
}


int main() {
    int N;
    scanf("%d", &N);
    pw[0] = 1;
    for (int i = 1; i < 87; i++)
        pw[i] = (pw[i - 1] * 2) % MOD;
    LL ans = 0;
    for (int i = 0; i < N; i++) {
        LL tmp;
        scanf("%lld", &tmp);
        for (int j = 0; j <= 60; j++) {
            int num = 0;
            if (tmp & ((LL)1 << j)) {
               num = i - cnt[j];
               cnt[j]++;
            } else {
               num = cnt[j];
            }
            ans = add(ans, mul(num, pw[j]));
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int ,int>;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    Graph G(n);
    rep(i, n) {
        int _, k; cin >> _ >> k;
        rep(j, k) {
            int x; cin >> x; x--;
            G[i].push_back(x);
        }
    }

    queue<int> que;
    vector<int> seen(n, -1);
    que.push(0);
    seen[0] = 0;
    while (que.size()) {
        int v = que.front();
        que.pop();
        for(const auto nv: G[v]) {
            if (seen[nv]!=-1) continue;
            seen[nv] = seen[v]+1;
            que.push(nv);
        }
    }
    
    rep(i, n) {
        cout << i+1 << " " << seen[i] << endl;
    }
}


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



int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N,0);
    vector<ll> B(M,0);
    ll sum_A = 0, sum_B = 0;
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        sum_A += tmp;
        A[i] = sum_A;
    } 
    for(int i = 0; i < M; i++){
        ll tmp;
        cin >> tmp;
        sum_B += tmp;
        B[i] = sum_B;
    }

    ll ans = 0;

    for(ll i = 0; i < N; i++){
        if(A[i] <= K){
            ans = max(ans,i + 1);
        }
    }


    for(ll i = 0; i < M; i++){
        if(B[i] <= K){
            ans = max(ans,i + 1);
        }
    }
    

    for(ll i = 0; i < N; i++){
        ll tmp = K - A[i];
        if(tmp < 0) continue;
        auto it = upper_bound(B.begin(), B.end(),tmp);
        if(it != B.end() && it != B.begin()){
            ans = max(ans,((it - B.begin())) + i + 1);
        }
        else if(it == B.end() && B[M - 1] <= tmp ){
            ans = max(ans,i + 1 + M); 
        }

    }

    cout << ans << endl;
}


Measured memory_bytes: 6380
#include  <stdio.h>
#include  <stdlib.h>	
#include  <string.h>

int top, S[1000];

void push(int x){
	top ++; 
	S[top] = x;
}
int pop(){
	top--;
	return S[top+1];
}

int main (void){
		int a,b;
	top = 0;
	char s [100];
	while ( scanf("%s",s) != EOF ){
	
		if( s[0] == '+' ){
			a = pop();
			b = pop();
			push ( a + b );
		} else if (s[0] == '-'){
			b = pop();
			a = pop();
			push (a-b);
		} else if ( s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		} else {
			push(atoi(s));
		}
	}

	printf( "%d\n",pop());
	return 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N, K;
		N = sc.nextLong();
		K = sc.nextLong();
		System.out.println(Math.min(N % K, ((-N % K)+K)%K));
	}
}

Measured memory_bytes: 35576
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=200005;

void solve()
{
    char ch;
    cin>>ch;
    if(ch>='A'&&ch<='Z')
        cout<<"A";
    else
        cout<<"a";
    cout<<endl;
    
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 3648
#include <iostream>

int main(int argc, char const *argv[]) {
  while(1){
    int H=0,W=0;
    std::cin >> H >> W;
    if((H==0)&&(W==0))break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i==0 || i==(H-1)){
          std::cout << "#";
        }else if(j==0 || j==(W-1)){
          std::cout << "#";
        }else std::cout << ".";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
 
#define reep(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	ll n;
	while(cin>>n,n){
		vector<ll> v(n-1);
		vector<ll> x((n-1)/2);
		for(ll i=0;i<n-1;i++){
			v[i]=((i+1)*(i+1))%n;
			// cout<<i<<" "<<v[i]<<endl;
		}
		sort(ALL(v));
		v.erase(unique(ALL(v)),v.end());
		rep(i,v.size()){
			// cout<<v[i]<<endl;
			rep(j,v.size()){
				if(i==j) continue;
				ll a=v[i]-v[j];
				if(a<0) a+=n;
				if(a>(n-1)/2) a=n-a;
				x[a-1]++;
			}
		}
		rep(i,x.size()){
			cout<<x[i]<<endl;
		}
		// cout<<endl;
	}
}

Measured memory_bytes: 1328
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a, b, c;
    string ans = "";
    cin >> a >> b >> c;
    if ((a == b && a != c) || (b == c && b != a) || (c == a && c != b)){
        ans = "Yes";
    }
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 3124
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var stack = new Stack<int>();
        var s = Console.ReadLine().Split();
        foreach (var item in s)
        {
            var i = 0;
            if (int.TryParse(item, out i))
            {
                stack.Push(i);
            }
            else
            {
                var a = stack.Pop();
                var b = stack.Pop();
                if (item == "+")
                {
                    stack.Push(a + b);
                }
                else if (item == "-")
                {
                    stack.Push(b - a);
                }
                else
                {
                    stack.Push(a * b);
                }
            }
        }
        Console.WriteLine(stack.Pop());
    }
}


Measured memory_bytes: 18340
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


H, W = map(int, input().split())

ans = H*W
hh = int(H%3!=0)
ww = int(W%3!=0)
if H>=3:
    ans = min(ans, W*hh)
if W>=3:
    ans = min(ans, H*ww)

ww1 = W//2
ww2 = W//2 + W%2
for i in range(1,H):
    v1,v2,v3 = ww1*i, ww2*i, W*(H-i)
    ans = min(ans, max(v1,v2,v3)-min(v1,v2,v3))
#     print(max(v1,v2,v3)-min(v1,v2,v3), i)

hh1 = H//2
hh2 = H//2 + H%2
for i in range(1,W):
    v1,v2,v3 = hh1*i, hh2*i, H*(W-i)
    ans = min(ans, max(v1,v2,v3)-min(v1,v2,v3))
print(ans)

Measured memory_bytes: 67860