akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
vi rmv(vi& a){
    vi b = {a[0]};

    for(auto& e : a){
        if(e == b.back()) continue;
        b.emplace_back(e);
    }

    return b;
}

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

    int n; cin >> n;
    vi h(n); for(auto& e : h) cin >> e;

    int res = 0;
    while(1){
        h = rmv(h);
        int m = h.size();
        if(m == 1) break;

        int h_max = *max_element(_all(h));
        rep(i, m){
            if(h[i] != h_max) continue;

            int l = (i-1 >= 0 ? h[i-1]:0);
            int r = (i+1 <  m ? h[i+1]:0);

            int nh = max(l, r);
            res += h_max - nh;
            h[i] = nh;
        }
    }
    res += h[0];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include<vector>
#include <queue>
using namespace std;
typedef long long ll ;
int arr[100001];
int main(){
	int a , b , temp1 , temp2 ; 
	cin >> a >> b ;
	for(int i=0;i<b;i++)
	{
		cin >> temp1 >> temp2 ;
		
		arr[temp1]++;
		arr[temp2]++;
		
	}

	//for(int i=1;i<b;i++)
	//	cout << arr[i] << endl;

	for(int i=1;i<=a;i++)
		if(arr[i]%2!=0){
			cout << "NO";
			return 0;
		}		

	cout << "YES";
	return 0;
}

Measured memory_bytes: 640
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, y = map(int, input().split())
    count = 0
    tmp = x
    while tmp <= y:
        tmp *= 2
        count += 1
    print(count)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
h , w = map(int, input().split())
c = [list(map(int,input().split())) for i in range(10)]
wa = [list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
ans = 0
for i in range(h):
    for j in range(w):
        if wa[i][j]!=1 and wa[i][j]!=-1:
            ans+=c[wa[i][j]][1]
print(ans)

Measured memory_bytes: 3444
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        
        String[] line = reader.readLine().split(" ");
        int a = Integer.parseInt(line[0]),
            b = Integer.parseInt(line[1]);
        
        if( a % 2 == 0 || b % 2 == 0){ writer.println("Even");
        }else{ writer.println("Odd");}
        
        reader.close();
        writer.close();
    }
}

Measured memory_bytes: 22868
N=int(input())

red=[]
blue=[]
counter=0

for _ in range(N):
    red.append(list(map(int,(input().split()))))

for _ in range(N):
    blue.append(list(map(int,(input().split()))))

blue.sort()

for i in blue:
    a=i[0]
    b=i[1]

    taisho=[j for j in red if j[0]<a]
    
    if len(taisho)>=1:
        taisho.sort(key=lambda x:x[1],reverse=True)
        for k in taisho:
            if k[1]<b:
                counter+=1
                red.remove(k)
                break

print(counter)  

Measured memory_bytes: 3064
A, B = map(int, input().split())

f_1_A = 0
for i in range((A // 4) * 4, A):
  f_1_A ^= i

f_1_B = 0
for i in range((B // 4) * 4, B+1):
  f_1_B ^= i

print(f_1_A ^ f_1_B)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

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

    vector<long long int> quan(N + 1);
    for(int i = 0; i < N; i++){
        quan[A[i]]++;
    }
    
    long long int ans = 0;
    for(int i = 0; i < N + 1; i++){
        ans += quan[i] * (quan[i] - 1) / 2;
    }

    for (int i = 0; i < N; i++){
        long long int ansans;
        long long int aa = quan[A[i]] - 1;
        ansans = ans - aa;
        cout << ansans << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var s, t []byte
	fmt.Scan(&s, &t)
	var ng bool
	for i := range s {
		if s[i] != t[i] {
			ng = true
		}
	}
	if len(t) == len(s)+1 && !ng {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1756
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;
      

	      while(t--)
{
ll n;
cin>>n;
cout<<n/3;
ee;




}
return 0;
}















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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        pq.push(a);
    }
    while(m--) {
        if (pq.top() == 0) {
            break;
        }
        int tmp = pq.top();
        pq.pop();
        tmp /= 2;
        pq.push(tmp);
    }
    ll sum = 0;
    while(!pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 892
import sys
import math
import itertools
import statistics
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
per_lis = itertools.permutations(list(range(1,n+1)))
a,b,i=0,0,0
for elem in per_lis:
    i+=1
    if elem==p:
        a=i
    if elem==q:
        b=i
print(abs(a-b))

Measured memory_bytes: 78420
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld\n",i)
#define fendl printf("\n")
//Library-End

int k,a,b,ans;
signed main() {
    cin>>k>>a>>b;
    ans=1;
    if (a<b) {
        if (a<k) {
            ans=a;
            k-=a-1;
            ans+=(k/2)*(b-a);
            ans+=(k&1);
            cout<<max(ans,k+a)<<endl;
        }else{
            cout<<k+1<<endl;
        }
    }else{
        cout<<k+1<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    getline(cin,s);
    char c ;
    bool mrk  = 0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]==' ')
            mrk = 1;
        if(s[i]!=' ' && mrk)
            {c = s[i];break;}
    }
    cout << "A" << c <<  "C" << endl;
}


Measured memory_bytes: 3612
k = int(input())
lst = [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]
print(lst[k-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
	ll n;
	cin >> n;
	ll ans = 1 + (n > 2);
	for(ll i = 2; i*i < n; i++){
		if((n-1) % i == 0){
			ans += 2;
			if(i*i == n-1) ans--;
		}
	}
	for(ll i = 2; i*i <= n; i++){
		if(i*i == n){
			ans++;
			break;
		}
		if(n%i == 0){
			ll j = i;
			ll tmp = n/i;
			while(tmp%j == 0) tmp /= j;
			ans += (tmp%j == 1);
			j = n/i;
			tmp =  i;
			while(tmp%j == 0) tmp /= j;
			ans += (tmp%j == 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int H,W;
char dis[100][100];
char tmpdis;
void dfs(int x,int y){
	tmpdis=dis[x][y];
	dis[x][y]='.';
	int xdi[4]={0,1,0,-1},ydi[4]={1,0,-1,0};
	for(int i=0;i<4;i++){
		int nx=x+xdi[i],ny=y+ydi[i];
		if(nx>=0&&nx<H&&ny>=0&&ny<W&&dis[nx][ny]==tmpdis){
			dfs(nx,ny);
		}
	}
}
int main(){
	while(scanf("%d%d",&H,&W)){
		if(H!=0&&W!=0){
			for(int i=0;i<H;i++){
				getchar(); 
		        for(int j=0;j<W;j++){
			        scanf("%c",&dis[i][j]);
		        }
	        }
	    int res=0;
	    for(int i=0;i<H;i++){
		    for(int j=0;j<W;j++){
			    if(dis[i][j]=='@'||dis[i][j]=='#'||dis[i][j]=='*'){
				    dfs(i,j);
				    res++;
			    }
		    }
	    }
	    printf("%d\n",res);
	
		}
		else
		    break;
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  string S, T;
  cin >> S >> T;

  int cnt =0;
  
  for(int i=0; i<S.size(); ++i){
    if(S[i] == T[i]) cnt++;
  }

  cout << cnt;
  return 0;
}
          

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

static const int N = 32769;
bool prime[N];

int main()
{
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  FOR(i, 2, N) {
    if (prime[i]) {
      for (int j = i+i; j < N; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (scanf("%d", &n), n) {
    int count = 0;
    FOREQ(i, 2, n/2) {
      if (prime[i] && prime[n-i]) {
        ++count;
      }
    }
    printf("%d\n", count);
  }
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	set<int> st;
	int d;
	for (int i = 0; i < n; ++i)
	{
		cin>>d;
		st.insert(d);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define N 123456

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

int n, a[3][N], hlf[3*N], mch[3*N], flc[2], par[4];
int ps[4][N];
bool mid[3*N];
int m;
int findp(int p[N], int len) {
    ordered_set st;
    ll ans = 0;
    fo(i,0,len) {
        int more = i - st.order_of_key(p[i]);
        ans += more;
        st.insert(p[i]);
    }

    return ans%2;
}
int main() {
    scanf("%d", &n);
    m = 3*n;
    fo(i,1,m+1) {
        if (i%3==2) mid[i] = 1;
        if ((i-1)%6 < 3) hlf[i] = 0;
        else hlf[i] = 1;
    }
    fo(i,1,m+1) if (!mid[i]) {
        if (i%3 == 1) mch[i] = i+2;
        else mch[i] = i-2;
    }
    fo(i,0,3) fo(j,0,n) scanf("%d", a[i]+j);
    fo(i,0,n) if (mid[a[0][i]] || mch[a[0][i]] != a[2][i]) {
        //puts("1");
        puts("No"); return 0;
    }
    fo(i,0,n) {
        int chlf = i%2;
        if (hlf[a[0][i]] != chlf) {
          //  puts("2");
            puts("No"); return 0;
        }
        if (a[0][i] > a[2][i]) flc[chlf]++;
        ps[chlf][i/2] = min(a[0][i],a[2][i]);
    }
    fo(i,0,n) {
        int chlf = i%2;
        if (hlf[a[1][i]] != chlf) {
            //puts("3");
            puts("No"); return 0;
        }
        ps[chlf+2][i/2] = a[1][i];
    }
    fo(i,0,4) {
        int len;
        if (i%2 == 0) len = (n+1)/2;
        else len = n/2;
        par[i] = findp(ps[i], len);
    }
    fo(i,0,2) if (par[i] != par[i+2]) {
        //puts("4");
        puts("No"); return 0;
    }
    fo(i,0,2) if (par[i] != flc[1-i]%2) {
        //puts("5");
        puts("No"); return 0;
    }
    puts("Yes");

        return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int N = 0, v[1001];
	double sum = 0;
	cin >> N;
	
	for(int i = 0 ; i < N ; i++){
	    cin >> v[i];
	}
	
	sort(v, v+N);
	
	sum += v[0];
	
	for(int i = 1 ; i < N ; i++){
	    sum += v[i];
	    sum /= 2.00000;
	}
    
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000

int main(){
  int n, i, j, maxV = 0, minV = 0;
  int a[N];
  scanf("%d", &n);
	
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
	
  minV = a[0];
  maxV = a[1] - a[0];
	
  for(j = 1; j < n; j++){
    if(maxV < (a[j] - minV)) maxV = a[j] - minV;
    if(minV > a[j]) minV = a[j];
  }
	
  printf("%d\n", maxV);
	
return 0; 
}

Measured memory_bytes: 1376
p = Array.new(5) do
  gets.strip.to_i
end

k = gets.strip.to_i

ok = true
0.upto(3) do |i|
  (i + 1).upto(4) do |j|
    ok = false if p[j] - p[i] > k 
  end
end

puts ok ? "Yay!" : ":("


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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1000005
#define MAXC 205
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;
int par[MAXN];
ll wt[MAXN];

int get(int x) {
	if(x == par[x]) return x;
	return par[x] = get(par[x]);
}

void join(int x, int y)
{
	x = get(x); y = get(y);
	if(x == y) return;
	par[x] = y;
}
bool is[MAXN];
vector <ll> edg[MAXN];
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	for(int i=0; i<N; i++) cin >> wt[i];
	for(int i=0; i<N; i++) par[i] = i;
	for(int i=0; i<M; i++) {
		int a, b;
		cin >> a >> b;
		join(a, b);	
	}
	int cc = 0;
	vector <int> v;
	for(int i=0; i<N; i++) {
		int x = get(i);
		if(!is[x]) {
			cc++;
			is[x] = 1;
			v.PB(x);
		}
	}

	int need = 2*(cc-1);
	if(need > N) {
		cout << "Impossible" << endl;
		return 0;
	}
	if(need <= 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for(int i=0; i<N; i++) edg[get(i)].PB(wt[i]);
	for(int i=0; i<v.size(); i++) sort(edg[v[i]].begin(), edg[v[i]].end());
	for(int i=0; i<v.size(); i++) ans += edg[v[i]][0];
	need -= cc;
	vector <ll> oth;
	for(int i=0; i<v.size(); i++) {
		int u = v[i];
		for(int j=1; j<edg[u].size(); j++) oth.PB(edg[u][j]);
	}
	sort(oth.begin(), oth.end());
	for(int i=0; i<need; i++) ans += oth[i];
	cout << ans << endl;
}

Measured memory_bytes: 31868
import itertools
import math
n=int(input())
data=[]
a=[]
for i in range(n):
    x,y=map(int,input().split())
    data.append([x,y])
    a.append(i)
d=0.0
for v in itertools.permutations(a):
    for i in range(n-1):
        d0=((data[v[i]][0]-data[v[i+1]][0])**2+(data[v[i]][1]-data[v[i+1]][1])**2)**0.5
        d+=d0
print(d/math.factorial(n))

Measured memory_bytes: 3188
N = int(input())
S = input()

len1 = set()
len2 = set()
len3 = set()

for d in S:
    for l2 in len2:
        len3.add(l2+d)
    for l1 in len1:
        len2.add(l1+d)
    len1.add(d)
print(len(len3))



Measured memory_bytes: 9284
h, w, k= (int(x) for x in input().split())
#print(h, w, k)

ans=0
x=['' for i in range(h)]

for i in range(h):
  x[i]=input()

#print(x)
for i in range(2**w):
    w1 = format(i, 'b').zfill(w)
    
    for i in range(2**h):
        h1 = format(i, 'b').zfill(h)
    
        count=0
        for i in range(w):
            for j in range(h):
                if w1[i]=='0' and h1[j]=='0':
                    if x[j][i]=='#':
                        count+=1
        if count==k:
            ans+=1

print(ans)


Measured memory_bytes: 9136
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<=a)
        printf("%d\n",k);
    else if(k<=a+b)
        printf("%d\n",a);
    else
        printf("%d\n",2*a-k+b);
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ppb pop_back
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;


struct node{
	int a, b, c, d;
};

int n, m, q, ans;
vector<int>v;
vector<node>Q;

void solve(int i, int j){
	if(i == n){
		int cnt = 0;
		
		for(auto it : Q){
			if(v[it.b-1] - v[it.a-1] == it.c) cnt += it.d;
		}
		
		ans = max(ans, cnt);
		return;
	}
	
	for(int k=j; k<=m; k++){
		v.pb(k);
		solve(i+1, k);
		v.ppb();
	}
}

int main(){

	fastcin
	
	cin >> n >> m >> q;
	
	for(int i=0; i<q; i++){
		struct node n;
		cin >> n.a >> n.b >> n.c >> n.d;
		Q.push_back(n);
	}	
	
	solve(0, 1);		
	 
	cout << ans << endl; 
	      
	return 0;
}


Measured memory_bytes: 3588
N=int(input())
A=list(map(int,input().split()))
for i in range(1,N):
  print(*A)
  v=A[i]
  j=i-1
  while j>=0 and A[j]>v:
    A[j+1]=A[j]
    j-=1
  A[j+1]=v
print(*A)


Measured memory_bytes: 5984
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  int K,S, res;
  cin >> K >> S;
  res = 0;

  rep(i, 0, K){
    rep(j, 0, K){
      int z = S-i-j;
      if(0<=z && z <=K){
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
int n1,n2,x=0;
cin>>n1;
cin>>n2;
for(int i=n1;i<=n2;i++){
int reversedInteger = 0, remainder, originalInteger,temp;


    originalInteger=i;
    temp=i;
    while( temp!=0 )
    {
        remainder = temp%10;
        reversedInteger = reversedInteger*10 + remainder;
        temp/= 10;
    }
    if (originalInteger == reversedInteger)
        x++;
}
cout<<x;
return 0;
}


Measured memory_bytes: 256
def ans(m):
    h = 0
    w = 0
    pas = []

    while True:
#        print("h={0} v={1} mark={2}".format(h,w,m[h][w]))
        if   m[h][w] == '>':
            w += 1
        elif m[h][w] == '<':
            w -= 1
        elif m[h][w] == '^':
            h -= 1
        elif m[h][w] == 'v':
            h += 1
        elif m[h][w] == '.':
            return  "{0} {1}".format(w,h)

        if (h,w) in pas:
            return "LOOP"
        else:
            pas.append((h,w))

while True:
    [h,w] = map(int,input().split())
    if h == 0 and w == 0:
        break

    m = []
    for _ in range(h):
        m.append(input())

    res = ans(m)
    print(res)

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

int main(){
	int a, b;
	int answer;
	string op;

	while (true){
		cin >> a >> op >> b;

		if (op == "+"){
			answer = a + b;
		}else if(op == "-"){
			answer = a - b;
		}else if(op == "*"){
			answer = a * b;
		}else if(op == "/"){
			answer = a / b;
		}else if(op == "?"){
			return 0;
		}

		cout << answer << endl;
	}
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;

	if (a.back() == b.front() && b.back() == c.front()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
    using namespace std;
    vector<string> S(3);
    cin >> S[1];
    unsigned long Q, x{3};
    cin >> Q;
    for(unsigned long i{0}, t; i < Q; ++i){
        cin >> t;
        if(t == 1)x ^= 3;
        else{
            unsigned long f;
            char c;
            cin >> f >> c;
            S[f ^ x].push_back(c);
        }
    }
    reverse(S[x ^ 1].begin(), S[x ^ 1].end());
    cout << S[x ^ 1] << S[x ^ 2] << endl;
    return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int d; cin >> d;
	vector<int> c(26);
	for(auto &x : c)
		cin >> x;
	vector<vector<int>> hash(d,vector<int>(26));
	for(int i = 0 ; i < d ; i++){
		for(int j = 0 ; j < 26 ; j++){
			cin >> hash[i][j];
		}
	}
	for(int i = 0 ; i < d ; i++){
		int S = 0;
		S+=hash[i][0];
		S-=hash[i][25]*25;
		int p = rand()%26;
		if(p==0)
			p++;
		cout<<p<<"\n";
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main() {
  int N;
  int i;
  char input[5];
  int cnt_ac, cnt_wa, cnt_tle, cnt_re;
  scanf("%d", &N);
  cnt_ac = 0;
  cnt_wa = 0;
  cnt_tle = 0;
  cnt_re = 0;
  for ( i = 0; i < N; i++ ) {
    scanf("%s", input);
    if ( strcmp(input, "AC") == 0 ) {
      cnt_ac++;
    }
    if ( strcmp(input, "WA") == 0 ) {
      cnt_wa++;
    }
    if ( strcmp(input, "TLE") == 0 ) {
      cnt_tle++;
    }
    if ( strcmp(input, "RE") == 0 ) {
      cnt_re++;
    }
  }
  printf("AC x %d\n", cnt_ac);
  printf("WA x %d\n", cnt_wa);
  printf("TLE x %d\n", cnt_tle);
  printf("RE x %d\n", cnt_re);
  return 0;
}


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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	vector<int> B(A);
	sort(B.begin(), B.end());
/*	for(i = 0; i < N; i++){
		printf("%d ", A[i]);
	}
	printf("\n");
	for(i = 0; i < N; i++){
		printf("%d ", B[i]);
	}
	printf("\n");
*/	for(i = 0; i < N; i++){
		if(A[i] == B[N - 1]){
			printf("%d\n", B[N - 2]);
		}
		else{
			printf("%d\n", B[N - 1]);
		}
	}
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();

		long min = 9999;
		for(long i = l ; i < r ; i++) {
			for(long j = i + 1 ; j <= r ; j++) {
				long mod = (i * j) % 2019;
				if(mod == 0L) {
					System.out.println(mod);
					System.exit(0);;
				}
				if(mod < min) {
					min = mod;
				}
			}
		}
		System.out.println(min);
		sc.close();

	}

}


Measured memory_bytes: 23252
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0)
            break;

        pair<int, int> v[25];
        for (int i = 0; i < n; ++i) {
            scanf("%d %d", &v[i].second, &v[i].first);
        }

        sort(v, v + n);

        int w = 0;
        bool f = true;
        for (int i = 0; i < n; ++i) {
            if (v[i].first < w + v[i].second) {
                f = false;
                break;
            }
            w += v[i].second;
        }
        if (f)
            puts("Yes");
        else
            puts("No");
    }
}

Measured memory_bytes: 1012
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = nextInt()
	}

	sort.Ints(v)
	base := float64(v[0])
	for i := 1; i < n; i++ {
		base = (base + float64(v[i])) / 2
	}
	fmt.Printf("%.6f\n", base)

}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

bool cmp(ll a, ll b){
	return a > b;
}

int main(){
	int cnt[3],k,i,j;

	scanf("%d %d %d %d",&cnt[0],&cnt[1],&cnt[2],&k);
	ll kali = cnt[0]*cnt[1]*cnt[2];
	ll a[3][1010];
	for(i=0;i<3;i++){
		for(j=0;j<cnt[i];j++){
			scanf("%lld",&a[i][j]);
		}
		sort(a[i],a[i]+cnt[i], cmp);
		// printf("i: %d\n",i );
		// for(j=0;j<cnt[i];j++){
		// 	printf("%lld ",a[i][j]);
		// }
		// printf("\n");
	}
	vi listAns;
	vi jawab;
	
	ll kiri = 3, kanan = 30000000000LL, mid,ans;

	while(kiri <= kanan) {
		listAns.clear();
		mid = (kiri+kanan)/2LL;
		int ukuran = 0;
		for(i=0;i<cnt[0];i++){
			for(j=0;j<cnt[1];j++){
				for(int l=0;l<cnt[2];l++){
					ll sum = a[0][i] + a[1][j] + a[2][l];
					if(sum >= mid){
						
						ukuran++;
						if(ukuran > k){goto here;}
					}else{
						break;
					}
				}
			}
		}
		here:;
		if(ukuran >= k){
			ans = mid;
			kiri = mid+1;
			
		}else{
			kanan = mid-1;
		}
	}
	int ukuran = 0;
	for(i=0;i<cnt[0];i++){
		for(j=0;j<cnt[1];j++){
			for(int l=0;l<cnt[2];l++){
				ll sum = a[0][i] + a[1][j] + a[2][l];
				
				if(sum >= ans){
					jawab.pb(sum);
					// printf("i: %d j: %d l: %d dipush: %lld idx: %d\n",i,j,l,sum,ukuran++);
				}else{
					break;
				}
			}
		}
	}

	sort(jawab.begin(), jawab.end(),cmp);
	
	for(i=0;i<k;i++){
		printf("%lld\n",jawab[i]);
	}

	



	return 0;
};

Measured memory_bytes: 132316
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <unordered_map>
#include <list>
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> umapi;

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif // _DEBUG
    //freopen("input.txt","r",stdin);
    string s;
    string t;
    cin>>s>>t;
    int count=0;
    forn(i,t.size())
        if(s[i]!=t[i])
            count++;
    cout<<count;


    return 0;
}



Measured memory_bytes: 3784
import java.util.Scanner;

class Main {
  private final static String INSERT = "insert";
  private static Tree ROOT = null;
  private static Tree END = null;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int times = Integer.parseInt(sc.next());
    // List<Tree> tree = new ArrayList<>(times - 1);

    for (int i = 0; i < times; i++) {
      if (sc.next().equals(INSERT)) {
        insert(sc.nextInt());
      } else {
        createBuilderInorder(ROOT);
        System.out.println();
        createBuilderByRoot(ROOT);
        System.out.println();
      }
    }
  }

  public static void insert(int key) {
    Tree y = null;
    Tree x = ROOT;
    Tree z = new Tree();
    z.key = key;

    while (x != null) {
      y = x;
      if (z.key < x.key) {
        x = x.left;
      } else {
        x = x.right;
      }
    }

    z.parent = y;

    if (y == null) {
      ROOT = z;
    } else if (z.key < y.key) {
      y.left = z;
    } else {
      y.right = z;
    }
  }

  public static void createBuilderInorder(Tree tree) {
    if (tree != null) {
      createBuilderInorder(tree.left);
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderInorder(tree.right);
    }
  }

  public static void createBuilderByRoot(Tree tree) {
    if (tree != null) {
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderByRoot(tree.left);
      createBuilderByRoot(tree.right);
    }
  }
}

class Tree {
  public int key;
  public Tree left;
  public Tree right;
  public Tree parent;

  public Tree() { }
}



Measured memory_bytes: 283904
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string w[1000] = {};
	string answer = "Yes";
	cin >> w[0];
	for (int i = 1; i < n; i++){
		cin >> w[i];
		if (w[i-1][w[i-1].length()-1] != w[i][0]) answer = "No";
		for(int j = 0; j < i; j++){
			if(w[i] == w[j]) answer = "No";
		}
	}
	cout << answer << endl;
}

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

std::string S;

int main() {
	std::cin >> S;
	int size = S.size();
	for (int i = 0; i < size - 8; i++) {
		std::cout << S[i];
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  char c[n];
  scanf("%s", c);
  int x = 0;
  int max = 0;
  for(int i = 0; i < n; i++){
    if(c[i] == 'I'){
      x++;
      if(x > max) max = x;
    }else{
      x--;
    }
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct Point {
    int x;
    int y;
    Point(){}
    Point(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main(){
    int n; cin >> n;
    int board[8][8] = {0};
    vector<Point> p;
    int x,y;
    rep(i, n) {
        cin >> x >> y;
        board[x][y] = 1;
        p.push_back(Point(x,y));
    }
    vector<int> v(8);
    rep(i, 8) {
        v[i] = i;
    }
    do {
        bool isOK = true;
        for(int i = 0; i < n; i++) {
            if(p[i].y != v[p[i].x]) {
                isOK = false;
                break;
            }
        }
        if(isOK) {
            for(int i = 0; i < 8; i++) {
                for(int j = i+1; j < 8; j++) {
                    if(i-v[i] == j-v[j])
                        isOK = false;
                    if(i+v[i] == j +v[j])
                        isOK = false;
                }
            }
        }
        if(isOK)
            break;
    } while(next_permutation(v.begin(), v.end()));
    for(int i = 0; i < 8; i++) {
        board[i][v[i]] = 1;
    }

    rep(i, 8) {
        rep(j, 8) {
            if(board[i][j])
                cout << 'Q';
            else
                cout << '.';
        }
        cout << endl;
    }
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];

    ll t = T[0];
    ll a = A[0];
    for (int i = 1; i < N; i++) {
        if (t <= T[i] && a <= A[i]) {
            t = T[i];
            a = A[i];
            continue;
        }

        ll m1 = t / T[i];
        if (t % T[i]) m1++;

        ll m2 = a / A[i];
        if (a % A[i]) m2++;

        ll m = max(m1, m2);
        t = T[i] * m;
        a = A[i] * m;
    }

    cout << t + a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}


int main()
{

fastIO;
ll test,t,i,j,k,n,m,a,b,x,y,u,temp;
cin>>n>>m;
ll arr[n+5];
rep(i,1,n+1)
    cin>>arr[i];
set <ll> s;
rep(i,0,m)
{
    cin>>x>>y;
    if(arr[x]<arr[y])
        s.insert(x);
    else if(arr[x]>arr[y])
        s.insert(y);
    else
    {
        s.insert(x); s.insert(y);
    }    
}
cout<<n-s.size();
return 0;
}

Measured memory_bytes: 7076
//#include<iostream>
//#include<cstdio>
//using namespace std;
//int main(){
//	long long a;
//	double b;
//	cin>>a>>b;
//	b=b*(100+0.1);
//	a*=(int)b;
//	cout<<a/100<<endl;
//	return 0;
//}
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long long a,b;
	char s[5];
	cin>>a>>s;
	b=100*(s[0]^'0')+10*(s[2]^'0')+(s[3]^'0');
	cout<<a*b/100<<endl;
	return 0;
}


Measured memory_bytes: 3172
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int k=38,n=k*(k-1)+1;
	
	cout<<n<<" "<<k<<endl;
	vvi out,t(k-1,vi(k-1));
	rep(i,k-1)rep(j,k-1)
		t[i][j]=j*(k-1)+i+1+k;
	vi w;
	rep(i,k)w.pb(i+1);
	out.pb(w);
	rep(i,k-1){
		w={1};
		rep(j,k-1)w.pb(t[j][i]);
		out.pb(w);
	}
	rep(i,k-1)rep(j,k-1){
		w={i+2};
		rep(l,k-1)w.pb(t[(j+i*l)%(k-1)][l]);
		out.pb(w);
	}
	
	rep(i,out.size()){
		rep(j,k)cout<<out[i][j]<<" ";
		cout<<endl;
	}
}
















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

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

template<typename T>
void dump_2d_mat(T &m, int N, int M) {
    REP(i, N) {
        REP(j, M) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    
    cout << fixed << setprecision(20);
    if (N > M) cout << "No";
    else cout << "Yes";
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int d[100010],n;
vector<int>e[100010];
void dfs(int a){
	if(e[a].empty())return;
	for(int i=0;i<e[a].size();i++)dfs(e[a][i]);
	vector<int>tp;
	for(int i=0;i<e[a].size();i++){
		tp.push_back(d[e[a][i]]);
	}
	sort(tp.begin(),tp.end());
	int mx=0,sz=tp.size();
	for(int i=0;i<sz;i++){
		mx=max(mx,tp[i]+sz-i);
		
	}
	d[a]=mx;
	return;
}
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<n;i++){
		int a;
		cin>>a;
		e[a].push_back(i+1);
	}
	dfs(1);
	cout<<d[1]<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 13952
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=Integer.parseInt(sc.nextLine());
                        if(n==0){
                            break;
                        }
			int pointA=0;
			int pointB=0;
			for(int i=0;i<n;i++){
				String[] str = sc.nextLine().split(" ");
				int numA=Integer.parseInt(str[0]);
				int numB=Integer.parseInt(str[1]);
				if(numA>numB){
					pointA+=numA+numB;
				}else if(numA<numB){
					pointB+=numA+numB;
				}else if(numA==numB){
					pointA+=numA;
					pointB+=numB;
				}
			}
			System.out.println(pointA+" "+pointB);			
		}

	}
}


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  int left = x - (k - 1);
  int right = x + (k - 1);
  for(int i = left; i <= right; ++i){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int ll
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int a[9] = {3, 9, 2, 4, 8, 10, 6, 12};
signed main(){
	int n = rd();
	if (n == 3){
		puts("2 5 63");
		return 0;
	}
	if (n % 2) n--,printf("30000 ");
	rep(i,0,n) printf("%d ", a[i % 8] + i / 8 * 12);
    return 0;
}

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

int main(){
    lli k;
    cin>>k;
    string s;
    cin>>s;
    unordered_map<char, lli> m;
    m['R'] = m['G'] = m['B'] = 0;
    for(int i = 0; i<k; i++){
        m[s[i]]++;
    }
    lli res = m['R']*m['G']*m['B'];
    for(lli i = 0; i<k; i++){
        for(lli j = 1; (i + 2*j)<k; j++){
            if(s[i]!=s[j+i] && s[j+i] != s[i+2*j] && s[i+2*j] != s[i])res--;
        }
    }
    cout<<res;
    return 0;
}

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

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

  ll res = 0;
  int right = 0;
  int sum = 0;
  for (int left = 0; left < n; ++left) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
        else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        }
  }
  cout << res << endl;
}


Measured memory_bytes: 1152