akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

int n,ans;
int a[25],b[25],c[25];

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

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c;
string s, t;

int main()
{
	cin >> a ;
	
	
	
	cout << a*a<< endl;
}


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

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K - A - B > 0)
    {
        ll cnum = (K - A - B > C) ? C : K - A - B;
        ll c = -1 * cnum;
        ll ans = A + c;
        cout << ans << endl;
    }
    else
    {
        cout << ((A > K) ? K : A) << endl;
    }
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.charAt(0) == S.charAt(1) && S.charAt(0) == S.charAt(2) ) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 21972
import sys
def input():
	return sys.stdin.readline().strip()


def soinsu_bunkai(n):
	num = n
	i = 2
	sosu = 1
	while i <= n**0.5:
		if num % i == 0:
			sosu = 0
			break
		i += 1
	return sosu

sosu = [0 for _ in range(100000)]
sosu[2 - 1] = 1

for i in range(2, 100000, 2):
	sosu[i] = soinsu_bunkai(i + 1)

sosu2017 = [0 for _ in range(100000)]
for i in range(3, 100000, 2):
	if sosu[i - 1] == 1 and sosu[(i + 1)//2 - 1] == 1:
		sosu2017[i] = 1

ruiseki = [0]
for i in range(100000):
	ruiseki.append(ruiseki[-1] + sosu2017[i])

#print(ruiseki)
Q = int(input())
for i in range(Q):
	l, r = list(map(int, input().split()))
	print(ruiseki[r + 1] - ruiseki[l])

Measured memory_bytes: 55636
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int d[10][10];

void Warshall_Floyd() {
	rep(k, 10) {
		rep(i, 10) {
			rep(j, 10) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

signed main(void) {
	int h,w;
	cin >> h >> w;
	rep(i, 10) {
		rep(j, 10) {
			cin >> d[i][j];
		}
	}
	vector<vector<int>>a(h,vector<int>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	Warshall_Floyd();
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] != -1) {
				ans += d[a[i][j]][1];
			}
		}
	}
	print(ans);
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct Dice {
  int face[6];
  Dice() {}
  int& operator [] (int i) { return face[i]; }
  bool operator == (const Dice& other) {
    for (int i = 0; i < 6; i++) if (face[i] != other.face[i]) return false;
    return true;
  }
  bool operator != (const Dice& other) {
    return !(*this == other);
  }
  void roll(int a, int b, int c, int d) {
    int tmp = face[a];
    face[a] = face[b];
    face[b] = face[c];
    face[c] = face[d];
    face[d] = tmp;
  }
  void roll(char c) {
    switch (c) {
      case 'N' : roll(0, 1, 5, 4); break;
      case 'S' : roll(0, 4, 5, 1); break;
      case 'E' : roll(0, 3, 5, 2); break;
      case 'W' : roll(0, 2, 5, 3); break;
      case 'R' : roll(1, 2, 4, 3); break;
      case 'L' : roll(1, 3, 4, 2); break;
    }
  }
  bool identical(Dice other) {
    for (int i = 0; i < 6; i++) {
      other.roll(i & 1 ? 'E' : 'N');
      for (int j = 0; j < 4; j++) {
        other.roll('R');
        if (*this == other) return true;
      }
    }
    return false;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  vector<Dice> D(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> D[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (D[i].identical(D[j])) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / find_greatest_common_divisor(x, y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

vector<LL> dp(100010, -1);
vector<vector<LL> > G(100010);

/*
全体の方針

i番目のノードから出発する時を考えてループをN回回す。
出発点となるノードの番号をメモ化再帰の関数に投げてdpテーブルを更新する。
再帰の枝分かれが多くなるが、dpが更新されている部分についてはすぐにdpの内容をreturnするため、無駄なく探索ができる。
*/

LL memorization_recursive(LL v) {
	if (dp[v] != -1) {//更新済み
		return dp[v];
	}

	LL res = 0;
	for (LL nv:G[v]) {
		chmax(res, memorization_recursive(nv) + 1);//再帰が進むごとに移動距離が増えるように実装
	}
	return dp[v] = res;//メモしながらリターン
}


int main(void) {
	LL N, M;
	cin >> N >> M;

	for (LL i = 0; i < M; i++) {
		LL x, y;
		cin >> x >> y;
		G[x].push_back(y);
	}
	
	LL ans = 0;
	for (LL v = 1; v <= N; v++) {
		chmax(ans, memorization_recursive(v));
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8576
N=int(input())
from math import gcd
from functools import reduce
l=list(map(int,input().split()))
sw=0
c=[0]*1000001
for i in l:
   c[i]+=1
if all(sum(c[i::i])<=1 for i in range(2,1000001)):
  print("pairwise coprime")
elif reduce(gcd,l)==1:
   print("setwise coprime")
else:
   print("not coprime")

Measured memory_bytes: 127852
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<int> > v(8);
int ans=0,n,m;
void dfs(int i,set<int> s){
    s.insert(i);
    if(s.size()==n){
        ans++;
        return;
    }
    for(int a:v[i]){
        if(s.find(a)==s.end())dfs(a,s);
    }
    return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    set<int> c; 
    dfs(0,c);
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  1桁目取得

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}



int main() {
	int p,q,r;
	cin>>p>>q>>r;
	cout<<min(p+q,min(q+r,p+r));
	return 0;


}
__int64_t product(ll m, ll d, ll n)
{
	if (n == 0)
		return 1;
	else
		return ((m %MOD)* product(m + d, d, n - 1)%MOD)%MOD;
}




int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int num[5];
    int i, j, tmp;
     
    for (i = 0; i < 5; i++) scanf("%d", &num[i]);
     
    for (i = 0; i < 5; i++){
    	for (j = i+1; j < 5; j++){
    		if (num[i] < num[j]){
    			tmp = num[i];
    			num[i] = num[j];
    			num[j] = tmp;
    		}
    	}
    }
     
    for (i = 0; i < 5 ; i++){
        if (i) printf(" ");
        printf("%d", num[i]);
    }
    printf("\n");
     
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 N;
    cin >> N;
    Vec<u32> A(N, 0);
    for (int i = 0; i < N - 1; i++) {
        u32 s;
        cin >> s;
        A[s - 1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << A[i]++ << endl;
    }
}


Measured memory_bytes: 3992
#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, m, k;
    cin >> n >> m >> k;
    string ans = "No";
    rep(i,n+1) {
        rep(j,m+1) {
            if (k == i*m + j*n - 2*i*j) ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string a,b;
    cin >> a >> b;
    int count = 0;
    while(atoi(a.c_str()) <= atoi(b.c_str()))
    {
        bool flag = true;
        for(int i = 0;i < a.size() / 2;i++)
        {
            if(a[i] != a[a.size() - 1 - i])
            {
                flag = false;
                break;
            }
        }
        if(flag)
        {
            count++;
        }
        int temp = atoi(a.c_str()) + 1;
        a = to_string(temp);
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int D;
int inf = 1e9+7;
int dp[10010][2][101] = {{{0}}};//何文字目か，小さいか，modD
string K;

int main(){
	cin >> K;
	cin >> D;
	int n = K.size();
	dp[0][0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<D;k++){
				int m = j ? 9 : K[i] - '0'; //j==1ならなんでもOK
				for(int l=0;l<m+1;l++){
					(dp[i+1][j || l<m][(k+l)%D] += dp[i][j][k])%=inf;
				}
			}
		}
	}
	int ans = 0;
	for(int i=0;i<2;i++){
		(ans += dp[n][i][0])%=inf;
	}
	cout << (ans-1+inf)%inf << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,0,n) cin>>p[i];
    int ans = 0;
    int now = INF;
    rep(i,0,n){
        if(p[i] <= now){
            ans++;
            now = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define MX_N 100000
int n;
int tab[MX_N+5];
int dp[MX_N+5];

int main( )
{
    cin>>n;
    for( int i=0; i<n; i++ )
        cin>>tab[i];

    dp[1]=abs(tab[0]-tab[1]);
    for( int i=2; i<n; i++ )
    {
        dp[i]=min( dp[i-1]+abs(tab[i-1]-tab[i]), dp[i-2]+abs(tab[i-2]-tab[i]) );
    }
    cout<<dp[n-1]<<"\n";

}


Measured memory_bytes: 1024
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    string s;
    cin>>s;
    cout<<s;
    ll l=s.length();
    if(s[l-1]=='s')
    cout<<"es";
    if(s[l-1]!='s')
    cout<<"s";
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

struct item {
    int w, v;
};

int main() {
    int N, W;
    cin >> N >> W;
    item *items = new item[N];
    for (int i = 0; i < N; i++) {
        cin >> items[i].w >> items[i].v;
    }
    long long **memo = new long long *[N];
    for (int i = 0; i < N; i++) {
        memo[i] = new long long[W + 1];
        for (int j = 0; j <= W; j++) {
            memo[i][j] = 0;
        }
    }
    for (int w = 0; w <= W; w++) {
        memo[0][w] = (items[0].w <= w) ? items[0].v : 0;
    }
    for (int i = 1; i < N; i++) {
        item curr = items[i];
        for (int w = 0; w <= W; w++) {
            if (curr.w > w) {
                memo[i][w] = memo[i - 1][w];
            } else {
                long long a = memo[i - 1][w - curr.w] + curr.v;
                long long b = memo[i - 1][w];
                memo[i][w] = max(a, b);
            }
        }
    }

    cout << memo[N - 1][W];
    delete[] items;
    for (int i = 0; i < N; i++) {
        delete[] memo[i];
    }
    delete[] memo;
    return 0;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    
    string S;
    cin >> S;
    int64_t L = S.size();
    int64_t ans_f = 0;
    for (int64_t tmp = 0; tmp < (1 << L - 1); tmp++){
        int64_t ans = 0;
        bitset<9> s(tmp);
        int64_t start = 0;
        
        rep(i, 0, L - 1){
            if(s.test(i)){
                ans += stoll(S.substr(start, i - start + 1));
                start = i + 1;
            }
        }
        
        //cout << s << endl;
        //cout << "ans_1 " << ans << endl;
        ans += stoll(S.substr(start, L - start));
        ans_f += ans;
        //cout << "ans_2 " << ans << endl;
         
    }
    cout << ans_f << endl;
}

Measured memory_bytes: 256
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

string str;
char s[100020];
int l,ans;

int main() {
	scanf("%s",s);
	l=strlen(s);
	str=string(s);
	for(int i=0;i<l;i++) if(s[i]=='0') ans++;
	printf("%d\n",2*min(ans,l-ans));
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

set<pair<int, int> > ans;

int main()
{
    int N;
    cin >> N;
    int cs = (N % 2 == 0 ? N + 1 : N);
    for (int i = 1;i <= N;i++)
    {
        for (int j = 1; j <= N;j++)
        {
            if(i + j != cs && i != j)
            {
                if(i > j)
                {
                    ans.insert(make_pair(j, i));
                }
                else
                {
                    ans.insert(make_pair(i, j));
                }
            }
        }
    }
    cout << ans.size() << endl;
    for (auto i = ans.begin(); i != ans.end(); i++)
    {
        cout << i->first << " " << i->second << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N;
  cin>>N;
  ll a[N];ll b[N];ll ok[N];
  rep(i,N){
    cin>>a[i]>>b[i];ok[i]=0;
  }
  
  rep(i,N){
    if(a[i]==b[i]){
      ok[i]=1;
    }
  }
  ll c=0;
  for(int i=1;i<N-1;i++){
    if(ok[i]==1&&ok[i-1]==1&&ok[i+1]==1){
      cout<<"Yes";c=1;break;
      
    }
  }
  if(c==0){
    cout<<"No";
  }
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, V,W, X, Y, Z;
ll S, T;

signed main(){
	std::cin >> A>>V;
	std::cin >> B>>W;
	std::cin >> T;
	
	if(W>=V){std::cout << "NO" << std::endl;}
	else if((A-B)*1.0/(V-W)>T*1.0){std::cout << "NO"<< std::endl;}
	else if((B-A)*1.0/(V-W)>T*1.0){std::cout << "NO"<< std::endl;}
	else std::cout << "YES" << std::endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
    int h, w; cin >> h >> w;
    char s[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int cnt = 0;
            if (s[i][j] == '.') {
                if (i - 1 >= 0 && s[i - 1][j] == '#') {
                    cnt++;
                }
                if (i + 1 < h && s[i + 1][j] == '#') {
                    cnt++;
                }
                if (j - 1 >= 0 && s[i][j - 1] == '#') {
                    cnt++;
                }
                if (j + 1 < w && s[i][j + 1] == '#') {
                    cnt++;
                }
                if (i - 1 >= 0 && j - 1 >= 0 && s[i - 1][j - 1] == '#') {
                    cnt++;
                }
                if (i - 1 >= 0 && j + 1 < w && s[i - 1][j + 1] == '#') {
                    cnt++;
                }
                if (i + 1 < h && j + 1 < w && s[i + 1][j + 1] == '#') {
                    cnt++;
                }
                if (i + 1 < h && j - 1 >= 0 && s[i + 1][j - 1] == '#') {
                    cnt++;
                }
                s[i][j] = cnt + '0';
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << s[i][j];
            if (j == w - 1) {
                cout << endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static Tuple<long, long> Search(int N, long[] S)
        {
            int i = 0;
            int j = N - 2;
            long sum = S[N - 1];

            if (S[i] >= sum - S[i])
            {
                long a = S[i];
                long b = sum - S[i];
                return new Tuple<long, long>(Math.Min(a, b), Math.Max(a, b));
            }

            if (S[j] <= sum - S[j])
            {
                long a = S[j];
                long b = sum - S[j];
                return new Tuple<long, long>(Math.Min(a, b), Math.Max(a, b));
            }

            while (j - i >= 2)
            {
                int m = (i + j) / 2;
                if (S[m] < sum - S[m]) { i = m; } else { j = m; }
            }

            long a1 = S[i];
            long b1 = sum - S[i];
            long dif1 = Math.Max(a1, b1) - Math.Min(a1, b1);

            long a2 = S[i + 1];
            long b2 = sum - S[i + 1];
            long dif2 = Math.Max(a2, b2) - Math.Min(a2, b2);

            return (dif1 <= dif2) ? new Tuple<long, long>(Math.Min(a1, b1), Math.Max(a1, b1))
                                  : new Tuple<long, long>(Math.Min(a2, b2), Math.Max(a2, b2));
        }
        static long Solve(int N, int[] A)
        {
            long[] a = new long[N];
            long[] b = new long[N];
            a[0] = A[0];
            b[0] = A[N - 1];
            for (int i = 1; i < N; ++i)
            {
                a[i] = a[i - 1] + A[i];
                b[i] = b[i - 1] + A[N - i - 1];
            }
            long min = long.MaxValue;
            for (int i = 2; N - i >= 2; ++i)
            {
                int j = N - i;
                var t1 = Search(i, a);
                var t2 = Search(j, b);
                min = Math.Min(Math.Max(t1.Item2, t2.Item2) - Math.Min(t1.Item1, t2.Item1), min);
            }
            return min;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 35036
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long k,a,b,i,m=0;
  cin>>k>>a>>b;
  for(i=a;i<=b;i++){
    if((i%k)==0){
      m=1;break;}
  }if(m==1)
    cout<<"OK";
  else
    cout<<"NG";
  return 0;
}

Measured memory_bytes: 3644
import math
def plot(x,y):
	print(f'{x:.8f} {y:.8f}')
def koch(n,x1,y1,x2,y2):
	if n==0:
		plot(x1,y1)
		return
	sx=(2*x1+x2)/3
	sy=(2*y1+y2)/3
	tx=(x1+2*x2)/3
	ty=(y1+2*y2)/3
	ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
	uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
	koch(n-1,x1,y1,sx,sy)
	koch(n-1,sx,sy,ux,uy)
	koch(n-1,ux,uy,tx,ty)
	koch(n-1,tx,ty,x2,y2)
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5748
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	int con = 0;
	
	cin>>s;
	
	for(int i = 1; i < s.size(); i++){
		if(s[i] == s[i-1]){
			if(s[i] == '0') s[i] = '1';
			else s[i] = '0';
			con++;
		}
	}
	
	cout<<con<<endl;
	
	return 0;
}

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
	FASTIO;
	string s;
	cin>>s;
	if(s=="ABC")
        cout<<"ARC"<<"\n";
    if(s=="ARC")
        cout<<"ABC"<<"\n";

}


Measured memory_bytes: 3616
n=int(input())                    
a=list(map(int,input().split()))  
c=[]                              
ans=0                             
for i in range(n):                
    c.append(a[i]-(i+1))          
c.sort()                          
if n%2==1:                        
    b=c[(n-1)//2]                 
    for i in range(n):            
        ans+=abs(c[i]-b)          
    print(ans)                    
else:                             
    p=c[n//2]                     
    q=c[n//2+1]                   
    P=0                           
    Q=0                           
    for i in range(n):            
        P+=abs(c[i]-p)            
        Q+=abs(c[i]-q)            
    print(min(P,Q))               

Measured memory_bytes: 26180
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[List[int]]"):
    import numpy as np
    from scipy.sparse.csgraph import floyd_warshall
    A = np.array(A, dtype=np.float64)
    B = floyd_warshall(A, directed=True)
    if not np.array_equal(A, B):
        return -1
    delta = 1e-1
    _, pre = floyd_warshall(A-delta, return_predecessors=True)
    return int(A[pre == [[i]*N for i in range(N)]].sum()) // 2

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 46412
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    set<int> S;
    rep(i,0,N) {
        int val; cin >> val;
        S.insert(val);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

M = pow(10, 9) + 7
import sys

dc = {}
al = [0]

rr = [1]


def search(ss, start, end):
    z = al[(start + end)//2]
    nz = al[(start + end)//2+1]
    if z <= ss and ss < nz:
        return (start+end)//2
    elif ss < z:
        return search(ss, start, (start+end)//2)
    else:
        return search(ss, (start+end)//2+1, end)

c = 0
cn = 0
for line in sys.stdin:
    a = int(line)
    if a in dc:
        ss = dc[a]
        if ss != c-1:
            if ss >= al[cn]:
                rr.append((rr[cn]*2)%M)
            else:
                i = search(ss, 0, cn)
                rr.append((rr[cn] + rr[i])%M)
            al.append(c)
            cn += 1
    dc[a] = c
    c += 1
print(rr[cn]%M)


Measured memory_bytes: 32632
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int a[90][90];
int dp[90][90][13000];

int main(int argc, char* argv[])
{
    int h,w;
    scanf("%d%d", &h, &w);
    int i,j;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            int tmp;
            scanf("%d", &tmp);
            a[i][j]-=tmp;
            a[i][j]=abs(a[i][j]);
        }
    }

    dp[0][0][0]=1;
    int max=13000;
    int k;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            for(k=0; k<max; k++) {
                if(dp[i][j][k]) {
                    int tmp=abs(k-a[i][j]);
                    if(tmp<max) {
                        dp[i+1][j][tmp]=1;
                        dp[i][j+1][tmp]=1;
                    }
                    tmp=abs(k+a[i][j]);
                    if(tmp<max) {
                        dp[i+1][j][tmp]=1;
                        dp[i][j+1][tmp]=1;
                    }
                }
            }
        }
    }
    for(i=0; i<max; i++) {
        if(dp[h][w-1][i]) {
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 369280
INFTY=1000000000

n=int(input())
A=list(map(int,input().split()))

def merge(A,left,mid,right):
    cnt=0
    n1=mid-left
    n2=right-mid
    L=[A[left+i] for i in range(n1)]
    R=[A[mid+i] for i in range(n2)]
    L.append(INFTY)
    R.append(INFTY)
    i=0
    j=0
    for k in range(left,right):
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
    return cnt

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        cnt1=mergeSort(A,left,mid)
        cnt2=mergeSort(A,mid,right)
        return merge(A,left,mid,right)+cnt1+cnt2
    return 0

cnt=mergeSort(A,0,n)
print(' '.join(map(str,A)))
print(cnt)


Measured memory_bytes: 66620
#include<bits/stdc++.h>
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;i++)
typedef long long int LL;

int main(){
    LL N;
    in >>N;
    std::vector<LL>a(N+1);
    rep(i,N) in>>a[i+1];

    std::vector<LL>ans(N+1);
    for(LL i=N;i>=1;--i){
        if(i*2>N)ans[i]=a[i];
        else{
            LL sum=0;
            for(LL j=i*2;j<=N;j+=i)sum+=ans[j];
            sum%=2;
            if(sum!=a[i])ans[i]=1;
        }
    }

    std::vector<LL>b;
    for(LL i=1;i<=N;i++){
        if(ans[i]==1)b.push_back(i);
    }
    out<<b.size()<<std::endl;
    rep(i,b.size())out<<b[i]<<std::endl;
}

Measured memory_bytes: 4980
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

long long int gcd(long long int x,long long int y){
    long long int r;
    if(x == 0 || y == 0)  return 0;
    while((r = x % y) != 0) 
    {
         x = y;
        y = r;
    }
    return y;
}

int main(){
    int t; cin >> t;
    rep(i,t){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        if(a < b || d < b){cout << "No" << endl; continue;}
        if(b <= c){cout << "Yes" << endl; continue;}
        if(b == 1){cout << "Yes" << endl; continue;}
      	if(d % b == 0 && a % b > c){cout << "No" << endl; continue;}
        else if(d % b == 0){cout << "Yes" << endl; continue;}
        d = d % b;
        ll gc = gcd(b , d);
        if(b-c-1 >= gc){cout << "No" << endl; continue;}
        bool flag = true;
        rep(i, 2500000){
            a = a % b;
            if(a > c){flag = false; break;}
            a += d;
        }
        if(flag){cout << "Yes" << endl; continue;}
        else{cout << "No" << endl; continue;}
    }
    return 0;
}


Measured memory_bytes: 256
from math import sqrt
from bisect import bisect_left
def circle_center(x1, y1, x2, y2):
    xd = x2 - x1; yd = y2 - y1
    d = xd**2 + yd**2
    k = sqrt((4.0 - d) / d) / 2.0
    xc = (x1 + x2) / 2.0; yc = (y1 + y2) / 2.0
    xd *= k; yd *= k
    return [[xc - yd, yc + xd], [xc + yd, yc - xd]]
while 1:
    n = int(raw_input())
    if n==0: break
    p = sorted(map(float, raw_input().split()) for i in xrange(n))
    px = [e[0] for e in p]; py = [e[1] for e in p]
    prev = 0
    ans = 1
    for i in xrange(n):
        bx = px[i]; by = py[i]
        while bx - px[prev] >= 2.0: prev += 1
        for j in xrange(i+1, n):
            cx = px[j]; cy = py[j]
            if cx - bx >= 2.0: break
            if (bx - cx)**2 + (by - cy)**2 <= 4.0:
                for ex, ey in circle_center(bx, by, cx, cy):
                    count = 2
                    for k in xrange(prev, n):
                        if k==i or k==j: continue
                        dx = px[k]; dy = py[k]
                        if dx - ex >= 1.0: break
                        if (ex - dx)**2 + (ey - dy)**2 <= 1.0:
                            count += 1
                    ans = max(ans, count)
    print ans

Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  int ka=0,ans=0;
  int nana=10000000;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j>i){
        ka+=s[j];
      }
      else{
        ans+=s[j];
      }
    }
    nana=min(nana,abs(ka-ans));
    ka=0;
    ans=0;
  }
  cout<<nana<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    int x=(n+999)/1000;
    cout << 1000*x-n << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int N, M, K; cin >> N >> M >> K;
	vector<vector<int>> F(N);
	vector<set<int>> L(N);
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b; a--; b--;
		L[a].insert(b); L[b].insert(a);
		uf.merge(a, b);
		
	}
	for (int i = 0; i < K; i++) {
		int a, b; cin >> a >> b; a--; b--;
		if (!uf.issame(a, b))continue;
		L[a].insert(b); L[b].insert(a);
	}
	for (int i = 0; i < N; i++) {
		int z = uf.size(i)-1;
		z -= L[i].size();
		cout << z << " ";
	}

	
	
}





Measured memory_bytes: 27008
#include<stdio.h>

#define NIL -1
#define MAX 25

typedef struct {
  int parent;
  int le;
  int ri;
}Node;


Node t[MAX];
int h,max;
void calcHeight(int);
 
int main() {

int i,j,n,id,left,right;
int depth[MAX],height[MAX],sibling[MAX],degree[MAX];
 
  scanf("%d",&n);

  for(i=0; i<n; i++) {
    t[i].parent=t[i].le=t[i].ri=sibling[i]=NIL;
    degree[i]=0;
  }    

  for(i=0; i<n; i++) {
    scanf("%d%d%d",&id,&left,&right);
    if(left!=NIL) {
      t[left].parent=id;
      degree[id]++;
    }
    if(right!=NIL){
      t[right].parent=id;
      degree[id]++;
    }
    t[id].le = left;
    t[id].ri = right;
    sibling[left]=right;
    sibling[right]=left;
  }
 
  for(i=0; i<n; i++) {
    depth[i]=height[i]=0;
    j=i;
    while(t[j].parent!=NIL) {
      j=t[j].parent;
      depth[i]++;
    }
    max=h=0;
    calcHeight(i);
    height[i] = max;
  }
  for(i=0; i<n; i++) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,t[i].parent,sibling[i],degree[i],depth[i],height[i]);
    if(t[i].parent==-1) printf("root");
    else if(t[i].le!=-1 || t[i].ri!=-1) printf("internal node");
    else printf("leaf");
    printf("\n");
  }
  return 0;
}
 
 
void calcHeight(int n)
{
  if(t[n].le==NIL || t[n].ri==NIL)  max = h>max ? h:max;
  if(t[n].le!=NIL) {
    h++;
    calcHeight(t[n].le);
  }
  if(t[n].ri!=NIL) {
    h++;
    calcHeight(t[n].ri);
  }
  h-=1;
}

Measured memory_bytes: 604
use std::io;

fn main() {
    let mut k = String::new();
    io::stdin().read_line(&mut k).unwrap();
    let k = k.trim().parse::<i32>().unwrap();
    let mut ans = 0_u64;
    for i in 1..= k {
        for j in 1..= k {
            for l in 1..= k {
                ans += gcd(i,gcd(j,l)) as u64;
            }
        }
    }
    print!("{}",ans);
}

fn gcd (x:i32 , y:i32) -> i32 {
    let mut max = std::cmp::max(x,y);
    let mut min = std::cmp::min(x,y);
    let mut r;
    while min != 0 {
        r = max;
        r %= min;
        max = min;
        min = r;
    } 
    max
}

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


using namespace std;



int main() {

	int A, B, K;

	cin >> A >> B >> K;

	for (int i = A; i <= B; i++) {
		if (i < A + K || B - K < i) {
			cout << i << "\n";
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[2][30];

int main(void) {
  REP(i, 2) {
    scanf("%s", buf[i]);
  }
  bool ok = true;
  REP(j, 3) {
    if(buf[0][j] != buf[1][2-j]) {
      ok = false;
    }
  }
  puts(ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

// Scane Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()

	result := make([]rune, len(s))

	for i, c := range s {
		result[i] = alphabetConverter(c)
	}

	fmt.Println(string(result))
}

func alphabetConverter(in rune) rune {

	if 'a' <= in && in <= 'z' {
		return in - ('a' - 'A')
	} else if 'A' <= in && in <= 'Z' {
		return in + ('a' - 'A')
	} else {
		return in
	}
}



Measured memory_bytes: 1104
#include <stdio.h>

int main(){
    int N, C, p , S;
    int ans;
    
    scanf("%d%d", &N, &C);
    for(S = 0; C > 0; C--){
        scanf("%d", &p);
        S += p;
    }
    ans = S / (N + 1);
    if (S % (N + 1)) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    string S, T;
    cin >> S >> T;
    bool ok = true;
    map<char, char> ma, ima;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i], t = T[i];
        if (ma.count(s) && (ma[s] != t)) ok = false; 
        if (ima.count(t) && (ima[t] != s)) ok = false; 
        ma[s] = t;
        ima[t] = s;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 776
#include <stdio.h>

int main(void) {
  int A,B;
  scanf("%d%d", &A, &B);
  if((A+B)%3 ==0 || A%3==0 ||B%3==0)
  printf("Possible\n");

  else
  printf("Impossible\n");

  return 0;
}

Measured memory_bytes: 128
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
import time

import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from numba import jit


def main():
    S = input()
    if S[-1]=='s':
        print(S+"es")
    else:
        print(S+"s")

if __name__ == '__main__':
    main()

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

int main(){
    int m,n; cin >> m; n = m - 1; int a[m];
    for(int i = 0; i < m; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < m - 1; ++i){
        cout << a[n] << " " << flush;
        n--;
    }
    cout << a[0] << endl;
}

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int jud(int x){
	
	if(x%2==0)return x/2;
	else return (3*x)+1;
}
int X;
int P_max=0;
int P_sum=0;
int cnt=0;
int m[10000001]={0};
string str= "Christmas Eve Eve Eve";

void solve(){
	
	cin>>X;
	if((X==3)||(X==5)||(X==7))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    NIL = -1

    m = int(input())

    root = NIL

    def insert(k):
        global root
        y = NIL
        x = root
        z = {'key':k, 'left':NIL, 'right':NIL}
        while x != NIL:
            y = x
            if z['key'] < x['key']:
                x = x['left']
            else:
                x = x['right']
        z['parent'] = y

        if y == NIL:
            root = z
        elif z['key'] < y['key']:
            y['left'] = z
        else:
            y['right'] = z

    def find(u, k):
        while u != NIL and k != u['key']:
            if k < u['key']:
                u = u['left']
            else:
                u = u['right']
        return u

    def tree_minimum(x):
        while x['left'] != NIL:
            x = x['left']
        return x

    def tree_successor(x):
        if x['right'] != NIL:
            return tree_minimum(x['right'])
        y = x['parent']
        while y != NIL and x == y['right']:
            x = y
            y = y['parent']
        return y

    def tree_delete(z):
        global root
        if z['left'] == NIL or z['right'] == NIL:
            y = z
        else:
            y = tree_successor(z)
        # yの子xを決める
        if y['left'] != NIL:
            x = y['left']
        else:
            x = y['right']

        if x != NIL:
            x['parent'] = y['parent']

        if y['parent'] == NIL:
            root = x
        elif y == y['parent']['left']:
            y['parent']['left'] = x
        else:
            y['parent']['right'] = x

        if y != z:
            z['key'] = y['key']

    def inorder(u):
        if u == NIL:
            return
        inorder(u['left'])
        print(' ' + str(u['key']), end='')
        inorder(u['right'])

    def preorder(u):
        if u == NIL:
            return
        print(' ' + str(u['key']), end='')
        preorder(u['left'])
        preorder(u['right'])

    for _ in range(m):
        command = input()
        if command[0] == 'f':
            _, x = command.split()
            x = int(x)
            t = find(root, x)
            if t != NIL:
                print('yes')
            else:
                print('no')
        elif command[:6] == 'insert':
            _, x = command.split()
            x = int(x)
            insert(x)
        elif command[:5] == 'print':
            inorder(root)
            print('')
            # pythonのprintは最後に改行記号をつけてくれるので、これで改行できる
            preorder(root)
            print('')
        else:
            _, x = command.split()
            x = int(x)
            tree_delete(find(root, x))



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

int main(){
	string s, t;
	cin >> s >> t;
	
	for ( int i = 0; i < s.size(); i++ ){
		if ( s[i] != t[i] ){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3612
x = int(input())

def fun(x):

    res = []

    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            mult = a**5 - b**5
            if mult == x:
                res = a, b
                break
    print(res[0], res[1])

fun(x)

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

int main() {

	int n; cin >> n;
	const int p = 100005;
	vector<ll> num(p, 0);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		num[a]++;
		sum += a;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		ll b, c; cin >> b >> c;
		sum -= num[b] * b;
		sum += num[b] * c;
		cout << sum << endl;
		num[c] += num[b];
		num[b] = 0;
	}
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    int B[M], A[N][M];

    for(int i = 0; i < M; i++) cin >> B[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        int tmp = 0;
        for(int j = 0; j < M; j++) {
            tmp += A[i][j]*B[j];
        }
        if(tmp+C > 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256