akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N, K; cin >> N >> K;
    vector<int> A(N+1);
    for(int i=1; i<=N; i++){
        cin >> A.at(i);
    }

    vector<int> dist(N+1,-1);

    int cnt = 0;
    int next = 1;
    while(dist.at(next) == -1 && K != 0){
        dist.at(next) = cnt+1;
        next = A.at(next);
        cnt++;
        K--;
    }

    if(K==0){
        cout << next << endl;
        return 0;
    }

    int loop = cnt+1 - dist.at(next);
    K %= loop;

    while(K != 0){
        next = A.at(next);
        K--;
    }
    cout << next << endl;

}

Measured memory_bytes: 4816
#include<stdio.h>
int main()
{
    int a[10],i,j,k,t;

    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    for(j=0;j<10;j++)
        for(k=0;k<9;k++)
        {
            if(a[k]<a[k+1])
            {
                t=a[k];
                a[k]=a[k+1];
                a[k+1]=t;
            }
        }
    for(i=0;i<3;i++)
        printf("%d\n",a[i]);

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,c=0,a[100];
    double s=0,av,ch;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    av=(double)(s/n);
    ch=abs(av-a[0]);
    if(ch==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    for(i=1; i<n; i++)
    {
        if(abs(av-a[i])==0)
        {
            cout<<i<<endl;
            return 0;
        }
        else
        {
            if(abs(av-a[i])<ch)
            {
                ch=abs(av-a[i]);
                c=i;
            }
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,count,k=1;
    
    cin >> A >> B;
    
    count = A;
    
    while(count < B){
        count += (A-1);
        k++;
    }
    if(B == 1) k = 0;
    cout << k << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
   int n;
   cin >> n;
  int kai = n/100;
  int atai = n-kai*100;
  if(kai*100<=n&&n<=kai*105)cout<<1<<endl;
  else{
    cout << 0 <<endl;
  }
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const LL inf = 1 << 30;
map<char,int>mp;
const int maxn = 1e4;
int n = 0,m;
int num[3];
int main(){
	for(int i = 0;i<3;i++)
		cin >> num[i];
	cin >> m;
	sort(num,num+3);
	for(int i = 0;i<m;i++)
		num[2]*=2;
	n += num[1],n+=num[2],n+=num[0];
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

vector<vector<int>> V;
vector<int> dx{0, 0, 1, 1, 1, -1, -1, -1};
vector<int> dy{1, -1, 0, 1, -1, 0, 1, -1};
vector<vector<bool>> seen;
int W = 1, H = 1, Ans = 0;


void dfs(int y, int x){
seen[y][x] = 1;

for(int i = 0; i < 8; i++){
int ny = y + dy[i], nx = x + dx[i];

if(ny < 0 || ny >= H || nx < 0 || nx >= W)continue;

if(V[ny][nx] == 0)continue;

if(seen[ny][nx])continue;

dfs(ny, nx);
}



}


int main() {


while(1){

cin >> W >> H;
if(H == 0 && W == 0)break;

V.resize(H);
seen.resize(H);

for(int i = 0; i < H; i++){
V[i].resize(W);seen[i].resize(W);}

for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
cin >> V[i][j];
//cout << V.at(i).at(j);
seen[i][j] = 0;
}}

for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(V[i][j] == 1 && seen[i][j] == 0){dfs(i, j);Ans++;}
}}
cout << Ans << endl;
Ans = 0;
}


}


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

int main()
{
	multiset<int> s;
	for(int i=0;i<10;i++){
		int in;
		cin >> in;
		s.insert(in);
	}
	
	multiset<int>::iterator it = s.end();
	--it;
	for(int i=0;i<3;i++){
		cout << *it << endl;
		--it;
	}
	return 0;
}

Measured memory_bytes: 1192
import Control.Applicative
import Control.Monad (replicateM, unless)

solver :: Int -> [Int] -> [String]
solver 10 _  = []
solver n xs =
  let y = length (filter ( == n) xs)
  in
    if y == 0
      then "-" : solver (n+1) xs
    else
      concat (replicate y "*") : solver (n+1) xs

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  unless (n == 0) $ do
    inputs <- map (read :: String -> Int) <$> replicateM n getLine
    mapM_ putStrLn $ solver 0 inputs
    main

Measured memory_bytes: 6212
#include <stdio.h>
#define inf 999999999
int main(){
    int h,w,cost[50][50],cnt;
    char s[50][50];
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",s[i]);
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cost[i][j]=inf;
    cost[0][0]=1;
    for(int k=1;cost[h-1][w-1]==inf;k++){
        cnt=0;
        for(int i=0;i<h;i++) for(int j=0;j<w;j++){
            if(cost[i][j]==k){
                cnt++;
                if(i>0&&s[i-1][j]=='.'&&cost[i-1][j]>k)cost[i-1][j]=k+1;
                if(j>0&&s[i][j-1]=='.'&&cost[i][j-1]>k)cost[i][j-1]=k+1;
                if(i<49&&s[i+1][j]=='.'&&cost[i+1][j]>k)cost[i+1][j]=k+1;
                if(j<49&&s[i][j+1]=='.'&&cost[i][j+1]>k)cost[i][j+1]=k+1;
            }
        }
        if(cnt==0){
            printf("-1\n");
            return 0;
        }
    }
    cnt=0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(s[i][j]=='.') cnt++;
    printf("%d\n",cnt-cost[h-1][w-1]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  if(s[0]=='S') puts("Cloudy");
  else if(s[0]=='C') puts("Rainy");
  else puts("Sunny");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

vector<char> ATGC={'A','T','G','C'};

int main() {
  string S;
  ll cnt1,Max=0;
  cin>>S;
  bool flag=false;
  rep0(i,S.size()){
    if(S[i]==ATGC[0]||S[i]==ATGC[1]||S[i]==ATGC[2]||S[i]==ATGC[3]){
      cnt1++; flag=true;
    }
    else if(flag){Max=max(Max,cnt1); cnt1=0; flag=false;}
    if(i==S.size()-1){Max=max(Max,cnt1);}
  }
  cout<<Max<<endl;
}



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



int main() {
	

	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	while (1) {
		if (x >= b) {
			x -= b;
		}
		else {
			cout << x << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	char str[1000][1000];
	for(int i=0;i<h;i++){
		cin>>str[i];
	}
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			if(i==0||i==h+1||j==0||j==w+1){
				cout<<"#";
			}
			else if(i!=0&&i!=h+1&&j==1){
				cout<<str[i-1];
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

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



Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
ull n;
int main() {
	cin >> n;
	if(n % 2) {
		cout << "0" << endl;
		return 0;
	}
	n /= 2;
	ull k = 1, ans = 0;
	while(n) {
		ans += n / 5;
		n /= 5;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;cin>>s;
  int N=s.size();
  for(int i=0;i<N;i++)
    if(s.at(i)=='?')
      s.at(i)='D';
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
  int L,R,d;
  cin >>L>>R>>d;
  int n=0;
  if(L%d==0){
    n++;
  }
  n=n+R/d-L/d;
  cout <<n;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    int H, W;
    char a[100][100];
    char sub;
    vector <int> line, low;
    
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> sub;
            a[i][j] = sub;
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j] == '#'){
                line.push_back(i);
                break;
            }
        }
    }
    
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(a[j][i] == '#'){
                low.push_back(i);
                break;
            }
        }
    }
    
    for(int i = 0; i < line.size(); i++){
        for(int j = 0; j < low.size(); j++){
            cout << a[line[i]][low[j]];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
s = input()
q = int(input())
before = []
after = []
isReversed = 0


for _ in range(q):
    tmp = input()
    if len(tmp) == 1:
        if isReversed:
            isReversed = 0
        else:
            isReversed = 1
    else:
        if tmp[2] == str(2):
            if isReversed:
                before.append(tmp[-1])
            else:
                after.append(tmp[-1])
        else:
            if isReversed:
                after.append(tmp[-1])
            else:
                before.append(tmp[-1])


if isReversed:
    ans = "".join(after[::-1]) + s[::-1] + "".join(before)
    print(ans)

else:
    ans = "".join(before[::-1]) + s + "".join(after)
    print(ans)


Measured memory_bytes: 69848
a = map(str, input().split())
line_a = ''.join(a)

b = map(str, input().split())
line_b = ''.join(b)

c = map(str, input().split())
line_c = ''.join(c)

print('{}{}{}'.format(line_a[0], line_b[1], line_c[2]))

Measured memory_bytes: 9116
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	int* B = new int[M];
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}
	int output = 0;

	for (int i = 0; i < N; i++)
	{
		int* A = new int[M];
		int sum = 0;
		for (int j = 0; j < M; j++)
		{
			cin >> A[j];
			sum += A[j] * B[j];

		}
		sum += C;
		if (sum > 0) output++;
	}

	cout << output << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main()
{
    ll i,j;
    string a;
    cin >> a;
    ll n = a.size();
    vector<ll> z(128, 0);
    for(i = 0;i < n;++i){
        ++z.at(a.at(i));
    }
    ll ans = 0;
    for(i = 0;i < 128;++i){
        ans += z.at(i)*(z.at(i)-1)/2;
    }
    cout << n*(n-1)/2 - ans + 1 << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n;
    cin >> n;

    int h, mxh;
    cin >> h;
    mxh = h;

    int cnt = 1;
    for (int i = 1; i < n; i++) {
        cin >> h;
        if (h >= mxh)
            cnt++;
        mxh = max(mxh, h);
    }

    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
import re


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        n, k = IO_for_Contest.read_n_int(2)
        return n, IO_for_Contest.read_n_int(k)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
            int,
            re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    n, d = IO_for_Contest.read_from_input()
    print(min_value_can_pay(n, d))


def min_value_can_pay(n, d):
    ints_can_be_used = think_ints_can_be_used(d)
    queue = []
    for i in ints_can_be_used:
        queue.append(i)
    while len(queue) > 0:
        j = queue.pop(0)
        if j >= n:
            return j
        if j == 0:
            continue
        for i in ints_can_be_used:
            queue.append(j * 10 + i)


def think_ints_can_be_used(d):
    ints = list(range(10))
    for i in d:
        ints.remove(i)
    return ints

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    solve()

Measured memory_bytes: 5740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  ll sum = 0;
  rep(i, 1, n+1) {
    if(i%3!=0 and i%5!=0) sum+=i;
  }
  
  cout << sum << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a, b;
    cin >> a >> b;
    int32 x = b - a;
    int32 ans = -a;
    REP(i,x)ans += i;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
// sky kaafi neeche aa gaya hai, sab choo rahe hain
// let's raise the bar now :P
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int N = 3e5 + 5;
ll p[N], q[N], r[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    multiset<pair<ll, int> > ms;
    for(int i = 0; i < a; i++){
        cin >> p[i];
        ms.insert({p[i], 1});
    }
    for(int i = 0; i < b; i++){
        cin >> q[i];
        ms.insert({q[i], 2});
    }
    for(int i = 0; i < c; i++){
        cin >> r[i];
        ms.insert({r[i], 3});
    }
    ll X = x, Y = y;
    int req = x + y;
    ll ans = 0;
    int xUsed = 0, yUsed = 0;
    while((int)ms.size() && req > 0){
        auto it = ms.end();
        --it;
        pair<ll, int> yo = (*it);
        ms.erase(it);
        ll w = yo.first;
        int id = yo.second;
        if(id == 1){
            if(xUsed == X) continue;
            xUsed++;
            req--;
            ans += w;
        }
        else if(id == 2){
            if(yUsed == Y) continue;
            yUsed++;
            req--;
            ans += w;
        }
        else{
            req--;
            ans += w;
        }
    }
    cout << ans;
return 0;
}


Measured memory_bytes: 23936
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M= scan.nextInt();
		int C = scan.nextInt();
		ArrayList<Integer> times = new ArrayList();
		ArrayList<Integer> number = new ArrayList();
		int count = 0;
 
		for (int i = 0; i < M; i++){
			int B = scan.nextInt();
			times.add(B);
		}
 
		for (int i = 0; i < N; i++){
			int answer = 0;
 
			for (int j = 0; j < times.size(); j++){
				int A = scan.nextInt();
				number.add(A);
				answer += times.get(j) * number.get(j);
			}
			answer += C;
			if (answer > 0){
				count++;
			}
			number.clear();
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 36336
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 10000007;
const int MAX2 = 7777;
const int MAXE = 100000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;

int p[MAX];

vector<int> g[107];
int M[107];
bool U[107];

bool dfs(int v) {
	if (U[v])  return 0;
	U[v] = 1;
	FOR(i,0,SZ(g[v]))
	{
		int to = g[v][i];
		if (M[to] == -1 || dfs(M[to])) {
			M[to] = v;
			return 1;
		}
	}
	return 0;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);

	for(int i = 2; i * i < MAX; ++i)
		if (!p[i])
			for(int j = i * i; j < MAX; j += i)
				p[j] = 1;

	p[2] = 1;
	p[1] = 1;
	p[0] = 1;

	vector<int> V[2];

	int n;
	cin >> n;
	VI A(n);
	FOR(i,0,n)
	{
		cin >> A[i];
	}

	FOR(i,0,n)
	{
		if (i == 0 || A[i - 1] + 1 != A[i])
		{
			V[A[i] % 2].push_back(A[i]);
		}
		if (i == n - 1 || A[i] + 1 != A[i + 1])
		{
			V[(A[i] + 1) % 2].push_back(A[i] + 1);
		}
	}

	FOR(i,0,SZ(V[0]))
		FOR(j,0,SZ(V[1]))
		{
			if (!p[abs(V[0][i] - V[1][j])])
			{
				g[i].push_back(j);
			}
		}

	int r = 0;

	FILL(M,-1);
	FOR(i,0,SZ(V[0]))
	{
		FILL(U,0);
		r += dfs(i);
	}



	int res = SZ(V[0]) + SZ(V[1]) - r;

	if ((SZ(V[0]) - r) % 2 == 1) ++ res;

	cout << res << endl;

    return 0;
}





Measured memory_bytes: 39296
from collections import Counter

N, M = map(int, input().split())
A = list(map(int, input().split()))

l = [0]
#累積和
for i in range(N):
    l.append(A[i]+l[i])
# print(l)

#Mの余りに変換
for i in range(N+1):
    l[i] %= M

c = Counter(l)
# print(c)
ans = 0
#同じ余り同士の区間は条件を満たす
for i in c.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 22036
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int main(void) {
    long y;
    int n;
    cin >> n >> y;
    for(int i = 0;i <= n && 10000*i <= y;i++)
        for(int ii = 0;ii + i <= n && 5000*ii <= y;ii++)
            if(i + ii + (y - 10000*i - 5000*ii) / 1000 == n)
            {cout << i << " " << ii << " " << (y - 10000*i - 5000*ii) / 1000 << endl;return 0;}
    cout << "-1 -1 -1" << endl;
}


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

int MAX_LEAF = 1LL << 60;

int cur_leaf = 1;
int n;
int A[100010];
int add[100010];
int _max[100010];
int32_t main(){
	cin >> n;
	n++;
	for(int i = 0; i < n; i++){
		_max[i] = MAX_LEAF;
	}
	_max[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	for(int i = 0; i < n; i++){
		if(cur_leaf < A[i]){
			cout << -1 << endl;
			return 0;
		}else{
			cur_leaf -= A[i];
			cur_leaf *= 2;
			if(cur_leaf > MAX_LEAF){
				cur_leaf = MAX_LEAF;
			}
		}
		_max[i + 1] = cur_leaf;
	}
	
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		add[i] += A[i];
	}
	for(int i = n - 1; i >= 0; i--){
		add[i] = add[i + 1] + A[i];
	}
	for(int i = 0; i < n; i++){
		add[i] = min(add[i], _max[i]);
	}
	
	for(int i = 0; i < n; i++){
		ans += add[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5964
// finish date: 2018/05/12
#include <bits/stdc++.h>


using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    string s;
    int K;
    cin >> s >> K;
    int count = 0;
    map<string, int> mp;
    for (char c = 'a'; c <= 'z'; c++) {
        vs strarray;
        rep(i, s.length()) {
            if (s[i] == c) strarray.push_back(s.substr(i));
        }
        sort(strarray.begin(), strarray.end());
        rep(i, strarray.size()) {
            rep(j, strarray[i].length()) {
                if (mp[strarray[i].substr(0, j + 1)] == 0) {
                    count++;
                    mp[strarray[i].substr(0, j + 1)]++;
                }
                if (count == K) {
                    cout << strarray[i].substr(0, j + 1) << endl;
                    return 0;
                }
            }
        }
    }


    return 0;
}

Measured memory_bytes: 16128
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

struct combi{
	deque<mint> kaijou;
	deque<mint> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(kaijou[i-1]*i);
		}
		
		mint b=kaijou[n].inv();
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(kaijou_[0]*k);
		}
	}
	
	mint combination(int n,int r){
		if(r>n)return 0;
		mint a = kaijou[n]*kaijou_[r];
		a *= kaijou_[n-r];
		return a;
	}
	
	mint junretsu(int a,int b){
		mint x = kaijou_[a]*kaijou_[b];
		x *= kaijou[a+b];
		return x;
	}
	
	mint catalan(int n){
		return combination(2*n,n)/(n+1);
	}
	
};

int main(){

	int N;
	cin>>N;
	
	vector<int> cnt(100000,0);
	
	rep(i,2*N){
		int h;
		cin>>h;
		h--;
		cnt[h]++;
	}
	
	combi C(1000000);
	
	queue<vector<mint>> Q;
	
	rep(i,cnt.size()){
		vector<mint> t(cnt[i]/2 + 1,0);
		mint temp = 1;
		rep(j,t.size()){
			t[j] = temp * C.kaijou_[j];
			temp *= cnt[i]-2*j;
			temp *= cnt[i]-2*j-1;
			temp /= 2;
		}
		Q.push(t);
	}
	
	while(Q.size()>1){
		vector<mint> a = Q.front();
		Q.pop();
		vector<mint> b = Q.front();
		Q.pop();
		Q.push(convolution(a,b));
	}
	
	vector<mint> V = Q.front();
	
	rep(i,V.size()){
		int t = (N-i);
		V[i] *= C.kaijou[t*2];
		V[i] /= mint(2).pow(t);
		V[i] *= C.kaijou_[t];
	}
	
	mint ans = 0;
	
	rep(i,V.size()){
		if(i%2==0)ans += V[i];
		else ans -= V[i];
	}
	
	cout<<ans.val()<<endl;
	
	return 0;
}


Measured memory_bytes: 18320
import           Control.Applicative
import           Control.Exception
import           Data.Char
import           System.IO.Error
import           Text.Printf

main :: IO ()
main = do
  n <- readLn
  first <- readWd
  (min,max,sum) <- solve (n-1) (first, first, first)
  printf "%d %d %d\n" min max sum

solve
  :: Int
  -> (Int, Int, Int)
  -> IO (Int, Int, Int)
solve 0 result        = pure result
solve n (min,max,sum) = do
  x <- readWd
  solve (n-1)
    $ if x < min
      then (x,max,sum+x)
      else if x > max
           then (min,x,sum+x)
           else (min,max,sum+x)

readWd :: Read a => IO a
readWd = getWord >>= readIO

getWord :: IO String
getWord = handle handleEOF $ do
  c <- getChar
  if isSpace c then pure [] else (c:) <$> getWord
  where
    handleEOF e = if isEOFError e then pure [] else throwIO e



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

using namespace std;

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

#define F first
#define S second

int main(){
  int n,k;
  string s;
  scanf("%d %d",&n,&k);
  cin>>s;
  s[k-1]+='a'-'A';

  cout<<s<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;


int main() {
	cin >> N;
	vector<vector<int>> adj(N);
	vector<int> c(N),d(N,0);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int sum=0;
	for (int i = 0; i < N; i++) {
		cin >> c[i];
		sum += c[i];
	}
	sort(c.rbegin(), c.rend());
	sum -= c[0];
	queue<int> q;
	q.push(0);
	int num = 1;
	d[0] = c[0];
	while (!q.empty()) {
		int ind = q.front();
		q.pop();
		for (int i = 0; i < adj[ind].size();i++) {
			int tmp = adj[ind][i];
			if (d[tmp] > 0)continue;
			d[tmp] = c[num];
			q.push(tmp);
			num++;
		}
	}
	cout << sum << endl;
	for (int i = 0; i < N-1; i++)cout << d[i]<<" ";
	cout << d[N - 1] << endl;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n_rows, n_cols = 3;
    cin >> n_rows;
    vector<vector<int>> h(n_rows, vector<int>(n_cols));
    REP(i, n_rows) { cin >> h[i][0] >> h[i][1] >> h[i][2]; }
    // 動的計画法の２次元配列は、前回の選択肢と幸福度を記録する
    vector<vector<int>> dp(n_rows + 1, vector<int>(n_cols, 0));
    REP(i, n_cols) { dp[0][i] = 0; }
    REP(i, n_rows) {
        REP(j, n_cols) {
            REP(k, n_cols) {
                if (k != j) {
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + h[i][j]);
                }
            }
        }
    }
    // for (auto x : dp) {
    //     for (auto y : x) {
    //         cout << y << " ";
    //     }
    //     cout << endl;
    // }
    cout << max({dp[n_rows][0], dp[n_rows][1], dp[n_rows][2]}) << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int n;
int d[53];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d, d + n);
	for (int i = 1; i < n; i += 2) d[i] = 24 - d[i];
	int ans = d[0];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) continue;
			ans = min(ans, (int)abs(d[i] - d[j]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const long double INF = 1e18;




int main(){
	int pos[]={1,0,0};
	char cup1,cup2,c;
	while(cin>>cup1>>c>>cup2){
		int p1,p2;
		if(cup1=='A')p1=0;
		else if(cup1=='B')p1=1;
		else p1=2;
		
		if(cup2=='A')p2=0;
		else if(cup2=='B')p2=1;
		else p2=2;
		swap(pos[p1],pos[p2]);
	}
	if(pos[0]==1)cout<<"A"<<endl;
	else if(pos[1]==1)cout<<"B"<<endl;
	else cout<<"C"<<endl;
	
	return 0;
}
/*

*/

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

int main(){
  int N; cin >>N;
  vector<int> card(N);
   for(int i=0;i<N;i++){
    cin >> card[i];
   }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int Alice=0; int Bob=0;
  for(int i=0;i<N;i=i+2){
    Alice=Alice+card[i];
  }
  for(int j=1;j<N;j=j+2){
    Bob=Bob+card[j];
  }
  cout <<Alice-Bob<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=100+10;
int a[maxn*2];
int main(){
	int n=read();
	REP(i,1,2*n) a[i]=read();
	sort(a+1,a+2*n+1);
	int ans=0;
	REP(i,1,n) ans+=a[i*2-1];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
D, G = [int(i) for i in input().split()]
pc = {i: list(map(int, input().split())) for i in range(D)}

ans = float("inf")
# 各難易度ごとに、全部解くor解かないで場合わけ
for bit in range(1 << D):
    score = 0
    count = 0
    rest = set(pc.keys())
    for i in range(D):
        if (bit >> i) & 1:
            n_problem, complete_score = pc[i]
            score += n_problem * (i + 1) * 100 + complete_score
            count += n_problem
            rest.discard(i)
    lack = G - score
    if lack <= 0:
        ans = min(ans, count)
        continue
    use = max(rest)
    n_problem = pc[use][0]
    extra_count = -(-lack // ((use+1) * 100))
    if extra_count >= n_problem:
        continue
    else:
        count += extra_count
    ans = min(ans, count)
print(ans)


Measured memory_bytes: 42860
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL AN, BN, M; cin >> AN >> BN >> M;
		vector<UL> A(AN), B(BN);
		rep(i, AN) cin >> A[i];
		rep(i, BN) cin >> B[i];
		UL ans = 1000000000;
		rep(i, M) {
			UL x, y, c; cin >> x >> y >> c; x--; y--;
			ans = min(ans, A[x] + B[y] - c);
		}
		sort(A.begin(), A.end());
		sort(B.begin(), B.end());
		ans = min(ans, A[0] + B[0]);
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 1024
nums = list(map(int, list(input())))
ans = ''
for n in range(8):
    bits = bin(n)[2:].zfill(3)
    total = nums[0]
    ans = str(nums[0])
    for i, b in enumerate(bits):
        if b == '0':
            total += nums[i+1]
            ans += '+' + str(nums[i+1])
        else:
            total -= nums[i+1]
            ans += '-' + str(nums[i+1])

    if total == 7:
        ans += '=7'
        break

print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << " " << x << "\n"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e5 + 3;

ll n, k, a[N][4], res[N][4];

ll _max(ll x, ll y, ll z) {
	return max(max(x, y), z);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n;
	for (ll i = 1; i <= n; ++i) {
		for (ll j = 1; j <= 3; ++j) cin >> a[i][j];
	}
	
	for (ll i = 1; i <= n; ++i) {
		for (ll j = 1; j <= 3; ++j) {
			for (ll k = 1; k <= 3; ++k) {
				if (k == j) continue;
				res[i][j] = max(res[i][j], res[i-1][k] + a[i][j]);
			}
		}
	}
	cout << _max(res[n][1], res[n][2], res[n][3]);
	
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


int main() {
    int n;
    cin >> n;
    WeightedGraph<ll> G(n);
    rep (i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    int q, k;
    cin >> q >> k;
    auto dist = dijkstra(G, k-1);
    rep (i, q) {
        int a, b;
        cin >> a >> b;
        cout << dist[--a] + dist[--b] << endl;
    }
}


Measured memory_bytes: 11120
S = input()
if (S[0:7] == 'keyence') or (S[-7:] == 'keyence'):
  print("YES")
else:
  flag = 0
  for i in range(1,7):
    if S[:i] + S[-(7-i):] == 'keyence':
      print("YES")
      flag=1
      break
  if flag==0:
    print("NO")

Measured memory_bytes: 3060
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    a = list(sys.stdin.readline())
    b = list(sys.stdin.readline())
    c = list(sys.stdin.readline())

    d = [a[:-1], b[:-1], c[:-1]]

    def saiki(idx):
        if len(d[idx]) == 0:
            return idx

        if d[idx][0] == "a":
            del d[idx][0]
            idx = 0
        elif d[idx][0] == "b":
            del d[idx][0]
            idx = 1
        else:
            del d[idx][0]
            idx = 2

        return saiki(idx)

    ans = saiki(0)

    print("A" if ans == 0 else "B" if ans == 1 else "C")


if __name__ == '__main__':
    main()


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

string toLowerCamel(string str){
    string l = "";
    char pre = ' ';
    for ( int i = 0; i < str.size(); i++ ){
	if ( isalpha(str[i]) ){
	    if ( pre == '_' ) l += toupper(str[i]);
	    else l += str[i];
	}
	pre = str[i];
    }
    l[0] = tolower(l[0]);
    return l;
}

main(){
    string name;
    char com;
    while(1){
	cin >> name >> com;
	if ( com == 'X' ) break;
	string l = toLowerCamel(name);
	if ( com == 'L' ) cout << l << endl;
	else if ( com == 'U' ){
	    l[0] = toupper(l[0]);
	    cout << l << endl;
	} else if ( com == 'D' ){
	    for ( int i = 0; i < l.size(); i++ ){
		if ( 'A' <= l[i] && l[i] <= 'Z' ){
		    cout << "_";
		    cout << (char)(tolower(l[i]));
		} else cout << l[i];
	    }
	    cout << endl;
	}
    }
}

Measured memory_bytes: 0
def in_rectangle(w, h, x, y, r):
    # ?????????????????????
    left = x - r
    right = x + r
    floor = y - r
    ceil = y + r

    # ?????????????????????????????¨???????????¢?????????????????°ok
    if 0 <= left and right <= w and 0 <= floor and ceil <= h:
        return True

    return False

# AOJ??¨
w, h, x, y, r = map(int, input().split())
if in_rectangle(w, h, x, y, r):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7728
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vi a(n);
  vi c(n);
  rep (i, n) {
    cin >> a[i];
    a[i]--;
    c[a[i]]++;
  }

  vi d(n + 1);
  rep (i, n) {
    d[c[i]]++;
  }
  vi sum(n + 1);
  sum[n] = d[n];
  for (int i = n - 1; i >= 0; i--) {
    sum[i] = sum[i + 1] + d[i];
  }
  //DEBUG_VEC(sum);

  vi ma(n + 1);
  ma[0] = inf;
  rep (i, n) {
    ma[1] += min(c[i], 1);
  }
  for (int x = 2; x <= n; x++) {
    ma[x] = ma[x - 1] + sum[x];
  }
  //DEBUG_VEC(ma);

  rep1 (x, n) {
    ma[x] /= x;
  }
  //DEBUG_VEC(ma);

  int k = 1;
  int ok = n;
  while (k <= n) {
    while (ok >= 0 and ma[ok] < k) {
      ok--;
    }
    cout << ok << endl;
    k++;
  }
}


Measured memory_bytes: 8704
import math 
N = int(input())
a = list(map(int,input().split()))
ans = 0
cnt = 1
for i in range(1,N):
    if a[i-1]==a[i]:
        cnt += 1
    else:
        ans += math.floor(cnt/2)
        cnt = 1
ans += math.floor(cnt/2) if cnt!=1 else 0
print(ans)


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

int main(void){
	int i,j,k,n,p[10000],s[10000];
	p[0]=2;p[1]=3;s[0]=2;s[1]=5;
	for(k=2,i=5;k<10000;i+=2){
		for(j=1;j<i;j++){
			if(i%p[j]==0)break;
			else if(p[j]*p[j]>i){p[k]=i;s[k]=s[k-1]+i;k++;break;}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break; else printf("%d\n",s[n-1]);
	}
	return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N), B(N), L(M), R(M);
    vector<int> unzip;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        unzip.push_back(A[i]);
    }
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
    unzip.push_back(2e9);
    sort(begin(unzip), end(unzip));
    unzip.erase(unique(begin(unzip), end(unzip)), end(unzip));
    map<int, int> zip;
    for (int i = 0; i < unzip.size(); i++) zip[unzip[i]] = i;
    vector<vector<pair<int, int>>> G(zip.size());
    for (int i = 0; i < M; i++) {
        auto s = lower_bound(begin(unzip), end(unzip), L[i]) - begin(unzip);
        auto t = upper_bound(begin(unzip), end(unzip), R[i]) - begin(unzip);
        if (s == t) continue;
        G[s].emplace_back(t, i);
        G[t].emplace_back(s, i);
    }
    vector<int> C(zip.size()), D(zip.size()), visited(zip.size());
    for (int i = 0; i < N; i++) {
        C[zip[A[i]]] = B[i];
    }
    for (int i = 0; i < zip.size(); i++) {
        D[i] = (i > 0 ? C[i - 1] : 0) ^ C[i];
    }
    vector<int> ans;
    function<int(int, int)> recur = [&](int node, int prev) -> int {
        if (visited[node]) return 0;
        visited[node] = 1;
        int sum = D[node];
        for (auto &p : G[node]) if (p.first != prev) {
            int t = recur(p.first, node);
            if (t) ans.push_back(p.second), sum ^= 1;
        }
        return sum;
    };
    for (int i = 0; i < N; i++) {
        if (visited[i]) continue;
        if (D[i]) {
            int t = recur(i, -1);
            if (t) { cout << -1 << '\n'; return 0; }
        }
    }
    sort(begin(ans), end(ans));
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] + 1 << " \n"[i == ans.size() - 1];
    }
    return 0;
}


Measured memory_bytes: 23672
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s1, s2, s3;	cin >> s1 >> s2 >> s3;
	string answer;

	std::transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
	std::transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
	std::transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

	cout << s1[0] << s2[0] << s3[0] << endl;
	cin >> s1;
	return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
  int k;
  cin >> k;
  cout << (k / 2) * ((k + 1) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int check = 0;
  bool flag = false;
  vector<vector<int>> D(100,vector<int>(2));
  for(int i = 0; i < n; i++){
    cin >> D.at(i).at(0) >> D.at(i).at(1);
    if(D.at(i).at(0) == D.at(i).at(1)){
      check ++;
      if(check == 3)flag = true;
    }
    else check =0;
  }    

  
  string s = "No";
  if(flag == true)s = "Yes";
  cout << s << endl;
    
}

Measured memory_bytes: 3640