akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

vector<int> Z_algorithm(const string &S){
    int N = (int)S.size();
    vector<int> res(N);

    for(int i = 1, left = 0, right = 0; i < N; i++){
        if(i > right){
            left = right = i;
            while(right < N && S[right-left] == S[right]) right++;
            res[i] = right - left;
            right--;
        }else{
            int k = i - left;
            if(res[k] < right - i + 1){
                res[i] = res[k];
            }else{
                left = i;
                while(right < N && S[right-left] == S[right]) right++;
                res[i] = right - left;
                right--;
            }
        }
    }
    res[0] = N;
    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for(int i = 0; i < N; i++){
        string T = S.substr(i);
        auto lcp = Z_algorithm(T);
        for(int j = 0; j < T.size(); j++){
            int l = min(lcp[j],j);
            res = max(res,l);
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 384
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		sc.close();
		out.println(s.equals("ABC")?"ARC":"ABC");
	}
}


Measured memory_bytes: 27020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
ll add(ll a, ll b){a += b; return a>=mod?a-mod:a;}
ll sub(ll a, ll b){a -= b; return (a<0?a+mod:a);}
ll mult(ll a, ll b){return (a*b)%mod;}
void solve(){
    fact(500005);
    int n, m, ans = 0;
    cin >> n >> m;
    rep(i, 0, n+1){
        ll temp = mult(mult(ncr(n, i), mult(ncr(m, i),ft[i])), mult(mult(ncr(m-i, (n-i)), ft[n-i]), mult(ncr(m-i,( n-i)), ft[n-i])));
        ans = i%2?sub(ans, temp):add(ans, temp); 
    }
    cout << ans << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 7380
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int a[200005];
int b[200005];
int main() {
    int n = read();
    for (int i = 1; i <= n; ++i) a[i] = read();
    sort(a + 1, a + 1 + n);
    long long rs = 0;
    if (n & 1) {
        rs -= a[n / 2 + 1] + a[n / 2];
        for (int i = 1; i < n / 2; ++i) {
            rs -= 2ll * a[i];
        }
        for (int i = n / 2 + 2; i <= n; ++i) {
            rs += 2ll * a[i];
        }
        long long tmp = 0;
        tmp += a[n / 2 + 1] + a[n / 2 + 2];
        for (int i = 1; i <= n / 2; ++i) {
            tmp -= 2ll * a[i];
        }
        for (int i = n / 2 + 3; i <= n; ++i) {
            tmp += 2ll * a[i];
        }
        rs = max(tmp, rs);
    } else {
        rs = a[n / 2 + 1] - a[n / 2];
        for (int i = 1; i < n / 2; ++i) {
            rs -= 2ll * a[i];
        }
        for (int i = n / 2 + 2; i <= n; ++i) {
            rs += 2ll * a[i];
        }
    }
    printf("%lld", rs);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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 RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int N;
	ll result=1;
	cin>>N;
	FOR(i,1,N+1) result=(result*i)%MOD;
	cout<<result<<endl;

	return 0;
}



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

const ll MOD = 1e9 + 7;
const ll MAX = 1e6 + 10;
vector<ll> inv(MAX, 0);

vector<pair<ll, ll>> factorization(ll n) {
  ll s = sqrt(MAX) + 5;
  vector<pair<ll, ll>> f;
  for (int i = 2; i <= s; i++) {
    if (n == 1) break;
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      f.emplace_back(make_pair(i, cnt));
    }
  }
  if (n > 1) f.emplace_back(make_pair(n, 1));
  return f;
}

ll modPow(ll a, ll x) {
  if (x == 0) return 1;
  if (x == 1) return a;
  ll temp = modPow(a, x / 2);
  ll ans = (temp * temp) % MOD;
  if (x % 2 == 1) ans = (ans * a) % MOD;
  return ans;
}

ll calcInv(ll a) {
  return modPow(a, MOD - 2);
}

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

  int N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<vector<pair<ll, ll>>> f;
  vector<ll> LMAX(MAX, 0);
  for (int i = 0; i < N; i++) {
    f.emplace_back(factorization(A[i]));
    for (auto p: f[i]) {
      LMAX[p.first] = max(LMAX[p.first], p.second);
    }
  }

  ll L = 1;
  for (int i = 0; i <= MAX; i++) {
    if (LMAX[i] == 0) continue;
    L = (L * modPow(i, LMAX[i])) % MOD;
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll B = L;
    for (auto p: f[i]) {
      ll pinv;
      if (inv[p.first] > 0) pinv = inv[p.first];
      else pinv = calcInv(p.first);
      inv[p.first] = pinv;
      B = (B * modPow(pinv, p.second)) % MOD;
    }
    ans = (ans + B) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  
  string s[h];
  int c1[w],c[h][w];
  
  if(h!=0){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      c[i][j]=0;
    }
  }
  
  for(int i=0;i<h;i++){cin>>s[i];}
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i].at(j)=='#'){
        if(j==0){
          if(i==0){
            if(i+1<h&&j+1<w){c[i+1][j+1]++;}
            if(j+1<w){c[i][j+1]++;} if(i+1<h){c[i+1][j]++;}
          }else if(i==h-1){
            if(j+1<w){c[i-1][j+1]++;} if(j+1<w){c[i][j+1]++;} c[i-1][j]++;
          }else{
            c[i-1][j]++; if(i+1<h){c[i+1][j]++;}
            if(j+1<w){c[i-1][j+1]++; c[i][j+1]++;}
            if(i+1<h&&j+1<w){c[i+1][j+1]++;}
          }
        }else if(j==w-1){
          if(i==0){
            if(i+1<h){c[i+1][j-1]++; c[i+1][j]++;} c[i][j-1]++; 
          }else if(i==h-1){
            c[i-1][j-1]++;c[i][j-1]++;c[i-1][j]++;
          }else{
            c[i-1][j]++;c[i-1][j-1]++;c[i][j-1]++;
            if(i+1<h){c[i+1][j-1]++; c[i+1][j]++;}
          }
        }else{
           if(i==0){
            c[i][j-1]++; if(i+1<h&&j+1<w){c[i+1][j+1]++;}
            if(i+1<=h){c[i+1][j-1]++; c[i+1][j]++;} if(j+1<=w){c[i][j+1]++;}
          }else if(i==h-1){
            c[i-1][j-1]++;c[i][j-1]++;c[i-1][j]++;
            if(j+1<w){c[i-1][j+1]++;c[i][j+1]++;}
          }else{
            c[i-1][j]++;c[i-1][j-1]++;c[i][j-1]++;
            if(j+1<w){c[i-1][j+1]++;c[i][j+1]++;}
            if(i+1<h){c[i+1][j]++;c[i+1][j-1]++;}
            if(i+1<h&&j+1<w){c[i+1][j+1]++;}
          }
        }
      }
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i].at(j)=='#'){cout<<'#';}
      else{cout<<c[i][j];}
      if(j==w-1){cout<<endl;}
    }
  }
  }else{
    
    for(int j=0;j<w;j++){
      c1[j]=0;
    }
  
	cin>>s[0];

    for(int j=0;j<w;j++){
      if(s[0].at(j)=='#'){
        	if(j==0){
            	if(j+1<w){c1[j+1]++;}
        	}else if(j==w-1){
            	c1[j-1]++; 
        	}else{
            	c1[j-1]++;c1[j+1]++;
       	 	}
     	}
    }
  
    for(int j=0;j<w;j++){
      if(s[0].at(j)=='#'){cout<<'#';}
      else{cout<<c1[j];}
      if(j==w-1){cout<<endl;}
    }
  }
}

Measured memory_bytes: 256
import bisect


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


cnt = 0

for b in B:
    mid = bisect.bisect_left(A, b)
    bottom = n - bisect.bisect_right(C, b)
    cnt += mid*bottom

print(cnt)


Measured memory_bytes: 23092
/* ABC144_B
    Stuartyg */

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


int main(void){
        int num; /*nのこと*/
        int counter_1,counter_2; 
        scanf("%d",&num); /*入力を受け取る*/
        for (counter_1=1;counter_1<=9;counter_1++){ /* for文二個で1*1,1*2,1*3,・・・9*9まで調べる*/
                for (counter_2=1;counter_2<=9;counter_2++){
                        if (num == counter_1*counter_2){
                                printf("Yes\n");
                                return 0; /*一致すればそこでYesと出力して終了*/
                        }
                }
        }
        /*一致しなかった場合*/
        printf("No\n");
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>

typedef long long ll;
using namespace std;
const ll INF = LLONG_MAX/3;

int main(){
    int n;
    ll W;
    cin >> n >> W;
    ll value[n];
    ll weight[n];
    for (int i = 0; i<n;i++){
        cin >> value[i] >> weight[i] ;
    }

    int hn = n/2;
    vector<pair <ll, ll> > sumList;

    for (int i=0;i<(1<<hn);i++){
        ll v_sum = 0;
        ll w_sum = 0;
        for (int j=0;j<hn;j++){
            if((i>>j)&1){
                v_sum += value[j];
                w_sum += weight[j];
            }
        }
        sumList.push_back(make_pair(w_sum, v_sum));
    }

    sort(sumList.begin(), sumList.end());
    vector<pair <ll, ll> > sumListOmitted;
    sumListOmitted.push_back(sumList[0]);
    int j=0;
    for (int i=1;i<sumList.size();i++){
        if(sumListOmitted[j].second < sumList[i].second){
            sumListOmitted.push_back(sumList[i]);
            j++;
        }
    }

    ll result = 0;
    for (int i=0;i<(1<<(n-hn));i++){
        ll v_sum = 0;
        ll w_sum = 0;
        for (int j=0;j<n-hn;j++){
            if ((i>>j)&1){
                v_sum += value[hn+j];
                w_sum += weight[hn+j];
            }
        }
        if (w_sum <= W){
            result = max(result, v_sum + (lower_bound(sumListOmitted.begin(), sumListOmitted.end(), make_pair(W-w_sum,INF))-1)->second);
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 19384
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

int A[200000];
int B[200000];

long long calc_num_of_invs(int begin, int end) {
	long long num_of_invs;

	if (begin == end) {
		return 0LL;
	}
	int mid = (begin + end) / 2;
	num_of_invs = calc_num_of_invs(begin, mid);
	num_of_invs += calc_num_of_invs(mid+1, end);
	int pB = 0;
	int pA1 = begin;
	int pA2 = mid + 1;
	while (pA1 <= mid && pA2 <= end) {
		if (A[pA1] < A[pA2]) {
			B[pB++] = A[pA1++];
		}
		else {
			num_of_invs += mid - pA1 + 1;
			B[pB++] = A[pA2++];
		}
	}
	if (pA1 > mid) {
		while (pA2 <= end) {
			B[pB++] = A[pA2++];
		}
	}
	else {
		while (pA1 <= mid) {
			B[pB++] = A[pA1++];
		}
	}
	pB = 0;
	for (int i = begin; i <= end; ++i) {
		A[i] = B[pB++];
	}

	return num_of_invs;
}

int main() {
	int n;

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}

	printf("%lld\n", calc_num_of_invs(0, n - 1));


	return 0;
}

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

using namespace std;


int main(void){
  int n, sum=0;
  cin >> n;
  vector<int> v(n);
  for (int i=0; i<n; i++) {
    cin >> v[i];
    sum+=v[i];
  }

  int m, ans;
  cin >> m;
  for (int i=0; i<m; i++) {
    ans=sum;
    int p, x;
    cin >> p >> x;
    ans-=v[p-1]-x;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  int ans = 0;
  if(s[0]=='+') ans++;
  else ans--;
  if(s[1]=='+') ans++;
  else ans--;
  if(s[2]=='+') ans++;
  else ans--;
  if(s[3]=='+') ans++;
  else ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if((N-N%10)%111==0){
    cout<<"Yes"<<endl;
  }
  else if(N%1000%111==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  
    
    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int flag = 1;
		for(int j = i; j < n; j++){
			if(s[j] != t[j-i]) flag = 0;
		}
		if(flag == 1 && ans < n - i) ans = n - i;
	}
	cout << 2 * n - ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int INF = 1e9 ;
const int maxN = 1e5 + 5;

int n,Q;
int a[maxN];
int X[maxN];
bool check(int x,int m)
{
	int z = a[n-m+1];
	if(z < x)
		return false;
	int d = z - x;
	int y = x - d;
	int p = lower_bound(a+1,a+1+n,y) - a;
	int q = n - m+1;
	if((q - p +1) >= m)
	{
		return true;
	}
	else
	{
		return false;
	}
}
ll s[maxN];
ll t[maxN];
int main()
{
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		s[i] = s[i-1] + (ll)a[i];
	}
	t[1] = a[1];
	t[2] = a[2]; 
	for(int i=3;i<=n;i++)
	{
		t[i] = t[i-2] + (ll)a[i];
	}
	for(int i=1;i<=Q;i++)
	{
		scanf("%d",&X[i]);
		int L=1,R=n;
		int ans = 0;
		ll cnt = 0;
		while(L<=R)
		{
			int mid = (L+R)/2;
			if(check(X[i],mid))
			{
				ans = mid;
				L = mid+1;
			}
			else
			{
				R = mid - 1;
			}
		}
		int p = n-ans +1;
		int q = n - 2*ans + 1;
		cnt += (s[n] - s[p-1]);
		cnt += t[q-1];
		cout<<cnt<<endl;
	}
	return 0;
} 

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=52;
int n,a;
long long dp[maxn][maxn][maxn*maxn];
int num[maxn],sum[maxn];
int main() {
    while (~scanf("%d%d",&n,&a)) {
        memset(sum,0,sizeof(sum));
        memset(dp,0,sizeof(dp));
        for (int i=1;i<=n;i++) scanf("%d",&num[i]),sum[i]=sum[i-1]+num[i];
        for (int i=0;i<=n;i++) dp[i][0][0]=1;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=i;j++)
                for (int k=0;k<=sum[i];k++) {
                    dp[i][j][k]=dp[i-1][j][k];
                    if (k-num[i]>=0) dp[i][j][k]+=dp[i-1][j-1][k-num[i]];
                }

        long long ans=0;
        for (int i=1;i<=n;i++) ans+=dp[n][i][i*a];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 57344
let n = stdin.ReadLine() |> int
let ls = stdin.ReadLine().Split() |> Array.map int

let sorted = ls |> Array.sort

//メモ化
let memoize fn =
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
        match cache.TryGetValue x with
        | true, v -> v
        | false, _ -> 
            let v = fn (x)
            cache.Add(x,v)
            v)

let searchC sum = 
    sorted |>Array.tryFindIndex (fun x -> x >= sum ) 
    |> fun i ->
        match i with
        |None -> n-1
        |Some(i) -> i - 1

let memSearchC = memoize searchC

seq{
    for i in 0..n-3 do
        for j in i+1..n-2 do
            yield sorted.[i], sorted.[j], j
}
|> Seq.map (fun (a,b,i) -> (memSearchC (a+b), i))
|> Seq.map (fun (x, y) -> x - y)
|> Seq.sum
|> stdout.WriteLine

Measured memory_bytes: 18808
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

int main(){
  int n;
  cin >> n;
  if(n == 0)cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 4e5;
const int PLS = 3e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e16;


ll n, a[20][20], dp[N], cnt[N], pw[30];


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    ll t = 1;
    for (int i = 0; i <= 18; i++) {
        pw[i] = t;
        t *= 2;
    }
    for (int mask = 1; mask < pw[n]; mask++) {
        int id;
        for (int j = 0; j < n; j++)
            if ((1 & (mask>>j))) {
                id = j;
                break;
            }
        ll sm = 0;
        for (int j = 0; j < n; j++)
            if ((1 & (mask>>j)))
                sm += a[id][j];
        cnt[mask] = cnt[(mask ^ pw[id])] + sm;
        for (int subm = mask; subm != 0; subm = (subm - 1) & mask)
            dp[mask] = max(dp[mask], cnt[subm] + dp[(mask ^ subm)]);
    }
    cout << dp[pw[n] - 1];
}


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

int main(){
   char str[20];
   char *s="CODEFESTIVAL2016";
   int len;
   int i,ans;

   scanf("%s",str);
   len=strlen(str);

   ans=0;
   for(i=0;i<len;++i){
      ans+=(str[i]!=s[i]);
   }

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

   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<int> a(n);
  int xorsum = 0;
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
    xorsum ^= a.at(i);
  }

  for(int i=0; i<n; i++) {
    int ans = xorsum ^ a.at(i);
    if (i != 0) {
      cout << ' ';
    }
    cout << ans;
  }
  cout << endl;
}

Measured memory_bytes: 4052
h, w = map(int, input().split())

S = []
for _ in range(h):
  S.append(input())

for i in range(h):
  ss = ''
  for j in range(w):
    if S[i][j] == '#':
      ss += '#'
    else:
      counter = 0
      for k in [-1, 0, 1]:
        for l in [-1, 0, 1]:
          if 0 <= i+k <= h-1 and 0 <= j+l <= w-1 and S[i+k][j+l] == '#':
            counter += 1
      ss += str(counter)
  print(ss)

Measured memory_bytes: 41200
using System;

namespace AtCoderDiverta2019C
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            int N = int.Parse(Console.ReadLine());

            int EndA = 0;
            int StartB = 0;
            int Both = 0;

            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                ans += (s.Length - s.Replace("AB", "").Length) / 2;

                if (s.StartsWith("B"))
                    StartB++;
                if (s.EndsWith("A"))
                    EndA++;
                if (s.StartsWith("B") && s.EndsWith("A"))
                    Both++;
            }

            if(EndA ==0 || StartB ==0)
            {
                Console.WriteLine(ans.ToString());
                return;
            }


            if (EndA == StartB)
            {
                if (EndA == Both)
                    ans += EndA - 1;
                else
                    ans += EndA;
            }
            else if (EndA > StartB)
                ans += StartB;
            else
                ans += EndA;

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13404
#include <iostream>
#include <vector>
#include <string>
#include <cmath>


using namespace std;

int main(){
    int N;
    int A[210];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    int res=0;

    while(true){
        bool exist_odd=false;
        for(int i=0;i<N;i++){
            if((A[i])%2!=0)exist_odd=true;
        }

        if(exist_odd)break;
        else{
            for(int i=0;i<N;i++){
                A[i]/=2;
            }
            ++res;
        }
    }
    cout<<res<<endl;

}

Measured memory_bytes: 256
let () =
  let (n, k) = Scanf.scanf "%d %d\n" (fun n k -> (n, k)) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d\n" (fun i -> i)) in
  let check p =
    let rec doit i j s =
      if i = n then n
      else if j >= k then i
      else
        let x = s + a.(i) in
        if x > p then doit i (j + 1) 0
        else doit (i + 1) j x
    in
    doit 0 0 0
  in
  let rec bin_search l r =
    if r < l then l
    else
      let m = (l + r) / 2 in
      if check m >= n then bin_search l (m - 1)
      else bin_search (m + 1) r
  in
  Printf.printf "%d\n" (bin_search 0 (100000 * 10000))

Measured memory_bytes: 5324
#include<stdio.h>
int main(){
	int i,j,h,w;
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1)a*=14;
    if(b==1)b*=14;
    if(a>b)printf("Alice\n");
    else if(b>a)printf("Bob\n");
    else if(a==b)printf("Draw\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N), pushed(N);
  for (int i=0; i<N; i++)
    cin >> a.at(i);
  int b = 1, c;
  pushed.at(b - 1) = 1;
  bool enable_finish = false;
  while (true) {
    b = a.at(b - 1);
    c++;
    if (b == 2) {
      enable_finish = true;
      break;
    } else if (pushed.at(b - 1) == 1) 
      break;
    else {
      pushed.at(b - 1) = 1;
    }
  }
  if (enable_finish) cout << c << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}
using P = pair<int, int>;

P f(int n) {
    int a = n % 10;
    int b = 0;
    while (n) {
        b = n;
        n /= 10;
    }
    return P(a, b);
}

int main(){
    int n;
    cin >> n;
    map<P, int> freq;

    for (int i = 1; i <= n; ++i) { 
        P p = f(i);
        freq[p]++;
    }

    ll ans = 0;

    for (int i = 1; i <= n; ++i) {
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<string>

using namespace std;

int main(){

	int sum;
	string data;

	for (;;){//0???????????´????????°????????????

		getline(cin, data);
		sum = 0;

		for (int i = 0; data[i]; i++){

			sum += data[i] - '0';

		}if (sum == 0)break;
		cout << sum << endl;
		
	}




	return 0;
}

Measured memory_bytes: 1176
#include <iostream>

using namespace std;

int main()
{string s ;
cin>>s ;
 
 if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
   cout<<3 ;
 else if(s[1]=='R'&&s[2]=='R') 
    cout<<2 ;
 else if(s[1]=='R'&&s[0]=='R')
 cout<<2 ;
 else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
 cout<<1 ;
 else 
 cout<<0 ;
}


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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  for(int i=0;i<s.size();i++){
    s[i] = char((s[i]-'A'+n)%26 + 'A');
  }
  cout<<s<<endl;
  return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  string result = "NO";
  
  for (int i = 1; i <= B; i++) {
    if ((i * A) % B == C) {
      result = "YES";
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    vec h(N);
    REP(i, N) {
        cin >> h[i];
    }

    SORT(h);
    ll ans = INF;

    REP(i, N - K + 1) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

static const string numbers[] = {"1111110","0110000","1101101","1111001","0110011",
	"1011011","1011111","1110010","1111111","1111011"};
static const int order[] = {'g'-'a','f'-'a','e'-'a','d'-'a','c'-'a','b'-'a','a'-'a'};

string changeOrder(string numbers){
	reverse(numbers.begin(),numbers.end());
	return numbers;
}

void setStage(bitset<7>& stage,bitset<7>& next){
	for(int i=0;i<7;i++){
		if(next[i] & 1){
			stage[i] = ~stage[i];
		}
	}
}

int main(){

	int n;	
	while(~scanf("%d",&n)){
		if(n==-1) break;
		bitset<7> next;
		bitset<7> stage;
		for(int i=0;i<n;i++){
			int light;
			scanf("%d",&light);
			bitset<7> num(changeOrder(numbers[light]));
			next = stage ^ num;	
			setStage(stage,next);
			printf("%s\n",next.to_string().c_str());
			
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<double, double>;

int main() {
  int N;
  int K;
  double a[200001];
  cin >> N >> K;
  a[0] = 0;
  rep(i, N) {
    cin >> a[i+1];
  }
  rep(i, N) {
    a[i+1] += a[i];
  }
  double b[200000];
  rep(i, N+1-K) {
    b[i] = a[i+K] - a[i];
  }
  double ans = 0;
  rep(i, N+1-K) {
    ans = max(ans, b[i]);
  }
  ans = (ans + K) / 2;
  cout << std::setprecision(8) << std::fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 6780
(defun f (n)
  (cond
    ((zerop n) 0)
    ((evenp n)
     (logxor n (if (evenp (/ n 2)) 0 1)))
    (t
     (logxor n
             (- n 1)
             (if (evenp (truncate n 2)) 0 1)))))

(defun h (a b)
  (if (zerop a)
      (f b)
      (logxor (f (- a 1)) (f b))))

(let ((a (read))
      (b (read)))
  (format t "~A~%" (h a b)))


Measured memory_bytes: 7392
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


class WeightedUnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [0] * N
        self.weight = [0] * N  # 親までの距離

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            r = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = r
            return r

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def diff_w(self, x, y):
        return self.weight[x] - self.weight[y]


def main():
    N, M = map(int, readline().split())
    m = map(int, read().split())
    LRD = list(zip(m, m, m))

    D = WeightedUnionFind(N)

    for l, r, d in LRD:
        l -= 1
        r -= 1
        D.union(l, r, d)

    for l, r, d in LRD:
        l -= 1
        r -= 1
        D.find(l)
        D.find(r)
        if d != D.diff_w(l, r):
            print('No')
            sys.exit()

    print('Yes')


main()


Measured memory_bytes: 62136
#include <bits/stdc++.h>
typedef unsigned long long ll;
#define INF 1000000000
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int m;
        cin>>m;
    }
    int ans=ceil((double)(n-1)/(k-1));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n; cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a,b; cin >> a >> b;
    cout << a + b << endl;
  }
}

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


int main(){
    long long h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << "1" << endl;
        return 0;
    }
    if(h % 2 == 0 && w % 2 == 0){
        cout << (h / 2) * w << endl;
        return 0;
    }else if(h % 2 == 0 && w % 2 == 1){
        cout << (h / 2) * w << endl;
        return 0;
    }else if(h % 2 == 1 && w % 2 == 0){
        cout << (w / 2) * h << endl;
        return 0;
    }else{
        if(h > w){
            cout << (((h - 1) / 2) * w) + ((w / 2) + 1) << endl;
            return 0;
        }else {
            cout << (((w - 1) / 2) * h) + ((h / 2) + 1) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
  int n;
  cin>>n;
  int n2=1<<n;  //=pow(2,n)と同義
  vi a(n2),s;
  rep(i,n2)cin>>a[i];
  sort(all(a));
  s.push_back(a.back());//aの最大をsに入れる
  a.back()=-1;
  rep(i,n){
    vi p=s;
    sort(all(p));
    int ai=n2-1;
    while(p.size()>0&&ai>=0){
      if(a[ai]==-1){
        --ai;
        continue;
      }
      if(a[ai]<p.back()){
        s.push_back(a[ai]);
        p.pop_back();
        a[ai]=-1;
      }
      --ai;
    }
      if(p.size()>0){
      puts("No");
      return 0;
      }

  }

  puts("Yes");



}




Measured memory_bytes: 2932
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        String s;
        read s;
        int ans = 0;
        for ( int i = 0; i < s.size(); i++ ) {
            if ( s[i]=='+' ) ans++;
            else ans--;
        }
        echo ans fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <tuple>
#include <algorithm>

using lli = long long int;
using tiiii = std::tuple<lli,lli,lli,lli>;

lli A[1000];
lli B[1000];
lli C[1000];

int main() {

	int X, Y, Z, K;

	std::cin >> X >> Y >> Z >> K;

	std::priority_queue<tiiii> pq;

	for (int i = 0; i < X; i++) {
		std::cin >> A[i];
	}
	for (int i = 0; i < Y; i++) {
		std::cin >> B[i];
	}
	for (int i = 0; i < Z; i++) {
		std::cin >> C[i];
	}

	std::sort(A, A + X);
	std::sort(B, B + Y);
	std::sort(C, C + Z);

	pq.push(tiiii{ A[X - 1] + B[Y - 1] + C[Z - 1],X - 1,Y - 1,Z - 1 });

	tiiii before = {};

	while (K > 0 && !pq.empty()) {

		tiiii p = pq.top();
		pq.pop();

		if (p == before)
			continue;
		
		before = p;
		K--;

		std::cout << std::get<0>(p) << std::endl;

		if (std::get<1>(p) > 0)
			pq.push(tiiii{ A[std::get<1>(p) - 1] + B[std::get<2>(p)] + C[std::get<3>(p)]
				,std::get<1>(p) - 1
				,std::get<2>(p)
				,std::get<3>(p) });

		if (std::get<2>(p) > 0)
			pq.push(tiiii{ A[std::get<1>(p)] + B[std::get<2>(p) - 1] + C[std::get<3>(p)]
				,std::get<1>(p)
				,std::get<2>(p) - 1
				,std::get<3>(p) });

		if (std::get<3>(p) > 0)
			pq.push(tiiii{ A[std::get<1>(p)] + B[std::get<2>(p)] + C[std::get<3>(p) - 1]
						,std::get<1>(p)
						,std::get<2>(p)
						,std::get<3>(p) - 1 });

	}

	return 0;
}

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

 int main() {
     int x1, x2, x3, x4, x5;
     cin>>x1>>x2>>x3>>x4>>x5;

        if(x1==0){cout<<"1";}
        else if(x2==0){cout<<"2";}
        else if(x3==0){cout<<"3";}
        else if(x4==0){cout<<"4";}
        else if(x5==0){cout<<"5";}
        else cout<<"not";

 }


Measured memory_bytes: 3588
N,W = map(int,input().split())
v = [0] * (N+1)
w = [0] * (N+1)

for j in range(1, N+1):
    v[j], w[j] = map(int,input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1, N+1):
    for j in range(1, W+1):
        if w[i] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])


Measured memory_bytes: 25940
#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>;
const int INF = 1001001001;
int main(){
  string O,E;
  cin>>O>>E;
  string ans;
  int countO=0; int countE=0;
  for(int i=1;i<=(O.size()+E.size());i++){
  if(i%2!=0){ans+=O[countO];countO++;}
  else{ans+=E[countE];countE++;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
const int N=100005;
int n,m,I,P,Q,co[N];
vector<int> e[N];
bool check(int x,int fa,int c){
	co[x]=c;
	bool ans=1;
	for (auto i:e[x]){
		if (i==fa) continue;
		if (!co[i]) ans&=check(i,x,-c);
		else ans&=(c!=co[i]);
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].PB(y); e[y].PB(x);
	}
	For(i,1,n){
		if (co[i]) continue;
		if (e[i].size()==0) I++;
		else if (check(i,0,1)) Q++;
		else P++;
	}
	printf("%lld\n",1ll*I*I+2ll*I*(n-I)+1ll*P*P+2LL*P*Q+2ll*Q*Q);
}

Measured memory_bytes: 11776
#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;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<string> G(N); cin >> G;
        
        int blacks = 0;        
        rep(i, N) {
            bool ok = true;
            rep(j, N) ok &= G[j][i] == '#';
            blacks += ok;
        }
        bool contain_black = false;
        rep(i, N) rep(j, N) contain_black |= G[i][j] == '#';
        int ans = INF;
        rep(i, N) {
            int left = 0;
            bool paintable = false;
            rep(j, N) {
                left += G[i][j] == '.';
                paintable |= G[j][i] == '#';
            }
            if(paintable or contain_black) {
                set_min(ans, left + (N - blacks) + !paintable);
            }            
        }        
        cout << (ans < INF ? ans : -1) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 512
N = int(input())
S = list(input())
A_1 = ["Z","Y","X","W","V","U","T","S","R","Q","P","O","N","M","L","K","J","I","H","G","F","E","D","C","B","A"]
A_2 = {}
for i in range(len(S)):
    S[i] = A_1[A_1.index(S[i])-N]
print(''.join(S))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string res = "No";
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i * 4 + j * 7 == N) {
				res = "Yes";
			}
		}
	}
	cout << res << endl;
}

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

using namespace std;

int main() {
	string s;
	cin>>s;
	int a[26];
	for (int i = 0; i < 26; ++i)
	{
		a[i]=0;
	}
	char x;
	x='z';

	int n;
	n=s.size();

	for (int i = 0; i < n; ++i)
	{
		a[s[i]-'a']=1;
	}



	for (int i = 0; i < 26; ++i)
	{
		if (a[i]==0)
		{
          	putchar('a'+i);
			cout<<endl;
			exit(0);
		}
	}
	cout<<"None"<<endl;


	return 0;
}


Measured memory_bytes: 512
#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n; scanf("%d", &n);

	std::vector<int> cnt(n);
	for(int i = 1; i < n; i++) for(int j = i; j < n; j += i) cnt[i]++;

	printf("%lld\n", std::accumulate(begin(cnt), end(cnt), 0LL));
	return 0;
}


Measured memory_bytes: 7140