akhauriyash/Code-Regression huggingface dataset:
data = []
while True:
    in_line = raw_input().split()
    n = int(in_line[0])
    x = int(in_line[1])
    if n == 0 and x == 0:
        break
    data.append([n,x])
for n in data:
    count = 0
    for i in range(1,n[0]+1):
        for j in range(i+1,n[0]+1):
            for k in range(j+1,n[0]+1):
                if i+j+k == n[1]:
                    count += 1
    print count

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

map<ll,ll> prime(ll n){  
    map<ll,ll> mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    if(n!=1)mp[n]++;
    return mp;
}

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

    unordered_map<int, int> um;
    bool pp = true;
    rep(i,n){
        auto p = prime(a[i]);
        for(const auto& j : p){
            um[j.first]++;
            if(um[j.first] > 1){
                pp = false;
                break;
            }
        }
        if(!pp) break; 
    }

    if(pp){
        cout << "pairwise coprime\n";
        return 0; 
    }
    int ggg = a[0];
    rep(i,n) ggg = gcd(a[i], ggg);

    if(ggg == 1){
        cout << "setwise coprime\n";
    }else{
        cout << "not coprime\n";
    }
}

Measured memory_bytes: 7160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int sum = 0;
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			
			int start = Integer.parseInt(tmpArray[0]);
			int end = Integer.parseInt(tmpArray[1]);
			
			sum += end - start + 1;
		}
		
		System.out.println(sum);
	}

}


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

int main() {
  int N, A, B; cin >> N >> A >> B;
  string S; cin >> S;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'c') cout << "No" << endl;
    else if (S.at(i) == 'a') {
      if (cnt1 < A + B) {
        cout << "Yes" << endl;
        cnt1++;
      }
      else cout << "No" << endl;
    }
    else {
      if (cnt1 < A + B && cnt2 < B) {
        cout << "Yes" << endl;
        cnt1++; cnt2++;
      }
      else cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
#include<stdio.h>
#include<math.h>
int main()
{
    int N,Number[2001],div[1001],x=0,k=0,counter=0;
    scanf("%d",&N);
    for(int i=0;i<=N;i++)
    {
              if(i%2!=0)
              {
                        Number[x]=i;
                        x++;
              }

    }
    for(int i=0;i<x;i++)
    {
              for(int j=1;j<=N;j++)
              {
                if(Number[i]%j==0)
                {
                          k++;
                }
              }
              if(k>=8)
              {
                        counter++;
              }
              k=0;
    }
    printf("%d",counter);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <ctype.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)
#define me(x) memset(x,0,sizeof(x))
#define scan(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define STR(s) strlen(s)
#define FOR(i,sta,n) for(i=sta;i<n;i++)
#define FOR1(i,sta,n) for(i=sta;i<=n;i++)

typedef long long ll;
char s[110][110];

int main()
{
    int n,m,i,j;
    scan2(n,m);
    getchar();
    FOR(i,0,n)
        scanf("%s",s[i]);
    FOR1(i,-1,n)
    {
        FOR1(j,-1,m)
        {
            if(i==-1||i==n||j==-1||j==m)
                cout << "#";
            else
                cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n, a;
    long long int ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        ans += a;
    }

    cout << ans - n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n;
  cin>>n;
  ll ans;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(i)ans=__gcd(ans,a);
    else ans=a;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
from math import factorial as F
N, M = map(int,input().split())
MOD = 10**9+7
if N == M:
  print(F(N) * F(M) % MOD * 2 % MOD)
elif N + 1 == M or M + 1 == N:
  print(F(N) * F(M) % MOD)
else:
  print(0)



Measured memory_bytes: 5180
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
	int num;
	int64_t sum = 0; 
	int min = 99999999, max=-99999999;
	vector<int> takepon;
	cin >> num;
	for (int i = 0; i < num; i++) {
		int temp;
		cin >> temp;
		takepon.push_back(temp);
	}
	//合計
	for (int i = 0; i < num; i++) {
		sum += takepon[i];
	}
	//最小
	for (int i = 0; i < num; i++) {
		if (takepon[i] < min) {
			min = takepon[i];
		}
	}
	//最大
	for (int i = 0; i < num; i++) {
		if (takepon[i] > max) {
			max = takepon[i];
		}
	}
	cout << min << " " << max 
		<< " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3212
s=str(input())
if len(s)<6 :
    print("INVALID")
else:
    num=0
    ABC=0
    abc=0
    for i in range(len(s)) :
        if ord(s[i])>=48 and ord(s[i])<=57:
            num+=1
        if ord(s[i])>=97 and ord(s[i])<=122:
            ABC+=1
        if ord(s[i])>=65 and ord(s[i])<=90:
            abc+=1
    if num==0 or ABC==0 or abc==0:
        print("INVALID")
    else :
        print("VALID")


Measured memory_bytes: 5560
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-24 16:15:40
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=5010;
int n,a[N],A,b[N],B,ans;
char s[N],c[N];
int main()
{
	n=read();
	scanf("%s%s",s+1,c+1);
	if(s[1]=='1') a[A=1]=0;
	if(c[1]=='1') b[B=1]=0;
	fr(i,2,n) if(s[i]!=s[i-1]) a[++A]=i-1;
	fr(i,2,n) if(c[i]!=c[i-1]) b[++B]=i-1;
//	fr(i,1,A) printf("%d%c",a[i],i==A?'\n':' ');
//	fr(i,1,B) printf("%d%c",b[i],i==B?'\n':' ');
	ans=1<<29;
	fr(d,-n-1,n+1) if(!(d&1))
	{
		int x=1,y=1,Ans=0;
		if(d<0) x-=std::abs(d);
		else y-=std::abs(d);
		while(x<=n||y<=n)
		{
//			printf(" %d %d  %d\n",x,y,std::abs((x<=0?0:x>A?n:a[x])-(y<=0?0:y>B?n:b[y])));
			Ans+=std::abs((x<=0?0:x>A?n:a[x])-(y<=0?0:y>B?n:b[y])); x++; y++;
		}
//		printf("%d %d\n",d,Ans);
		ans=std::min(ans,Ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, m] <- getIntList
  print $ n * (n - 1) `div` 2 + m * (m - 1) `div` 2


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  vector<int> d(n);
  rep(i, n) d[i] = a[i] - b[i];
  sort(d.begin(), d.end());
  int ci = 0;
  ll qi = 0;
  rep(i, n) if (d[i] < 0) {
    ++ci;
    qi += -d[i];
  }
  int cd = 0;
  ll qd = 0;
  reverse(d.begin(), d.end());
  rep(i, n) {
    if (qd >= qi) break;
    qd += d[i];
    ++cd;
  }
  int ans = -1;
  if (qd >= qi) ans = ci + cd;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
ll dp[105][2][5];
double dist(vector<ll> v1,vector<ll> v2){
  double ans=0;
  rep(i,v1.size()){
    ans+=(v1[i]-v2[i])*(v1[i]-v2[i]);
  }
  ans = sqrt(ans);
  return ans;
}
int main(){
  ll n; cin >> n;
  ll d; cin >> d;
  vector<vector<ll>> vs;
  rep(i,n){
    vector<ll> v(d);
    rep(i,d){
      cin >> v[i];
    }
    vs.push_back(v);
  }
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;j++){
      double p = dist(vs[i],vs[j]);
      if(p==ceil(p)) ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long n, k;
    cin >> n >> k;
    long long temp = n / k;
    long long a = abs(n - temp * k);
    long long b = abs(n - (temp + 1) * k);
    if(a < b) cout << a;
    else cout << b;
    return 0;
}

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

const int INF = 1001001001;
vector<vector<int>> to(N_MAX);

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

  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }

  queue<int> q;
  vector<int> dist(N, INF);
  vector<int> pre(N, -1);
  dist.at(0) = 0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : to.at(v)){
      if(dist.at(u) != INF) continue;
      dist.at(u) = dist.at(v) + 1;
      pre.at(u) = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i, N){
    if(i == 0) continue;
    int ans = pre.at(i);
    ans++;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, K; cin >> N >> K;
	vector<ll> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];

	ll lo = 1, hi = 1e9;
	while (lo < hi) {
		ll mid = (lo + hi) / 2;
		ll cnt = 0;
		for (int i = 0; i < N; i++)
			cnt += (v[i] - 1) / mid;

		if (cnt <= K) hi = mid;
		else lo = mid + 1;
	}
	cout << hi << '\n';
	return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  vector<bool> pass(B, false);
  int num = 0;
  while (true){
    int tar = (num * A) % B;
    if (tar == C){
      cout << "YES" << endl;
      exit(0);
    }
    
    if (pass.at(tar) == true){
      cout << "NO" << endl;
      exit(0);
    }
    
    pass.at(tar) = true;
    num++;
  }
}

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		//		new Main().solveC();
		new Main().solveC2();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			if (numN % 2 == 0) {
				System.out.println(numN);
			} else {
				System.out.println(numN * 2);
			}

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			int[] wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}
			Arrays.sort(wk);

			System.out.println(wk[wk.length - 1] - wk[0]);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getCry(int b, int currentI, int maxI, int[] wk) {
		if (currentI == maxI) {
			return 0;
		}

		return getCry(b, currentI + 1, maxI, wk) + Math.abs(wk[currentI] - (b + currentI + 1));
	}

	private void solveC2() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - (i + 1);
		}
		sc.close();
		Arrays.sort(A);
		int med = N % 2 == 0 ? N / 2 - 1 : N / 2;
		int b = A[med];
		long ans = 0;
		for (int a : A) {
			ans += Math.abs(a - b);
		}

		System.out.println(ans);
	}

	/**
	 * ⅰ)abs(xi-a)の総和(aとの距離の総和)を最小にするのは中央値で、
	 * ⅱ)(xi-a)^2の総和を最小にするのは平均値
	 */
	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int[] wk = new int[numN];
			for (int i = 0; i < numN; i++) {
				wk[i] = scanner.nextInt() - (i + 1);
			}
			Arrays.sort(wk);

			//			int b = 0;
			//			if (numN % 2 == 0) {
			//				b = wk[(numN / 2) - 1];
			//			} else {
			//				b = wk[numN / 2];
			//			}

			int med = numN % 2 == 0 ? numN / 2 - 1 : numN / 2;
			int b = wk[med];

			int res = 0;

			for (int a : wk) {
				res += Math.abs(a - b);
			}
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 87904
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max(a - k, 0LL) << " " << max(0LL, b - max(0LL, k - a)) << endl;
}

Measured memory_bytes: 3608
// Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int p_max = -1;
		int d_max = -1;
		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;

			if(d1+d2>d_max){
				p_max = p;
				d_max = d1+d2;
			}
		}

		cout << p_max << ' ' << d_max << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    int q;
    cin >> q;
    while (q--) {
        int c, a, n;
        cin >> c >> a >> n;

        int ans = 0;

        int cnt = min({ c,a,n });
        c -= cnt, a -= cnt, n -= cnt;
        ans += cnt;

        cnt = min(c / 2, a);
        c -= cnt * 2, a -= cnt;
        ans += cnt;

        ans += c / 3;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int ara[1000000];
int main()
{
    long long int n,h,i,k,x;

    cin>>n>>k;
    for(i=0; i<n; i++)
        cin>>ara[i];
    if(k>=n)
    {
        cout<<"0\n";
        return 0;
    }
    else if(k==0)
    {
        long long int  sum=0;
        for(i=0; i<n; i++)
        {
            sum+=ara[i];

        }
        cout<<sum<<endl;
    }
    else
    {
        sort(ara,ara+n);
        while(k--)
        {
            ara[n--]=0;
        }
        long int  sum=0;
        for(i=0; i<n; i++)
        {
            sum+=ara[i];

        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

const MOD: i64 = 1e+9 as i64 + 7;
const FACT_MAX: usize = 300000;
static mut FACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
static mut RFACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
fn init_fact() {
    unsafe {
        if FACTORIAL[0] == 0 {
            FACTORIAL[0] = 1;
            for i in 1..FACT_MAX + 1 {
                FACTORIAL[i] = (FACTORIAL[i - 1] * i as i64) % MOD;
            }
            RFACTORIAL[FACT_MAX] = inv_mod(FACTORIAL[FACT_MAX], MOD);
            for i in (0..FACT_MAX).rev() {
                RFACTORIAL[i] = RFACTORIAL[i + 1] * (i as i64 + 1) % MOD;
            }
        }
    }
}
#[allow(dead_code)]
fn fact(n: usize) -> i64 {
    init_fact();
    unsafe { FACTORIAL[n] }
}
#[allow(dead_code, unused_comparisons)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m || m < 0 {
        return 0;
    }
    init_fact();
    unsafe { FACTORIAL[n] * RFACTORIAL[m] % MOD * RFACTORIAL[n - m] % MOD }
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let k = read::<usize>();
    let mut ans = 0;
    for y in 0..n {
        let ds = ((n - 1 - y) * (n - y) / 2 + y * (y + 1) / 2) as i64;
        let v = ds * m as i64 % MOD * m as i64 % MOD * combi(n * m - 2, k - 2) % MOD;
        ans = (ans + v) % MOD;
    }
    for x in 0..m {
        let ds = ((m - 1 - x) * (m - x) / 2 + x * (x + 1) / 2) as i64;
        let v = ds * n as i64 % MOD * n as i64 % MOD * combi(n * m - 2, k - 2) % MOD;
        ans = (ans + v) % MOD;
    }
    ans = (ans * inv_mod(2, MOD)) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 8956
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    long long a[100][100],b[100][100],c[100][100];
    cin>>n>>m>>l;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)cin>>a[i][j];
    for(int i=0;i<m;i++)
        for(int j=0;j<l;j++)cin>>b[i][j];
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]=0;
            for(int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j)cout<<" ";
            cout<<c[i][j];
        }
        cout<<endl;
    }
    return 0;    
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    vec<vec<ll>> dp(N + 1, vec<ll>(3));
    dp[1][0] = a[0];
    dp[1][1] = b[0];
    dp[1][2] = c[0];

    for (int i = 1; i < N; ++i)
        rep(j, 3) {
            if (j != 0) dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + a[i]);
            if (j != 1) dp[i + 1][1] = max(dp[i + 1][1], dp[i][j] + b[i]);
            if (j != 2) dp[i + 1][2] = max(dp[i + 1][2], dp[i][j] + c[i]);
        }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
}


Measured memory_bytes: 11152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};


int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;

    vector<int> quotients(1, 0);
    for(int i=1;i<=min(n, ll(sqrt(n))+1);++i) {
        quotients.push_back(n/i);
        quotients.push_back(n/(n/i));
    }
    sort(quotients.begin(), quotients.end());
    quotients.erase(unique(quotients.begin(), quotients.end()), quotients.end());
    int m = quotients.size();

    vector<int> inv_quotients_idx(m, -1);
    {   
        int j = m-1;
        for(int i=1;i<m;++i) {
            while(i <= j && quotients[i]*quotients[j] > n) --j;
            if(i > j) break;
            inv_quotients_idx[i] = j;
            inv_quotients_idx[j] = i;
        }
    }
    
    vector<vector<ll>> dp(k+1, vector<ll>(m, 0));
    for(int j=1;j<m;++j) dp[0][j] = quotients[j];
    for(int i=1;i<k;++i) {
        for(int j=1;j<m;++j) {
            dp[i][j] = (dp[i-1][inv_quotients_idx[j]] * (quotients[j] - quotients[j-1])) % MOD;
        }

        for(int j=1;j<m;++j) {
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[k-1][m-1] << endl;
    
}

Measured memory_bytes: 51452
#include<stdio.h>
int main(void){
    int a, b, i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a, &op, &b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else if(op=='?'){
            break;
        }

    }
    return 0;
}



Measured memory_bytes: 2104
// AOJ 2026: Divisor is the Conqueror
// 2017.11.03 bal4u@uu

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

int c[15];
int ans[54];
char f[14][365];		// 364=(13+1)*13/2*4

int rec(int j, int k)
{
	int i;
	if (j < 0) return 0;
	for (i = 1; i <= 13; i++) {
		if (!c[i]) continue;
		if (f[i][k-i]) {
			c[i]--, ans[j] = i;
			if (!rec(j-1, k-i)) return 0;
			c[i]++;
		}
	}
	return 1;
}

int main()
{
	int n, i, v, s;

	memset(f[1], 1, sizeof(f[1]));
	for (i = 2; i <= 13; i++) {
		f[i][0] = 1;
		for (v = i; v < 365; v += i) f[i][v] = 1;
	}

	while (scanf("%d", &n) && n > 0) {
		memset(c, 0, sizeof(c));
		for (s = 0, i = 0; i < n; i++) {
			scanf("%d", &v);
			s += v, c[v]++;
		}
		memset(ans, 0, sizeof(ans));
		if (rec(n-1, s)) puts("No");
		else {
			printf("%d", ans[0]);
			for (i = 1; i < n; i++) printf(" %d", ans[i]);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> > v;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[n+1],b[m+1];
    for(int i=0; i<n; i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        v.push_back(make_pair(a[i],b[i]));
    }
    sort(v.begin(),v.end());
    for(int i=0; i<n; i++)
    {
        if(v[i].second<=m)
        {
            cout<<v[i].first<<endl;
            return 0;
        }
    }
    cout<<"TLE\n";

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int N, K;
	cin >> N >> K;

	vector<int> V(N);

	for(auto &i : V) cin >> i;

	vector<int> P = V;

	map<int,int> M;

	for(int i = 1; i < N; i++){
		if(V[i] - P[i-1] > 0)
			M[-(V[i] - P[i-1])]++;
		P[i] = min(P[i-1],V[i]);
	}

	for(auto x : M){
		cout << x.s << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 8672
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] t = new long[n];
        for(int i = 0; i<n; i++) {
            t[i] = sc.nextLong();
        }
        if(n==1) {
            System.out.println(t[0]);
            return;
        }
        long min = t[0]/gcd(t[0],t[1])*t[1];
        //System.err.println(gcd(t[0],t[1]));
        for(int i = 2; i<n; i++) {
            min = min/gcd(t[i],min)*t[i];
        }
        System.out.println(min);


    }
    public static long gcd(long a, long b) {
        if(a<b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        long r = a%b;
        while(r!=0) {
            a = b;
            b = r;
            r = a%b;
        }
        return b;
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e6 + 10;
int dp1[MAX_N], dp2[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string in;
    cin >> in;
    for(int i = 0; i < in.size(); i ++) {
        if(in[i] == 'P') {
            cout << 'P';
        } else {
            cout << 'D';
        }
    }
    return 0;
}




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

int main()
{
    int D,G;
    cin >> D >> G;
    int p[D],c[D];
    for(int i = 0;i<D;i++){
        cin >> p[i];
        cin >> c[i];
    }
    int mincount = 100000;
    for(int bit=0;bit<(1<<D);++bit){
        int score = 0,count = 0;
        for(int i = 0;i<D;++i){
            if(bit & 1<<i){
                score += (p[i]*(i+1)*100+c[i]);
                count += p[i];
            }
        }
        int next = -1;
        for(int j = D-1;j >= 0;--j){
            if(!(bit & 1<<j)){
                next = j;
                break;
            }
        }
        if(next!=-1){
            int restscore = max(G-score,0);
            int rest = (restscore + (next+1)*100-1)/((next+1)*100);
            if (rest > p[next]){
                continue;
            }
            count += rest;
        }
        mincount = min(mincount,count);
    }
	cout << mincount << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string maze_num(List<List<string>> maze,int h,int w,int i,int j){
        int count = 0;
        if (0<j)
        {
          if (maze[i][j-1]=="#")
          {
            count+=1;
          }
          if (i<h-1 && maze[i+1][j-1]=="#")
          {
            count+=1;
          }
          

          if (0<i && maze[i-1][j-1]=="#")
          {
            count+=1;
          }         
        }
        if (j<w-1)
        {
          if (maze[i][j+1]=="#")
          {
            count+=1;
          }
          if (i<h-1 && maze[i+1][j+1]=="#")
          {
            count+=1;
          }
          if (0<i && maze[i-1][j+1]=="#")
          {
            count+=1;
          }     
        }
        if (0<i && maze[i-1][j]=="#")
        {
          count+=1;
        }
        if (i<h-1 && maze[i+1][j]=="#")
        {
          count+=1;
        }
        return count.ToString();
      }
      
      string[] input = Console.ReadLine().Split();
      int h = int.Parse(input[0]);
      int w = int.Parse(input[1]);
      List<List<string>> maze = new List<List<string>>();
      
      for (int i=0;i<h;i++)
      {
        maze.Add(Console.ReadLine().ToCharArray().ToList().ConvertAll(x=>x.ToString()));
      }
      
      
      for (int i=0;i<h;i++){
        //Console.WriteLine(string.Join(" ", maze[i]));
        for (int j=0;j<w;j++){
          //Console.WriteLine(i+","+j);
          //Console.WriteLine(maze[i][j]);
          if (maze[i][j]==".")
          {
          	maze[i][j]=maze_num(maze,h,w,i,j);
            //Console.WriteLine(maze_num(maze,h,w,i,j));
          }
        }
      }
      for (int i=0;i<h;i++)
      {
        Console.WriteLine(string.Join("", maze[i]));
      }
      
    }
}


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

int main(){
	int d;
	cin >> d;
	if(d == 25)cout << "Christmas" << endl;
	if(d == 24)cout << "Christmas Eve" << endl;
	if(d == 23)cout << "Christmas Eve Eve" << endl;
	if(d == 22)cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
HashMap<Integer,Integer> m=new HashMap<>();
    for (int i = 1; i <= 10; i++) {
        m.put(i, 0);
    }
    for (int i = 0; i < 3; i++) {
        int n=Integer.parseInt(sc.next());
        int c=m.get(n);
        c++;
        m.put(n,c);
    }
    if(m.get(5)==2&&m.get(7)==1){
        out.println("YES");
    }else{
        out.println("NO");
    }
}}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  ll l = 4*a*b;
  ll rq = c-a-b;
  if (rq < 0) {
    cout<<"No"<<endl;
    return 0;
  }
  ll r = rq*rq;
  if(l<r) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
A= list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
N = int(input())
D = [int(input()) for j in range(N)]
a = D.count(A[0])
b = D.count(A[1])
c = D.count(A[2])
d = D.count(B[0])
e = D.count(B[1])
f = D.count(B[2])
g = D.count(C[0])
h = D.count(C[1])
i = D.count(C[2])
Sum1 = (a + b + c +1) % 4
Sum2 = (d + e + f + 1) % 4
Sum3 = (g + h + i +1) % 4
Sum4 = (a + e + i +1) % 4
Sum5 = (c + e + g +1) % 4
Sum6 = (a + d + g +1) % 4
Sum7 = (b + e + h +1) % 4
Sum8 = (c + f + i +1) % 4
list = [Sum1,Sum2,Sum3,Sum4,Sum5,Sum6,Sum7,Sum8]
s = list.count(0)
if s >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<char>v(26,0),foo;

int main() {
	int n;
	cin >> n;
	if (n == 3) {
		printf("2 5 63\n");
		return 0;
	}
	if (n > 15000) {
		n -= 4998;
		REP(i, 0, 4998) {
			cout << i * 6 + 15 << " ";
		}
	}
	if (n % 3 == 0) {
		cout << "3 6 9 ";
		n -= 3;
	}
	else if (n % 3 == 1) {
		cout << "2 3 4 9 ";
		n -= 4;
	}
	else {
		cout << "2 3 4 6 9 ";
		n -= 5;
	}
	REP(i, 0, n / 3) {
		cout << i * 6 + 8 << " " << i * 6 + 10 << " " << i * 6 + 12 << " ";
	}
	cout << endl;
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> H(N);

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

    if(N == 1){
        cout << "Yes" << endl;
    }else{
        bool flag = true;
        for(int i = N - 1; i > 0; i--){
            int count = 0;
            while(H[i - 1] > H[i]){
                H[i - 1]--;
                count++;
                if(count >= 2){
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }   
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastio;
    int n;
    cin >> n;
    if ((n / 10 == 9) || (n % 10 == 9))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    int a[6];
    for(i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i+1;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

def func():
    N = int(input())

    A = list(map(int, input().split()))
    P = [[(A[0], 0), (0, 0)] for i in range(2 ** (N + 1))]

    for i in range(1, 2 ** N):
        if (A[i], i) > P[i][0]:
            P[i][1] = P[i][0]
            P[i][0] = (A[i], i)
        elif (A[i], i) > P[i][1]:
            P[i][1] = (A[i], i)
        for j in range(N):
            if (i & (1 << j)) == 0:
                index = i + (1 << j)
                for k in range(2):
                    if P[i][k] > P[index][0]:
                        P[index][1] = P[index][0]
                        P[index][0] = P[i][k]
                    elif P[i][k] > P[index][1] and P[i][k] != P[index][0]:
                        P[index][1] = P[i][k]
    ans = 0
    for i in range(1, 2 ** N):
        ans = max(ans, P[i][0][0] + P[i][1][0])
        print(ans)
    #print(P)

func()

Measured memory_bytes: 132300
n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    a,b = list(map(int,input().split()))
    link[a-1].append(b-1)
    link[b-1].append(a-1)

from collections import deque
Q = deque()
Q.append([0,0])

visited=[-1]*n
visited[0]=1

while Q:
    now,cnt = Q.popleft()
    for nxt in link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=now+1
        Q.append([nxt,cnt+1])

print("Yes")
for a in visited[1:]:
    print(a)

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

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


Measured memory_bytes: 256
// AOJ 1243 Weather Forecast
// 2018/1/21

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

int n;
int date[367];
int cd[4];
char mk[367][10][8][8][8][8];
int pos[12] = {0,1,2,3,0,4,5,6,0,7,8,9};
int mv[9][2] = {{0,0},{0,1},{0,-1},{1,0},{-1,0},{0,2},{0,-2},{2,0},{-2,0}};

char check(int k, int x, int y, int *cd)
{
	int a = ((x - 1) << 2) + y;
	if ((date[k] & (1<< a  ))  || (date[k] & (1<<(a+4))) ||
		(date[k] & (1<<(a+1))) || (date[k] & (1<<(a+5)))) return 0;
	if (mk[k][pos[a]][cd[0]][cd[1]][cd[2]][cd[3]]) return 0;
    return 1;
}

int dfs(int k, int x, int y, int *cd)
{
	int i, j, m, x2, y2;
	int a[5];

	if (k == n) return 1;
	m = 9; if (!k++) m = 1;
	for (i = 0; i < m; i++) {
		x2 = x + mv[i][0], y2 = y + mv[i][1];
		if (x2 < 1 || x2 > 3 || y2 < 1 || y2 > 3) continue;
		for (j = 0; j < 4; j++) a[j] = cd[j] + 1;
		if (x2 == 1) {
			if      (y2 == 1) a[0] = 0;
			else if (y2 == 3) a[1] = 0;
		} else if (x2 == 3) {
			if      (y2 == 1) a[2] = 0;
			else if (y2 == 3) a[3] = 0;
		}
		if (a[0] >= 7 || a[1] >= 7 || a[2] >= 7 || a[3] >= 7) continue;

		if (check(k, x2, y2, a)) {
			mk[k][pos[((x2-1)<<2)+y2]][a[0]][a[1]][a[2]][a[3]] = 1;
			if (dfs(k, x2, y2, a)) return 1;
		}
	}
	return 0;
}

int main ()
{
	int i, j;
	char buf[40], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);

		memset(date, 0, sizeof(date));
		for (i = 1; i <= n; i++) {
			fgets(p=buf, 40, stdin);
			for (j = 1; j <= 16; j++) {
				while (*p < '0') p++;
				date[i] |= (*p++ & 0xf) << j;
//				p += 2;
			}
		}

		memset(mk, 0, sizeof(mk));
		memset(cd, 0, sizeof(cd));
		putchar('0' + dfs(0, 2, 2, cd));
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb emplace_back
#define pii pair<int,int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
const int N = 1e6 + 10;
char s[N];
int n;
ll f[N], g[N], mod, mod1;
ll f1(ll x)
{
    ll ans = 0;
    while(x) {
        if(x&1) ans++;
        x = x / 2;
    }
    return ans;
}
void run(ll x)
{
    ll ans = 1;

    while(x)
    {
        ll mod = f1(x);
        //printf("mod:%lld\n", mod);
        x = x % mod;
        ans++;
    }
    printf("%lld\n", ans);

}
int main()
{
    //run(10);
    n = read();
    scanf("%s", s + 1);
    ll sum = 0;
    for(int i = 1; i <= n; ++i) sum += s[i] - '0';
    mod = sum + 1;
    mod1 = sum - 1;
    f[0] = g[0] = 1;
    if(mod1 == -1){
        for(int i = 1; i <= n; ++i) puts("1");
        return 0;
    }
    if(mod1 == 0){
        if(s[n] == '0'){
            for(int i = 1; i < n; ++i) {
                if(s[i]=='0') puts("1");
                else puts("0");
            }
            puts("2");
        }
        else{
            for(int i = 1; i < n; ++i)puts("2");
            puts("0");
        }
        return  0;
        //for(int i = 1; i <= n; ++i) f[i] = f[i-1] * 2 % mod;

    }


    for(int i = 1; i <= n; ++i) f[i] = f[i-1] * 2 % mod;
    for(int i = 1; i <= n; ++i) g[i] = g[i-1] * 2 % mod1;

    ll res = 0, res1 = 0;
    for(int i = 1; i <= n; ++i) if(s[i] == '1'){
        res = (res + f[n - i]) % mod;
        //printf("i:%d %lld\n", i, res);
        res1 = (res1 + g[n - i]) % mod1;
    }

    //printf("res:%lld res1:%lld\n", res, res1);

    for(int i = 1; i <= n; ++i){
        ll ans;
        if(s[i] == '1'){
            if(mod1 == 0){puts("0");continue;}

            ans = ((res1 - g[n - i]) % mod1 + mod1) % mod1;
            run(ans);
        }
        else{
            if(mod == 0){puts("0");continue;}
            ans = (res + f[n - i]) % mod;
            run(ans);
        }
    }
}


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,nn,ans,tmp,hoge,fuga,piyo;
ll w[60],x[60],y[60],z[60];
string s,str;
int main(){
  ll max=0;
  cin>>a>>b>>n;
  if(n>=b){
    max=b-1;
  }else{
    max=n%b;
  }
  ans=(max*a)/b;
  cout<<ans;
  return 0;
}

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


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> num_like(M);
  for(int ii=0; ii<N; ii++){
    int k;
    cin >> k;
    for(int jj=0; jj<k; jj++){
      int like_No;
      cin >> like_No;
      like_No--;
      num_like[like_No]++;
    }
  }
  cout << count(num_like.begin(), num_like.end(), N) << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; i++)cin >> D[i];

	vector<int> s(25,0);
	s[0] = 1;
	sort(D.begin(), D.end());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			s[D[i]] += 1;
		}
		else {
			s[24 - D[i]] += 1;
		}
	}
	int ans = INF;
	for (int i = 0,cnt = 0,flag = 0; i < 25; i++) {
		//cout << s[i] << " ";
		if (s[i] > 1)ans = 0;
		if (!s[i]) {
			cnt++;
			flag = 1;
		}
		else {
			if (flag) {
				ans = min(ans, cnt+1);
			}
			cnt = 0;
		}
		if (i != 24 && s[i] == 1 && s[i + 1] == 1)ans = min(ans, 1);
	}
	//cout << endl;
	cout << ans << endl;
}

Measured memory_bytes: 3632
N,M=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(M)]



if N>=2:
    for i in range(10**(N-1),10**N):
        letter=str(i)
        for j in range(M):
            if letter[S[j][0]-1]!=str(S[j][1]):
                break
        else:
            print(i)
            break
    else:
        print('-1')
else:
    for k in range(0,10):
        letter=str(k)
        for l in range(M):
            if letter[S[l][0]-1]!=str(S[l][1]):
                break
        else:
            print(k)
            break
    else:
        print('-1')

Measured memory_bytes: 3188
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 1010000
ll MOD=1e9+7;
vector<vec> G;
int g[1010][1010];
vec visited;
vec ans;
bool dfs(int x,int s,int t){
    if(x==s&&t)return 1;
    if(visited[x]){
        return 0;
    }
    visited[x]=1;
    for(auto e:G[x]){
        if(dfs(e,s,1)){
            ans.pb(x);
            return 1;
        }
    }
    return 0;
}
int main(){
    int n=in(),m=in();
    G.resize(n+1);
    rep(i,m){
        int a=in(),b=in();
        G[a].pb(b);
        g[a][b]=1;
    }
    visited.resize(n+1);
    rep2(i,1,n){
        visited=vec(n+1);
        if(ans.size()==0)dfs(i,i,0);
    }
    if(ans.size()==0){
        cout<<-1;return 0;
    }
    reverse(all(ans));
    vec nomore(n+1);
    while(1){
        if(nomore[ans[0]])break;
        nomore[ans[0]]=1;
        bool flag=false;
        rep3(i,ans.size()-1,2){
            if(g[ans[0]][ans[i]]){
                vec ne;
                rep2(j,i,ans.size()-1)ne.pb(ans[j]);
                ne.pb(ans[0]);
                flag=true;
                ans=ne;break;
            }
        }
        if(!flag){
            vec ne;
            rep2(i,1,ans.size()-1)ne.pb(ans[i]);
            ne.pb(ans[0]);
            ans=ne;
        }
    }
    cout<<ans.size()<<endl;
    for(auto e:ans)cout<<e<<endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int ans = 0;
    while(b <= a){
        b*=2;
        ans++;
    }
    while(c <= b){
        c*=2;
        ans++;
    }

    if (ans <= k) cout << "Yes";
    else cout << "No";

}



Measured memory_bytes: 3620
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	s := make(map[string]bool)
	sum := 0
	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")

		if inputs[0] == "0" {
			if !s[inputs[1]] {
				s[inputs[1]] = true
				sum++
			}
			fmt.Printf("%d\n", sum)
		} else if inputs[0] == "1" {
			if s[inputs[1]] {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		}
	}
}


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

int main() {
	int			n;
	vector<int> A;

	cin >> n;
	rep(i, n)
	{
		int	x;
		cin >> x;
		A.push_back(x);
	}
	rep(i, n)
	{
		if (i)
			cout << ' ';
		cout << A.at(i);
	}
	cout << endl;
	for (int i = 1; i < n; i++)
	{
		int	j;
		int	v;

		v = A.at(i);
		j = i - 1;
		while (j >= 0 && A.at(j) > v)
		{
			A.at(j + 1) = A.at(j);
			j--;
		}
		A.at(j + 1) = v;
		rep(i, n)
		{
			if (i)
				cout << ' ';
			cout << A.at(i);
		}
		cout << endl;
	}
}



Measured memory_bytes: 3176