akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int r, g, b, n; cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0; i<=3000; i++){
        for(int j=0; j<=3000; j++){
            int R = r * i;
            int G = g * j;

            int rest = n - R - G;
            if(0 <= rest && rest % b == 0){
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
class Union:
    def __init__(self, n):
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uni = Union(n)
for a, b in ab:
    a -= 1
    b -= 1
    uni.unite(a, b)
print(-min(uni.parents))

Measured memory_bytes: 50100
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    A, B, C = read_values()
    if len({A, B, C}) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3948
N = int(input())
D = [int(d) for d in input().split()]

f = 0
if D[0] != 0:
    f = -1
mod = 998244353
L = []

num = 0
cnt = 0
D.sort()
for i in range(N):
    if D[i] == num:
        cnt += 1
    elif D[i] == num+1:
        L.append(cnt)
        cnt = 1
        num += 1
    else:
        f = -1
        break
        
L.append(cnt)
ans = 1
if f == 0:
    if D[0] != 0:
        ans = 0
    if N > 1:
        if D[1] != 1:
            ans = 0
    if ans > 0:
        for i in range(1, len(L)):
            ans *= L[i-1]**L[i]
            ans %= mod
else:
    ans = 0
    
print(ans)

Measured memory_bytes: 56172
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 200001
int32_t main() {
	fast;
	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);









}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<=N;i++)

signed main(){
  int N;
  cin>>N;
  int ans=0;
  rep(i,N){
    int yaku=0;
    rep(j,i){
      if(i%j==0)yaku+=1;
    }
    if(i%2==1&&yaku==8)ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, A, B;
  cin >> N >> A >> B;

  // 解答
  cout << min(N * A, B) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
def factorization(n):
    D = {}
    a = n
    p = 2
    while a != 1:
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt != 0:
            D[p] = cnt
        p += 1
        if p * p > n and a != 1:
            D[a] = 1
            break
    return D
f = factorization(N)
X = [0 for _ in range(101)]
for i in range(101):
    X[i] = i*(i+1)//2
p = 0
for i in f:
    x = f[i]
    for j in range(100):
        if X[j] <= x < X[j+1]:
            p += j
            f[i] -= X[j]
            break
print(p)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A[N];
    REP(i, N){
        REP(j, M){
            int x;
            cin >> x;
            A[i].push_back(x);
        }
    }
    ll res = 1000;
    if(M==1){
        cout << N << endl;
        return 0;
    }
    for(int i=0;i<M-1;i++){
        vector<int> count(M+1, 0);
        REP(j, N){
            count[A[j][0]]++;
        }
        ll ma = -1;
        ll ind = -1;
        REP(j, M+1){
            if(ma < count[j]){
                ma = count[j];
                ind = j;
            }
        }
        res = min(ma, res);
        REP(j, N){
            A[j].erase(find(A[j].begin(), A[j].end(), ind));
            /*
            REP(k, A[j].size()){
                cout << A[j][k] << " ";
            }
            cout << endl;
            */
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 896
parseInt(x) = parse(Int, x)
function calc()
    a=zeros(Int64,6)
    ok=true
    for i in 1:6
        a[i]=parseInt(readline())
    end
    for i in 1:5
        for j in 1:5
            if i>j
                if a[i]-a[j]>a[6]
                    ok=false
                end
            end
        end
    end
    if ok
        println("Yay!")
    else
        println(":(")
    end
end
  
calc()


Measured memory_bytes: 163124
#include <cstdio>
#include <vector>
const int MAXN = 1e5+5;
std::vector<int> G[MAXN];
unsigned deg[MAXN]{ };
int B[MAXN];
int C[MAXN];        // Edge color
int start[MAXN];    // Node starting color
int N;

int main() {
    scanf("%d", &N);
    for (int i = 1; i < N; ++i) {
        int a;
        scanf(" %d%d", &a, &B[i]);
        G[a].push_back(i);
        ++deg[a];
        ++deg[B[i]];
    }
    unsigned K = 0;
    for (int i = 1; i <= N; ++i) {
        K = std::max(deg[i], K);
    }
    start[1] = 1;
    for (int cur = 1; cur <= N; ++cur) {
        int tint = start[cur];
        for (int e: G[cur]) {
            C[e] = tint;
            tint = tint % K + 1;
            start[B[e]] = tint;
        }
    }
    printf("%u\n", K);
    for (int i = 1; i < N; ++i) {
        printf("%d\n", C[i]);
    }
    return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, c;
  cin >> n >> c;
  vector<vector<pair<int, int>>> vp(c, vector<pair<int, int>>());
  rep(i, n){
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    vp.at(c).push_back(make_pair(s, t));
  }
  rep(i, c) sort(vp.at(i).begin(), vp.at(i).end());
  vector<int> imos(1e5+5, 0);
  rep(i, c){
    int sz = vp.at(i).size();
    rep(j, sz){
      if(j+1 == sz || vp.at(i).at(j+1).first != vp.at(i).at(j).second) imos.at(vp.at(i).at(j).second)--;
      if(j == 0 || vp.at(i).at(j-1).second != vp.at(i).at(j).first) imos.at(vp.at(i).at(j).first - 1)++;
    }
  }
  int mx = 0, now = 0;
  rep(i, imos.size()){
    now += imos.at(i);
    mx = max(mx, now);
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 2172
n= int(input())
s1=input()
s2=input()
index=0
s=''
while index<n:
    if s1[index]==s2[index]:
        index+=1
        s=s+'t'
    else:
        index+=2
        s=s+'y'
adict = {'tt':2,'ty':2,'yt':1,'yy':3}
ans = 0
if s[0]=='t':ans=3
else:ans=6
for i in range(len(s)-1):
    ans = (ans%1000000007) * (adict[s[i:i+2]]%1000000007) % 1000000007
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

height_list=list(map(int, input().split()))
cost_list=[0 for _ in range(n)]
cost_list[1]=abs(height_list[1]-height_list[0])

for position in range(2, n):
    one_hop=abs(height_list[position]-height_list[position-1])
    two_hop=abs(height_list[position]-height_list[position-2])
    
    cost_list[position]=min(cost_list[position-1]+one_hop, cost_list[position-2]+two_hop)

print(cost_list[n-1])

Measured memory_bytes: 13928
/**
*    created: 23.05.2020 01:06:06
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int MAX_N=10000;

pair<int,int> dp [MAX_N];
int n,m;

void solve(){
  sort(dp,dp+n,greater<pair<int,int> >());
  for(int i=0;i<n;i++){
    int tmp=dp[i].second;
    if(tmp>=m){
      dp[i].second-=m;
      break;
    }else{
      dp[i].second=0;
      m-=tmp;
    }
  }
  long long int sum=0;
  REP(i,n){
    sum+=dp[i].first*dp[i].second;
  }
  cout<<sum<<endl;
}

int main(){ _;
  while(cin>>n>>m,(n|m)!=0){
    REP(i,n)cin>>dp[i].second>>dp[i].first;
    solve();
  }
}

Measured memory_bytes: 1268
import sys
input = sys.stdin.readline
X = int(input())
ans = [1]
for i in range(2, 1 + int(X ** (1/2))):
    ans.append(i)
    x = i
    while x < X:
        x *= i
        if x <= X:
            ans.append(x)
print(max(ans))

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

using namespace std;
typedef long long int ll;

const int M = 2019;

int main(){
	string s;
	cin >> s;
	int n = (int)s.size();	
	vector<int> p(n),in(n);
	int base = 10;
	int mul = 1;
	for(int i = n-1; i >= 0; i--){
		p[i] = (s[i]-'0') * mul % M;
		mul = mul * base % M;
		in[i] = p[i];
	}
	vector<int> cnt(2019);
	int sm = 0;
	//cout << p[0] << " ";
	cnt[p[0]]++;
	for(int i = 1; i < n; i++){
		p[i]+=p[i-1];
		p[i]%=M;
	//	cout << p[i] << " ";
		cnt[p[i]]++;
	}
	ll res = 0;
	for(int i = 0; i < n; i++){
		res+= cnt[sm];
		cnt[p[i]]--;
		sm+=in[i];
		sm%=M;
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 5188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[20];
long long s;
int f(int x,int y)
{
     int k=1;
     for(int i=1;i<=y;i++)
     {
          k=k*x;
     }
     return k;
}
int main(void)
{
     int i,j,k,n;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
          scanf("%d",&a[i]);
     }
     s=0;
     for(i=0;i<n;i++)
     {
          for(j=a[i]-1;j<=a[i]+1;j++)
          {
               if(j%2==1)
                    continue;
               int l=1;
               for(k=0;k<i;k++)
               {
                    if(a[k]%2==1)
                         l=l*1;
                    else
                         l=l*2;
               }
               if(n-1-i>0)
                    l=l*f(3,n-1-i);
               s=s+l;
          }
     }
     printf("%lld\n",s);
     return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
typedef pair<string,int> P;
int n;
int main(){
	string str;
	map<string,std::vector<int> > data;
	while(cin>>str>>n){
		data[str].push_back(n);
	}
	map<string,vector<int> >::iterator it =data.begin();
	for(;it!=data.end();it++){
		cout <<(*it).first<<endl;
		vector<int>v =(*it).second;
		sort(v.begin(),v.end());
		for(int i = 0;i <v.size();i++){
			if(i)cout <<" ";
			cout <<v[i];
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
<?php
$n = int();
$A = ints();
$min = 10**10;
for($i = 1; $i <= 100; $i++){
    $tmp = 0;
    foreach($A as $a){
        $tmp+=($a-$i)**2;
    }
    chmin($min, $tmp);
}
echo $min,"\n","\n";


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
typedef long long ll;
const ll mod=1e9+7;
ll dp[3001][3001];

ll solve(vector<int>&v,int i,int j,bool turn){
	if(i>j)
		return 0;
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(turn ==1)
		return dp[i][j]=max(v[i]+solve(v,i+1,j,0),v[j]+solve(v,i,j-1,0));
	else
		return dp[i][j]=min(solve(v,i+1,j,1),solve(v,i,j-1,1));
}
int main()
{

	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr);
    
    memset(dp,-1,sizeof dp);
    int n;cin>>n;
    ll sum=0;
    vector<int>A(n+1);
    for(int i=1;i<=n;i++){
    	cin>>A[i];
    	sum+=A[i];
    }
    ll scoreX=solve(A,1,n,1);
    ll scoreY=sum-scoreX;
    cout<<scoreX-scoreY;
    return 0; 
}

/*
here player 1 want to miximum the score where as player two wants to minimum the score of player 1
that's why
if turn ==1
dp[i][j]=max(v[i]+solve(A,i+1,j,0),v[j]+solve(A,i,j-1,0)) // here i can take either from first or last

if the turn is player two then it wants to minimum the score of player 1
dp[i][j]=min(solve(A,i+1,j,1),solve(A,i,j-1,1))


*/

Measured memory_bytes: 70912
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll a; cin>>a;
    cout << a + a*a + a*a*a << '\n';
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int a[200010],b[200010],y[200010];
int aa[30][200010];
int n,c,d,e,f;
ll ans=0;
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;++i)  scanf("%d",&b[i]);
	for(i=0;i<28;++i){
		if(i==0)  for(j=1;j<=n;++j)  aa[i][j]=a[j]&1;
		else{
			for(j=1;j<=n;++j)  aa[i][j]=aa[i-1][j]^((1<<i)&a[j]);
		}
	}
	for(i=0;i<28;++i)  sort(aa[i]+1,aa[i]+1+n);
	for(i=0;i<28;++i){
		for(j=1;j<=n;++j){
			y[j]^=(1<<i)&b[j];
			int k=int(lower_bound(aa[i]+1,aa[i]+1+n,(1<<(i+1))-y[j])-aa[i]);
			ans^=((n-k+1)%2)<<(i+1);
		}
	}
	for(i=0;i<28;++i){
		c=d=e=f=0;
		for(j=1;j<=n;++j){
			if((1<<i)&a[j])  c++;
			else  d++;
			if((1<<i)&b[j])  e++;
			else  f++;
		}
		ans^=(((1LL*c*f%2+1LL*d*e%2)%2)<<i);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

string Input;
bool judgeResult[8][5];

void solve() {
	int j, k, len;
	string tmp;

	len = Input.size();
	tmp = "";
	for (int i = 0; i < 5 - len; i++) {
		tmp += "0";
	}
	Input = tmp + Input;
	len = Input.size();
	//cout << Input << endl;

	for (int i = len - 1; i > -1; i--) {
		//cout << Input[i] << endl;
		if (Input[i] > '4') {
			judgeResult[1][i] = true;
			k = Input[i] - '0' - 5;
		}
		else {
			judgeResult[0][i] = true;
			k = Input[i] - '0';
		}

		for (j = 0; j < k; j++) {
			judgeResult[3+j][i] = true;	
		}
		for (int t = 4 + j; t < 8; t++) {
			judgeResult[t][i] = true;
		}
	}
}


int main() {
	bool flag = false;

	while (cin >> Input) {
		if (flag) {
			cout << endl;
		}
		flag = true;
		memset(judgeResult, false, sizeof(judgeResult));
		solve();
		for (int i = 0; i < 8; i++) {
			if (i == 2) {
				cout << "=====" << endl;
				continue;
			}
			for (int j = 0; j < 5; j++) {
				cout << (judgeResult[i][j] ? "*" : " ");
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(2500 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

signed main()
{
	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		int a[n+1];
		
		for(int i = 0 ; i <= n ; i++)
		{
			a[i] = i;
		}

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

		int sum = 0;
		for(int i = k ; i <= n+1 ; i++)
		{
			if(i == n+1)
			{
				sum = (sum + 1)%mod;
				continue;
			}
			int l = a[i-1];
			int r = a[n] - a[n-i];
			//cout<<l<<" "<<r<<"\n";
			int val = r-l+1;
			sum = (sum + val)%mod;
		}

		cout<<sum<<"\n";
	}
}



Measured memory_bytes: 5216
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #define _CRT_SECURE_NO_WARNINGS
    #pragma warning(disable:4996)
#endif

#define ll long long
#define vi vector<ll>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

ll INF = 1e9 + 7;



int main()
{
    ll n, sz;
    cin >> n >> sz;
    vi v(n), w(n);
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    vector<vi> dp(n + 1, vi(100001, sz + 1));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= 100000; j++)
            dp[i][j] = min(dp[i - 1][j], j - v[i - 1] >= 0 ? min(sz + 1, dp[i - 1][j - v[i - 1]] + w[i - 1]) : sz + 1);
    int ans = 0;
    for (int i = 100000; i >= 0; i--)
        if (dp[n][i] <= sz)
        {
            ans = i;
            break;
        }
    cout << ans;
}

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

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String S = scanner.next();
        String T = scanner.next();
        int[][] dp = new int[S.length() + 1][T.length() + 1];
        int[][] px = new int[S.length() + 1][T.length() + 1];
        int[][] py = new int[S.length() + 1][T.length() + 1];
        for (int i = 1; i <= S.length(); i++) {
            for (int j = 1; j <= T.length(); j++) {
                if (S.charAt(i - 1) == T.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    px[i][j] = i - 1;
                    py[i][j] = j - 1;
                }
                else {
                    if (dp[i - 1][j] > dp[i][j - 1]) {
                        dp[i][j] = dp[i - 1][j];
                        px[i][j] = i - 1;
                        py[i][j] = j;
                    } else {
                        dp[i][j] = dp[i][j - 1];
                        px[i][j] = i;
                        py[i][j] = j - 1;
                    }
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        int cx = S.length(), cy = T.length();
        while (cx > 0 && cy > 0) {
            if (S.charAt(cx - 1) == T.charAt(cy - 1)) {
                sb.append(S.charAt(cx - 1));
            }
            int nx = px[cx][cy];
            cy = py[cx][cy];
            cx = nx;
        }
        sb.reverse();

        System.out.println(sb);

    }

}



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

int main(){
 long a, b, c, k, ans = 0;
  
  cin >> a >> b >> c >> k;
  
  if(k >= a) ans += a;
  else ans += k;
  
  if(k - a - b > 0) ans += -1 * (k - a - b);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3680
n, m, l = map(int, input().split())

matrix_A = [list(map(int, input().split())) for _ in range(n)]
matrix_B = [list(map(int, input().split())) for _ in range(m)]

matrix_B_transposed  = list(map(list, zip(*matrix_B)))

for a in matrix_A:
    c = []
    for bt in matrix_B_transposed:
        c.append(sum(x * y for (x, y) in zip(a, bt)))
    print(*c)



Measured memory_bytes: 6688
N = int(input())
alpha=list('abcdefghijklmnopqrstuvwxyz')
res=['']
for i in range(N):
    tmp = []
    for j in res:
        for k in alpha[:len(set(list(j))) +1]:
            tmp.append(j+k)
    res = tmp

for i in res:
    print(i)

Measured memory_bytes: 12972
from collections import deque
 
S = input()
Q = int(input())
S = deque(S)


flg_reverse = False
for q in range(Q):
  _ = input()
  if _[0] == '1':
    flg_reverse = flg_reverse ^ True
  else:
    _T, _F, _C = _.split()
    if (_F == '1') ^ flg_reverse:
      S.appendleft(_C)
    else:
      S.append(_C)        

S = list(S)
# reverseの部分を対応
if flg_reverse:
  S.reverse()

print(''.join(S))

Measured memory_bytes: 8556
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  vector<vector<P>> v(n+1);
  rep(i, m) {
    ll ai, bi; cin >> ai >> bi;
    v[ai].emplace_back(make_pair(bi, i));
    v[bi].emplace_back(make_pair(ai, i));
  }

  ll ans = 0;
  rep(i, m) {
    vector<bool> visited(n+1);
    queue<ll> qx, qc;
    ll start = -1;
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < v[j].size(); k++) {
        if (v[j][k].second != i) {
          start = j;
          goto START_BFS;
        }
      }
    }
    START_BFS:
    qx.push(start);
    ll cnt = 0;
    visited[start] = true;
    // 辺iを使わずにBFSする
    while (!qx.empty()) {
      ll x = qx.front(); qx.pop();
      cnt++;

      for (int j = 0; j < v[x].size(); j++) {
        ll y = v[x][j].first;
        if (visited[y]) continue;
        if (v[x][j].second == i) continue;

        qx.push(y);
        visited[y] = true;
      }
    }
    if (cnt != n) ans++;
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long a,b,k;
  long ii,last;
  cin >> a >> b >> k;
  for(ii=0;ii<k;ii++){
	if(a+ii<=b){
	  cout << a+ii << endl;
	  last = a+ii;
	}
	else{
	  break;
	}
	//cout << "k:" << k << endl;
  }
  for(ii=k-1;ii>=0;ii--){
	if(b-ii > last && b-ii <= b){
	  cout << b-ii << endl;
	}
	else{
	  //break;
	}
  }
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int h,a; cin >> h >> a;
  int ans = h/a;
  h -= ans * a;
  if(h>0) ans++;

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


Measured memory_bytes: 3552
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

const int MXN = 1e5 + 5;
//const ll MOD = 998244353;
const ll MOD = 1000000007;
//const ll INF = 1000000007;



int N, K;
ll A[MXN], fact[MXN+1], inv[MXN+1], finv[MXN+1];

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

ll mul(ll a, ll b){
	return (a*b) % MOD;
}

ll madd(ll a, ll b){
	return (a + b) % MOD;
}




int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");
	
	cin >> N >> K;
	F0R(i,N) cin >> A[i];
	sort(A,A+N);

	fact[0] = 1;
	FOR(i,1,MXN+1){
		fact[i] = fact[i-1] * i % MOD;
	}
	inv[1] =1 ;
	FOR(i,2,MXN+1){
		inv[i] = (MOD - (MOD/i) * inv[MOD %i] % MOD) % MOD;
	}
	finv[0] = 1;
	finv[1] = 1;
	FOR(i, 2, MXN+1) finv[i] = finv[i-1] * inv[i] % MOD;

	ll sm = 0;

	F0R(i,N){
		sm = madd(sm, mul(bc(1LL*i, 1LL*(K-1)), A[i]));
		sm = madd(sm, mul(bc(1LL*(N-i-1), 1LL*(K-1)), 1LL*-1*A[i]));
	}
	cout << sm << newl;






















	return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	
	for (int rep=0; rep<n; rep++) {
		
		int x = 0, y = 0;
		int maxdist = 0, memox = 0;
		int ansx = 0, ansy = 0;
		
		while (1) {
			int dx, dy; cin >> dx >> dy; if (dx==0 && dy==0) break;
			
			x += dx; y += dy;
			int dist = x*x  + y*y;
			
			if (maxdist < dist) {
				maxdist = dist;
				memox = x;
				ansx = x; ansy = y;
			} else if (maxdist == dist && x > memox) {
				maxdist = dist;
				memox = x;
				ansx = x; ansy = y;
			}
		}
		
		cout << ansx << " " << ansy << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)


int main(){
    ll N,M; cin >> N >> M;
    vl w(N),v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }
    ll MAX_W = 3*N+10;
    vvvl dp(N+1,vvl(N+1,vl(MAX_W,0)));
    rep(i,N){
        rep(j,N){
            rep(k,MAX_W-5){
                chmax(dp[i+1][j][k],dp[i][j][k]);
                if(k+(w[i]-w[0])<MAX_W){
                    chmax(dp[i+1][j+1][k+((w[i]-w[0]))],dp[i][j][k] + v[i]);
                }
            }
        }
    }
    ll ans = 0;
    rep(i,N+1){
        rep(j,MAX_W){
            if((i)*w[0] + j <= M) chmax(ans,dp[N][i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25600
#include <iostream>
#include <iomanip>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

template<class T>
class set2 : public set<T> {
private:
    typename set<T>::iterator back_itr() {
        auto e = this->end();
        e--;
        return e;
    }

public:
    T front() {
        if (this->empty()) throw;
        return *this->begin();
    }

    T back() {
        if (this->empty()) throw;
        return *this->back_itr();
    }

    void erase_front() {
        if (!this->empty()) this->erase(this->begin());
    }

    void erase_back() {
        if (!this->empty()) this->erase(this->back_itr());
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (auto &e:a) cin >> e;
    for (auto &e:b) cin >> e;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    bool f = true;
    for (int i = 1; i < n; i++) if (a[i] == a[i - 1]) f = false;
    for (int i = 1; i < m; i++) if (b[i] == b[i - 1]) f = false;
    if (!f) {
        cout << 0 << endl;
        return 0;
    }
    auto in_r = [](vector<int> r, int e) { return binary_search(r.begin(), r.end(), e); };
    auto in_a = [&in_r, &a](int e) { return in_r(a, e); };
    auto in_b = [&in_r, &b](int e) { return in_r(b, e); };
    ll r = 1;
    for (int i = n * m; i > 0; i--) {
        if (in_a(i) && in_b(i)) {
            r *= 1;
        } else if (in_a(i)) {
            r *= b.end() - lower_bound(b.begin(), b.end(), i);
        } else if (in_b(i)) {
            r *= a.end() - lower_bound(a.begin(), a.end(), i);
        } else {
            r *= (a.end() - lower_bound(a.begin(), a.end(), i)) * (b.end() - lower_bound(b.begin(), b.end(), i)) -
                 (n * m - i);
        }
        r %= mod;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int N, A[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	sort(A, A + N);
	printf("%d", A[N-1]-A[0]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int n = scanner.nextInt();

        
      for(int i=0;i<n;i++){
        int a = scanner.nextInt();
      h = h-a;
      }
      if(h<=0){
      System.out.println("Yes");
      }
      else{
      System.out.println("No");
      }
    }
 }
 

Measured memory_bytes: 50372
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i

  t = (n * (n + 1)) / 2
  s = 0
  n.times do |i|
    m = (i + 1)
    s += m if ((m % 3 == 0) or (m % 5 == 0))
  end

  puts (t - s).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int const N = 2000, md = 998244353;
int dp[N + 1][N + 2][2], dp2[N + 1][N + 1];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int main(){
	int k, n;
	scanf("%d%d", &k, &n);
	dp[0][1][0] = 1;
	f(i, 0, n + 1)f(j, 1, k + 1){
		ad(dp[i][j + 1][0], dp[i][j][0]);
		ad(dp[i][j + 1][0], dp[i][j][1]);
		if (i != n)ad(dp[i + 1][j][1], dp[i][j][0] * 2 % md);
		if (i != n)ad(dp[i + 1][j][1], dp[i][j][1]);
	}
	dp2[0][1] = 1;
	f(i, 0, n + 1)f(j, 1, k + 1){
		if (j != k)ad(dp2[i][j + 1], dp2[i][j]);
		if (i != n)ad(dp2[i + 1][j], dp2[i][j]);
	}
	dp2[0][0] = 1;
	f(i, 2, k << 1 | 1){
		int p = i > k ? k - (i - k) + 1 >> 1 : i - 1 >> 1;
		int an = 0;
		f(j, 0, n + 1)ad(an, (ll)dp[j][p + 1][0] * dp2[n - j][k - (p << 1) - (i + 1 & 1)] % md);
		if (!(i & 1))f(j, 0, n)ad(an, (ll)dp[j][p + 1][0] * dp2[n - 1 - j][k - (p << 1) - 1] % md);
		printf("%d\n", an);
	}
}

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

int main() {
  int a,b,a1,b1;
  cin>>a>>b;
  if(a==2)a1=1;
  else if(a==4||a==6||a==9||a==11)a1=2;
  else a1=3;
  if(b==2)b1=1;
  else if(b==4||b==6||b==9||b==11)b1=2;
  else b1=3;
  if(a1==b1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
  int h, w;
  char t;
  cin >> h >> w;
  for(int i = 0; i < w + 2; i++)
    cout << '#';
  cout << endl;
  for(int i = 0; i < h; i++){
    cout << '#';
    for(int j = 0; j < w; j++){
      cin >> t;
      cout << t;
    }
    cout << '#' << endl;
  }
   for(int i = 0; i < w + 2; i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
/**
 *    author:  erekle
 *    created: 19.09.2020 12:43:24
**/
#include <bits/stdc++.h>

using namespace std;

#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define swap2(x,y) x=x^y; y=x^y; x=x^y;


const int BASE = 998244353;

int main() {
	fastIO
	
	int n, k; cin >> n >> k;
	vector< pair<int, int> > segments;
	for (int i = 0; i < k; ++i) {
		int l, r; cin >> l >> r;
		segments.push_back({l, r});
	}

	vector<long long> dp(1+n);
	for (int i = 1; i <= n; ++i) {
		dp[i] = (dp[i] + dp[i-1]) % BASE;

		if (i == 1) ++dp[i];
		for (pair<int, int> s : segments) {
			if (i + s.first <= n) dp[i + s.first] = (dp[i + s.first] + dp[i]) % BASE;
			if (i + s.second + 1 <= n) dp[i + s.second + 1] = (dp[i + s.second + 1] - dp[i] + BASE) % BASE;
		}
		if (i == 1) --dp[i];
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 4776
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]

ctr = defaultdict(int)

for i in range(N):
    tmp = [0] * 26
    for j in range(10):
        tmp[ord(S[i][j]) - ord("a")] += 1
    ctr[tuple(tmp)] += 1

ans = 0
for v in ctr.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 163064
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	
	int N;
	cin >> N;
	vector<lli> A(N);
	lli allsum = 0, evensum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i % 2) {
			evensum += A[i];
		}

		allsum += A[i];
	}

	vector<lli> ans(N);
	ans[0] = allsum - 2 * evensum;
	for (int i = 1; i < N; i++) {
		ans[i] = 2 * A[i - 1] - ans[i - 1];
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << " \n"[i == N - 1];
	}

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.



int main() {
    int N,M,C, count, sum;
    cin >> N >> M >> C;
    int a[N+1][M];
    count = 0 ;

    for (int i = 0; i < N+1; ++i)
    {
    	for (int j = 0; j < M ; ++j)
    	{
    		cin >> a[i][j];
    	}
    }

    for (int i = 1; i < N+1; ++i)
    {
    	sum = 0;
    	sum = sum +C;

    	for (int j = 0; j < M; ++j)
    	{
    		sum = sum +a[i][j]*a[0][j];
    	}
    	if (sum > 0)
    	{
    		count ++;
    	}
    }

    cout << count<<endl;  
   

   return 0;
}

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

#define ll long long
#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()

ll dp[105][4][2]; //i桁目, 0以外の数, Nより小さい確定のとき=0

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n;
    ll k;
    cin >> n;
    cin >> k;
    dp[0][0][0] = 1;
    
    rep(i,0,n.size()) rep(j,0,4) rep(m,0,2){
        int nd = n[i] - '0';
        rep(d,0,10){
            int ni = i+1 ,nj = j,nm = m;
            if(d != 0) nj++;
            if(nj > k) continue;
            if(m == 0){
                if(d > nd) continue;
                if(d < nd) nm = 1;
            }
            dp[ni][nj][nm] += dp[i][j][m];
        }
    }
    cout << dp[n.size()][k][0] + dp[n.size()][k][1] << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

	60 88 34
	92 41 43
	65 73 48
	10
	60
	43
	88
	11
	48
	73
	65
	41
	92
	34

	`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	a := [][]int{
		{nextInt(), nextInt(), nextInt()},
		{nextInt(), nextInt(), nextInt()},
		{nextInt(), nextInt(), nextInt()},
	}
	n := nextInt()
	for j := 0; j < n; j++ {
		b := nextInt()
		for x := 0; x < 3; x++ {
			for y := 0; y < 3; y++ {
				if a[y][x] == b {
					a[y][x] = 0
				}
			}
		}
	}

	ans := "No"
	for i := 0; i < 3; i++ {
		if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) || (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) {
			ans = "Yes"
			break
		}
	}
	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) || (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) {
		ans = "Yes"
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

struct Sieve {
  vector<int> p;
  Sieve(int n) : p(n + 1, 1) {
    for (int i = 2; i <= n; ++i) {
      if (p[i] == 1) {
        p[i] = i;
        for (int j = 2 * i; j <= n; j += i) p[j] = i;
      }
    }
  }

  vector<P> fact(int x) {
    map<int, int> mp;
    while (x != 1) {
      ++mp[p[x]];
      x /= p[x];
    }
    vector<P> f;
    for (auto p : mp) f.emplace_back(p.first, p.second);
    return f;
  }
};

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  Sieve sieve(1e6 + 1);

  int g = a[0];
  rep(i, n) g = gcd(g, a[i]);
  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  set<int> s;
  rep(i, n) {
    auto f = sieve.fact(a[i]);
    for (auto p : f) {
      if (s.find(p.first) != s.end()) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      s.insert(p.first);
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}


Measured memory_bytes: 11144