akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Read();
            //Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var i = 2L;
            var hs = new HashSet<long>();
            hs.Add(N);
            if (N - 1 != 1)
                hs.Add(N - 1);
            for (; i * i <= N; ++i)
            {
                var t = N;
                while (t % i == 0)
                    t /= i;
                if (t % i == 1) hs.Add(i);
                if ((N - 1) % i == 0) hs.Add((N - 1) / i);
            }
            WriteLine(hs.Count());
        }
    }
}

Measured memory_bytes: 28220
/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

# define M_PI           3.14159265358979323846
#define ll long long
const ll mod=1e9 +7;
vector<ll> f(200009);
int main()
{
    string s;
    cin>>s;
    string r="ABC";
    string t="ARC";
    if(s==r)
    cout<<t<<endl;
    else 
    cout<<r<<endl;
    return 0;
}

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

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
const int N = 1e6 + 7, M = 1000000007, inf = INT_MAX;

int dp[N][2][2];


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

	dp[n][1][1] = 1;
	for (int i = n - 1; i >= 0; i--)
	{
		for (int f1 = 0; f1 < 2; f1++)
		{
			for (int f2 = 0; f2 < 2; f2++)
			{
				int &res = dp[i][f1][f2] ;
				res =  8 * dp[i + 1][f1][f2];
				res += dp[i + 1][1][f2];
				res += dp[i + 1][f1][1];
				res %= M;
			}
		}
	}

	cout << dp[0][0][0] << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}






















Measured memory_bytes: 34832
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>

#include<queue>
using namespace std;

int main()
{
  int64_t N, D, A, x, h, leng, p, position;
  int64_t count, ac, attack;
  bool flag;
  cin >> N >> D >> A;
  leng = D * 2;
  vector<pair<int64_t, int64_t>> vp(N);
  for(int i = 0; i < N; i++){
    cin >> x >> h;
    vp.at(i).first = x;
    vp.at(i).second = h;
  }
  sort(vp.begin(), vp.end());
  
  int64_t tot = 0;
  queue<pair<int64_t, int64_t>> q;//有効範囲, 火力
  count = 0;
  for(int i = 0; i < N; i++){
    x = vp.at(i).first;
    h = vp.at(i).second;
    while(q.size() && q.front().first < x){
      tot -= q.front().second;
      q.pop();
    }
    h -= tot;
    
    if(h > 0){
      ac = (h + (A-1)) / A;
      count += ac;
      attack = A*ac;
      tot += attack;
      q.emplace(x+leng, attack);
    }
  }
  cout << count << endl;
  /*
  p = count = 0;
  while(1){
    int i;
    position = vp.at(p).first;
    ac = (vp.at(p).second + (A-1)) / A;
    count += ac;
    attack = A*ac;
    flag = false;
    for(i = p; i < N; i++){
      if(vp.at(i).first <= (position + leng)){
        vp.at(i).second -= attack;
        if(flag == false && vp.at(i).second > 0){
          p = i;
          flag = true;
        }
      }else break;
    }
    if(flag == false) p = i;
    if(p == N) break;
  }
  cout << count << endl;
  */
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>

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


using namespace std;

LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}



int main(void){
    int c;
    cin >>c;
    vector<pair<int,int>> tasks(c);
    
    rep(i,c){
        int a,b;
        cin >>a>>b;
        tasks[i].first=b;
        tasks[i].second=a;
    }
    sort(tasks.begin(),tasks.end());
    LL sum =0;
    string ans ="Yes";


    rep(i,c){
        sum+=tasks[i].second;
        if (sum>tasks[i].first){
            ans="No";
            break;
        }
    }
    cout << ans<<endl;
    return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
typedef long long LL;
using namespace std;
int p[105][105];
int main()
{
    int n,m;
    int k;
    scanf("%d%d%d",&n,&m,&k);
    int x=1,y=1;
    bool ju=true;
    int co=0;
    for(int i=1;i<=k;++i)
    {
        scanf("%d",&co);
        while(co--)
        {
            p[y][x]=i;
            if(ju)
            {
                ++x;
                if(x>m)
                {
                    ju=false;
                    x=m;
                    ++y;
                }
            }else
            {
                --x;
                if(x<1)
                {
                    ++y;
                    ju=true;
                    x=1;
                }
            }
        }
    }
    for(int i=1;i<=n;++i)
    {
        printf("%d",p[i][1]);
        for(int j=2;j<=m;++j)
            printf(" %d",p[i][j]);
        putchar('\n');
    }
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner

//文字列が一致しているか判定する
fun isSame(S: String, T: String): Boolean{
	val N = S.length

	var foo = true

	for(i in 0..N-1){
		if(S[i]==T[i]){
			continue
		}
		else{
			foo = false
			break
		}
	}

	return foo
}

//文字列を１回転する
fun rot(S: String): String{
	var T = S.drop(1)
	T += S[0]

	return T
}

fun main(args: Array<String>){
	val sc = Scanner(System.`in`)
	val S = sc.nextLine()
	var T = sc.nextLine()
	val N = S.length

	var answer = "No"

	for(i in 1..N){
		T = rot(T)

		if(isSame(S,T)){
			answer = "Yes"
			break
		}
	}

	println(answer)

}

Measured memory_bytes: 31260
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
pair<int,int> dp[(1<<18)][18];
int ans[1<<18];
int main() 
{ 
    fastio;
    int n;
    cin>>n;
    int a[1<<n];f(i,0,(1<<n))cin>>a[i];
    f(mask,0,(1<<n)){
        if((mask&1)){
            dp[mask][0]={mask,mask-1};
        }
        else dp[mask][0]={mask,-1};
    }
    f(mask,0,(1<<n)){
        f(pos,1,n){
            if((mask&(1<<pos))){
                vt <pair<int,int>> temp;
                if(dp[mask][pos-1].first==-1) temp.push_back({-10,-1});
                else temp.push_back({a[dp[mask][pos-1].first],dp[mask][pos-1].first});
                if(dp[mask][pos-1].second==-1) temp.push_back({-10,-1});
                else temp.push_back({a[dp[mask][pos-1].second],dp[mask][pos-1].second});
                if(dp[mask-(1<<pos)][pos-1].first==-1) temp.push_back({-10,-1});
                else temp.push_back({a[dp[mask-(1<<pos)][pos-1].first],dp[mask-(1<<pos)][pos-1].first});
                if(dp[mask-(1<<pos)][pos-1].second==-1) temp.push_back({-10,-1});
                else temp.push_back({a[dp[mask-(1<<pos)][pos-1].second],dp[mask-(1<<pos)][pos-1].second});
                sort(temp.begin(),temp.end());
                dp[mask][pos]={temp[3].second,temp[2].second};
            }   
            else dp[mask][pos]=dp[mask][pos-1];
        }
    }
    f(i,1,(1<<n)){
        // cout<<dp[i][n-1].first<<" "<<dp[i][n-1].second<<"\n";
        ans[i]=max(ans[i-1],a[dp[i][n-1].first]+a[dp[i][n-1].second]);
    }
    f(i,1,(1<<n)){
        cout<<ans[i]<<"\n";
    }
    return 0; 	
}



Measured memory_bytes: 41984
# -*- coding: utf-8 -*-
import fractions

a,b,c,d=map(int, input().split())

n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
#print("n_c: ", n_c)
#print("n_d: ", n_d)

cd = c*d//fractions.gcd(c,d)
n_cd = b//cd - (a-1)//cd
#print("n_cd: ", n_cd)

n_ab = b+1-a
#print("n_ab: ", n_ab)

print(n_ab-(n_c+n_d)+n_cd)



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



int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a > k){
    a -= k;
  }
  else{
    k -= a;
    a = 0;
    b -= k;
  }
  if(b < 0) b = 0;
  
  cout << a << ' ' << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int k;
    string s;
    cin>>k>>s;

    if(s.size()<=k){
        cout<<s;
    }else{
        cout<<s.substr(0,k)+"...";
    }

    return 0;
}



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

int main() {
	int Number = 0;//カードの枚数
	int Alice = 0;//Aliceの得点
	int Bob = 0;//Bobの得点
	int Max = 0;//最適な戦略
	int Cheak = 0;//この数が最大かどうか確認
	int Max_index = 0;//一回使用した配列の要素番号を記録
	cin >> Number;
	vector<int> Card(Number);//カードの数字を記録  
	for (int Loop = 0; Loop < Number; Loop++) {
    	cin >> Card.at(Loop);
    }  
	for (int Loopi = 0; Loopi < Number; Loopi++) {
        Max = 0;
        Max_index = 0;
		for (int Loopii = 0; Loopii < Number; Loopii++) {
        	Cheak = Card.at(Loopii);
    		if (Cheak > Max) {
            	Max = Cheak;
        		Max_index = Loopii;
            }
        }
        //cout << Max << endl;
        //cout << Max_index << endl;
        	if (Loopi % 2 == 0) {
            	Alice += Max;
            }
      		else {
            	Bob += Max;
            }
         	Card.at(Max_index) = 0;
    }
    cout << Alice - Bob << endl;
    //cout << Alice << endl;
    //cout << Bob << endl;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline

import numpy as np

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N = int(input())
if N == 1 or N == 2:
    print("0")
else:
    N_divisors = make_divisors(N)

    N_length = len(N_divisors)
    N_length_half = N_length // 2
    N_length_mod = N_length % 2

    N_length_half_temp = 0

    if N_length_mod == 1:
        N_length_half_temp = N_length_half + 1
    else:
        N_length_half_temp = N_length_half
    if N_divisors[N_length_half_temp]-1 == N_divisors[N_length_half_temp-1]:
        N_length_half_temp += 1
    print(sum(N_divisors[N_length_half_temp:]) - (N_length - N_length_half_temp))

Measured memory_bytes: 12704
while(True):
  h, w = map(int, input().split())
  if h == 0 and w == 0:
    break
    
  for i in range(h):
    c =""
    for j in range(w):
      if (i+j)%2 == 0: 
        c += "#"
      else :
        c += "."
    print(c)
  print("")


Measured memory_bytes: 5612
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int check(int N, vector<vector<int>>&S) {
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < i; ++j) {
			if (S[i][j] != S[j][i])return 0;
		}
	}
	return 1;
}

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

	int N;
	cin >> N;
	vector<vector<int>>S(N, vector<int>(N));
	rep(i, N) {
		string s;
		cin >> s;
		rep(j, N)S[i][j] = s[j];
	}

	int ans = 0;
	ans += check(N, S)*N;
	REP(a, 1, N) {
		vector<vector<int>>T(N, vector<int>(N));
		rep(i, N)rep(j, N)T[i][j] = S[(i + a) % N][j];
		ans += check(N, T)*(N - a);
		rep(i, N)rep(j, N)T[i][j] = S[i][(j + a) % N];
		ans += check(N, T)*(N - a);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line1 = sc.nextInt();
		int line2 = sc.nextInt();
		sc.close();
		long sum = line1 + line2;
		if (sum >= 10) {
			System.out.println("error");
		} else {
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 21844
import math
N = int(input())
F = N
A = 0
B = 0
for i in range (1,math.ceil(math.sqrt(N))+1):
    if N % i == 0:
        A = len(str(i))
        B = len(str(N//i))
        if F >= max(A, B):
            F = max(A, B)
        else:
            pass
    else:
        pass
print(F)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll K,A,B;
    cin >> K >> A >> B;
    if(A + 2 >= B || K <= A){
        cout << K + 1 << endl;
        return 0;
    }
    ll c = A;
    K -= A-1;
    c += (B-A) * (K/2);
    if(K % 2)c++;
    cout << c << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll c = 1000;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i + 1] > a[i]) {
      ll d = c / a[i];
      dbg(c, d, a[i], a[i + 1]);
      c -= d * a[i];
      c += d * a[i + 1];
    }
  }
  out(c);
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long a[90];
int main()
{
    int i,j,k,n;
    a[0]=2;
    a[1]=1;
    for(i=2;i<=86;i++)
    a[i]=a[i-1]+a[i-2];
    scanf("%d",&n);
    printf("%lld\n",a[n]);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <map>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
using P = std::pair<ll, ll>;

ll N, X;
ll two[60];
std::map<P, ll> dp;

ll calc( ll lev, ll x )
{
  ll ret = 0;

  if( dp.count( P( lev, x ) ) )
    return dp[P( lev, x )];

  if( !lev )
    return x > 0 ? 1 : 0;

  ret += calc( lev-1, std::min( two[lev+1]-3, x-1 ) );

  if( x-1 > two[lev+1]-2 )
    ret += calc( lev-1, x-1-two[lev+1]+2 );

  if( x-1 >= two[lev+1]-2 )
    ++ret;

  return dp[P( lev, x )] = ret;
}

int main()
{
  scanf( "%lld%lld", &N, &X );

  two[0] = 1;
  rep( i, N+2 )
    two[i+1] = two[i]*2;

  printf( "%lld\n", calc( N, X ) );

  return 0;
}

Measured memory_bytes: 384
n = int(input())
Alis = list(map(int,input().split()))
Alis.sort(reverse=True)
ans = Alis[0]
t = 0
num = 1
for i in range(n-2):
  if t == 0:
    ans += Alis[num]
    t += 1
  elif t == 1:
    ans += Alis[num]
    t = 0
    num += 1
print(ans)

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

#define ll long long
const ll MOD = 1e9+7;

int h[100000+5];
int n;
int dp[100000+5];
int rec(int i)
{
    if(i >= n-1) return 0;
    if(dp[i] != -1) return dp[i];

    return dp[i] = min(rec(i+1)+abs(h[i]-h[i+1]), rec(i+2)+abs(h[i]-h[i+2]));
}
int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> h[i];
    h[n] = INT_MAX;
    cout << rec(0) << endl;
}


Measured memory_bytes: 6724
using System;

namespace ABC094_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            if((a + b > c) && a <= c)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main()
{
	string a,b;
	cin>>a>>b;
	int cnt=0,cnt2=a.size() ;
	if(cnt2==1&&a[0]==b[0]){cout<<"Yes"<<endl; return 0;}
	for(int i=0;i<a.size() ;i++){if(a[i]==b[i])cnt++;}
	if(cnt==cnt2){cout<<"Yes"<<endl;  return 0;}
	cnt=0;
	for(int i=0;i<a.size() ;i++){
		if(b[i]==a[0]){
			for(int j=0;j<a.size() ;j++){
				int x;
				if(i+j>=cnt2)x=i+j-cnt2;
				else x=i+j;
				if(a[j]==b[x])cnt++;}}
		if(cnt==cnt2){cout<<"Yes"<<endl;return 0;}
		else cnt=0;}
		
cout<<"No"<<endl;
			
			

   system("pause");
    return 0;
}



Measured memory_bytes: 504
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut odd = 0;
    for a in aa {
        if a%2 == 1 {
            odd += 1;
        }
    }
    if odd % 2 == 0 {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


Measured memory_bytes: 4352
n=int(input())
a=list(map(int,input().split()))
gray=[]
brown=[]
green=[]
skyblue=[]
blue=[]
yellow=[]
orange=[]
red=[]
for i in range(1,3200):
    if 0<i<400:
        gray.append(i)
    elif 399<i<800:
        brown.append(i)
    elif 799<i<1200:
        green.append(i)
    elif 1299<i<1600:
        skyblue.append(i)
    elif 1599<i<2000:
        blue.append(i)
    elif 1999<i<2400:
        yellow.append(i)
    elif 2399<i<2800:
        orange.append(i)
    else:
        red.append(i)
collor=[gray,brown,green,skyblue,blue,yellow,orange,red]
ans0=0
for i in range(len(collor)):
    if len(set(collor[i])&set(a))!=0:
        ans0+=1
cnt=0
for x in a:
    if x>=3200:
        cnt+=1
if ans0!=0:
    print(ans0,ans0+cnt)
else:
    print(1,ans0+cnt)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  // 入力
  long long N, X, M, Sum_A = 0;
  cin >> N >> X >> M;
  
  if (M > 1) {

    // 数列{A_n}
    vector<long long> A(M+1, 0);
    A.at(1) = X;
    for (int i = 2; i <= M; i++) {
      A.at(i) = (A.at(i-1)*A.at(i-1))%M;
    }

    // 循環節があるか確認
    int nagasa = 0, hajime = 0;
    for (int i = 1; i < M; i++) {
      if (A.at(M-i) == A.at(M)) {  // A_{1~M-1}のうちA_Mと同じで最も近いもの
        nagasa = i;  // 循環節の最小の長さ
        for (int j = 1; j <= M-i; j++) {
          if (A.at(j) == A.at(M)) {  // A_{1~M-1}のうちA_Mと同じで最も遠いもの
            hajime = j-1;  // 循環節1節目のうちA_Mと同じものの添え字
            break;  //ループを抜ける
          }
        }
        if (nagasa == i) {
          break;  //ループを抜ける
        }
      }
    }

    // 循環しない場合
    if (nagasa == 0) {
      for (int i = 0; i <= N; i++) {
        Sum_A += A.at(i);
      }
    }

    // 循環する場合
    else {
      long long shou, amari;
      shou = (N-hajime)/nagasa;  // 循環節の数-(0or1)
      //amari = hajime + (N-hajime)%nagasa;  // 循環節(or2節目)にたどり着くまで
      amari = N-shou*nagasa;

      // 循環節の部分の和
      for (int i = M-nagasa; i < M; i++) {
        Sum_A += A.at(i) * shou;
      }

      // 循環節にたどり着くまでの和
      for (int i = 0; i <= amari; i++) {
        Sum_A += A.at(i);
      }
    }
    
  }
  // 出力
  cout << Sum_A << endl;
}

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

//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const ll M = (ll)1e9 + 7;
const int N = 1e3 + 3;
const int W = 1e4 + 3;

ll n, w, f[W << 1];

main() {
    scanf("%lld%lld", &w, &n);
    ms(f, inf);
    f[0] = 0;
    while (n--) {
        ll a, b; scanf("%lld%lld", &a, &b);
        fore(i, a, W << 1) mini(f[i], f[i - a] + b);
    }
    ll ans = inf;
    ford(i, (W << 1) - 1, w) mini(ans, f[i]);
    printf("%lld\n", ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<i64> h(n);
	for(int i = 0; i < n; ++i) cin >> h[i];
	vector<i64> dp(n, INF<i64>);
	dp[0] = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 1; j <= k; ++j){
			if(i + j >= n) break;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, M;
int u[110000], v[110000], w[110000];
vint G[110000];
bool visited[110000];

void dfs(int x) {
    visited[x] = true;
    for (int i = 0; i < G[x].size(); i++) {
        if (visited[G[x][i]])continue;
        dfs(G[x][i]);
    }
}

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> u[i] >> v[i] >> w[i];
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (!visited[i])ans++, dfs(i);
    }
    cout << ans << endl;

}

Measured memory_bytes: 11648
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d %d",&a,&b);
	if(a<b){
		c=0;
		c=b-a;
		printf("%d\n",c);
	}else{
	d=0;
	d=a-b;
	printf("%d\n",d);
}
	return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <cmath>
int hextodec(char h){
  int res;
  if(h >= '0' && h <= '9')
    res = h - '0';
  else
    res = h - 'a' + 10;
  return res;
}

int main(){
  int color[8][3] = {{0, 0, 0}, {0, 0, 256}, {0, 256, 0},
                     {0, 256, 256}, {256, 0, 0}, {256, 0, 256},
                     {256, 256, 0}, {256, 256, 256}};
  std::string name[8] = {"black", "blue", "lime",
                         "aqua", "red", "fuchsia",
                         "yellow", "white"};

  std::string c;
  while(std::cin >> c, c.compare("0")){
    int r = hextodec(c[1]) * 16 + hextodec(c[2]),
        g = hextodec(c[3]) * 16 + hextodec(c[4]),
        b = hextodec(c[5]) * 16 + hextodec(c[6]);
    int min_v = 1000000, min_c;
    for(int i=7;i>=0;i--){
      if(color[i][0] == r && color[i][1] == g && color[i][2] == b){
        min_c = i; break;
      }
      int t = pow(r-color[i][0], 2) + pow(g-color[i][1], 2) +
              pow(b-color[i][2], 2);
      if(min_v > t)min_v = t, min_c = i;
    }
    std::cout << name[min_c] << std::endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    int ti=h2*60+m2-h1*60-m1;
    if(ti>k) cout<<ti-k<<endl;
    else cout<<0<<endl;
}

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

using namespace std;

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

constexpr int MAXN = 200000, MAXQ = 200000;

char s[MAXN + 2];
char q[MAXQ + 2][2];
int N, Q;

int sim(int p) {
	if(!(p >= 0 && p < N))
		return p;
	for(int i = 0; i < Q; i++) {
		if(q[i][0] == s[p]) {
			if(q[i][1] == 'L') {
				if(--p < 0)
					return p;
			} else {
				if(++p >= N)
					return p;
			}
		}
	}
	return p;
}

int main() {
	cin >> N >> Q >> s;
	for(int i = 0; i < Q; i++)
		cin >> q[i][0] >> q[i][1];
	int l = -1, r = N - 1;
	do {
		int m = (l + r) / 2;
		if(sim(m) == -1)
			l = m + 1;
		else
			r = m - 1;
	} while(l <= r);
	int ans = l;
	l = 0, r = N;
	do { 
		int m = (l + r) / 2;
		if(sim(m) == N)
			r = m - 1;
		else
			l = m + 1;
	} while(l <= r);
	ans += N - l;
	ans = N - ans;
	cout << ans << endl;
}


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

long long mod = 1000000007;

void Main() {
  string s;
  cin >> s;
  long long dp[13];
  memset(dp, 0, sizeof(dp));

  dp[0] = 1;
  int mul = 1;
  for (int i = s.size() - 1; i >= 0; i--) {
    long long ndp[13];
    memset(ndp, 0, sizeof(ndp));
    if (s[i] == '?') {
      for (int k = 0; k < 10; k++) {
        for (int j = 0; j < 13; j++) {
          ndp[(k * mul + j) % 13] += dp[j];
          ndp[(k * mul + j) % 13] %= mod;
        }
      }
    } else {
      long long k = s[i] - '0';
      int m = k % 13;
      for (int j = 0; j < 13; j++) {
        ndp[(k * mul + j) % 13] += dp[j];
        ndp[(k * mul + j) % 13] %= mod;
      }
    }
    mul *= 10;
    mul %= 13;
    for (int j = 0; j < 13; j++) {
      dp[j] = ndp[j];
    }
  }
  cout << dp[5] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 592
X,Y=map(int,input().split())
if X==1:
  if Y==1:
    print(1000000)
  elif Y==2:
    print(500000)
  elif Y==3:
    print(400000)
  else:
    print(300000)
elif X==2:
  if Y==1:
    print(500000)
  elif Y==2:
    print(400000)
  elif Y==3:
    print(300000)
  else:
    print(200000)
elif X==3:
  if Y==1:
    print(400000)
  elif Y==2:
    print(300000)
  elif Y==3:
    print(200000)
  else:
    print(100000)
else:
  if Y==1:
    print(300000)
  elif Y==2:
    print(200000)
  elif Y==3:
    print(100000)
  else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i = 0; i < N-1; ++i) cin >> C[i] >> S[i] >> F[i];

    for(int i = 0; i < N-1; ++i){
        int time = C[i] + S[i];
        for(int j = i+1; j < N - 1; ++j){
            if(time > S[j]){
                int k = 0;
                while(time > S[j] + F[j] * k){
                    ++k;
                }
                time = S[j] + F[j] * k + C[j];
            }else{
                time = C[j] + S[j];
            }
        }
        cout << time << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,s;

int dp(int x,int y,int z)
{
	if(z==k)
	{
		if(y==s)return 1;
	}
	if(x==n+1)return 0;
	int ans = 0;
	for(int i=x+1;i<=n;i++)
	{
		ans+=dp(i,y+i,z+1);
	}
	return ans ;
}
int main ()
{
	
	while(cin>>n>>k>>s&&n)
	{
	cout<<dp(0,0,0)<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	ll a[10000];
	cin>>n;
	fori(n){cin>>a[i];}
	ll sum=0;
	fori(n){
		int j;
		for(j=0;a[i]%2==0;a[i]/=2,++j);
		sum+=j;
	}
	cout<<sum;
}

Measured memory_bytes: 384
#include <stdio.h>
 int main(void){
    long int a,b,n;
    scanf("%ld %ld %ld",&n,&a,&b);
    if ((b-a)%2==0){
        printf("%ld",(b-a)/2);
    }else{
        if (b-1<=n-a){
            printf("%ld",(b-a)/2+1+a-1);
        }else{
            printf("%ld",(b-a)/2+1+n-b);
        }
    }
}

Measured memory_bytes: 128
N = int(input())
l = [0]*(10**5+1)
A = list(map(int,input().split()))
Q = int(input())
for a in A:
  l[a] += a
suml = sum(l)
for _ in range(Q):
  b,c = map(int,input().split())
  suml += (l[b]//b*c - l[b])
  l[c] += l[b]//b*c
  l[b] = 0
  print(suml)

Measured memory_bytes: 21544
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    int N,A,B,ans;

    cin >> N >> A >> B;

    cout << min(A,B) <<" ";
    if(N < A+B){
        cout << A+B-N << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

bool solved[100005];
int pen[100005];

void solve() {
  int n, q;
  cin >> n >> q;
  int aa = 0;
  ll bb = 0;
  while(q--) {
    int a;
    string b;
    cin >> a >> b;
    if(b == "AC") {
      if(solved[a]) continue;
      solved[a] = true;
      aa++;
      bb+=pen[a];
    }
    else pen[a]++;
  }
  cout << aa << " " << bb << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	string d="",s;
	rep(i,3){
		cin>>s;
		d+=s[i];	
	}
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
sys.setrecursionlimit(100000)
N = int(input())
edge = dd(lambda: dd(int))
for _ in range(N-1):
  a, b, w = map(int, input().split())
  edge[a-1][b-1] = w
  edge[b-1][a-1] = w

ans = [None] * N
def dfs(n, dist):
  ans[n] = dist % 2
  for t in edge[n]:
    if ans[t] is not None:
      continue
    dfs(t, dist + edge[n][t])
dfs(0, 0)
for a in ans:
  print(a)

Measured memory_bytes: 97608
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll K,N;
    cin >> K >> N;
    vll A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll d = K-A[N-1] + A[0];
    gnr(i,1,N){
        d = max(d, A[i]-A[i-1]);
    }
    print(K-d);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4660
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 51

struct Info{
	Info(int arg_node_id,int arg_num){
		node_id = arg_node_id;
		num = arg_num;
	}
	bool operator<(const struct Info & arg) const{ //残数の降順
		return num > arg.num;
	}

	int node_id,num;
};

int N;
int in_table[NUM],out_table[NUM],calc_out[NUM];
int edge_exist[NUM][NUM];
vector<int> G[NUM];


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)edge_exist[i][k] = 0;
	}

	int sum = 0,in_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&in_table[i]);
		sum += in_table[i];
		in_sum += i*in_table[i];
	}

	if(sum != N){ //ノードの合計がNでないならNO
		printf("NO\n");
		return 0;
	}

	sum = 0;
	int out_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&out_table[i]);
		sum += out_table[i];
		out_sum += i*out_table[i];
	}

	if(sum != N){ //ノードの合計がNでないならNO
		printf("NO\n");
		return 0;
	}

	if(in_sum != out_sum){ //入次数の合計と出次数の合計が合わなければNO
		printf("NO\n");
		return 0;
	}

	vector<Info> IN_NODE;
	int index = 0;

	//入次側のノードを仮想的に定める
	/*自己ループがOKなので、入次ノード側には、多重辺が不可という以外に制約がない(出元はどれでも良い)。
		 * よって、インデックスが若い順に役割(出次数を何個にするか、入次数を何個にするか)を割り振っても、結果には影響しない。
		ただし、辺の割り当て方(マッチング)には、少なくとも不適な手順が存在する模様 */
	for(int i = N; i >= 0; i--){ //★★降順に引いていった方がよさそう
		for(int k = 0; k < in_table[i]; k++){
			IN_NODE.push_back(Info(index++,i)); //★indexと書かれた入次側の端点をi個作るイメージ★
		}
	}

	index = 0;

	//出次側のノードを仮想的に定める
	for(int i = 0; i <= N; i++){
		for(int k = 0; k < out_table[i]; k++){
			calc_out[index++] = i; //★indexと書かれた出次側の端点をi個作るイメージ★
		}
	}

	/*for(int i = 0; i < N; i++){
		printf("calc_out[%d]:%d\n",i,calc_out[i]);
	}*/

	int count;

	for(int i = 0; i < N; i++){ //出次ノードのループ
		if(calc_out[i] == 0)continue;

		count = 0; //辺を張った数を計上
 		for(int k = 0; k < N; k++){ //入次ノード側のループ
 			if(IN_NODE[k].num == 0)break;
 			count++;
 			IN_NODE[k].num--;
 			G[i].push_back(IN_NODE[k].node_id);
 			if(count == calc_out[i])break;
		}

 		if(count < calc_out[i]){ //グラフ作成不可
 			printf("NO\n");
 			return 0;
 		}

 		sort(IN_NODE.begin(),IN_NODE.end()); //毎回降順に並べなおす
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < G[i].size(); k++){
			edge_exist[i][G[i][k]] = 1;
		}
	}

	printf("YES\n");

	for(int i = 0; i < N; i++){
		printf("%d",edge_exist[i][0]);
		for(int k = 1; k < N; k++){
			printf(" %d",edge_exist[i][k]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3288
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,ac=0,wa=0,tle=0,re=0;
    char com[4];
    scanf("%d",&N);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%s",com);
        switch(com[0])
        {
            case 'A':
                ac++;
                break;
                
            case 'W':
                wa++;
                break;
                
            case 'T':
                tle++;
                break;
                
            case 'R':
                re++;
                break;
        }
    }
    
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
}


Measured memory_bytes: 3820
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: i64,
        x: [i64; n],
    }
    let sum: i64 = x.iter().sum();
    let ave1 = sum / n;
    let ave2 = (sum + n - 1) / n;
    let ans: i64 = min(x.iter().map(|a| (a - ave1) * (a - ave1)).sum(),
                       x.iter().map(|a| (a - ave2) * (a - ave2)).sum());
    println!("{}", ans);
}

Measured memory_bytes: 4352
# coding: utf-8

# 標準入力 <int>
K = int(input())

k = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

kl = k.split(", ")

print(kl[K-1])


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

int main(){
    int N;
    cin >> N;
    int count = 0;
    rep(i,N){
        int d1,d2;
        cin >> d1 >> d2;
        if( d1 == d2 ){
             ++count;
            if( count >= 3 ){
                cout << "Yes" << endl;
                return 0;
            }
        }
        else count = 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define Hina ios_base::sync_with_stdio(false), cin.tie(0)
#define MAXC 1000000
#define MAXN 200000
#define int long long
#define pb push_back
using namespace std;

const int p = 998244353;
int n, a, ans, sum;
int num[MAXC+5];
int w[MAXC+5];
int inv[MAXC+5];

void init(){
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= MAXC; i++) {
        inv[i] = ((p - p/i) * inv[p % i]) % p;
    }
}

int cal(int a) {
    int v = 0;
    for (int i = a; i <= MAXC; i += a)
        v = (v + num[i] * i) % p;
    return ((v * v) % p * w[a]) % p;
}

signed main() {
    Hina;
    init();
    for (int i = 1; i <= MAXC; i++) {
        w[i] = (w[i] + inv[i]) % p;
        for (int j = i+i; j <= MAXC; j+=i) {
            w[j] = (w[j] - w[i] + p) % p;
        }
    }
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        num[a]++, sum = (sum + a) % p;
    }
    for (int i = 1; i <= MAXC; i++) {
        ans = (ans + cal(i)) % p;
    }
    cout << ((ans - sum + p) * inv[2]) % p << endl;
}

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

int main() {
int N; int X;
cin>>N>>X;
int cor[N+1];
cor[0]=0;
int ab;
for(int x=0;x<N+1;x++){
	cin>>ab;
	cor[x+1]=cor[x]+ab;
}
int ans=0;
for(int a=0;a<N+1;++a){
	if(cor[a]<=X){
		ans+=1;
	}
}
cout<<ans;

	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
	int k, x, i;

	scanf("%d %d", &k, &x);

	//黒石の座標を出力する
	for (i = (-1 * k) + 1; i < k; i++) {
		printf("%d ", x + i);
	}
	
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <cmath>

using namespace std;

int main() {
  int a, b, c;

  #ifdef DEBUG
  freopen("5-08-a.txt", "r", stdin);
  #endif

  while (cin >> a >> b) {
    c = a * b;
    cout << (c % 2 == 0 ? "Even" : "Odd") << endl;
  }

  return 0;
}


Measured memory_bytes: 504