akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

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

struct RMQ {
  pair<int, int> DEF;
  int n;
  vector<pair<int, int> > d;
  
  RMQ(int n) {
    DEF = make_pair(-1e9, 1e9);
    this-> n = n;
    d.resize(2 * n - 1);
    rep (i, 2 * n - 1) d[i] = DEF;
  }

  void update(int k, int a) {
    k += n - 1;
    d[k] = make_pair(a, k - (n - 1));
    while (k > 0) {
      k = (k - 1) / 2;
      d[k] = function(d[k * 2 + 1], d[k * 2 + 2]);
    }
  }

  pair<int, int> query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return DEF;
    if (a <= l && r <= b) return d[k];
    pair<int, int> vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    pair<int, int> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return function(vl, vr);
  }

  pair<int, int> query(int a, int b) {
    return query(a, b, 0, 0, n);
  }

  pair<int, int> function(pair<int, int> l, pair<int, int> r) {
    if (l.first > r.first) return l;
    if (l.first < r.first) return r;
    if (l.second < r.second) return l;
    return r;
  }
};

int main() {
  int n, r, l;
  cin >> n >> r >> l;
  int score[n], res[n];
  RMQ rmq(n);
  rep (i, n) rmq.update(i, 0);
  rep (i, n) rmq.update(i, 0);
  rep (i, n) res[i] = 0;
  rep (i, n) score[i] = 0;
  int pre = 0;
  rep (i, r) {
    int d, t, x;
    cin >> d >> t >> x;
    int k = rmq.query(0, n).second;
    res[k] += t - pre;
    --d;
    score[d] += x;
    rmq.update(d, score[d]);
    pre = t;
  }
  int k = rmq.query(0, n).second;
  res[k] += l - pre;
  int mi = 0, mx = 0;
  rep (i, n) if (mx < res[i]) {
    mi = i;
    mx = res[i];
  }
  cout << mi + 1<< endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)

ll n,a[100005],dp[100005];

ll f(int i)
{
    if(i==n-1)return dp[i]=abs(a[n]-a[i]);
    if(i==n)return dp[i]=0;
    if(dp[i]!=-1)return dp[i];

    return dp[i]=min(abs(a[i]-a[i+1])+f(i+1),abs(a[i]-a[i+2])+f(i+2));
}

int main()
{
    fastio;

    ll i;
    cin >> n;
    for(i=1;i<=n;i++)cin >> a[i];
    memset(dp,-1,sizeof(dp));
    cout << f(1);

    return 0;
}


Measured memory_bytes: 3328
s=input()
n=len(s)-1

for i in range(2**n):
    op=['-']*n
    for j in range(n):
        if ((i>>j)&1):
            op[n-1-j]='+'

    formula=''
    for x,y in zip(s,op+['']):#sとopの長さをそろえている(多分
        formula+=(x+y)
    if eval(formula)==7:
        print(formula+'=7')
        break

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  
  cout<<0<<endl;
  string S;
  cin>>S;
  VI X(N);
  if(S=="Vacant") return 0;
  if(S=="Male") X[0]=1;
  else X[0]=2;
  
  cout<<N-1<<endl;
  cin>>S;
  if(S=="Vacant") return 0;
  if(S=="Male") X[N-1]=1;
  else X[N-1]=2;
  
  int L=0;
  int R=N-1;
  rep(i,18){
    int mid=(L+R)/2;
    cout<<mid<<endl;
    cin>>S;
    if(S=="Vacant") return 0;
    if(S=="Male") X[mid]=1;
    else X[mid]=2;
    if((mid-L)%2){
      if(X[L]!=X[mid]) L=mid;
      else R=mid;
    }else{
      if(X[L]!=X[mid]) R=mid;
      else L=mid;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define maxn 500010
using namespace std;
struct node{
	int v,nxt;
}e[maxn<<2];
int n,m;
int head[maxn],cnt;
void add(int u,int v){
	e[++cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;
}
int col[maxn];
bool dfs(int u,int f){
//	printf("%d %d %d %d\n",u,col[u],f,col[f]);
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(!col[v]){
			col[v]=col[u]^1;
			if(!dfs(v,u))return 0;
		}
		else if(col[v]==col[u]){
			col[v]=col[u]=2;
			return 0;
		}
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	col[1]=1;
	int ty=dfs(1,0);
/*	for(int i=1;i<=n;i++){
		printf("%d ",col[i]);
	}cout<<endl;*/
	ll c0=0,c1=0,c2=0;
	for(int i=1;i<=n;i++){
		if(col[i]==0)c0++;
		else if(col[i]==1)c1++;
		else c2++;
	}
	if(ty){
		ll ans=(ll)c0*c1-(ll)m;
		printf("%lld\n",ans);
	}
	else{
		ll ans=(ll)n*(n-1)/2-(ll)m;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8704
s = list(input())
if s[0] != 'A':
    print('WA')
elif s[2:-1].count('C') != 1:
    print('WA')
else:
    i = s.index('C')
    s.pop(i)
    s.pop(0)
    s = ''.join(s)
    if s.islower():
        print('AC')
    else:
        print('WA')

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

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  if(n < 3){
    cout << 0 << endl;
    return 0;
  }
  
  ll r=0, g=0, b=0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  ll ans = r*g*b;
  
  for(int j = 0; j < n; j++){
    for(int i = 0; i < j; i++){
      int k = j+j-i;
      if(k < n){
        if(s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i)) ans--;
      }
    }
  }
  
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3612
N,A,B = map(int,input().split())
count=0
for n in range(1,N+1):
    sumn=0
    strn = str(n)
    for lenn in range(len(strn)):
        if lenn == 0:
            sumn += n%10
        else:

            sumn += int(n/(10**lenn))%10

    if sumn >= A:
        if sumn <= B:
            count+=n
print(count)

Measured memory_bytes: 3064
// AISING2020A.cpp
//#include "pch.h"
#include <iostream>
#include <numeric>
using namespace std;
int main()
{
	int L, R, d;
	cin >> L>> R>> d;
	int f[110] = {};
	int now = 0;
	int ans = 0;
	while(now<=100)
	{
		now += d;
		f[now] = 1;
	}
	for (int i = L; i <= R; i++) {
		if (f[i] == 1) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    vector<bool> win(k+1);
    rep(i,1,k+1) {
        for(int x:a) {
            if(i-x>=0 && !win[i-x]) win[i] = true;
        }
    }
    if(win[k]) cout << "First\n";
    else cout << "Second\n";
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S =[["."]*(W+2)]

for i in range(H):
    S.append("."+input()+".")
    
S.append("."*(W+2))

for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="."and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2048
module procedure_module
  implicit none
  public

  contains

  recursive function dfs(n, l, ta, tb, tc, cur, a, b, c) result(cost)
    integer, intent(in) :: n, l(:), cur, ta, tb, tc, a, b, c
    integer :: cost, r0, r1, r2, r3
    if (cur > n) then
      if (minval([a, b, c]) > 0) then
        cost = abs(a - ta) + abs(b - tb) + abs(c - tc) - 30
      else
        cost = huge(cost) / 2
      end if
    else
      r0 = dfs(n, l, ta, tb, tc, cur + 1, a, b, c)
      r1 = dfs(n, l, ta, tb, tc, cur + 1, a + l(cur), b, c) + 10
      r2 = dfs(n, l, ta, tb, tc, cur + 1, a, b + l(cur), c) + 10
      r3 = dfs(n, l, ta, tb, tc, cur + 1, a, b, c + l(cur)) + 10
      cost = minval([r0, r1, r2, r3])
    end if
  end function dfs
end module procedure_module

program main
  use procedure_module
  implicit none
  integer :: n, a, b, c
  integer, allocatable :: l(:)
  read (*, *) n, a, b, c
  allocate (l(n))
  read (*, *) l(:)
  write (*, "(i0)") dfs(n, l(:), a, b, c, 1, 0, 0, 0)
end program main


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

int p, r, t;
int L[320], tL[320], R[302][302], tR[302][302];
int P[200020][2];
int End[320];

bool is_dead(int tim){
	rep(i, p)End[i] = 0;
	rep(i, p){
		rep(j, r)tR[i][j] = R[i][j];
	}
	rep(i, r)tL[i] = L[i];
	
	for(int i=0;i<tim;i++){
		int x = P[i][0], y = P[i][1];
		tR[x][y]--, tL[y]--;
	}
	rep(i, p){
		int c = 0;
		for(c=0;c<r;c++)if(tR[i][c] != 0)break;
		
		if(c == r){
			rep(j, r)tL[j] += R[i][j];
			End[i] = 1;
		}
	}
	
	
	while(1){
		int changed = 0;
		rep(i, p){
			if(End[i])continue;
			int c;
			for(c=0;c<r;c++)if(tL[c] < tR[i][c])break;
			
			if(c == r){
				rep(j, r){
					tL[j] += R[i][j] - tR[i][j];
				}
				End[i] = 1;
				changed = 1;
			}
		}
		if(changed == 0)break;
	}
	
	//rep(i, p)printf("%d", End[i]);
	
	bool res = 0;
	rep(i, p)res |= !End[i];
	return res;
}

void solve(int tc){
	scanf("%d%d%d", &p, &r, &t);
	for(int i=0;i<r;i++)scanf("%d", L+i);
	for(int i=0;i<p;i++){
		for(int j=0;j<r;j++)scanf("%d", R[i]+j);
	}
	for(int i=0;i<t;i++)scanf("%d%d", P[i], P[i]+1);
	for(int i=0;i<t;i++)P[i][0]--, P[i][1]--;
	
	int low = 1, high = t, ans = -1;
	while(low <= high){
		int mid = (low + high) / 2;
		if(is_dead(mid))ans = mid, high = mid - 1;
		else low = mid + 1;
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1;// scanf("%d",&Tc);
	for(int i=1;i<=Tc;i++){
		solve(i);
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,A; cin >> N >> A;
    if(N%500 <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll n,ans=1,x=0,y=0,a[100005];
bool flag;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n;
  REP(i,n)cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  REP(i,n){
    if(a[i]==a[i+1]){
      ans*=a[i];
      if(flag)break;
      i++;
      flag=true;
    }
    if(i==n-1)ans=0;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int n;
int main(){
	while(cin >> n){
		for(int i=1;i<=n;i++){
			bool judge = false;
			if(i%3==0) judge = true;
			int j = i;
			while(j>0 && !judge){
				if(j%10==3) judge = true;
				j /= 10;
			}
			if(judge) cout << " " << i;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
n = int(input())
a = list(map(int, input().split()))

cnt = [[0] * 2 for _ in range(61)]

for i in range(61):
    mask = 1 << i
    for j in range(n):
        if mask & a[j] >= 1:
            cnt[i][1] += 1
        elif mask & a[j] == 0:
            cnt[i][0] += 1
        else:
            continue

ans = 0
mod = 10**9 + 7
for i in range(61):
    ans += cnt[i][1] * cnt[i][0] * pow(2, i, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 125624
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    string s;
    cin >> s;
    cout << string(s.size(), 'x') << endl;
    return 0;
}

Measured memory_bytes: 256
#49 ABC129E
#桁DP
mod=10**9+7
l=input()
n=len(l)
dp1,dp2=[0]*n,[0]*n
dp1[0],dp2[0]=1,2
for i in range(1,n):
	if l[i]=="1":
		dp1[i]=(3*dp1[i-1]+dp2[i-1])%mod
		dp2[i]=(2*dp2[i-1])%mod
	else:
		dp1[i]=(3*dp1[i-1])%mod
		dp2[i]=dp2[i-1]%mod
print((dp1[n-1]+dp2[n-1])%mod)

Measured memory_bytes: 41456
n, k = map(int, raw_input().strip().split())

if k == 0:
    print n ** 2
    exit()

total = 0
for m in xrange(k + 1, n + 1):
    # print "m: %s" % (m,)
    total += n / m * (m - k)
    # print "n / m * (m - k): %s" % (n / m * (m - k),)
    total += max(n % m - (k - 1), 0)
    # print "n rem m - (k - 1): %s" % (max(n % m - (k - 1), 0),)

print total


Measured memory_bytes: 2568
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                ans+=1
print(ans)                


Measured memory_bytes: 9100
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);

		int all=sc.nextInt();
      	int foot=sc.nextInt();
      	int tsuru = all * 2;
      	if (tsuru == foot){
          	System.out.print("Yes");
          	return;
        }else if(tsuru > foot){
          	System.out.print("No");
          	return;
        }else if(tsuru < foot){
          	int kame = foot - tsuru;
          	if(kame/2 <= all && kame%2 == 0){
              System.out.print("Yes");
              return;
            }
          	System.out.print("No");
        }
	}
}

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

int main() {
  int n,m,a,b;
  cin >> n >> m;
  int city[n];
  for (int i = 0; i < n; i++) city[i] = 0;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (int j = 0; j < n; j++) {
      if (a-1== j || b-1==j )  city[j]++;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << city[i] << endl;
  }  
}

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

int main() {
	int a, b, c, x, y, z, ope = 0;
  	cin >> a >> b >> c;
	if (a <= b) {
	    y = a;
	    z = b;
	} else {
	    y = b;
	    z = a;
	}
	if (z <= c) {
	    x = y;
	    y = z;
	    z = c;
	} else if (y <= c) {
	    x = y;
	    y = c;
	} else {
	    x = c;
	}
	if ((z - x) % 2 == 0 && (z - y) % 2 == 0) {
	    ope = ope + ((z - x) / 2) + ((z - y) / 2);
	} else if ((z - x) % 2 == 0 && (z - y) % 2 == 1) {
	    ope = ope + ((z - x) / 2) + ((z - y) / 2) + 2;
	} else if ((z - x) % 2 == 1 && (z - y) % 2 == 0) {
	    ope = ope + ((z - x) / 2) + ((z - y) / 2) + 2;
	} else {
	    ope = ope + ((z - x) / 2) + ((z - y) / 2) + 1;
	}
  	cout << ope;
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a;
  cin >> a;
  if (a[0] == 'A') {
    cout << 'T';
  }
  if (a[0] == 'T') {
    cout << 'A';
  }
  if (a[0] == 'C') {
    cout << 'G';
  }
  if (a[0] == 'G') {
    cout << 'C';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005,MOD=1000000007;

char str[MAXN];
int cnt[30],ans=1,n;

int main()
{
	scanf("%d%s",&n,str);
	for(int i=0;i<n;i++)
		cnt[str[i]-'a']++;
	for(int i=0;i<30;i++)
		ans=1LL*ans*(cnt[i]+1)%MOD;
	ans=(ans-1+MOD)%MOD;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.math.abs
import kotlin.math.max


fun main() {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val infant = Array(n+1){0 to 0L}
    val dp = Array(n+1){LongArray(n+1){-1L} }

    for(i in 0 until n) {
        infant[i] = i to sc.nextLong()
    }

    infant.sortByDescending { it.second }

    fun solve(i:Int, j:Int): Long {
        val len = j - i + 1
        val idx = n - len
        val (p, a)  = infant[idx]
        if(len == 1) {
            return abs(i - p) * a
        }
        if(dp[i][j] != -1L) return dp[i][j]
        dp[i][j] = max(solve(i + 1, j) + abs(i - p) * a, solve(i, j - 1) + abs(j - p) * a)
        return dp[i][j]
    }
    val ans = solve(0, n -1)
    print(ans)
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\


int main()
{
    IOS;
    //fileRead
    int tc = 1;
    //cin>>tc;
    while(tc--)
    {
        string s, t; cin>>s>>t;
        int c=0;
        for0(i,s.sz) if(s[i]!=t[i]) c++;
        cout<<c;
    }
}

Measured memory_bytes: 3776
#include <stdio.h>
int main(void)
{
	char c;
	int a;
	while(scanf("%c", &c), c != '0'){
		a=0;
		a += c%48;
		while(scanf("%c", &c), c != '\n'){
			a += c%48;
		}
		printf("%d\n", a);
	}
    return 0;
}

Measured memory_bytes: 536
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a<b)
    {
        for(int i = 0; i < b; i++)
            cout << a;
    }
    else
    {
        for(int i = 0; i < a; i++)
            cout << b;
    }
    return 0;
}

Measured memory_bytes: 3604
use std::io::prelude::*;
use std::io::{stdin, stdout, BufReader, BufWriter};

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut writer = BufWriter::new(stdout.lock());
    let mut reader = BufReader::new(stdin.lock());
    solve(&mut writer, &mut reader).unwrap();
}

fn solve<W: Write, R: Read>(writer: &mut W, reader: &mut R) -> std::io::Result<()> {
    let mut s = String::new();
    reader.read_to_string(&mut s)?;
    let mut s = s.split_whitespace();
    let a: i32 = s.next().unwrap().parse().unwrap();
    let b: i32 = s.next().unwrap().parse().unwrap();
    if a < 10 && b < 10 {
        writer.write_all(format!("{}", a * b).as_bytes())?;
    } else {
        writer.write_all(b"-1")?;
    }
    Ok(())
}

macro_rules! make_test {
    ($name:ident, $input:expr, $output:expr ) => {
        #[test]
        fn $name() {
            use std::io::Cursor;
            use std::str::from_utf8;

            let mut writer = Cursor::new(vec![]);
            let mut reader = Cursor::new($input);

            solve(&mut writer, &mut reader).unwrap();

            assert_eq!(
                &writer.get_ref(),
                &$output,
                "\n  left: `{}`\n right: `{}`\n",
                from_utf8(&writer.get_ref()).unwrap(),
                from_utf8($output).unwrap()
            );
        }
    };
}

make_test!(test2, b"2 5", b"10");


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

#define ALL(V) (V).begin(),(V).end()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> using VVV = VV<V<T>>;
template <typename T, typename U> using P = pair<T, U>;

using ld = long double;
using ll = int64_t;
using PLL = P<ll, ll>; 

V<char> clis = { 'a', '+', '(', ')', '[', ']' };

ll c2ll(char c) { 
    for(ll i = 0; i < clis.size(); i++) if(c == clis[i]) return i;
    assert(false);
}

char ll2c(ll l) { return clis[l]; }

int main() {
    while(true) {
        ll N, M, S, T;
        cin >> N >> M >> S >> T;
        if(!(N + M + S + T)) break;
        S--;
        T--;
        VVV<ll> edges(N, VV<ll>(7));
        auto redges = edges;
        VV<ll> op_list(N), rop_list(N);
        
        for(ll i = 0; i < M; i++) {
            ll a, b;
            char c;
            cin >> a >> b >> c;
            a--;
            b--;
            c = (c == '*' ? '+' : c);
            ll l = c2ll(c);
            edges[a][l].push_back(b);
            redges[b][l].push_back(a);
        }
        
        for(ll loops = 0; loops <= 1; loops++) {
            auto &vvv = loops ? edges : redges;
            for(auto &vv : vvv) for(auto &v : vv) {
                sort(ALL(v));
                auto ite = unique(ALL(v));
                v.erase(ite, v.end());
            }
        }
        
        for(ll a = 0; a < N; a++) for(ll b : edges[a][c2ll('+')]) {
            op_list[a].push_back(b);
            rop_list[b].push_back(a);
        }
        
        queue<PLL> q;
        VV<bool> dp(N, V<bool>(N, false));
        
        for(ll i = 0; i < N; i++) for(ll j : edges[i][c2ll('a')]) {
            dp[i][j] = true;
            q.emplace(i, j);
        }

        while(q.size()) {
            ll l, r;
            tie(l, r) = q.front();
            q.pop();
            for(auto p : { make_pair('(', ')'), make_pair('[', ']') }) {
                char lc, rc;
                tie(lc, rc) = p;
                for(ll lb : redges[l][c2ll(lc)]) for(ll rb : edges[r][c2ll(rc)]) {
                    if(dp[lb][rb]) continue;
                    dp[lb][rb] = true;
                    q.emplace(lb, rb);
                }
            }
            for(ll nxtb : op_list[r]) {
                for(ll nxte = 0; nxte < N; nxte++) {
                    if(dp[l][nxte]) continue;
                    if(!dp[nxtb][nxte]) continue;
                    dp[l][nxte] = true;
                    q.emplace(l, nxte);
                }
            }
            for(ll nxte : rop_list[l]) {
                for(ll nxtb = 0; nxtb < N; nxtb++) {
                    if(dp[nxtb][r]) continue;
                    if(!dp[nxtb][nxte]) continue;
                    dp[nxtb][r] = true;
                    q.emplace(nxtb, r);
                }
            }
        }

        cout << (dp[S][T] ? "Yes" : "No") << endl;
    }
    return 0;
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string o, e;
    cin >> o >> e;

    for(int i=0;i<e.size();i++) {
        cout << o.at(i) << e.at(i);
    }
    if(o.size()!=e.size()) cout << o.at(o.size()-1);
    cout << endl;
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  bool isA = false;
  bool isB = false;
  for (char c : S) {
    if (c == 'A') isA = true;
    if (c == 'B') isB = true;
  }
  cout << (isA && isB ? "Yes" : "No") << endl;
    

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	map<char,int> mm;
	
	for(int i=0;i<(int)s.size();i++){
		//cerr<<s[i]<<endl;
		mm[s[i]]++;
	}
	//cerr<<"hi"<<endl;
	if(mm.size()<2){
		cout<<"No"<<endl;
		return 0;
	}else{
		int count=0;
		for(auto it:mm){
			if(it.second>=2){
				count++;
			}
			if(count>=2){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
		cout<<"No"<<endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var p, cc, pc int
	var s string
	ac := map[int]bool{}
	wa := map[int]int{}
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &s)
		if ac[p] {
			continue
		}
		if s == "AC" {
			ac[p] = true
			cc++
			pc += wa[p]
		} else {
			wa[p]++
		}
	}

	fmt.Println(cc, pc)
}


Measured memory_bytes: 9528
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, m, x, left = 0, right = 0;
    cin >> n >> m >> x;
    for (int i = 0; i < m; i++) {
        int t;
        cin >> t;
        if (t <= x)left++;
        else right++;
    }
    cout << min(left, right) << endl;
    return 0;
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, w, d;
  while(cin >> n >> w >> d, w != 0 && d != 0) {
    vt<pi> vec;
    vec.push_back({w, d});
    
    rep(i, 0, n) {
      int p, s;
      cin >> p >> s;
      p--;
      int l = vec[p].first, h = vec[p].second;
      vec.erase(vec.begin() + p);

      s %= (l + h);
      int nl = l, nh = h;
      if(s < l) {
        nl = l - s;
        l -= nl;
      }
      else {
        nh = h - (s - l);
        h -= nh;
      }

      if(nl * nh < l * h) {
        swap(nl, l);
        swap(nh, h);
      }

      vec.push_back({l, h});
      vec.push_back({nl, nh});
    }

    vt<int> area(n + 1);
    rep(i, 0, n + 1) {
      area[i] = vec[i].first * vec[i].second;
    }
    sort(all(area));
    rep(i, 0, n + 1) cout << area[i] << " \n"[i == n];
  }
}


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

int main(){
    int h1, m1, h2, m2;
    cin>>h1>>m1>>h2>>m2;
    int k;cin>>k;
    int t1, t2;
    t1=60*h1+m1;
    t2=60*h2+m2;
    cout<<t2-t1-k<<endl;
}

Measured memory_bytes: 3600
s = input()
q = int(input())
a = 0
c = ""
d = ""
for i in range(q):
    b = list(input().split())
    if b[0] == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):
            c += b[2]
        else:
            d += b[2]
s = c[::-1]+s+d
if a == 0:
    print(s)
else:
    print(s[::-1])

Measured memory_bytes: 4540
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
int q;
LL A,B;
int main() {
    cin>>q;
    while(q--){
        cin>>A>>B;
        LL x=sqrt(A*B-1);
        x=max(x-2,0LL);
        while((x+1)*(x+1)<A*B) ++x;
        if(A>B)swap(A,B);
        if(B-A<=1){
            printf("%d\n", 2*A-2); continue;
        }
        LL ans=2*x;
        if(x*(x+1) < A*B)ans--;
        else ans-=2;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
from math import sqrt
n = int(input())
p = 0

for i in range(n):
    x = int(input())
    if x == 2:
        p += 1
    elif x%2 == 1:
        j=3
        f = 0
        while j < (int(sqrt(x))+1):
            if x%j == 0:
                f = 1
                break
            else:
                j += 2
        if f == 0:
            p += 1



print(p)


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i],v[i]-= (i+1);
  sort(ALL(v));
  ll res = 0;
  rep(i,n)res += abs(v[i]-v[n/2]);
  ll sum = 0;
  rep(i,n)sum += abs(v[i]-v[(n+1)/2]);
  cout << min(res,sum) << endl;
  




  return 0;
}

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


int main() {
long long n,k;
cin >> n >> k;
vector<long long> p(n);
for(long long i=0;i<n;i++){
    cin >> p.at(i);
}
vector<long long> sums(n+1);
sums.at(0)=0;
for(long long i=0;i<n;i++){
    sums.at(i+1)=sums.at(i)+p.at(i);
}
long double ans=0;
for(long long i=0;i<n-k+1;i++){
    long long tmp=sums.at(k+i)-sums.at(i);
    if(tmp > ans)ans=tmp;
}
cout << fixed << setprecision(15) <<(ans+double(k))/2;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<math.h>
int main()
{
    int N, K, a=0, r, i, b=0;
    scanf("%d%d", &N, &K);
    for(i=0; N>0; i++)
    {
        r=N%K;
        b=b+r*powl(10,i);
        N=N/K;
        while(b!=0)
            b=b/10;
        a++;
    }
    printf("%d", a);
    return 0;
}

Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        x: u32,
        ll: [u32;n]
    }
    let mut a = 0;
    let mut cnt = 0;
    for l in ll {
        a += l;
        if a <= x {
            cnt += 1;
        }
    }
    println!("{}", cnt+1);
}
 

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, K;  cin >> N >> K;
    vector<int> x(N);  rep(i, N) cin >> x[i];

    int sum = 0;
    rep(i, N) {
        sum += 2 * min(x[i], abs(K-x[i]));
    }

    print(sum);
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdio.h>

int main(){
    
    int n,a;
    cin >> n;
    int list[n];
    for(int i=0;i<n;i++){
        cin >> a;
        list[n-i-1]=a;
    }
    int k;
    for ( k = 0; k < n; k++ ){
        if ( k ) printf(" "); 
        printf("%d", list[k]);
    }
    printf("\n");
}


Measured memory_bytes: 3108
#include<cstdio>
int main(){
	int n;
	scanf("%d",&n);
	int a[n+1]={};
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	int b[n+1]={};
	int k=1;
	for(int i=0;1;i++){
		ans++;
		b[k]=1;
		k=a[k];
		if(k==2){
			printf("%d\n",ans);
			break;
		}else if(b[k]==1){
			ans=-1;
			printf("%d\n",ans);
			break;
		}
	}
	return 0;
}

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

int N;
string Exp;
int ExpSize;

int Aparts[26][12];

void Ainit(int* a){
	for(int i=0;i<N;i++){
		a[i]=i;
	}
}

//a = b
void Acopy(int* a,int* b){
	for(int i=0;i<N;i++){
		a[i]=b[i];
	}
}

//a = b + c
void Ajoin(int* a,int* b,int* c){
	for(int i=0;i<N;i++){
		a[i]=c[b[i]];
	}
}

int* Aeval(int start,int end){
	int* ans=new int[N];
	int* tmp;
	int loopN;
	int loopPow;
	int loopA[32][12];
	char c;
	int nextStart;
	int nest;

	Ainit(ans);

	int i=start;
	while(i<end){
		loopN=0;

		while(c=Exp[i],'0'<=c && c<='9'){
			loopN=loopN*10+(int)(c-'0');
			i++;
		}
		if(loopN==0){loopN=1;}

		if(c=='('){
			Ainit(loopA[0]);
			i++;
			nextStart=i;
			nest=1;
			while(nest){
				c=Exp[i];
				switch(c){
				case '(':
					nest++;
					break;
				case ')':
					nest--;
					break;
				case '+':
					if(nest==1){
						tmp=Aeval(nextStart,i);
						Ajoin(loopA[0],loopA[0],tmp);
						delete tmp;
						nextStart=i+1;
					}
					break;
				}
				i++;
			}
			i++;
			tmp=Aeval(nextStart,i-1);
			Ajoin(loopA[0],loopA[0],tmp);
			delete tmp;
		}else{
			Acopy(loopA[0],Aparts[c-'A']);
			i+=2;
		}

		loopPow=0;
		while(loopN){
			while(loopN<(1<<loopPow)){
				loopPow--;
			}
			
			Ajoin(ans,ans,loopA[loopPow]);
			loopN-=(1<<loopPow);

			loopPow++;
			Ajoin(loopA[loopPow],loopA[loopPow-1],loopA[loopPow-1]);
		}
	}

	return ans;
}

int main(){
	int i;
	int K;

	cin>>N>>K;

	while(K--){
		char p;
		int h;
		int g[12];
		cin>>p>>h;
		p-='A';
		h--;

		Ainit(g);
		while(h--){
			for(i=1;i<N;i++){
				int tmp;
				cin>>tmp;
				if(tmp){swap(g[i-1],g[i]);}
			}
		}
		for(i=0;i<N;i++){
			Aparts[p][g[i]]=i;
		}
	}

	int E;
	cin>>E;

	while(E--){
		cin>>Exp;

		ExpSize=Exp.size();
		int *a=Aeval(0,ExpSize);
		int ans[12];
		for(i=0;i<N;i++){
			ans[a[i]]=i+1;
		}
		delete a;

		for(i=0;i<N;i++){
			if(i!=0) cout<<' ';
			cout<<ans[i];
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3276
N = int(input())
zahyo = list(map(int, input().split()))
av= sum(zahyo) // len(zahyo)
av2 = sum(zahyo) / len(zahyo)

if av2 - av >= 0.5:
    av += 1

sumv = 0
for i in range(N):
    sumv += (zahyo[i] - av)**2
    
print(sumv)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k;
    cin >> n >> k;
    int A[n];
    int cnt = 0;
    REP(i,n){
        cin >> A[i];
        if(A[i] >= k) cnt ++;
    }
    cout << cnt << endl;

}

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

int main() {
    long H; cin >> H;
    long W; cin >> W;

    long ans = H / 2 * W;
    if(H % 2 == 1){
        for(int i = 0; i < W; i++){
            if(i % 2 == 0){
                ans ++;
            }
        }
    }
    if(H == 1 || W == 1) ans = 1;
    cout << ans << endl;
}

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

int main(void){
    int N, M;
    cin >> N >> M;
    int a[M];
    int b[M];
    int ans[N];
    int count;

    for(int i = 0; i < M; i++)
        cin >> a[i] >> b[i];

    for(int i = 1; i <= N; i++){
        count = 0;
        for(int j = 0; j < M; j++){
            if(a[j] == i || b[j] == i)
            count++;
        }
        ans[i-1] = count;
        cout << ans[i-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

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

using namespace std;
using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll K, A, B, bsk = 1, K_tmp;
  cin >> K >> A >> B;
  K_tmp = K;
  if(A < B && A < K){
    bsk = A;
    K -= (A - 1);
    //cerr << K << endl;
    bsk += (K / 2) * (B - A);
    bsk += (K % 2);
  }else{
    bsk += K;
  }

  cout << max(bsk, K_tmp + 1) << endl;
  return 0;
}


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

int main()
{
	int num;
	cin >> num;
	int* T = new int[num];
	for (int i = 0; i < num; i++)
	{
		cin >> T[i];
	}
	int num1 = 0;
	for(int i=0;i<num;i++)
	{
		for(int j=num-1;j>i;j--)
		{
			if (T[j] < T[j - 1])
			{
				swap(T[j], T[j - 1]);
				num1++;
			}
		}
	}
	for (int j = 0; j < num; j++)
	{
		cout << T[j] << (j == num - 1 ? '\n' : ' ');
	}
	cout << num1<<endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char inp; cin >> inp;
            c[i][j] = inp;
        }
    }

    int ans = 0;
    for (int ic = 0; ic < (1<<h); ++ic) {
        for (int jc = 0; jc < (1<<w); ++jc) {
            int cnt = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if (ic>>i&1) continue;
                    if (jc>>j&1) continue;
                    if (c[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if 1&(i>>ii)&(j>>jj):
          if C[ii][jj]=='#':
            c+=1
    if c==K:
      ans+=1
print(ans)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define all(x) (x).begin(),(x).End()
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define pb(x) push_back(x)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
using std::bitset;
typedef long long ll;
const ll maxn=1e6+5;
const ll mod=998244353;
const ll INF=0x3f3f3f3f3f3f3f3f;
const long double PI=acos(-1.0);
const long double eps=1e-5;
inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

map<string,int>mp;

int main()
{
    int n,f;
    cin>>n;
        string t;
        f=1;
        for(int i=0;i<n;i++)
        {
            cin>>t;
            mp[t]++;
            if(mp[t]>1)
                f=0;
        }
        if(f)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
}


Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

double a, b, x;

int main(){
  cin >> a >> b >> x;
  double ans;
  if(a*a*b <= 2*x) {
    ans = atan(2*(a*a*b-x)/(a*a*a));
  }else{
    ans = M_PI/2 - atan(2*x/(a*b*b));
  }
  ans *= 180.0 / M_PI;
  printf("%.10lf\n", ans);

  return 0;
}

// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int H1, M1, H2, W2, K; cin >> H1 >> M1 >> H2 >> W2 >> K;
	int x = (H2 * 60 + W2) - (H1 * 60 + M1);
	cout << max(0, x - K) << "\n";

	return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for(int x = 0; x <= K; x++) {
      for(int y = 0; y <= K; y++) {
        if(((S - x - y) >= 0) && ((S - x - y) <= K)) count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 9808
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
void solve()
{
	int n;
	cin>>n;
	if(n>=400&&n<=599)
	{
		cout<<8<<endl;
	}
	else if(n>=600&&n<=799)
	{
		cout<<7;
	}
	else if(n>=800&&n<=999)
	{
		cout<<6;
	}
	else if(n>=1000&&n<=1199)
	{
		cout<<5;
	}
	else if(n>=1200&&n<=1399)
	{
		cout<<4;
	}
	else if(n>=1400&&n<=1599)
	{
		cout<<3;
	}
	else if(n>=1600&&n<=1799)
	{
		cout<<2;
	}
	else if(n>=1800&&n<=1999)
	{
		cout<<1;
	}
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
	solve();
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

template<class T>
void dcomb(T n,T m, string s){
    if(n==0) cout << s << endl;
    else {
        for(T i=0; i<m; ++i){
            dcomb(n-1,m,s+to_string(i));
        }
    }
}

int  INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==0){
            continue;
        }else{
            ans = 1;
        }
    } 
    if(ans) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 640
s=list(input())
b=[]
w=[]
n=len(s)
for i in range(n):
    if i%2==0:
        b+=s[i]
    else:
        w+=s[i]
bc=b.count('1')
wc=w.count('0')
print(min(bc+wc,n-bc-wc))

Measured memory_bytes: 50056