akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;
const int MOD = 1e9+7;
// const int MOD = 998244353;
const int MAX = 1000010;
int fac[MAX],finv[MAX],inv[MAX];

//テーブル作成
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

//nCkを求める
int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//ModInt
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
  
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
  
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<MOD>;

signed main(){
    int n; cin >> n;
    vector<int> c(n);
    REP(i,n) cin >> c[i];
    sort(rall(c));
    mint res = 0;
    REP(i,n) res += (mint)c[i] * (mint)(i+2);
  	mint wow = 4;
    res *= pow(wow,n-1);
    cout << res << endl;
}

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

typedef long long ll;
int w=0,p=0,y=0,g=0;
int main()
{
   int n;
   cin>>n;
    char s[111];
    for(int i=0;i<n;i++)
        cin>>s[i];
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W') w++;
       else if(s[i]=='P') p++;
          else if(s[i]=='Y') y++;
        else g++;
    }
    if(w==0 || p==0||y==0||g==0) cout<<"Three\n";
    else cout<<"Four\n";


    return 0;
}


Measured memory_bytes: 256
/*
                                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
     
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
     
    #include <bits/stdc++.h>
     
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
     
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {
            if(n % 2 ==1)
                result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
        return result % M;
    }
    signed main()
    {   jaldi
    	int n,m;
    	cin>>n>>m;
   		if(n>m)
        {	for(int i=0;i<n;i++)
          	cout<<m;
        }
     	else
        {	for(int i=0;i<m;i++)
          	cout<<n;
        }
     	return 0;
    }

Measured memory_bytes: 256
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define mul min
#define add max
#define n(x) (2-(x))

int _p,_q,_r;

int parse(char *p){
  switch(*p){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case 'P': return _p;
    case 'Q': return _q;
    case 'R': return _r;
    case '-': return n(parse(p+1));
    case '(': {
                int x=0;
                p++;
                char *q=p;
                for(;;p++){
                  if(*p=='(')x++;
                  if(*p==')')x--;
                  if(x==0&&*p!='-')break;
                }
                p++;
                switch(*p){
                  case '*': return mul(parse(q),parse(p+1));
                  case '+': return add(parse(q),parse(p+1));
                }
              }
  }
}

int main(){
  char p[81];
  int s;
  while(1){
    s=0;
    scanf("%s",p);
    if(*p=='.')return 0;
    for(_p=0;_p<3;_p++)
      for(_q=0;_q<3;_q++)
        for(_r=0;_r<3;_r++)
        if(parse(p)==2)s++;
    printf("%d\n",s);
  }
}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int d[50];

int main()
{
	int N;
	int ans = 0;

	cin >> N;
	rep(i, N) cin >> d[i];

	rep1(i, 0, N - 2) {
		rep1(j, i + 1, N - 1) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

    while(true){
        int n, m; cin >> n >> m;
        if(n == 0 and m == 0) break;

        UnionFind uf(n);
        rep(i, m){
            int a, b; cin >> a >> b; a--, b--;
            uf.unionSet(a, b);
        }

        int num = 0;
        rep(i, n){
            if(uf.root(i) == i){
                num++;
            }
        }

        ll res = 1LL;
        rep(i, num){
            res = MUL(res, 2LL, mod);
        }
        if(num < n){
            res = ADD(res, 1LL, mod);
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3504
#B - Collatz Problem(ABC116)
s=int(input())
A=[]
A.append(s)
c=0
while len(set(A))==len(A):
    if A[c]%2==0:
        A.append(A[c]/2)
    else:
        A.append(3*A[c]+1)
    c+=1
print(c+1)  

Measured memory_bytes: 3060
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
itra = list(itr.accumulate(a))
ans_c = itra.count(0)
dev = {}
for i in itra:
    if i in dev:
        dev[i] += 1
    else:
        dev[i] = 1
for i in dev:
    ans_c += dev[i] * (dev[i] - 1) // 2
print(ans_c)

Measured memory_bytes: 41360
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n, k, mn=1e9, a[100005];
int main() {
	int i;
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	for(i=k-1; i<n; i++) {
		mn = min(mn, a[i] - a[i-k+1] + min((int)abs(a[i]), (int)abs(a[i-k+1])));
	}
	printf("%d", mn);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

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

using namespace std;
using ll = long long;

int main()
{
	string s; cin >> s;
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	int len = s.size();
	int c = 0;
	for (int i = 1; i < len; ++i) {
		if (i < len - 1 && i > 1) {
			if (s[i] == 'C')
				c++;
			if (c >= 2) {
				cout << "WA" << endl;
				return 0;
			}
			continue;
		}
		if (s[i] >= 'a' && s[i] <= 'z')
			continue;

		cout << "WA" << endl;
		return 0;
	}
	if (c == 0) {
		cout << "WA" << endl;
		return 0;
	}
	cout << "AC" << endl;
}



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

int main() {
    string s;
    cin >> s;
    int len = s.size();
    vector<bool> is_used(26);
    for (int i = 0; i < len; i++) {
        is_used.at(s.at(i) - 'a') = true;
    }

    for (int i = 0; i < 26; i++) {
        if (!is_used.at(i)) {
            cout << s + (char)('a' + i) << endl;
            return 0;
        }
    }
    
    vector<int> index(26, -1);
    for (int i = len - 1; i >= 0; i--) {
        for (int j = s.at(i) - 'a'; j <= 25; j++) {
            if (i < index.at(j)) {
                s.at(i) = 'a' + j;
                for (int k = 0; k <= i; k++) {
                    cout << s.at(k);
                }
                cout << endl;
                return 0;
            }
        }
        index.at(s.at(i) - 'a') = i;
    }
    
    cout << -1 << endl;
}

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

int n, k, a[5002], b[5002], dp[5002][5002];

int pre(int i){
    if(i==n) return true;
    if(a[i]>=k) return true; 
    int ii=0;
    for(int j=0; j<n; j++){
        if(i==j) continue;
        b[ii++] = a[j];
    }
    memset(dp, 0, sizeof(dp));
    for(int pos=n-1; pos>=0; pos--){
        for(int sum=0; sum<=k; sum++){
            if(pos==(n-1)){
                dp[pos][sum] = (sum==0)?1:0;
            }
            else{
                dp[pos][sum] = dp[pos+1][sum];
                if(sum-b[pos]>=0){
                    dp[pos][sum] = max(dp[pos+1][sum], dp[pos+1][sum-b[pos]]);
                }
            }
        }
    }
    for(int sum=k-a[i]; sum<k; sum++){
        if(dp[0][sum]){
            return true;
        }
    }
    return false;
}

int main(){
    while(scanf("%d %d", &n, &k)!=EOF){
        for(int i=0; i<n; i++){
            scanf("%d", &a[i]);
        }
        sort(a, a+n);
        /*
        int hi=-1;
        while(a[hi+1]<k){
            hi++;
        }
        */
        int lo=0, hi=n;
        while(lo<hi){
            int mid=lo+(hi-lo)/2;
            if(pre(mid)){
                hi=mid;
            }
            else{
                lo=mid+1;
            }
        }
        printf("%d\n", lo);
    }
    return 0;
}

Measured memory_bytes: 98176
using System;

class ABC160B{
  static void Main(){
    int X = int.Parse(Console.ReadLine());
    int hund = X / 500;
    int down = hund * 500;
    int luck = hund * 1000;
    int yend = X - down;
    int yen = yend / 5;
    int yenl = yen * 5;
    int output = luck + yenl;
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    sort(a.begin(), a.end(), greater<int>());
    int result = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) result += a[i];
        else result -= a[i];
    }
    cout << result << endl;
}

Measured memory_bytes: 3604
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2<<'\n';
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    int64_t sgn = 1;
    bool zero = false; //zeroが存在するか
    for ( int64_t i = 0; i < N; ++i){
        cin >> A[i];
        if ( A[i] ==0 ) zero = true;
        else if ( A[i] < 0 ) sgn *= -1;
    }
    
    int64_t res = 0;
    if ( zero or sgn == 1){
        for ( int64_t i = 0; i < N; ++i){
            res = res + abs(A[i]);
        }
    } else {
        for ( int64_t i = 0; i < N; ++i){
            A[i] = abs(A[i]);
        }
        sort(A.begin(),A.end());
        for ( int64_t i = 0; i < N; ++i){
            if ( i == 0 ) res = res - A[i];
            else res = res + A[i];
        }
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 4044
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		System.out.println(3*a*a);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();		
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

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

    map<char,int> mp;
    for(int i=0; i<s.size(); i++){
        char c = s.at(i);
        mp[c]++;
    }

    bool check = true;
    for(int i=0; i<s.size(); i++){
        char c = s.at(i);
        if(mp[c] != 2){
            check = false;
            break;
        }
    }

    string ans = check ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long n; cin >> n; 
    long cnt = 0;
    for(long i=1;i<1000000;i++){
        if(i >= n)break;
        for(long j=1;j<1000000;j++){
            if(i*j < n)cnt++;
            else break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3596
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int A;
    int B;
    int C;
    int N;
    
    cin >> N;
    cin >> A;
    cin >> B;

    if(B > A * N) cout << A * N << endl;
    else cout << B << endl;;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int R = 100000+10;
int bit[R], npri[R];

int main(){
npri[0]=npri[1]=1;
for(int i=2;i<R;++i) if(npri[i]==0) for(long long j=(long long)i*i; j<R; j+=i) npri[j]=1;

for(int i=1;i<R;i+=2) bit[i] = (npri[i]==0)&&(npri[(i+1)/2]==0);
for(int i=1;i<R;++i) bit[i]+=bit[i-1];

int q, le, ri;
cin>>q;
for(int _c=0; _c<q; _c++){
cin>>le>>ri;
cout<<bit[ri]-bit[le-1]<<endl;
}


return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n), b(n, 0);
  rep(i, n){
    cin >> a[i];
  }
  bool ans = true;
  int count = 0;
  int k;
  n % 2 == 0 ? k = n / 2 + 1 : k = (n + 1) / 2;
  for(int i = n; i >= k; i--){
    b[i-1] = a[i-1];
    count += b[i-1];
  }
  for(int i = k-1; i >= 1; i--){
    for(int j = 2; j * i <= n; j++){
      a[i-1] = a[i-1] ^ b[j * i - 1];
    }
    b[i-1] = a[i-1];
    count += b[i-1];
  }

  out(count);
  int c=0;
  rep(i, n){
    if(b[i]) cout << i+1 << " ";
    c++;
  }
  if(c) cout << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  map<int,int>se;
  rep(i,n)
  {
    int a;cin>>a;
    se[min(8,a/400)]++;

  }
  if(se.count(8))
  {
    cout<<max(1,(int)se.size()-1)<<" "<<max(0,(int)se.size()-1)+se[8]<<endl;
  }
  else
  {
    cout<<se.size()<<" "<<se.size()<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream fin("../data.txt");

int n, x, a1, a2, eat;
long long ans;

int main() {

  cin >> n >> x >> a1;
  n--;
  while (n--) {
    cin >> a2;
    if (a1 + a2 > x) {
      eat = a1 + a2 - x;
      ans += eat;
      if (eat > a2) {
        a2 = 0;
      } else {
        a2 -= eat;
      }
    }
    a1 = a2;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3648
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if (y,x) in d:
            d[(y,x)]+=1
        else:
            d[(y,x)]=1
        if y+1<=h and (y+1,x) in d:
            d[(y+1,x)]+=1
        elif y+1<=h:
            d[(y+1,x)]=1
        if y+2<=h and (y+2,x) in d:
            d[(y+2,x)]+=1
        elif y+2<=h:
            d[(y+2,x)]=1
 
        if x+1<=w and (y,x+1) in d:
            d[(y,x+1)]+=1
        elif x+1<=w:
            d[(y,x+1)]=1
        if x+2<=w and (y,x+2) in d:
            d[(y,x+2)]+=1
        elif x+2<=w:
            d[(y,x+2)]=1
        if x+1<=w and y+1<=h and (y+1,x+1) in d:
            d[(y+1,x+1)]+=1
        elif x+1<=w and y+1<=h:
            d[(y+1,x+1)]=1
        if x+2<=w and y+1<=h and (y+1,x+2) in d:
            d[(y+1,x+2)]+=1
        elif x+2<=w and y+1<=h:
            d[(y+1,x+2)]=1
        if x+1<=w and y+2<=h and (y+2,x+1) in d:
            d[(y+2,x+1)]+=1
        elif x+1<=w and y+2<=h:
            d[(y+2,x+1)]=1
        if x+2<=w and y+2<=h and (y+2,x+2) in d:
            d[(y+2,x+2)]+=1
        elif x+2<=w and y+2<=h:
            d[(y+2,x+2)]=1
    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1
 
    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)
        
if __name__=="__main__":
    sol()

Measured memory_bytes: 163288
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
s = ns()

rr = 0
gg = 0
bb = 0
for c in s:
    if c == "R":
        rr += 1
    if c == "G":
        gg += 1
    if c == "B":
        bb += 1
ans = rr*gg*bb
for i in range(n):
    for j in range(i+1, n):
        if s[i] != s[j] and 2*j-i < n and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
            ans -= 1
print(ans)



Measured memory_bytes: 68292
N, K, D = map(int, input().split())
S = [True if x == 'o' else False for x in input()]

l_lst, r_lst = [], []
i = 1
for _ in range(K):
    while not S[i - 1]:
        i += 1
    l_lst.append(i)
    i += D + 1

i = N
for _ in range(K):
    while not S[i - 1]:
        i -= 1
    r_lst.append(i)
    i -= D + 1
r_lst.reverse()

for i in range(K):
    ans = l_lst[i]
    if ans == r_lst[i]:
        print(ans)


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

using namespace std;
vector<vector<int>> memo(3007, vector<int>(3007, -1));
int lcs(string &s, string &t, int m, int n ) 
{
	if (m < 0 || n < 0) 
		return 0;
	if (memo[m+1][n+1] != -1)
		return memo[m+1][n+1];
	if (s[m] == t[n]) 
		return memo[m+1][n+1] = 1 + lcs(s, t, m-1, n-1); 
	else
		return memo[m+1][n+1] = max(lcs(s, t, m, n-1), lcs(s, t, m-1, n)); 
} 


int main()
{
	#ifdef ME
		freopen("input.txt", "r", stdin);
	#endif

	string 	s ,t;
	cin >> s >> t;

	int m = s.length()-1; 
	int n = t.length()-1; 

	int l = lcs(s, t, m, n);

	string ans = "";
	while (m >= 0 && n >= 0)
	{
		if (s[m] == t[n])
		{
			ans += s[m];
			m--; n--;
		}
		else if (memo[m+1][n] > memo[m][n+1])
			n--;
		else
			m--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}


Measured memory_bytes: 36224
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        char c[] = s.toCharArray();
        Arrays.sort(c);
        for(int i = 0; i < s.length(); i++){
            int count = 0;
            for(int j = i; j < s.length(); j++){
            	if(c[i] == c[j]){
            		count++;
            	}
            }
            if(count % 2 != 0){
            	System.out.println("No");
                return;
            }else{
            	i += count - 1;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35672
n,x=map(int,input().split())
a=list(map(int,input().split()))
k=0
count=0
if a[1]+a[0]>x and x>=a[0]:
    k=x-a[0]
    count+=a[1]+a[0]-x
elif a[1]+a[0]>x and x<a[0]:
    k=0
    count+=a[1]+a[0]-x
else:
    k=a[1]
for i in range(1,n-1):
    if k+a[i+1]<=x:
        k=a[i+1]
        
    elif x>=k:
        count+=k+a[i+1]-x
        k=x-k
    else:
        count+=k+a[i+1]-x
        k=0
print(count)

Measured memory_bytes: 14428
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int main(){
 int N;
 char str[11];
 priority_queue<string> pque;
 cin >> N;
 for(int i=0;i<N;i++){
   cin >> str;
   sort(str,str+10);
   pque.push(string(str));
 }
  
  long long cnt=1;
  long long sum=0;
  string str1,str2;
  str1=pque.top();pque.pop();
  while(!pque.empty()){
    str2 = pque.top(); 
    pque.pop();
    if( strcmp(str1.c_str(),str2.c_str())==0)cnt++;
    else{
      sum+=cnt*(cnt-1)/2;
      cnt=1; str1=str2;
    }
  }sum+=cnt*(cnt-1)/2;
  cout << sum << endl;  
}


Measured memory_bytes: 5748
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y: return False
    #sizeの大きいほうがx
    if par[x] > par[y]: x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

n, m = map(int, input().split())
ab = []
ans = m
for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])
for i in range(m):
    par = [-1]*n
    for j in range(m):
        if i==j: continue
        unite(ab[j][0], ab[j][1])
    if -min(par) == n: ans -= 1
print(ans)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;

int h, ans;
int foo(int n) {
	if (n == 1) return 1;
	return 1 + 2*foo(n/2);
}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> h;
	ans = foo(h);
	cout << ans;
	time
}

Measured memory_bytes: 3792
#include<cstdio>

int main() {
  int S;
  scanf("%d", &S);
  int h = S / 3600;
  int m = (S - h * 3600) / 60;
  int s = S - h * 3600 - m * 60;
  printf("%d:%d:%d\n", h, m, s);
}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,m,x,y,z;
    cin>>n>>m>>x>>y>>z;
    ll a[x],b[y],c[z];
    for(int i=0;i<x;i++) cin>>a[i];
    for(int i=0;i<y;i++) cin>>b[i];
    for(int i=0;i<z;i++) cin>>c[i];
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());
    ll ans = 0;
    for(int i=0;i<n;i++) ans += a[i];
    for(int i=0;i<m;i++) ans += b[i];
    n--,m--;
    for(int i=0;i<z;i++){
        if(n>=0&&m>=0){
            if(a[n] <= b[m] && c[i] > a[n]){
                ans += c[i] - a[n];
                n--;
            }
            else if(a[n] >= b[m] && c[i] > b[m]){
                ans += c[i] - b[m];
                m--;
            }
        }
        else if(n>=0){
            if(a[n] < c[i]){
                ans += c[i] - a[n];
                n--;
            }
        }
        else if(m >= 0){
            if(b[m] < c[i]){
                ans += c[i] - b[m];
                m--;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int d = s.nextInt();
		String str = null;

		if ((a + b) == (c + d)) {
			str = "Balanced";
		} else if ((a + b) < (c + d)) {
			str = "Right";
		} else {
			str = "Left";
		}

		System.out.println(str);

	}
}


Measured memory_bytes: 21844
n=int(input())
g=[[] for i in range(n)]
ro=[0]*n
for i in range(n-1):
    a,b=map(int,input().split())
    ro[a-1]+=1
    ro[b-1]+=1
    g[a-1].append(b-1)
    g[b-1].append(a-1)
c=list(map(int,input().split()))
c.sort(reverse=True)
m=max(ro)
mi=ro.index(m)
q=[mi]
ans=[0]*n
v=[0]*n
v[mi]=1
ans[mi]=c.pop(0)
while len(q)>0:
    s=q.pop()
    for i in g[s]:
        if v[i]==0:
            v[i]=1
            ans[i]=c.pop(0)
            q.append(i)
print(sum(ans)-max(ans))
print(*ans)


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

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

    vector<pair<int, int>> left, right;
    for(int i = 0;i < N;i++){
        string s;
        cin >> s;
        int d = 0, mi_d = 0;
        for(auto c : s){
            if(c == '(')d++;else d--;
            mi_d = min(mi_d, d);
        }
        if(d > 0)left.emplace_back(mi_d, d);
        else right.emplace_back(mi_d - d, -d);
    }
    sort(rbegin(left), rend(left));
    sort(rbegin(right), rend(right));
    int D = 0, sum = 0;
    bool ok = true;
    for(auto p : left){
        int mi = p.first, d = p.second;
        if(D + mi < 0)ok = false;
        D += d;
        sum += d;
    }
    D = 0;
    for(auto p : right){
        int mi = p.first, d = p.second;
        if(D + mi < 0)ok = false;
        D += d;
        sum -= d;
    }
    if(ok && sum == 0)cout << "Yes" << endl;
    else cout << "No" << endl;





}


Measured memory_bytes: 11212
N = int(input()) 
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

x1 = sorted(s)[-1]
x2 = sorted(s)[-2]

if ( x1 == x2 ) :
    for val in s:
        print ( x1 )
else :
    for val in s:
        if ( val == x1 ):
            print ( x2 )
        else:
            print ( x1 )

Measured memory_bytes: 14636
#include <stdio.h>

int main() {
    int h, w;
    while (1) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) {break;}
        for (int i=0; i<w; i++) {
            printf("#");
        }
        printf("\n");
        for (int j=0; j<(h-2); j++){
            printf("#");
            for (int k=0; k<(w-2); k++) {
                printf(".");
            }
            printf("#\n");
        }
        for (int l=0; l<w; l++) {
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}


Measured memory_bytes: 2048
S = list(input())
N = len(S)
cnt = 0
for i in range(1,(N-1)//2 + 1):
    if S[i-1] != S[(N-1)//2 - i]:
        cnt += 1
for i in range((N+3)//2,N+1):
    if S[i-1] != S[(N-1)//2 - i -1 + (N+3)//2]:
        cnt += 1
if cnt == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node{
	int L,R;
	bool operator <(const node s)const{
		if(L==s.L)return R>s.R;
		return L<s.L;
	}
}a[500010];
int al[100010],ar[100010],dl[100010],dr[100010];
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].L>>a[i].R;
	sort(a+1,a+n+1);
	al[1]=a[1].L;ar[1]=a[1].R;
	for(int i=2;i<=n;i++){
		al[i]=max(al[i-1],a[i].L);
		ar[i]=min(ar[i-1],a[i].R);
	}
	dl[n]=a[n].L;dr[n]=a[n].R;
	for(int i=n-1;i>=1;i--){
		dl[i]=max(dl[i+1],a[i].L);
		dr[i]=min(dr[i+1],a[i].R);
	}
	int ans=0;
	for(int i=1;i<n;i++)ans=max(ans,max(0,ar[i]-al[i]+1)+max(0,
	dr[i+1]-dl[i+1]+1));
	if(n>1)for(int i=1;i<=n;i++)ans=max(ans,a[i].R-a[i].L+1
	+max(0,min(ar[i],dr[i+1])-max(al[i],dl[i+1])+1));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;



	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    vector<set<int>> archive(26);
    rep(i,n){
        archive[s[i]-'a'].insert(i);
    }
    vector<int> ans;
    rep(qi,q){
        int t;
        cin >> t;
        if (t==1){
            int l; cin >> l;
            l--;
            char c; cin >> c;
            if (c!= s[l]){
                archive[s[l] - 'a'].erase(l);
                archive[c-'a'].insert(l);
                s[l]=c;
            }
        }
        else{
            int l,r; cin >> l >> r;
            l--;r--;
            int count = 0;
            rep(j,26){
                auto lb = archive[j].lower_bound(l);
                if (lb != archive[j].end() && *lb<=r) count++;
            }
            ans.pb(count);
        }
    }
    rep(i,ans.size()) cout << ans[i] << endl;
    rn 0;
}


Measured memory_bytes: 24452
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const double INF = 1e7;
const double eps = 1e-6;
const int maxn = 1e6 + 7;
const int maxm = (1 << 10) + 7;
const int mod = 1e9 + 7;
#define IO                        \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
int main()
{
	IO;
	string s;
	cin>>s;
	int len=s.length();
	while (len--)
	cout<<"x";
	cout<<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 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));
using namespace std;
int l,n,a[200005];
ll A[200005],ans;
int main(){
	scanf("%d%d",&l,&n); 
	For(i,1,n) scanf("%d",&a[i]),A[i]=A[i-1]+a[i];
	For(at,0,n){
		int pre=at,suf=n-at;
		if (pre<suf) suf=min(suf,pre+1);
		else pre=min(pre,suf+1);
		ll tmpv=(A[at]-A[at-pre])+1ll*l*suf-(A[at+suf]-A[at]);
		tmpv*=2;
		ll delta=0;
		if (suf>pre)
			delta=min(l-a[at+1],2*(l-a[at+suf])+a[at]);
		else if (pre>suf) 
			delta=min(a[at],2*a[at-pre+1]+(l-a[at+1]));
		else delta=min(l-a[at+1],a[at]);
		ans=max(ans,tmpv-delta);
		//printf("%lld %lld\n",ans,tmpv-delta);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2688
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S;
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int dig[100010] = {1};
ll dp[100010][13];
string S;
int main(){
    cin >> S;
    reverse(S.begin(), S.end());

    for(int i = 1; i <= S.size(); i++){
        dig[i] = dig[i - 1] * 10 % 13;
    }
    vector<int> q;
    int rem = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '?') q.push_back(dig[i]);
        else rem = (rem + (S[i] - '0') * dig[i]) % 13;
    }

    dp[0][rem] = 1;
    for(int i = 0; i < q.size(); i++){
        for(int j = 0; j < 13; j++){
            for(int k = 0; k < 10; k++){
                int r = (j + k * q[i]) % 13;
                dp[i + 1][r] = (dp[i + 1][r] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[q.size()][5] << endl;
    return 0;
}


Measured memory_bytes: 11512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          ll i;

	          ll n,p;
	          cin >> n >> p;
	          ll od=0;
	          for(i=1;i<=n;i++){
	        	  ll a;
	        	  cin >> a;
	        	  if(a%2==1) od++;
	          }

	          if(od==0){
	        	  if(p==1){
	        		  cout << 0 << endl;
	        		  return 0;
	        	  }else{
	        		  cout << (1LL<<n) << endl;
	        		  return 0;
	        	  }
	          }


	          ll ans=1;
	          for(i=1;i<=n-1;i++) ans*=2;

	          cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b;
    cin >> a >> b;
    repi(i,4,1){
        if(i == a || i == b){
            continue;
        }
        cout << i << endl;
    }
    return 0;
}

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

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

  if (abs(B - A) <= D && abs(C - B) <= D) cout << "Yes" << endl;
  else if (abs(C - A) <= D) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,Q;
	cin >> N >> Q;
	vector<pair<int,int>> A(N-1);
	vector<int> P(N);
	vector<int> point(N);
	rep(i,0,N-1){
		cin >> A[i].first >> A[i].second;
		A[i].first--;
		A[i].second--;
	}
	rep(i,0,N){
		point[i] = 0;
	}
	rep(i,0,Q){
		int tmp1,tmp2;
		cin >> tmp1 >> tmp2;
		point[tmp1-1] += tmp2;
	}
	sort (all(A));
	rep(i,0,N-1){
		P[A[i].second] = A[i].first;
		/*
		rep(j,0,P[A[i].first].size()){
			P[A[i].second].push_back(P[A[i].first][j]);
		}
		*/
	}
	
	rep(i,0,N){
		int ans = 0;
		if(i != 0) point[i] = point[P[i]] + point[i];
		cout << point[i] << endl;
	}
}


Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>
#include <string>
#include <array>
#include <functional>
#include <vector>
#include <set>

/*-------- sort --------*/
//vector<int> homeDistance(0);
//for (int i = 0; i < kensu; i++) {
//    cin >> in;
//    homeDistance.push_back(in);
//}
//sort(homeDistance.begin(), homeDistance.end(),);               //昇順
//sort(homeDistance.begin(), homeDistance.end(), greater<int>());//降順
//for (auto a : homeDistance) {
//    std::cout << a << " ";
//}
//std::cout << '\n';
/* ----end----  */

using namespace std;
int main()
{
    int count, input;

    cin >> count; 
    set<int> cyokei;
    for (int i = 0; i < count; i++) {
        cin >> input;
        cyokei.insert(input);    
    }

 //   for (auto itr = cyokei.begin(); itr != cyokei.end(); ++itr) { 
//        cout << endl << *itr << endl;
//    }
    auto k = cyokei.size();

    cout << k << endl;


}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

VI g[MAX];
int ST[MAX];
int TO[MAX];

int D[MAX];

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, k;
	scanf("%d%d", &n, &k);

	int res = 0;

	int x;
	scanf("%d", &x);
	if (x != 1) res++;

	FOR (i, 1, n)
	{
		int x;
		scanf("%d", &x);
		x--;
		TO[i] = x;
		ST[x]++;
	}

	ST[0] = INF;

	queue<int> q;

	FOR (i, 1, n)
	{
		if (ST[i] == 0) q.push(i);
		D[i] = 0;
	}

	while(SZ(q))
	{
		int x = q.front();
		q.pop();

		if (D[x] == k - 1 && TO[x] != 0)
		{
			res ++;
			D[x] = -1;
		}

		{
			int to = TO[x];
			D[to] = max(D[to], D[x] + 1);
			ST[to]--;
			if (ST[to] == 0) q.push(to);
		}
	}
	cout<<res<<endl;





}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007

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

int main() {
	int n, k, q; cin >> n >> k >> q;
	map<int, int> mp;
	rep(i, q) {
		int tmp;
		cin >> tmp;
		tmp--;
		mp[tmp] ++;
	}
	rep(i, n) {
		int res = k - q + mp[i];
		if (res <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}


}



Measured memory_bytes: 7296