akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    var  inKeys = readLine()?.split("").orEmpty()
    var printStr = ""

    inKeys = inKeys.drop(1).dropLast(1)

    inKeys.forEach{
        if(it == "0"){
            printStr += "0"
        } else if(it == "1"){
            printStr += "1"
        }else if(it == "B"){
            if(printStr != ""){
                printStr = printStr.dropLast(1)
            }
        }
    }

    println(printStr)
}

Measured memory_bytes: 38028
#include <stdio.h>
#include <string.h>
char s[101];
int main(void) {
  scanf("%s", s);
 int res = 0;
 int n = strlen(s);
 for (int i = 0; i < n; i++) {
 if (s[i] != s[n - 1 - i]) res++;
 }
 printf("%d\n", res / 2);
 }
 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define ascii 97
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll ans = 0;
	vector<vector<ll> > slist;
	vector<ll> slistN;
	vector<ll> tlist;
	slist.resize(26);
	slistN.resize(26);
	string s, t;
	ll sL, tL;
	cin >> s;
	cin >> t;
	sL = s.length();
	tL = t.length();
	tlist.resize(tL);
	for (i = 0; i < sL; i++)
	{
		ll stmp = (int)s[i] - ascii;
		slist[stmp].push_back(i);
		//cout << stmp << endl;
		slistN[stmp]++;
	}
	for (i = 0; i < tL; i++)
	{
		ll ttmp = (int)t[i] - ascii;
		tlist[i] = ttmp;
	}
	for (i = 0; i < tL; i++)
	{
		//cout << i << " A " << ans << endl;
		ll ttmp = tlist[i];
		ll si = ans % sL;
		ll L = 0;
		ll R = slistN[ttmp];
		bool s_not = false;
		while (1)
		{
			ll M = (L + R) / 2;
			if (M == slistN[ttmp])
			{
				s_not = 1;
				break;
			}
			if (slist[ttmp][M] < si)
				L = M + 1;
			else
				R = M;
			if (L == R)
			{
				if (R == slistN[ttmp])
					s_not = 1;
				break;
			}
		}
		//cout << ttmp << endl;
		//cout << R << " B " << slist[ttmp][R] << endl;
		//cout << i << " C " << s_not << endl;
		if(!s_not)
			ans += (slist[ttmp][R] - si);
		else
		{
			ans += (sL - si);
			si = 0;
			L = 0;
			R = slistN[ttmp];
			s_not = 0;
			while (1)
			{
				ll M = (L + R) / 2;
				if (M == slistN[ttmp])
				{
					s_not = 1;
					break;
				}
				if (slist[ttmp][M] < si)
					L = M + 1;
				else
					R = M;
				if (L == R)
					break;
			}
			if (s_not)
			{
				ans = -1;
				i = tL;
			}
			else
			{
				ans += slist[ttmp][R];
			}
		}
		ans++;
	}
	if (ans == 0)
		ans = -1;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    char c;
    cin>>c;
    c++;
    cout << c << endl;
    return 0;
}


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

int main(){
 int N;
 int a[100];
 int c;
 int i;
 int temp;
 int ans;
 int over=0;
 int min;
 int max;
 cin>>N;
 for(c=0;c<N;c++){
 	cin>>a[c];
	if(a[c]>=3200){
		over++;
	}
 }
 //ソート
 for(c=0;c<N-1;c++){
 	for(i=0;i<N-1;i++){
		if(a[i]>a[i+1]){
			temp=a[i+1];
			a[i+1]=a[i];
			a[i]=temp;
		}
	}
 }
 ans=0;
 if(a[0]<3200){
 	temp=a[0]/400;
	ans++;
 }
 //仕分け
 for(c=1;c<N;c++){
 	if(a[c]>=3200){
		break;
	}
 	if(a[c]/400>temp && a[c]<3200){
		ans++;
 	}
	temp=a[c]/400;
 }
 if(over!=0 && N-over!=0){
 	min=ans;
	max=ans+over;
 }else if(over!=0 && N-over==0){
 	min=1;
	max=over;
 }else{
 	min=ans;
	max=ans;
 }
 
 cout<<min<<" "<<max;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[505][505];
long long s1[505][505],s2[505][505];
long long dp[505][505];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==j)
			{
				continue;
			}
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<i;j++)
		{
			s1[i][j]=s1[i][j-1]+a[i][j];
		}
		for(int j=i-1;j>=0;j--)
		{
			s2[i][j]=s2[i][j+1]+a[j][i];
		}
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp[i][j]=1000000000000000000LL;
		}
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<=j;k++)
			{
				if(dp[j][k]<dp[i-1][j])
				{
					dp[i-1][j]=dp[j][k];
				}
			}
		}
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<=j;k++)
			{
				dp[j][k]+=s1[i][k]+s2[i][j+1];
			}
		}
	}
	long long ans=1000000000000000000LL;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(dp[i][j]<ans)
			{
				ans=dp[i][j];
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int n;
multiset<int>s;
multiset<int>::iterator it;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(s.empty()) s.insert(x);
        else
        {
            it=s.lower_bound(x);
            if(it==s.begin()) s.insert(x);
            else
            {
                it--;
                s.erase(s.find(*it));
                s.insert(x);
            }
        }
    }
    printf("%d\n",s.size());
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node{
  int key;
  struct Node *left,*right,*p;
};
struct Node *root;
void insert(int k){
  struct Node *y=NULL,*x=root,*z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;z->left=NULL;z->right=NULL;
  while(x){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else 
      x=x->right;
  }
  if(y==NULL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else 
    y->right=z;
}
void inorder(struct Node *u){
  if(u==NULL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(struct Node *u){
  if(u==NULL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int m,k,i;
  char c[20];
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25136
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli n,i;
    cin>>n;
    lli a[n+10],b[n+10],c[n+10];
    a[0]=b[0]=c[0]=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(c[i-1],a[i-1]);
        c[i]+=max(a[i-1],b[i-1]);
    }
    cout<<max(a[n],max(b[n],c[n]))<<"\n";
    return 0;
}


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

int main(){
    long long n;
    cin>>n;
    long long ans=0;
    long long cnt=0;
    /*for(int i=1;i<=n;i++){
        if(n/i==n%i) cnt++;
    }*/
    
    for(long long i=1;i*i<=n;i++){
        long long t=(n+i-1)/i-1;
        if(t==0) break;
        if(n%t==n/t) ans+=t;
        //cerr<<i<<" "<<t<<endl;
    }
    //err<<cnt<<endl;
    cout<<ans<<endl;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

class UnionFind{
  public:
      ll uni[100500]; //親の番号 or 根のときは木の要素数×(-1)
      UnionFind(int s){
      	for(int i = 0; i < 100500; i++) uni[i] = -1;
      }
      //頂点aが所属するグループを調べる
      int root(int a){ if (uni[a] < 0) return a; return uni[a] = root(uni[a]);}
      //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
      void unite(int a,int b){
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (uni[a] < uni[b]){
        	uni[a] = uni[a] + uni[b];
        	uni[b] = a;
        }else{
            uni[b] = uni[b] + uni[a];
        	uni[a] = b;
        }
        return;
      }
        //頂点a,bが同じグループであるかを調べる
      bool isConnect(int a,int b){return root(a) == root(b);}
        //頂点aを含むグループの頂点数を調べる
      int size(int a){return -uni[root(a)];}
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,M,K;
  cin >> N >> M >> K;
  UnionFind U(N);
  ll adj[N+1]={};
  ll ans[N+1]={};
  ll u,v;
  REP(i,M){
      cin >> u >> v;
      adj[u]++; adj[v]++;
      U.unite(u,v);
  }
  
  REP2(i,1,N+1) ans[i] = U.size(i) - 1 ;
  
  REP(i,K){
    cin >> u >> v;
    if(U.isConnect(u,v)){
      ans[u]--;
      ans[v]--;
    }
  }


 for(int i = 1; i <= N; i++) cout << ans[i] - adj[i] << " ";

  return 0;
}


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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  int max=vec.at(0),j=0;
  
  for(j;j<N;j++){
    if(j!=0&&j!=N-1&&max<vec.at(j+1)-vec.at(j)){
      max=vec.at(j+1)-vec.at(j);
    }
  }
  int b;
  b=K-vec.at(N-1)+vec.at(0);
  if(b>max){
    max=b;
  }
    cout<<K-max<<endl;
  }
      

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


int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string s, t;
    cin >> s >> t;
    if(t.substr(0,s.length()) == s)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3596
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = []
for i in range(D):
    t.append(int(input())-1)
v = 0 
last = [-1 for _ in range(26)]
for d in range(D):
    v += s[d][t[d]]
    last[t[d]]=d
    for i in range(26):
        v -= c[i] * (d - last[i])

    print(v)


Measured memory_bytes: 9272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if(s == "SUN")
            {
                Console.WriteLine(7);
            }else if(s == "MON")
            {
                Console.WriteLine(6);
            }
            else if (s == "TUE")
            {
                Console.WriteLine(5);
            }
            else if (s == "WED")
            {
                Console.WriteLine(4);
            }
            else if (s == "THU")
            {
                Console.WriteLine(3);
            }
            else if (s == "FRI")
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }


        }
        
    }

}


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

#pragma GCC optimize("O2")

#define pb push_back
#define mp make_pair
#define ll long long
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REFOR(i, a, b) for(int i = (a); i > (b); i--)

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
 #ifdef LOCAL_EXEC
 #else
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 #endif // LOCAL_EXEC
  long long int n,k,i,j,sum=0;
  cin>>n>>k;
  long long int prices[n];
  for(i=0;i<n;i++){
    cin>>prices[i];
  }
  sort(prices,prices+n);
  for(i=0;i<k;i++){
    sum+=prices[i];
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3648
n,a,b = map(int, input().split())
mod = 10**9+7
#2**10**9の計算

total = pow(2, n, (10**9+7)) - 1

c_a = 1

for i in range(n-a+1, n+1):
	c_a *= i
	c_a %= mod

for i in range(1,a+1):
	c_a *= pow(i, mod-2, mod)
	c_a %= mod

c_b = 1

for i in range(n-b+1, n+1):
	c_b *= i
	c_b %= mod

for i in range(1,b+1):
	c_b *= pow(i, mod-2, mod)
	c_b %= mod

ans = (total - c_a - c_b) % mod
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int x;
	cin >> x;

	if(x==7 or x==5 or x==3) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

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

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

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

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<f64> = (0..n)
        .map(|_| (itr.next().unwrap().parse::<f64>().unwrap() + 1.0) / 2.0)
        .collect();
    let mut ans: f64 = 0.0;
    let mut tmp: f64 = 0.0;
    for i in 0..n {
        tmp += a[i];
        if i as isize - k as isize + 1 >= 0 {
            ans = f64::max(ans, tmp);
            tmp -= a[(i as isize - k as isize + 1) as usize];
        }
    }
    println!("{0:.10}", ans);
}


Measured memory_bytes: 6396
import sys
n, m = map(int, input().split())
A = [int(input()) for _ in range(m)]
mod = 1000000007

if n == 1:
    print(1)
    sys.exit()

B = ['.'] * (n + 1)
for a in A:
    B[a] = '#'
    
dp = [0] * (n + 1)
if B[1] == '.' and B[2] == '.':
    dp[1] = 1
    dp[2] = 2
elif B[1] == '#' and B[2] == '.':
    dp[2] = 1
elif B[1] == '.' and B[2] == '#':
    dp[1] = 1
    
for i in range(3, n + 1):
    if B[i] == '.':
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    
print(dp[-1])

Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(a[i] == a[j]) continue;
      else if(a[i] < a[j]) ans += k*(k-1)/2;
      else ans += k*(k+1)/2;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e15;
const int mod = 998244353;//1e9 + 7;//786433;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, k;
long long a[200005];
long long ans = 0;
long long BIT[200005];
vector <long long> Val;

void Update(int node, long long val)
{
	for(node; node <= n + 1; node += node & -node)
	{
		BIT[node] += val;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n >> k;
	Val.eb(0);
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] -= k;
		a[i] += a[i - 1];
		Val.eb(a[i]);
	}
	sort(Val.begin(), Val.end());
	for(int i = 0; i <= n; i++)
	{
		a[i] = lower_bound(Val.begin(), Val.end(), a[i]) - Val.begin() + 1;
	}
	for(int i = 0; i <= n; i++)
	{
		ans += Get(a[i]);
		Update(a[i], 1);
	}
	cout << ans;
}

Measured memory_bytes: 8096
#include <stdio.h>
#define A 100

main(){
  int c,i,j,k,n,minj=0,count=0;
  int b[A];

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&b[i]);

  for(i=0;i<=n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(b[j]<b[minj])minj = j;
    }
    c = b[i];
    b[i] = b[minj];
    b[minj] = c;
    if(minj != i)count++;
  }
  
  for(i=0;i<n;i++){
    printf("%d",b[i]);
    if(i != n-1)printf(" ");
  }
  
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, r = 0, g = 0;
    cin >> n;
    string s;
    cin >> s;
    rep(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
    }
    ll ans = r * g * (n - r - g);

    rep(i, n-2){
        Rep(j, i+1, n-1){
            if(s[i] != s[j] && (2*j-i) <= (n-1) && s[i] != s[2*j-i] && s[j] != s[2*j-i]) ans--;
        }
    }
    cout << ans << endl;
}


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

int main() {
	int a,b,c,sum=0;
	cin>>a;
	for(int i=0;i<a;i++) {
		cin>>b>>c;
		sum+=(c-b)+1;
		if(sum>100000) {
			sum=100000;
			break;
		}
	}
	cout<<sum<<"\n";
}

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

class P
{
    static void Main()
    {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(s[0] <= s[2] && s[2] <= s[1] ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001;


int a[MAXN] , ps[MAXN] , ps2[MAXN];

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n , k ;
   cin >> n >> k ;
   for(int i = 0 ; i < n ; i ++ )
   {
       cin >> a[i] ;
       ps[i+1] = ps[i] + a[i] ;
       ps2[i+1] = ps2[i] + max(0ll,a[i]) ;
   }
   int ans = 0 ;
   for(int i = 0 ; i + k <= n ; i ++ )
    ans = max(ans,ps[i+k]-ps[i]+ps2[i]+ps2[n]-ps2[i+k]), ans = max(ans,ps2[i]+ps2[n]-ps2[i+k]);
   cout<<ans;

}


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

int main()
{
    char s[1];
    gets(s);
    if(s[0]>=65 && s[0]<=90)
    {
        printf("A\n");
    }
    if(s[0]>=97 && s[0]<=122)
    {
        printf("a\n");
    }
    return 0;
}


Measured memory_bytes: 1520
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s, t; cin>>s>>t;
    ll n = sz(s), m = sz(t);
    vvl ss(n + 1, vl(2)), ts(m + 1, vl(2));
    rep(i, n) {
        ss[i + 1][0] = ss[i][0];
        ss[i + 1][1] = ss[i][1];
        if (s[i] == 'A') ss[i + 1][0]++;
        else ss[i + 1][1]++;
    }
    rep(i, m) {
        ts[i + 1][0] = ts[i][0];
        ts[i + 1][1] = ts[i][1];
        if (t[i] == 'A') ts[i + 1][0]++;
        else ts[i + 1][1]++;
    }
    ll Q; cin>>Q;
    rep(q, Q) {
        ll a, b, c, d;
        cin>>a>>b>>c>>d; a--; c--;
        ll sa = ss[b][0] - ss[a][0];
        ll sb = ss[b][1] - ss[a][1];
        ll ta = ts[d][0] - ts[c][0];
        ll tb = ts[d][1] - ts[c][1];
        if (((sa - ta) - (sb - tb)) % 3) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 11728
#include <iostream>

using namespace std;

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

int main () {
    int N;
    ll K;
    cin >> N >> K;

    ll A[N];
    rep(i, N) cin >> A[i];

    ll X = 0;
    for (int d = 39; d >= 0; d--) {
        int c = 0;
        for (int i = 0; i < N; i++) {
            c += (A[i] >> d) & 1;
        }
        X |= c < N - c ? (1ll << d) : 0;
    }

    for (int d = 39; d >= 0; d--) {
        ll k = (K >> d) & 1;
        ll b = (X >> d) & 1;
        if (k == 1 && b == 0) break;
        X ^= (k ^ b) << d;
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i] ^ X;
    }

    cout << ans << endl;

    return 0;
}


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

int main (){
    string str;
    cin >> str;
    int num = (int)(str.length());

    int i,flag=0;
    for(i=1;i<num;i++){
        if( str[i-1] != str[i]){
            flag = 1;
            break;
        }
    }

    if(flag == 0) cout << "No" << endl;
    if(flag == 1) cout << "Yes" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int tmp=min(b,d)-max(a,c);
	if(tmp<=0)cout<<"0"<<endl;
	else cout<<tmp<<endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 14.12.2019 10:29:56       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < (int) a.size(); i++) {
    cin >> a[i];
  }
  while (a.size() > 1) {
    vector<int> b;
    for (int i = 0; i < (int) a.size(); i += 2) {
      b.push_back(abs(a[i] - a[i + 1]));
    }
    swap(a, b);
  }
  cout << a[0] << '\n';
  return 0;
}


Measured memory_bytes: 1916
N = int(input())
score = [list(map(int, input().split())) for _ in range(N)]
players = [0 for _ in range(N)]
for play in list(zip(*score)):
    for i, p in enumerate(play):
        if play.count(p) == 1:
            players[i] += p
print(*players, sep='\n')

Measured memory_bytes: 7736
#include <iostream>

using namespace std;

int main()
{
    double d;
    while(cin>>d)
    {
        double n,s=0;
        n=600/d;
        for(int i=0;i<n;++i)s+=(d*i)*(d*i)*d;
        cout<<int(s)<<endl;
    }
}

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

int N,a,b;
vector<pair<int,int>> v[100005];
int c[100005],K=0;

void root(int x, int p,int nowc){
    int color=1;
    for(auto i : v[x]){
        K=max(K,(int)v[x].size());
        if(i.second==p) continue;
        if(color==nowc) color++;
        c[i.first]=color;

        root(i.second,x,color);        color++;
    }
}

int main(){
    cin>>N;
    for(int i=0;i<N-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(make_pair(i,b));
        v[b].push_back(make_pair(i,a));
    }
    root(0,-1,0);
    cout<<K<<endl;
    for(int i=0;i<N-1;i++){
        cout<<c[i]<<endl;
    }
}

Measured memory_bytes: 9344
from collections import deque
n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])
color = [-1]*n
que = deque([[0, -1, 0]])
while que:
    u, v, c = que.popleft()
    color[u] = c
    for i, j in edge[u]:
        if i == v: continue
        que.append([i, u, (c+j)%2])
print(*color, sep="\n")

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

#define FOR(i,a,b)      for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b)     for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)        FOR(i,0,n)
#define RREP(i,n)       RFOR(i,n,0)
#define ALL(v)          (v).begin(),(v).end()
#define BIT(n)          (1LL<<(n))
#define IN(x,l,r)       ((l)<=(x)&&(x)<=(r))
#define INCLUDE(s,v)    (s.find(v)!=string::npos)
#define LEN(s)          (string(s)).length()
#define DUMP(x)         cerr<<#x<<" = "<<x<<endl
#define SORT(v)         sort(ALL(v))
#define SZ(v)           (ll)(v).size()
#define UNIQ(v)         SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)         for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)           priority_queue<T,vector<T>,greater<T>>
#define REPLACE(s,f,t)  for(auto p=s.find(f);p!=string::npos;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);

template<class T>string join(const vector<T>& v,string d=" ") {stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}
template<class T>ostream& operator<<(ostream& o,const vector<T>& v) {o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}
template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p) {o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    ll a, b, c; cin >> a >> b >> c;
    DUMP(b-a);
    if (b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> maze(h,vector<char>(w));
    int white = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> maze[i][j];
            if(maze[i][j] == '.') white++;
        }
    }
    vector<vector<int>> seen(h,vector<int>(w,-1));
    seen[0][0] = 1;

    queue<pair<int,int>> q;
    q.push(make_pair(0,0));

    vector<int> dy(4); dy = {1,0,0,-1};
    vector<int> dx(4); dx = {0,1,-1,0};

    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop();

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

            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(maze[ny][nx] == '#') continue;
            if(seen[ny][nx] != -1) continue;

            seen[ny][nx] = seen[y][x] + 1;
            q.push(make_pair(ny,nx));
        }
    }
    int ans;
    if(seen[h-1][w-1] == -1) ans = -1;
    else ans = white - seen[h-1][w-1];
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    if(A > B){
        swap(A, B);
    }

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
        return 0;
    }

    ll ans, temp;
    temp = (A + B - 1) / 2;
    ans = min(temp, N - temp);

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

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

int main(){
  int n;
  cin >> n;
  map<int, int> m;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    m[num]++;
  }
  if(m.size() == 3){
    for(auto itr : m){
      if(itr.second != n/3){
        cout << "No" << endl;
        return 0;
      }
    }
    int res = 0;
    for(auto itr : m){
      res ^= itr.first;
    }
    if(res == 0){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }else if(m.size() == 2){
    if(m[0] == n/3){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }else if(m.size() == 1){
  	if(m[0]){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }else{
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 3840
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

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


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  vector<ll> v;
  cin>>n>>k;
  for(ll i=0;i<n;i++) v.push_back(k+i),v.push_back(k-i);
  set<ll> st;
  sort(ALL(v));
  rep(i,v.size()) st.insert(v[i]);
  for(auto e:st){
    cout<<e<<' ';
  }
  cout<<endl;
}

Measured memory_bytes: 256
import sys
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
b=0
c=0
for x in range(N):
  if P[x]<=A:
    a+=1
  elif P[x]>A and P[x]<=B:
    b+=1
  elif P[x]>B:
    c+=1
  else:
    sys.stderr.write("error")
print(min(a,b,c))

Measured memory_bytes: 9132
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,a,b,ans=0;
    cin>>n>>a>>b;
    lvec x(n);
    rep(i,n) cin>>x[i];
    rep(i,n-1){
        if((x[i+1]-x[i])*a<b) ans+=(x[i+1]-x[i])*a;
        else ans+=b;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

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

	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v.at(i);
	}

	for (int i = 0; i < n; i++)
	{
		cin >> c.at(i);
	}

	int vs = 0;
	int cs = 0;
	for (int i = 0; i < n; i++)
	{
		if (v.at(i) - c.at(i) > 0)
		{
			vs += v.at(i);
			cs += c.at(i);
		}
	}

	cout << vs - cs << endl;
}

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

using namespace std;

int main(void) {
  long long W, H;

  cin >> H >> W;
  
  long long ans = (W * H) / 2;
  if ((W * H) % 2 != 0) ans += 1;
  if (W == 1 || H == 1) {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}

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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}
template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



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

    ll K, N; cin >> K >> N;
    vector<ll> A(N); cin >> A;
    A.push_back(K + A[0]);
    ll mx = 0;
    rep(i, N) set_max(mx, A[i+ 1] - A[i]);
    cout << K - mx << endl;
    return 0;
}


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

vector<int> divisors(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end(), greater<int>());
    return res;
}

int main() {
    int N, K;  cin >> N >> K;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    for (int d : divisors(sum)) {
        bool ok;
        vector<int> r(N);
        int allsum_r = 0;
        for (int i = 0; i < N; ++i) {
            r[i] = A[i] % d;
            allsum_r += r[i];
        }
        sort(r.begin(), r.end());
        int sum_r = 0;
        for (int i = 0; i < N; ++i) {
            sum_r += r[i];
            if (sum_r == (N - i - 1) * d - (allsum_r - sum_r)) {
                ok = sum_r <= K;
                break;
            }
        }
        if (ok) {
            cout << d << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
X = int(input())
sosu = True
if X == 2:
    print(2)
else:
    while(sosu):
        for i in range(2,X):
            if X%i == 0:
                break
            if i == X-1:
                sosu = False
        if sosu == False: break
        X += 1

    print(X)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 1e5 + 7;

vector <int> g[N];
int col[N], comp[N], ans[N];

void dfs(int v, int c) {
    col[v] = c;
    ++comp[c];
    for (int u : g[v])
        if (!col[u])
            dfs(u, c);
}

void solve() {
    int n, mf, mb;
    cin >> n >> mf >> mb;
    loop(i, mf) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int cnt = 0;
    loop1(v, n)
        if (!col[v])
            dfs(v, ++cnt);
    loop1(v, n)
        ans[v] = comp[col[v]] - g[v].size() - 1;
    loop(i, mb) {
        int u, v;
        cin >> u >> v;
        if (col[u] == col[v]) {
            --ans[u]; --ans[v];
        }
    }
    loop1(i, n)
        cout << ans[i] << " ";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 12252
//Reverse Sequence
// 2018.3.13

#include <stdio.h>
#include <string.h>

int
main (void)
{
  char str[21] = {0};
  
  scanf("%s\n", str);
  int l;
  l = strlen(str);
  while(l--)
    {
      printf("%c", str[l]);
    }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2032
#include<algorithm>
#include<typeinfo>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#define eps 0.01
#define pi acos(-1)
#define e exp(1)
using namespace std;
typedef long long ll;
const int maxn = 1e5;
int n, k;
int main() {
    while (cin >> n >> k) {
        for (int i = 0; i < n; ++i) {
            int num;
            cin >> num;
        }
        n--, k--;
        if (n%k == 0)
            cout << n / k << endl;
        else
            cout << n / k + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define fi first
#define se second
 
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);
const int inf = 1e9;
const double eps = 1e-6;

int n;
ll k,a[maxn],b[maxn],c[maxn];

bool check (ll x) {
    ll sum = 0;
    rep(i,1,n) {
        if(c[i] - x + b[i] - 1 >= 0) {
            sum += (c[i] - x + b[i] - 1ll) / b[i];
        }
    }
    if(sum <= k) return true;
    else return false;
}
int main()
{
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    rep(i,1,n) cin >> a[i];
    rep(i,1,n) cin >> b[i];
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);
    reverse(b + 1, b + 1 + n);
    rep(i,1,n) c[i] = a[i] * b[i];
    ll l = -1, r = 1e12 + 1;
    //cout << l << " " << r << endl;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        if (check(mid))
        {
            r = mid;
        }
        else l = mid;
         //cout << l << " " << r << endl;
    }
    cout << r << endl;
    return 0;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  ll m = n % k;
  ll mk = abs(m - k);
  ll ans = m;
  if (m >= mk) ans = mk;
  cout << ans << endl;
}


Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };


int main () {
	int h, w, n,a;
	cin >> h >> w;
	vector<vector<int>> v (h, vector<int> (w, 0));
	cin >> n;
	vector<pair<int, int>> p;

	rep (i, n) {
		cin >> a;
		p.emplace_back (a, i + 1);
	}
	sort (all (p));
	/*rep (i, n) {
		cout << p[i].first << " " << p[i].second << endl;
	}*/
	a = 0;
	int num=n-1;
	while (a < h) {
		if (a % 2 == 0) {
			for (int i = 0; i < w; i++) {
				v[a][i] = p[num].second;
				p[num].first--;
				if (p[num].first == 0) num--;
			}
		} else {
			for (int i = w - 1; i >= 0; i--) {
				v[a][i] = p[num].second;
				p[num].first--;
				if (p[num].first == 0) num--;
			}
		}
		a++;
	}

	rep (i, h) {
		rep (j, w) {
			cout << v[i][j];
			if (j != w - 1) cout << " ";
			else cout << "\n";
		}
	}



	
}

 

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    ll n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    ll csum[n+1];
    csum[0]=0;
    rep(i,n)csum[i+1]=csum[i]+v[i];
    map<ll,ll> m;
    ll ans=0;
    for(int i=n;i>=0;i--){
        ans+=m[csum[i]];
        m[csum[i]]++;
    }
    fin(ans);
}

Measured memory_bytes: 15872