akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <vector>
#include <functional>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;

const int MOD = 1e9 + 7;

int Cases;
int N, K;
vector<vector<int>> e;
vector<int> child_cnt;
vector<int> ret;

unordered_set<int> S;
//void DFS(int x) {
//	S.insert(x);
//	for (auto y : e[x]) {
//		if (!S.count(y)) {
//			child_cnt[x]++;
//			DFS(y);
//		}
//	}
//}

void DFS2(int x, int base) {
	ret[x] = max(base, 0);
	S.insert(x);
	// cout << x << endl;
	int nbase = (x == 0) ? K - 1 : K - 2;
	for (auto y : e[x]) {
		if (!S.count(y)) {
			DFS2(y, nbase);
			nbase--;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> N >> K;
	e.resize(N);
	child_cnt = vector<int>(N, 0);
	ret = vector<int>(N, 0);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	// DFS(0);
	//for (int i = 0; i < N; i++) {
	//	cout << i << ": ";
	//	for (int j : e[i]) cout << j << " ";
	//	cout << endl;
	//}
	S.clear();
	DFS2(0, K);

	long long cumul = 1;
	for (int x : ret) {
		// cout << x << endl;
		cumul = cumul * x % MOD;
	}
	cout << cumul << endl;
	return 0;
}

Measured memory_bytes: 12964
#include <iostream> 
#include <string>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  int counter=0;
  for (int i=0; i<N/2; i++){
    if (S[i]!=S[N-1-i]) {counter++;}
  }
  cout<<counter<<endl;}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int q;
  set <int> a;
  cin>>q;

  for(int i=0;i<q;i++){
    int n,x;
    cin>>n>>x;
    if(n==1) cout<<(a.end()!=a.find(x))<<endl;
    else if(n==2) a.erase(x);
    else{
      a.insert(x);
      cout<<a.size()<<endl;
    }
  }
  return 0;

}



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

int main() {
	long long int A, B, K; cin >> A >> B >> K;
	if (A >= K)cout << A - K << ' ' << B << endl;
	else if (B >= K - A) cout << 0 << ' ' << B + A - K << endl;
	else cout << 0 << ' ' << 0 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;


class Main{
	static long ans=0;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[] dp=new long[K+1];
		for(int i=0; i<=K; i++) {
			dp[i]=0;
		}
		if(N>K) {
			pl(0);
		}
		else {
			long ans=1;
			long mod=1000000007;
			for(int i=K; i>=K-N+1; i--) {
				ans=(ans*((long)i))%mod;
			}
			pl(ans);
			//kPn
		}
	}
	public static void dfs(int nokori,int kosu,int kei) {

	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24484
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine();
        var b = Console.ReadLine();

        
        var a2 = a.ToCharArray();
        var b2 = b.ToCharArray();

        int ans = 0;

        for (int i = 0; i < a.Length; i++)
        {
            if (a2[i] != b2[i])
            {
                ans++;
            }
        }

        Console.WriteLine($"{ans}");
    }
}

Measured memory_bytes: 28268
from collections import Counter
N = int(input())
A = []
for i in range(N):
  A.append(input())
C= Counter(A)
B = 0
for v in C.values():
  B = max(B,v)
ans = []
for k, v in C.items():
  if v == B:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

Measured memory_bytes: 35824
#include<iostream>
using namespace std;
struct P{
  double x;
  double y;
};
int main(){
  P a,b,c,d;
  while(cin >>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y){
    P v,w;
    v.x = a.x-b.x;
    v.y = a.y-b.y;
    w.x = c.x-d.x;
    w.y = c.y-d.y;
    if(v.x*w.x+v.y*w.y == 0) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	if(s.length()+1==t.length())
	{
		int i=0;
  		for(i=0;i<s.length();i++)
  		{	
  			if(s[i]!=t[i])
  			{
  				break;
			}
		}
		if(i>=s.length())
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
  	else
  	{
  		cout<<"No\n";
	}
  /*t.pop_back();
  if(s==t)
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }*/
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m,k;

ll qpow(ll n,ll b){
	ll res = 1;
	while(b){
		if(b&1) res = res*n;
		n= n*n;
		b>>=1;
	}
	return res;
}

ll solve(ll n,ll x){
	return (n/qpow(10,x))%10;
}

int main(){
	cin>>k;
	ll tot=1;
	ll dep = 0;
	ll pc=1;
	while(pc<k){
		if(dep==0) tot++;
		else{
			ll i=0;
			if(solve(tot,i)>solve(tot,i+1)||solve(tot,i)==9){
				while((solve(tot,i)>solve(tot,i+1)||solve(tot,i)==9)&&i<dep){
					i++;
				}
				if(i==dep&&solve(tot,i)==9) {
					tot++;
					pc++;
					dep++;
					continue;
				}
				tot+=qpow(10,i);
				F(j,1,i){
					tot=tot - solve(tot,i-j)*qpow(10,i-j) + max((solve(tot,i-j+1)-1),0ll)*qpow(10,i-j);
				}
			}
			else{
				tot++;
			}
		}
		if(tot==qpow(10,dep+1)) dep++;
		pc++;
	}
	cout<<tot<<endl;
}

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

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

    if (x % 100 <= x / 100 * 5)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;

typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<P> c;
    REP(i,n) {
        ll a, b;
        cin >> a >> b;
        c.push_back({a, b});
    }
    sort(c.begin(), c.end());
    ll M = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        while(1){
            ll pr = c[i].first;
            ll num = c[i].second;
            if (num == 0) break;
            c[i].second--;
            M++;
            ans += pr;
            //cout << num << endl;
            if (M == m) break;
        }
        if (M == m) break;
    }
    cout << ans << endl;
    return 0;
}

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

struct St {
	int left;
	int right;
};
int main()
{
	int ans = 0;
	int a; cin >> a;
	int b; cin >> b;
	int N; cin >> N;
	
	int s;
	int f;
	
	vector<St> vec(0);
	vector<St>::iterator it;
	vec.push_back(St{0,1000});

	for (int i = 0;i < N;i++) {
		cin >> s;
		cin >> f;
		it = vec.begin();

		unsigned int j = 0;

		//予約リストの更新
		for (St st : vec) {
			if (st.left <= s && f <= st.right) {
				break;
			}
			j++;
			it++;
		}

		if (vec[j].left == s && f == vec[j].right) {
			vec.erase(vec.begin() + j);
		}else if(vec[j].left == s && f < vec[j].right){
			vec[j].left = f;
		}else if (vec[j].left < s && f == vec[j].right){
			vec[j].right = s;
		}else if (vec[j].left < s && f < vec[j].right) {
			int ns = vec[j].right;
			vec[j].right = s;
			if (j + 1 == vec.size()) {
				vec.push_back(St{f ,ns });
			}
			else {
				vec.insert(++it, St{f ,ns });
			}
			if (f < b) {
				j++;
			}
		}
		
		bool flag = false;
		for (St st : vec) {
			if (st.left <= a && b <= st.right) {
				flag = true;
			}
			if (st.right > a || flag) {
				break;
			}
		}

		if (!flag) {
			ans = 1;
			break;
		}
	}

	cout << ans << endl; 
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define N         100005
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
    
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll tree[8*N];
ll build()
{
	rep(i,0,8*N)
	tree[i]=0;
}
void update(ll node,ll start,ll end,ll idx,ll val)
{
	if(start==end)
	tree[node]=val;
	else
	{
		ll mid=(start+end)/2;
		if(idx>=start && idx<=mid)
		update(2*node+1,start,mid,idx,val);
		else
		update(2*node+2,mid+1,end,idx,val);
		tree[node]=max(tree[2*node+1],tree[2*node+2]);
	}
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
	if(start>r || end<l)
	return -1*mod;
	if(start>=l && end<=r)
	return tree[node];
	ll mid=(start+end)/2;
	return  max(query(2*node+1,start,mid,l,r),query(2*node+2,mid+1,end,l,r));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,first,last,n,x,y;
    	cin>>n;
		m=0;
    	ll a[n],h[n],dp[n+1];
    	rep(i,0,n)
		{
    		cin>>h[i];
    		dp[i]=0;
		}
		dp[n]=0;
    	rep(i,0,n)
    	cin>>a[i];
    	build();
    	rep(i,0,n)
		{
    		x=query(0,0,n,0,h[i]-1);
    		dp[h[i]]=max(dp[h[i]],x+a[i]);
    		update(0,0,n,h[i],dp[h[i]]);
		}
    	repi(i,1,n)
    	m=max(m,dp[i]);
    	cout<<m;
	}
	return 0;
}

Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const int M = 1000000007;

            string[] input = Console.ReadLine().Split(' ');
            int m = int.Parse(input[0]);
            int n = int.Parse(input[1]);

            Console.WriteLine(CalcPow(m, n, M));
        }

        static long CalcPow(int m, int n, int M)
        {
            if (n == 0) return 1;

            long ret = CalcPow(m, n / 2, M);

            ret = (ret * ret) % M;

            if (n % 2 == 1) ret = (ret * m) % M;

            return ret;
        }
    }
}

Measured memory_bytes: 9228
N, K = map(int, input().split())
P = [int(i) for i in input().split()]

E = [0 for i in range(N+1)]
for i in range(N):
    E[i+1] = E[i] + (P[i] + 1) / 2
    
ans = 0
for i in range(N-K+1):
    ans = max(ans, E[i+K] - E[i])

print(ans)

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

int a[100], b[100];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i, j, k, res=0, n;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<n;i++)
        if(a[i]>b[i])
           res += a[i]- b[i];

    cout<<res<<endl;


    return 0;
}


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

using namespace std;
//using namespace atcoder;
using usize = ::std::size_t;
//using u64 = ::std::int_least64_t;
using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    cin >> S;
    if (S[S.length() - 1] == 's') {
        S += "es";
    } else {
        S += "s";
    }
    
    cout << S << endl;
    
    return 0;
    
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int K, T;
	cin >> K >> T;
	vector<int> a(T);
	for (int& x : a) cin >> x;
	int r = 0;
	if (T == 1) {
		r = K-1;
	} else {
		for (int x : a) {
			int y = x - (K-x+1);
			r = max(r, y);
		}
	}
	cout << r << endl;
}


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

const int maxn(105);

ll n, x[maxn], y[maxn], h[maxn];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i] >> h[i];
	for (int cx = 0; cx <= 100; ++cx)
		for (int cy = 0; cy <= 100; ++cy) {
			ll lh = 1, rh = 2e9;
			for (int i = 1; i <= n; ++i) {
				ll d = abs(x[i] - cx) + abs(y[i] - cy);
				if (h[i] == 0) rh = min(rh, d);
				else lh = max(lh, h[i] + d), rh = min(rh, h[i] + d);
			}
			if (lh <= rh) {
				cout << cx << " " << cy << " " << rh << endl;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<"NO"; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n=5;
 vector<int> v(n);
 forn cin>>v[i];
 forn
 {
           if(v[i]==0) 
           {
                     cout<<i+1;
                     exit(0);
           }
 }
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
m = [[ai] for ai in a]
for d in range(n):
    for s in range(1 << n):
        if s >> d & 1 == 0:
            t = s | 1 << d
            m[t] = sorted(m[t] + m[s])[-2:]
for k in range(1, 1 << n):
    ans = sum(m[k])
    for d in range(n):
        if k >> d & 1 == 1:
            t = k ^ 1 << d  | (1 << d) - 1
            ans = max(ans, sum(m[t]))
    print(ans)

Measured memory_bytes: 231644
import java.util.Scanner;

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

        int[][] sumArr = new int[r][c+1];
        int[] sumCArr = new int[c+1];
        
        for(int i=0; i<r; i++) {
            for(int j=0; j<c; j++){
                sumArr[i][j] = scanner.nextInt();
            }
        }
        
        for(int i=0; i<r; i++) {
            int sum = 0;
            for(int j=0; j<=c; j++){
                if(j != c){
                    sum += sumArr[i][j];
                    sumCArr[j] += sumArr[i][j];
                } else {
                    sumArr[i][j] = sum;
                }
                
            }
            sumCArr[c] += sum;
        }
        

        for(int i=0; i<r; i++) {
            for(int j=0; j<=c; j++){
                if(j != c){
                    System.out.print(sumArr[i][j] + " ");
                } else {
                    System.out.println(sumArr[i][j]);
                }
            }
        }
        

        for(int i=0; i<c+1;i++ ){
            if(i != c){
                System.out.print(sumCArr[i] + " ");
            } else {
                System.out.println(sumCArr[i]);
            }

        }
    }
}


Measured memory_bytes: 41920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  if(s[k-1] == 'B') s[k-1] = 'b';
  if(s[k-1] == 'C') s[k-1] = 'c';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>
using namespace std;

//macros
typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;




#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9
ll series(ll x){
	return x*(x+1)/2;
}
int main() {
	ll k;
	cin>>k;
	string s="ACL";
	for(ll i=0;i<k;i++)
        cout<<s;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define rep_cs(i, l, n) for (int i = (l); i <= (n); i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long combination(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];

void combination_for_small()
{
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i)
    {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j)
        {
            Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
        }
    }
}

bool isPalindrome(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    rep(i, 0, n)
    {
        cout << 'x';
    }
    cout << endl;
}


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

const int INF = 1e9;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    int min_sum = INF;
    for (int p = 1; p <= 100; p++) {
        int sum = 0;
        for (int x : X) {
            int tmp = x - p;
            sum += tmp * tmp;
        }
        min_sum = min(sum, min_sum);
    }
    cout << min_sum << endl;
    return 0;
}



Measured memory_bytes: 256
student_info = []
while True:
    s = map(int,raw_input().split(" "))

    if s[0] is s[1] is s[2] is -1:
        break
    
    student_info.append(s)

score_info = []
for s in student_info:
    if s[0] == -1 or s[1] == -1:
        score_info.append("F")

    elif s[0]+s[1] >= 80:
        score_info.append("A")

    elif 65 <= s[0]+s[1] < 80:
        score_info.append("B")

    elif 50 <= s[0]+s[1] < 65:
        score_info.append("C")

    elif 30<= s[0]+s[1] < 50:
        if s[2] >= 50:
            score_info.append("C")
        else:
            score_info.append("D")
    else:
        score_info.append("F")

for i in score_info:
    print i

Measured memory_bytes: 6472
N , x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
if a[0] > x:
    count += a[0] - x
    a[0] = x 
for i in range(1, N):
    temp = a[i] + a[i-1] - x
    if temp > 0:
        count += temp
        a[i] -= temp

print(count)

Measured memory_bytes: 14132
#include <stdio.h>

typedef struct _tree_t {
	int id;
	struct _tree_t *p, *l, *r;
} tree_t;

tree_t* tree_insert(tree_t* root, int id){
	tree_t *y = NULL;
	tree_t *x = root;
	tree_t *z = (tree_t*)malloc(sizeof(tree_t));
	z->id = id;
	z->l = z->r = z->p = NULL;

	while(x != NULL) {
	    y = x;
	    if(z->id < x->id) {
	        x = x->l;
	    } else { 
	        x = x->r;
	    }
	}
	z->p = y;
	if(y == NULL) {
    	root = z;
	} else if(z->id < y->id) {
	    y->l = z;
	} else { 
	    y->r = z;
	}
	
	return root;
}

void print_find(tree_t *tree, int id) {
	if(tree==NULL) {
		printf("no\n");
		return;
	}
	
	if(id == tree->id) {
		printf("yes\n");
		return;
	} else if(id < tree->id) {
		print_find(tree->l, id);
	} else {
		print_find(tree->r, id);
	}
}

void print_preorder(tree_t *tree) {
    printf(" %d", tree->id);
    if(tree->l != NULL) print_preorder(tree->l);
    if(tree->r != NULL) print_preorder(tree->r);
}

void print_inorder(tree_t *tree) {
    if(tree->r == NULL && tree->l == NULL) {
        printf(" %d", tree->id);
    } else if(tree->r == NULL) {
        print_inorder(tree->l);
        printf(" %d", tree->id);
    } else if(tree->l == NULL) {
        printf(" %d", tree->id);
        print_inorder(tree->r);
    } else {
        print_inorder(tree->l);
        printf(" %d", tree->id);
        print_inorder(tree->r);
    }
}

int main(void) {
	int i, n, id;
	char buff[100];
	tree_t *root = NULL;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%s %d\n", buff, &id);
		if(buff[0] == 'i') {
			root = tree_insert(root, id);
		} else if(buff[0] == 'f') {
			print_find(root, id);
		} else if(buff[0] == 'p') {
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 19368
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 1000000007
#define inv2 500000004
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int f[3010][3010],g[3010][3010],a[3010];
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)
	for(rt j=1;j<=n;j++)if(a[i]>a[j])f[i][j]=1;
	for(rt i=1;i<=m;i++){
		x=r;y=r;
		for(rt j=1;j<=n;j++)g[x][j]=f[x][j],g[j][x]=f[j][x],g[y][j]=f[y][j],g[j][y]=f[j][y];
		f[x][y]=f[y][x]=1ll*(g[x][y]+g[y][x])*inv2%p;
		for(rt j=1;j<=n;j++){
			const int v1=1ll*(g[x][j]+g[y][j])*inv2%p,v2=1ll*(g[j][x]+g[j][y])*inv2%p;
			if(j!=y&&j!=x)f[x][j]=v1,f[j][x]=v2;
			if(j!=x&&j!=y)f[y][j]=v1,f[j][y]=v2;
		}	
	}

	int ans=0;
	for(rt i=1;i<n;i++)
	for(rt j=i+1;j<=n;j++)(ans+=f[i][j])%=p;
	for(rt i=1;i<=m;i++)ans=ans*2%p;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 70912
n=int(input())
cityscore=[]
cityscore_true=[]
for i in range(n):
  s,p=input().split()
  cityscore.append((s,int(p)))
cityscore_true=sorted(cityscore)
for i in range(n):
  for j in range(n):
    if cityscore_true[i][0]==cityscore_true[j][0]:
      if cityscore_true[i][1]>cityscore_true[j][1]:
        cityscore_true.insert(j,cityscore_true[i])
        cityscore_true.pop(i+1)
for i in range(n):
  print(cityscore.index(cityscore_true[i])+1)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool comp(P a, P b) {
	return a.second > b.second;
}

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

	int n;
	cin >> n;
	set<int> s;
	rep(i, n) {
		int d;
		cin >> d;
		s.insert(d);
	}
	out(sz(s));

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
vector<ll> adj[100005];
ll dp[100005][2];
void dfs(int curr,int pt){

	for(int i=0;i<adj[curr].size();i++){
		ll k=adj[curr][i];
		if(k!=pt){
			dfs(k,curr);
			dp[curr][0]=((dp[k][0]+dp[k][1])*dp[curr][0])%mod;
			dp[curr][1]=(dp[curr][1]*dp[k][0])%mod;
          
			 
		}
	}
}

int main(){
	int n;
	cin>>n;
	for(ll i=0;i<=n;i++){
		dp[i][0]=dp[i][1]=1;
	}
   for(int i=0;i<n-1;i++){
      ll u,v;
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }

  dfs(1,-1);
  cout<<(dp[1][0]+dp[1][1])%mod<<endl;
 
}

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

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        String s = scanner.next();
        int n = s.length();
        int[] ans = new int[n];
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if ((s.charAt(i) == 'R') == (list.size() % 2 == 0)) {
                list.add(1);
            } else {
                list.set(list.size() - 1, list.get(list.size() - 1) + 1);
            }
        }

        int sum = 0;
        for (int i = 0; i < list.size(); i++) {

            if (i % 2 == 0) {
                sum += list.get(i);
                ans[sum] += list.get(i) / 2;
                ans[sum - 1] += list.get(i) - list.get(i) / 2;
            } else {
                ans[sum] += list.get(i) - list.get(i) / 2;
                ans[sum - 1] += list.get(i) / 2;
                sum += list.get(i);
            }
        }
        for (int i : ans) {
            System.out.println(i);
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

Measured memory_bytes: 49632
#include <iostream>
#include <string>

using namespace std;

int main(){
    int count = 0;
    string s;
    cin >> s;

    for(int i = 0;i < s.size();i++)
        if(s[i] == 'o')
            count++;
    
    cout << 700 + count*100 << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut vec: Vec<(i64, i64)> = Vec::new();
    for _i in 0..n {
        let x: i64 = iterator.next().unwrap().parse().unwrap();
        let y: i64 = iterator.next().unwrap().parse().unwrap();
        vec.push((x, y))
    }

    let perm = make(n);
    let mut total: f64 = 0.0;
    for p in &perm {
        let mut sub_total: f64 = 0.0;

        let mut current = vec[p[0] - 1];
        for i in 1..n {
            let next = vec[p[i] - 1];
            sub_total += (((current.0 - next.0).pow(2) + (current.1 - next.1).pow(2)) as f64).sqrt();
            current = next;
        }

        total += sub_total;
    }

    let answer: f64 = total / (perm.len() as f64);

    return format!("{:.10}", answer);
}

fn make(n: usize) -> Vec<Vec<usize>> {
    let mut original = Vec::new();
    for i in 1..(n + 1) {
        original.push(i)
    }

    let mut result = Vec::new();
    _make(original, Vec::new(), &mut result);
    return result;
}

fn _make(candidate: Vec<usize>, perm: Vec<usize>, result: &mut Vec<Vec<usize>>) {
    if candidate.is_empty() {
        result.push(perm);
        return;
    }

    for i in 0..candidate.len() {
        let mut c = candidate.clone();
        let mut p = perm.clone();
        p.push(c.remove(i));
        _make(c, p, result);
    }
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"3
0 0
1 0
0 1"
        ),
        "2.2761423749"
    );
    assert_eq!(
        solve(
            r"2
-879 981
-866 890"
        ),
        "91.9238815543"
    );
    assert_eq!(
        solve(
            r"8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310"
        ),
        "7641.9817824387"
    );
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

int N;
int A[SIZE];


int main(){

	scanf("%d",&N);

	int maximum = -1,second = -1,num_max = 0;

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

		scanf("%d",&A[i]);
		if(A[i] > maximum){
			second = maximum;
			maximum = A[i];
			num_max = 1;
		}else if(A[i] == maximum){

			num_max++;
		}else if(A[i] > second){

			second = A[i];
		}
	}

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

		if(A[i] != maximum){

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

		}else{ //A[i] == maximum

			if(num_max > 1){

				printf("%d\n",maximum);
			}else{

				printf("%d\n",second);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2432
package main
 
import (
	"fmt"
	"strconv"
)
 
func main() {
	var n string
	fmt.Scanf("%s", &n)
	
	var a int
	a = 0
	var i int
	for _, d := range n { 
		var e = string(d)
		i, _ = strconv.Atoi(e)
		a = a + i
	}

	var b int
	b = a % 9

	var c string
	if b == 0{
		c = "Yes"
	} else {
		c = "No"
	}
	fmt.Printf("%s\n", c)
}

Measured memory_bytes: 3284
//#define MODE 1
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl

const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 

bool Prime_Check(int a){
	if(a==1)return false;
	int dim=int(sqrt(a));
	for (int i=2;i<=dim;i++){
		if(a%i==0)return false;
	}
	return true;
}

int main(){
	//#if 1
	int n,ans[100000],so[100000]={};
	TFDEB(Prime_Check(2))END
	for(int i=1;i<=100000;i++){
		if(i%2==0)continue;
		if(Prime_Check(i) && Prime_Check((i+1)/2)){
			so[i]=1;
		}
	}
	REP(i,10){ARDEB(i,so)END}
	for(int i=1;i<=100000-1;i++){
		so[i+1]=so[i]+so[i+1];
	}
	REP(i,10){ARDEB(i,so)END}
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b,count=0,sum=0;
		cin>>a>>b;
		sum=so[b]-so[a-1];
		ans[i]=sum;
	}
	REP(i,n){
		cout<<ans[i]<<endl;
	}
	//#endif
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){

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

    string s;
    cin>>s;
    int cnt=0,mx=0;
    for(unsigned int i=0;i<s.size();i++){
        if(s.at(i)=='R'){
            cnt++;
            mx=max(mx,cnt);
        }
        else{
            cnt=0;
        }
    }

        cout<<mx;
}



Measured memory_bytes: 3596
#include <iostream>

using namespace std;

#define A 1
#define B 2

int main() {
  int a, b;
  cin >> a >> b;
  // cout << a << b << endl;

  int pi[16] = {0};

  // for (size_t i = 0; i < 16; i++) {
  //   cout << pi[i] << endl;
  // }

  // i = 0のときの処理（最初の一切れ）
  if (a > 0) {
    pi[0] = A;
    a--;
  } else if (b > 0) {
    pi[0] = B;
    b--;
  }

  for (size_t i = 1; i < 15; i++) {
    if (a > 0 && pi[i - 1] != A) {
      pi[i] = A;
      a--;
    } else if (b > 0 && pi[i - 1] != B) {
      pi[i] = B;
      b--;
    }
  }

  // i = 16のときの処理（最後の一切れ）

  if (a > 0 && pi[14] != A && pi[0] != A) {
    pi[15] = A;
    a--;
  } else if (b > 0 && pi[14] != B && pi[0] != B) {
    pi[15] = B;
    b--;
  }

  if (a == 0 && b == 0) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long M = sc.nextLong();
        long[] A = new long[N+1];
        for(int i=1;i<=N;i++){
            A[i] = sc.nextLong();
        }
        HashMap<Long,LinkedList<Integer>> dic = new HashMap<>();

        long[] rem = new long[N+1];
        long[] end = new long[N+1];
        long[] sum = new long[N+1];
        for(int i=1;i<=N;i++){
            sum[i] = sum[i-1]+A[i];
            rem[i] = (rem[i-1]+A[i])%M;
            if(dic.containsKey(rem[i])){
                dic.get(rem[i]).addLast(i);
            }
            else{
                LinkedList<Integer> cur = new LinkedList<>();
                cur.add(i);
                dic.put(rem[i],cur);
            }
        }
        for(int i=1;i<=N;i++){
            if(sum[i]<M) continue;
            LinkedList<Integer> cur = dic.get(rem[i]);
            if(A[i]%M==0){
                end[i] = end[i-1]+1;
                while(cur.size()>0&&cur.peek()<i){
                    cur.poll();
                }
            }
            else {
                if(cur.size()>0&&cur.peek()<i){
                    end[i] = end[cur.poll()]+1;
                }
                else{
                    end[i] = rem[i]==0?1:0;
                }
            }
        }
        long ans = 0;
        for(int i=1;i<=N;i++) ans += end[i];
        System.out.println(ans);
    }
}

Measured memory_bytes: 69004
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,k;
    cin >> n >> k;

    vector<int> x(n);
    for(auto &y:x)cin >> y;

    int sum=0;
    for(int i=0;i<n;i++){
        sum+=2*min(x[i],k-x[i]);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int n,d,x,k,s=0;
    scanf("%d%d%d",&n,&d,&x);
    for(int i=0; i<n; i++)
        {
           scanf("%d",&k);
           s+=d/k;
           if(d%k!=0)
            s++;
        }
        s+=x;
        printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve [a, b] | a == '9' || b == '9' = "Yes"
             | otherwise            = "No"

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // NIKI - lowkey
    int x, y; cin >> x >> y;
    cout << y/2+x;
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int ans = 0;
	int nax = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (x == y) {
			ans++;
			nax = max(nax, ans);
		}
		else
			ans = 0;
	}
	if (nax >= 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int a, b, c, d, e, f;

int main()
{
    cin >> a >> b >> c >> d >> e >> f;
    int p = a + b + c + d;
    cout << p - min({a, b, c, d}) + max(e, f) << endl;
}


Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))
MOD = 1_000_000_007

cnt = [0, 0, 0]
ans = 1
for i in range(N):
    ans *= sum(c == A[i] for c in cnt)
    ans %= MOD
    for j in range(3):
        if cnt[j] == A[i]:
            cnt[j] += 1
            break
print(ans)


Measured memory_bytes: 20624
#include <iostream>
	
int main ()
{
	int s;
	std::cin >> s;
	int s_ = s % 60;
	int m = s / 60 % 60;
	int h = s / 3600;
	std::cout << h << ":";
	std::cout << m << ":";
	std::cout << s_ << std::endl;
}

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

int n,br;
multiset<int> s;
set<int> s1;

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

    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        s.insert(x);
        s1.insert(x);
    }
    for(auto u: s1)
    {
        int tr=s.count(u);
        if(tr>=u)
            br+=tr-u;
        else
            br+=tr;
    }

    cout<<br<<endl;

    return 0;
}


Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()

{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = a[0]-1;
    int high = 2;
    for(int i = 1; i < n; i++)
    {
        int cand = a[i];
        if(cand < high)
        {
            continue;
        }
        else if(cand == high)
        {
            high++;
            continue;
        }
        else
        {
            int count = cand / high;
            if(cand % high == 0)
            {
                count--;
            }
            ans += count;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from collections import defaultdict


def solve():
    n, m = map(int, input().split())
    wa_count = 0
    dict1 = defaultdict(int)
    dict2 = defaultdict(int)
    ac_p, wa_p = set(), set()
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        if s == 'AC':
            dict1[p] = 1
            ac_p.add(p)
        else:
            if dict1[p] != 1:
                dict2[p] += 1
                wa_p.add(p)
    for ac in ac_p:
        if ac in wa_p:
            wa_count += dict2[ac]
    print(sum(dict1.values()), wa_count)


if __name__ == '__main__':
    solve()


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


using namespace std;

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c;
    cin >>x >> y;
    long long rez = 999999999999LL;

    for(int i = 0; i <= max(x, y); i ++)
    {
        rez = min(rez, 2LL * i * c + max(0, x - i) * a * 1LL + max(0, y - i) * b * 1LL);
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 764
# include <cstdio>
# include <iostream>

using namespace std;

int n,x,ans;
int a[100005];

int gcd (int a,int b)
{
	return b?gcd(b,a%b):a;
}

int main()
{
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		a[i]-=x;
		if(a[i]<0) a[i]=-a[i];
	}
	ans=a[1];
	for (int i=2;i<=n;++i)
		ans=gcd(ans,a[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640