akhauriyash/Code-Regression huggingface dataset:
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
 int n;
 vector<bool> res;
bool work(const string &s) {
    for (int i = 1; i < n - 1; i++) {
        if(s[i] == 'o') {
            if(res[i]) {
                res[i + 1] = !res[i - 1];
            } else {
                res[i + 1] = res[i - 1];
            }
        } else {
            if(res[i]) {
                res[i + 1] = res[i - 1];
            } else {
                res[i + 1] = !res[i - 1];
            }
        }
    }
    bool f1, f2;
    f1 = f2 = 0;
    if(s[n - 1] == 'o') {
        if(res[n - 1]) {
            f1 =  res[n - 2] != res[0];
        } else {
            f1 =  res[n - 2] == res[0];
        }
    } else {
        if(res[n - 1]) {
            f1 =  res[n - 2] == res[0];
        } else {
            f1 =  res[n - 2] != res[0];
        }
    }

    if(s[0] == 'o') {
        if(res[0]) {
            f2 =  res[n - 1] != res[1];
        } else {
            f2 =  res[n - 1] == res[1];
        }
    } else {
        if(res[0]) {
            f2 =  res[n - 1] == res[1];
        } else {
            f2 =  res[n - 1] != res[1];
        }
    }
    return f1 && f2;
}
void pr() {
    for (int i = 0; i < n; i++) {
        if(res[i]) cout << 'W';
        else cout << 'S';
    }
    cout << endl;
}
void solve() {
    string s;
    while(cin >> n) {
        cin >> s;
        res.clear();
        res.resize(n);
        res[0] = res[1] = 0;
        bool f = work(s);
        if(f) {
            pr();
            continue;
        }
        res[0] = res[1] = 1;
        f = work(s);
        if(f) {
            pr();
            continue;
        }
        res[0] = 1; res[1] = 0;
        f = work(s);
        if(f) {
            pr();
            continue;
        }
        res[0] = 0; res[1] = 1;
        f = work(s);
        if(f) {
            pr();
            continue;
        }
        cout << -1 << endl;
    }
}
int main() {
  //  freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 592
N = int(input())
A = list(map(int,input().split()))
s = [0]*N
for i in range(N):
    s[i] = s[i-2]+A[i]

dp = [0]*N
for n in range(N):
    if n%2==1:
        dp[n] = max(A[n]+dp[n-2],s[n-1])
    else:
        dp[n] = max(A[n]+dp[n-2],dp[n-1])

print(dp[-1])

Measured memory_bytes: 94204
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
struct node{int x,y;}p[300300];
bool operator <(node p,node q) {return p.x<q.x;}
int w,h,ans=0,n,seg[1200200],tag[1200200],sta[2][300300];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void pushdown(int id)
{
	if (tag[id])
	{
		seg[id<<1]+=tag[id];
		tag[id<<1]+=tag[id];
		seg[id<<1|1]+=tag[id];
		tag[id<<1|1]+=tag[id];
		tag[id]=0;
	}
}

void build(int id,int l,int r)
{
	seg[id]=h<<1;tag[id]=0;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(id<<1,l,mid);build(id<<1|1,mid+1,r);
}

void modify(int id,int l,int r,int ql,int qr,int val)
{
	if (ql>qr) return;
	if ((l>=ql) && (r<=qr))
	{
		seg[id]+=val;tag[id]+=val;
		return;
	}
	pushdown(id);
	int mid=(l+r)>>1;
	if (ql<=mid) modify(id<<1,l,mid,ql,qr,val);
	if (qr>mid) modify(id<<1|1,mid+1,r,ql,qr,val);
	seg[id]=max(seg[id<<1],seg[id<<1|1]);
}

void solve()
{
	sort(p+1,p+1+n);
	build(1,1,n);
	int tp0=0,tp1=0;
	sta[0][0]=sta[1][0]=1;
	rep(i,2,n)
	{
		modify(1,1,n,1,i-1,(p[i].x-p[i-1].x)<<1);
		ans=max(ans,seg[1]);
		if (p[i].y>=h/2)
		{
			modify(1,1,n,sta[0][tp0],i-1,(p[i].y-h)<<1);
			while ((tp0) && (p[sta[0][tp0]].y>=p[i].y))
			{
				int delta=p[i].y-p[sta[0][tp0]].y;
				modify(1,1,n,sta[0][tp0-1],sta[0][tp0]-1,delta*2);
				tp0--;
			}
			sta[0][++tp0]=i;
		}
		else
		{
			modify(1,1,n,sta[1][tp1],i-1,-(p[i].y<<1));
			while ((tp1) && (p[sta[1][tp1]].y<=p[i].y))
			{
				int delta=p[sta[1][tp1]].y-p[i].y;
				modify(1,1,n,sta[1][tp1-1],sta[1][tp1]-1,delta*2);
				tp1--;
			}
			sta[1][++tp1]=i;
		}
	}
}

int main()
{
	w=read();h=read();n=read();
	rep(i,1,n) {p[i].x=read();p[i].y=read();}
	p[++n].x=w;p[++n].y=h;
	solve();
	swap(w,h);
	rep(i,1,n) swap(p[i].x,p[i].y);
	solve();
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll n,m;
    cin>>n>>m;
    char grid[n][m];
    for(ll i=0;i<n;i++)
      for(ll j=0;j<m;j++)
      {
        cin>>grid[i][j];
      }
    ll dp[n][m];
    for(ll i=0;i<n;i++)
    {
      for(ll j=0;j<m;j++)
      {
        if(i==0 and j==0)
        {
          dp[i][j]=1;
          continue;
        }
        if(grid[i][j]=='.')
        {
            if(i==0 and j-1>=0)
            {
              dp[i][j]=dp[i][j-1];
            }
            else if(j==0 and i-1>=0)
            {
               dp[i][j]=dp[i-1][j];
            }
            else
            {
              dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;  
            }
        }
         else
          dp[i][j]=0;
      }
    }
    cout<<dp[n-1][m-1];  
   
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define int long long

int N;
signed main(){
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    
    int ans = 0;
    int minimum = INT_MAX;
    for(int i: P){
        if(minimum > i) ans++;
        minimum = min(i, minimum);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
def main(argv)
  n = gets.chomp.to_i
  d = gets.chomp.split(' ').map(&:to_i)
  
  s = d.reduce(:+)
  t = d.map{|x| x ** 2}.reduce(:+)
  
  puts (((s ** 2) - t) / 2).to_s
end

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

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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

vector<int> G[100000];

vector<int> bfs(int n,int s){
  vector<int> dist(n,1e9),visited(n);
  dist[s]=0;
  visited[s]=1;
  queue<int> que;
  que.push(s);
  while(!que.empty()){
    int i = que.front();
    que.pop();
    rep(j,G[i].size()){
      int to = G[i][j];
      if (visited[to]!=1) {
        visited[to]=1;
        dist[to] = dist[i]+1;
        que.push(to);
      }
    }
  }
  return dist;
}

signed main(){

  int n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  vector<int> dist = bfs(n,s);
  vector<int> dist_r = bfs(n,t);
  int min_dist = dist[t];

  vector<int> dd(min_dist,0),dd_r(min_dist,0);
  rep(i,n){
    if (dist[i]<=min_dist-2)dd[dist[i]]++;
    if (dist_r[i]<=min_dist-2)dd_r[dist_r[i]]++;
  }
  long long sum = 0;
  for(int i=0;i<min_dist-1;i++){
    sum += dd[i]*dd_r[min_dist-2-i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e3+10;
int dp[MAX][MAX];
int let[MAX][MAX], ant[MAX][MAX];
int s1[MAX], s2[MAX];
vector<int> ans;
void cDP(int i, int j)
{
	
}
int main()
{
	int n1, n2;
	string a, b;
	cin >> a; cin >> b;
	if(a.size() < b.size()) swap(a,b);
	n1 = a.size(); n2 = b.size(); // n1>=n2
	for(int i=0;i<n1;i++) s1[i+1] = a[i] - 'a'; a.clear();
	for(int i=0;i<n2;i++) s2[i+1] = b[i] - 'a'; b.clear();
	for(int i=1;i<=n1;i++) for(int j=1;j<=n2;j++)
	{
		if(s1[i] == s2[j])
		{
			dp[i][j] = dp[i-1][j-1] + 1;
			ant[i][j] = 2; let[i][j] = s1[i];
		}
		else
		{
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			if(dp[i][j] == dp[i-1][j]) ant[i][j] = 1;
		}
	}
	int i=n1,j=n2;
	while(i>0 && j>0)
	{
		if(ant[i][j] == 2)
		{
			ans.push_back(let[i][j]);
			i--; j--; continue;
		}
		if(ant[i][j]) i--;
		else j--;
	}
	for(int i = ans.size()-1;i>=0;i--) printf("%c",'a'+ans[i]);
}

Measured memory_bytes: 106368
#include <bits/stdc++.h>
using namespace std;
const int INF=100000000;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin>>x[i];
  
  long long ans=INF;
  for(int p=1;p<=100;p++){
    long long res=0;
    for(int i=0;i<n;i++){
      int a=x[i]-p;
      res+=a*a;
    }
    ans=min(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;
}


int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length() - 1; i++)
    {
        if (s[i] == s[i+1])
        {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
  {
  static void Main()
    {
    int n = int.Parse(Console.ReadLine());
    if(n ==1)
      {
      Console.WriteLine("Hello World");
      }
    else
      {
      int a = int.Parse(Console.ReadLine());
      int b = int.Parse(Console.ReadLine());
      Console.WriteLine(a+b);
      }
    }
  }

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

int insertion_sort(int N, int A[]){
    for (int i=1; i<N; i++){
        int v = A[i];
        int j = i-1;
        while (j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (int k=0; k<N; k++){
         if (k==N-1) cout << A[k] << "\n";
         else cout << A[k] << " ";
        }
    }
}

int main(){
    int N;
    cin >> N;
    int A[N] = {};
    for (int i=0; i<N; i++){
        cin >> A[i];
        if (i==N-1) cout << A[i] << "\n";
        else cout << A[i] << " ";
    }
    insertion_sort(N,A);
    
    return 0;
}


Measured memory_bytes: 3088
d0 = [int(i) for i in input().split()]
d1 = [int(i) for i in input().split()]
d2 = [int(i) for i in input().split()]


x0 = d1[0]-d0[0]
x1 = d2[0]-d0[0]

y0 = d1[1]-d0[1]
y1 = d2[1]-d0[1]

z0 = d1[2]-d0[2]
z1 = d2[2]-d0[2]


i0 = d0[1]-d0[0]
i1 = d0[2]-d0[0]

j0 = d1[1]-d1[0]
j1 = d1[2]-d1[0]

k0 = d2[1]-d2[0]
k1 = d2[2]-d2[0]

if (x0 == y0) and (x0 == z0) and (x1 == y1) and (x1 == z1):
    if (i0 == j0) and (i0 == k0) and (i1 == j1) and (i1 == k1):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
struct edge{
	int to,cap,cost,rev;
};
typedef vector<edge> ve;
typedef vector<ve> vve;
class MCF{	//Minimum Cost Flow
	public:
	int n;
	vve G;
	vi h,dist,prev,pree;
	MCF(int size){
		n=size;
		G=vve(n);
		h=dist=prev=pree=vi(n);
	}
	void add_edge(int s,int t,int ca,int co){
		edge e={t,ca,co,G[t].size()};
		G[s].pb(e);
		edge ee={s,0,-co,G[s].size()-1};
		G[t].pb(ee);
	}
	int mcf(int s,int t,int f){
		int out=0;
		h=vi(n);
		while(f>0){			
			priority_queue<pii,vector<pii> >q;
			dist=vi(n,inf);
			dist[s]=0;
			q.push(pii(0,s));
			while(!q.empty()){
				pii p=q.top();q.pop();
				int v=p.second;
				if(dist[v]<-p.first)continue;
				rep(i,G[v].size()){
					edge &e=G[v][i];
					if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
						dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
						prev[e.to]=v;
						pree[e.to]=i;
//						cout<<" "<<dist[e.to]<<endl;
						q.push(pii(-dist[e.to],e.to));
					}
				}
			}
//			rep(i,n)dist[i]*=-1;
//			rep(i,n)cout<<dist[i]<<endl;
			if(dist[t]==inf)return -1;
			rep(i,n)h[i]+=dist[i];
			int d=f;
			for(int v=t;v!=s;v=prev[v])d=min(d,G[prev[v]][pree[v]].cap);
			f-=d;
			out+=d*h[t];
			for(int v=t;v!=s;v=prev[v]){
				edge &e=G[prev[v]][pree[v]];
				e.cap-=d;
				G[v][e.rev].cap+=d;
			}
//			cout<<f<<endl;
		}
		return out;	
	}
};
int main(){
	int n,m,f;
	cin>>n>>m>>f;
	MCF mcf(n);
	while(m--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		mcf.add_edge(a,b,c,d);
	}
	cout<<mcf.mcf(0,n-1,f)<<endl;;
}

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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(3 * n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(3 * i) >> a.at(3 * i + 1) >> a.at(3 * i + 2);
  }
  sort(a.begin(), a.end());

  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a.at(n + 2 * i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 2560
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(A[K - 1])

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <vector>
using namespace std;

int main(){
    string S;
    cin >> S;
    int N =S.size()-1;
    long long sum;
    long long ans = 0;
    for(int bit = 0;bit < (1<<N);++bit){
        sum = S[0] - '0';
        for(int i = 0;i < N;++i){
            if(bit&(1<<i)){
                ans += sum;
                sum = S[i+1]-'0';
            }else sum = sum*10 + S[i+1] - '0';
        }
        ans += sum;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    long x,a,b;
    scanf("%ld%ld%ld",&x,&a,&b);
    if(a>=b) printf("delicious");
    else if((b-a)<=x) printf("safe");
    else printf("dangerous");
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

vector<int> v;
void compute() {

}

int cost(int L,int R,int K) {
  priority_queue<int> Q;
  int sum = 0;
  rep(i,L) {
    if( v[i] < 0 ) Q.push(-v[i]);
    sum += v[i];
  }
  rep(i,R) {
    int j = (int)v.size()-1-i;
    if( v[j] < 0 ) Q.push(-v[j]);
    sum += v[j];
  }
  rep(i,K) {
    if( Q.empty() ) break;
    int cur = Q.top(); Q.pop();
    sum += cur;
  }
  return sum;
}

int main() {
  int n,K;
  cin >> n >> K;
  v.resize(n);
  rep(i,n) cin >> v[i];
  int maxi = 0, sumL = 0, sumR = 0;
  rep(useL,n+1) {
    rep(useR,n+1) {
      int used = useL + useR;
      if( used > K ) break;
      if( used > n ) break;
      int rem = K - used;
      rep(useK,rem+1) {
	maxi = max(maxi,cost(useL,useR,rem));
      }
    }
  }
  cout << maxi << endl;
  compute();
  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(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d )
        cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;

    return 0;
}


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

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    int N = S.size();

    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 3584
<?php
list($n) = ints();
$ans = '';
while ($n !== 0) {
    --$n;
    $ans .= chr(97 + $n % 26);
    $n = intdiv($n, 26);
}
echo strrev($ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

signed main() {
    int n, bit_k[63] = {}, bit_sum[63][2] = {};
    long long k, a, ans;
    bool islimit;

    cin >> n >> k;

    for(int i=0 ;i<63 ;i++ ) {
        bit_k[i] = k%2;
        k = k / 2;
    }

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

        for(int j=0 ;j<63 ;j++ ) {
            bit_sum[j][a%2] += 1;
            a = a / 2;
        }
    }

    islimit = true;
    ans = 0;
    for(int i=62 ;i>=0; i-- ) {
        ans = ans * 2;

        if(islimit) {
            if(bit_k[i] == 0) {
                ans += bit_sum[i][1];
            }
            else {
                if(bit_sum[i][1] > bit_sum[i][0]) {
                    islimit = false;       
                }
                ans += max(bit_sum[i][0], bit_sum[i][1]);
            }
        }
        else {
            ans += max(bit_sum[i][0], bit_sum[i][1]);
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int change[26][26];

int main()
{
    string s, t;

    map<char, int> rep1, rep2;
    cin >> s >> t;
    for (auto &c : s)
    {
        rep1[c]++;
    }
    vector<int> mapOfS;
    for (auto &a : rep1)
    {
        mapOfS.push_back(a.second);
    }
    sort(mapOfS.begin(), mapOfS.end());

    for (auto &c : t)
    {
        rep2[c]++;
    }
    vector<int> mapOfT;
    for (auto &a : rep2)
    {
        mapOfT.push_back(a.second);
    }
    sort(mapOfT.begin(), mapOfT.end());

    if (mapOfS == mapOfT)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 1020
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
LL n, k;
LL ans = 0;
/**********************************************/

signed main(){
    cin >> n >> k;
    // bはkより大きい．この時のaは(b-k)個存在するはず…(?)
    
    if(k == 0){
        cout << n * n << endl;
        return 0;
    }

    for(LL b = k+1; b <= n; b++){
        LL num = 0;
        num += n / b * (b-k);
        if(n % b >= k) {
            num +=  n % b - k + 1;
        }
        ans += num;
        }
    cout << ans << endl;

}


Measured memory_bytes: 256
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
ei = {}
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)
    ei[(a,b)] = ei[(b,a)] = i

max_e = root = 0
for i in range(N):
    if len(es[i]) > max_e:
        max_e = len(es[i])
        root = i

ans = [None]*(N-1)
visited = [0]*N
visited[root] = 1
stack = []
for i,to in enumerate(es[root]):
    ans[ei[(root,to)]] = i+1
    visited[to] = 1
    stack.append((to,i+1))

while stack:
    v,pc = stack.pop()
    c = 0
    for to in es[v]:
        if visited[to]: continue
        visited[to] = 1
        c += 1
        if c == pc:
            c += 1
        pi = ei[(v,to)]
        ans[pi] = c
        stack.append((to,c))

print(max(ans))
print(*ans, sep='\n')

Measured memory_bytes: 66968
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[234];

int main()
{
    int n,gh,sum=0;
    scanf("%d",&n);
    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+2*n);
    for(int i=0;i<2*n;i+=2)
    {
        sum+=a[i];
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = list(map(int, input().split()))
c = {}
for i in b:
    if i not in c:
        c[i] = 1
    else:
        c[i] += 1
c = sorted(c.items(), key=lambda x: x[0], reverse=True)
d = 0
for k, v in c:
    if v // 2 == 1:
        if d != 0:
            print(d * k)
            exit()
        else:
            d = k
    elif v // 2 >= 2:
        if d != 0:
            print(d * k)
            exit()
        else:
            print(k ** 2)
            exit()
print(0)


Measured memory_bytes: 21768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;

struct Point{double x, y;};

void show(Point p){
  printf("%.8f %.8f\n", p.x, p.y);
}

void koch(int d, Point p1, Point p5){
  if(d == 0) return ;

  Point v12 = {(p5.x-p1.x)/3, (p5.y-p1.y)/3};
  Point p2 = {p1.x+v12.x, p1.y+v12.y};
  Point p3 = {p1.x+v12.x*3/2+v12.y*(-sqrt(3)/2), p1.y+v12.y*3/2+v12.x*(sqrt(3)/2)};
  Point p4 = {p1.x+v12.x*2, p1.y+v12.y*2};

  koch(d-1, p1, p2);
  show(p2);

  koch(d-1, p2, p3);
  show(p3);

  koch(d-1, p3, p4);
  show(p4);

  koch(d-1, p4, p5);

}

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

  Point start = {0, 0};
  Point goal = {100, 0}; 
  
  show(start);
  koch(n, start, goal);
  show(goal);
 
  return 0;
}







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

int main() {
	int n,t,s,f,g;
	while (cin >> t && t>0) {
	 cin >> n; g=0;
	 for (;n>0;n--) { cin >> s >> f; g+=f-s;}
	 if (g<t) cout << t-g; else cout << "OK";
	 cout << endl;
 }
 return 0;
}  	 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main(){
    ll n; cin >> n;
    ll ans = 0; // self

    const auto &res = enum_divisors(n-1);
    // for (int i = 0; i < res.size(); ++i) cout << res[i] << " ";
    // cout << endl;
    ans += res.size() - 1;

    const auto &res2 = enum_divisors(n);
    for(auto x : res2){
        if(x==1) continue;
        ll nc = n;
        while(nc % x == 0){
            nc = nc / x;
        }
        if(nc % x == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(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 find(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() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n,q;cin>>n>>q;
    UF uf(n+1);
    for(int i=0;i<q;i++){
        int com,x,y;cin>>com>>x>>y;
        if(com){
            cout<<(uf.find(x,y) ? 1 : 0)<<endl;
        }
        else uf.unite(x,y);
    }
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<P>> edges(100010);
vector<ll> dist(100010,0);

void dfs(int i,int p = -1) {
    for (P& j : edges[i]) if (j.first != p) {
        dist[j.first] = dist[i]+j.second;
        dfs(j.first,i);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n-1;++i) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        edges[u].push_back(P(v,w));
        edges[v].push_back(P(u,w));
    }
    dfs(0);
    for (int i = 0;i < n;++i) {
        cout << (dist[i]&1 ? "0" : "1") << "\n";
    }
    // p_ary(dist,0,n,i);
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n;
string s;

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    cin >> s;
    n /= 2;
    if (s.size() % 2 == 0 && s.substr(0, n) == s.substr(n, n))
        cout << "Yes";
    else cout << "No";
    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

bool check(string s, char c) {
	assert(s.size() == 3);
	assert(c == 'o' || c == 'x');

	if (c == 'o') {
		if (s[1] == 'S') {
			if ((s[0] == 'S' && s[2] == 'S') || (s[0] == 'W' && s[2] == 'W')) return true;
			else return false; 
		}
		else if (s[1] == 'W') {
			if ((s[0] == 'S' && s[2] == 'W') || (s[0] == 'W' && s[2] == 'S')) return true;
			else return false; 
		}
	}
	else if (c == 'x') {
		if (s[1] == 'S') {
			if ((s[0] == 'S' && s[2] == 'W') || (s[0] == 'W' && s[2] == 'S')) return true;
			else return false; 
		}
		else if (s[1] == 'W') {
			if ((s[0] == 'S' && s[2] == 'S') || (s[0] == 'W' && s[2] == 'W')) return true;
			else return false; 
		}
	}
}

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

    string t = "";
    bool flag_making;
    // まず1, 2, 3番目を固定して考える(8パターン)
    vector<string> first_t = {"SSS", "SSW", "SWS", "SWW", "WSS", "WSW", "WWS", "WWW"}; 
    REP(i, first_t.size()) {
    	if (check(first_t[i], s[1])) {
    		t = first_t[i];
    		for (int j = 2; j < N; ++j) {
  				char c = s[j];
    			// t が完成したとき
    			if (j == N - 1) {
    				string last_s(3, 'a');
    				last_s[0] = t[j - 1];
    				last_s[1] = t[j];
    				last_s[2] = t[0];
    				string first_s(3, 'a');
    				first_s[0] = t[j];
    				first_s[1] = t[0];
    				first_s[2] = t[1];
    				flag_making = check(last_s, s[j]) && check(first_s, s[0]);
    			}
    			else {
    				if (c == 'o') {
    					if (t[j - 1] == 'S' && t[j] == 'S') t += 'S';
    					else if (t[j - 1] == 'S' && t[j] == 'W') t += 'W';
    					else if (t[j - 1] == 'W' && t[j] == 'S') t += 'W';
    					else if (t[j - 1] == 'W' && t[j] == 'W') t += 'S';
    				}
    				else if (c == 'x') {
    					if (t[j - 1] == 'S' && t[j] == 'S') t += 'W';
    					else if (t[j - 1] == 'S' && t[j] == 'W') t += 'S';
    					else if (t[j - 1] == 'W' && t[j] == 'S') t += 'S';
    					else if (t[j - 1] == 'W' && t[j] == 'W') t += 'W';
    				}
    			}
    		}
    	}
    	if (flag_making) break;
    }

    if (flag_making) cout << t << endl;
    else cout << "-1" <<endl;
}


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

string dfs(int n){
	if( n == 0 ) return "";
	if ( n % 3 == 2 ){
		return dfs((n+2)/3) + "-";
	}else if( n % 3 == 1 ){
		return dfs(n/3) + "+";
	}else if( n % 3 == 0 ){
		return dfs(n/3) + "0";
	}
	
}
int main(){
	int n;
	cin >> n;
	cout << dfs(n) << endl;

}

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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------

void Main()
{
    lint A, B, C;
    cin >> A >> B >> C;
    if(A+B+C >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }

    // cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

bool dprime[1000000] = { false };
void dPrime() {
	dprime[1] = true;
	for (int i = 2; i*i<1000000; i++) {
		if (!dprime[i]) {
			for (int j = 2 * i; j<1000000; j += i) {
				dprime[j] = true;
			}
		}
	}

	return;
}

int main() {
	dPrime();
	int n, a, d;
	while (cin >> a >> d >> n&&a&&d&&n) {
		int count = 0;
		for (int i = a;; i += d) {
			if (!dprime[i]) count++;
			if (count == n) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
    int a[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	sort(a,a+4);
	if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> a(3);
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		if (x <= A) ++ a[0];
		else if (x <= B) ++ a[1];
		else ++ a[2];
	}
	cout << min(min(a[0],a[1]),a[2]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << en; cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << en; cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll n, x=0, m=0, y=0, d=1, k=mod;
		cin >> n >> m;
		ll a[n + 1], v[n + 1];
		ll dp[n + 1][m + 1] = {};
		
		for(int i = 1; i <= n; i++)
			cin >> a[i] >> v[i];		
		
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				if(j >= a[i])
					dp[i][j] = max(v[i] + dp[i - 1][j - a[i]], dp[i - 1][j]);
				else
					dp[i][j] = dp[i - 1][j];
			}
		}
		cout << dp[n][m] << endl;
	}
}

Measured memory_bytes: 79232
from scipy.special import comb

N, P = map(int, input().split())
A = list(map(int, input().split()))

o,e = 0,0
for a in A:
    if a%2==0:
        e+=1
    else:
        o+=1

if P == 0:
    # select even cnt from o
    t = 0
    for i in range(0, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)
else:
    t = 0
    for i in range(1, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)





Measured memory_bytes: 42400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  map<ll,int> m;
  ll sum=0;
  rep(i,0,n){
    m[a[i]]++;
    sum+=a[i];
  }
  int q;
  cin>>q;
  rep(i,0,q){
    ll b,c;
    cin>>b>>c;
    if(m.count(b)){
      sum+=m[b]*(c-b);
      m[c]+=m[b];
      m.erase(b);
    }
    cout<<sum<<endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

int n;
vector<int> v;

int main() {
    while(cin>>n) {
        v.clear();
        rep(i,2*n) {
            int a;cin>>a;
            v.pb(a);
        }
        sort(ALL(v));
        int ans = 0;
        for(int i=0; i<2*n; i+=2) {
            ans += min(v[i], v[i+1]);
        }

        cout << ans << "\n";
    }

    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a > x || a + b < x) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define int long long 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
//ll a[1000010];
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

signed main(){

    ll n,k;
    cin>>n>>k;
    vector<int>a(n);
    ll sum=0;
    
    REP(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    for (int i = 0; i < n; i++)
    {
        sum+=a[i];
    }
   /* if(k>=sum){
        cout<<sum<<endl;
        return 0;
    }*/
   // cerr<<sum<<endl;
    vector<ll>v;
    for (ll i = 1; i*i<=sum ; i++)
    {
        if(sum%i==0){
        v.push_back(i);
        if(i*i!=sum)
        v.push_back(sum/i);
        }
    }
    //これの答えが候補
    sort(v.rbegin(),v.rend());
    for (int i = 0; i < v.size(); i++)
    {
        vector<int>amari;
        for (int j = 0; j < n; j++)
        {
            amari.push_back(a[j]%v[i]);    
        }
        sort(amari.rbegin(),amari.rend());
        
        for (int l = 0; l < amari.size(); l++)
        {
            ll sum=0;
            for (int j = 0; j < l; j++)
            {
                   sum+=v[i]-amari[j];  
               
            }
       //     cerr<<sum<<"a"<<endl;
            if(sum>k) continue;
            for (int j = l; j < amari.size(); j++)
            {
                    sum-=amari[j];
            }
          //  cerr<<sum2<<"b"<<sum<<endl;
            if(sum==0) {
                cout<<v[i]<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
t = defaultdict(int)
n = int(input())
for i in range(n):
    s = input()
    t[s]+=1
print("AC x "+str(t["AC"]))
print("WA x "+str(t["WA"]))
print("TLE x "+str(t["TLE"]))
print("RE x "+str(t["RE"]))

Measured memory_bytes: 9488
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int f(int X) {
  if (X == 0) return 0;
  int pc = __builtin_popcount(X);
  return f(X % pc) + 1;
}
signed main() {
  int N;
  cin >> N;
  string X;
  cin >> X;

  int pc = 0;
  rep(i, 0, N) {
    if (X[i] == '1') pc++;
  }

  auto f_first = [&](int pc) {
    int t = 0;
    int p = 1;
    rrep(i, 0, N) {
      if (X[i] == '1') {
        t = (t + p) % pc;
      }
      p = p * 2 % pc;
    }
    return t;
  };

  int pc_x = pc - 1;
  int f_x = -1;
  if (pc_x > 0) f_x = f_first(pc_x);

  int pc_z = pc + 1;
  int f_z = -1;
  if (pc_z > 0) f_z = f_first(pc_z);

  int p_x = 1, p_z = 1;
  vi ans(N);
  rrep(i, 0, N) {
    if (X[i] == '0') {
      if (pc_z == 0) {
        ans[i] = 0;
      } else {
        int t = (f_z + p_z + pc_z) % pc_z;
        ans[i] = f(t) + 1;
      }
    } else {
      if (pc_x == 0) {
        ans[i] = 0;
      } else {
        int t = (f_x - p_x + pc_x) % pc_x;
        ans[i] = f(t) + 1;
      }
    }

    if (pc_x > 0) p_x = p_x * 2 % pc_x;
    if (pc_z > 0) p_z = p_z * 2 % pc_z;
  }
  for (int x : ans) cout << x << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 5176
#include<stdio.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>

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

using namespace std;

int main(){
  int n;
  int cnt=0;

  scanf("%d", &n);
  vector<int> vi(n+1);
  FOR(i,1,n+1){
    scanf("%d", &vi[i]);
  }
  FOR(i,1,n){
    if(i == vi[i]){
      swap(vi[i],vi[i+1]);
      ++cnt;
    }
  }
  if(n == vi[n]){
    swap(vi[n-1],vi[n]);
    ++cnt;
  }
  printf("%d\n",cnt);

  return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vi a(n) ;
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  ll cnt = 0;
  rep(i,n-1){
    if(a[i]==a[i+1])cnt++;
  }
  cout << n-(cnt+1)/2*2 << endl;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;

int main()
{
    int n;
    long long a,s=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
         cin>>a;
         s += a-1;
    }
        
    cout << s;
    return 0;
}


Measured memory_bytes: 256
def gcd(m, n):
    if m < n:
        return gcd(n, m)
    elif n == 0:
        return m
    return gcd(n, m % n)

def gcd_list(lst):
    ans = lst[0]
    for e in lst:
        ans = gcd(ans, e)
    return ans

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K <= max(A) and K % gcd_list(A) == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14480
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	int dp[10001]{};
	for (int c = 0; c < a; c++) {
		int d, e;
		cin >> d >> e;
		for (int f = e; f <= b; f++) {
			dp[f] = max(dp[f], dp[f - e] + d);
		}
	}
	cout << dp[b] << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int i=0;
char AC[10];
int main()
{
    cin.getline(AC,10);
    for(int i=0;i<10;i++)
    {
        if(AC[i]=='A'&&AC[i+1]=='C')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        int x = i;
        if (x % 3 != 0 && x % 5 != 0) {
            sum += x;
        }
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 3664
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int a = in.nextInt();
       int b = in.nextInt();
       if (a < b) System.out.println("a < b");
       else if(a > b) System.out.println("a > b");
       else System.out.println("a == b");
    }
}

Measured memory_bytes: 17216
import java.io.*;

public class Main {

    public static void main(String[] argv) throws IOException {
        //*
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while(true) {
            String s = in.readLine();
            if (s == null) {
                break;
            }
            f(s);
        }
        //*/
    }

    public static void f(String s) {
        int n = Integer.parseInt(s);
        int count = 0;
        for(int a = 0; a < 10; a++)
        for(int b = 0; b < 10; b++)
        for(int c = 0; c < 10; c++)
        for(int d = 0; d < 10; d++)
            if (a+b+c+d == n) count++;
        System.out.println(count);
    }
}

Measured memory_bytes: 9372
#include<iostream>

using namespace std;

int main(void){
	int hisi,chouhoukei,length[3];
	hisi=chouhoukei=0;
	while(scanf("%d,%d,%d",&length[0],&length[1],&length[2])!=EOF){
		
		
		
		if(length[0]==length[1]){
			hisi++;
		}
		else if(length[0]*length[0]+length[1]*length[1]==length[2]*length[2]){
			chouhoukei++;
		}
	}
	cout<<chouhoukei<<endl<<hisi<<endl;
}

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

int main(){
    int A, B; cin >> A >> B;
    if(A == 1) A = 14;
    if(B == 1) B = 14;

    if(A < B) cout << "Bob" << endl;
    else if(A > B) cout << "Alice" << endl;
    else cout << "Draw" << endl;
    
    return 0;
}

Measured memory_bytes: 256
//For fast competitive programming

//INCLUDE
#include <bits/stdc++.h>
using namespace std;

//DATA_TYPES
typedef long long ll; 
typedef vector<int> vi;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f; //Infinity

//INITIALISING
//memset(arr, 0, sizeof arr);
//vi v(N, 0);

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(NULL);
	
	//write your code here
	int t;
	cin>>t;
/*	for(int z=0;z<t;z++)
	{
	cout<<"Case #"<<z+1<<":";
	//take inputs for TC
*/	
//int no =0;
	if ((t %10)==7)
	{cout<<"Yes"<<endl;
	    return 0;
	}
	t=t/10;
	if ((t %10)==7)
	{cout<<"Yes"<<endl;
	    return 0;
	}
	t=t/10;
	if (t==7)
	{cout<<"Yes"<<endl;
	    return 0;
	}
	
	cout<<"No"<<endl;
	

	
	
	return 0;
}

Measured memory_bytes: 3636