akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m;cin>>n>>m&&n|m;){
		vi as(n),bs(n);
		rep(i,n) cin>>as[i]>>bs[i];

		vi is(n); iota(all(is),0);
		sort(all(is),[&](int i,int j){return bs[i]<bs[j];});
		reverse(all(is));

		set<int> ds;
		rep(i,m+1) ds.insert(i);

		ll res=0;
		vi mx(m+1);
		for(int i:is){
			if(m-as[i]<0)
				continue;
			auto it=ds.upper_bound(m-as[i]);
			if(it==begin(ds))
				continue;
			it--;
			res+=bs[i];
			ds.erase(it);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 6528
/* author   : mpily :-()
    title : Competing.cpp
    time :Sun Sep 29 15:10:42 2019
     
    */
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	long long A,B;
    	cin>>A>>B;
    	long long C = __gcd(A,B);
    	int count = 1;
    	long long lim = sqrt(C+1)+1;
    	for(long long i = 2; i <= lim; i++){
    		if(C%i == 0){count+=1;while(C%i == 0 && i != 1)C/=i; }
		if(i%2)i+=1;
    	}
    	 if(C !=1)count+=1;
    	 cout<<count<<"\n";
    	return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

bool cmp(pii a,pii b)
{
	return a.F-a.S>b.F-b.S;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<pii> v(n);
	For(i,0,n-1) cin>>v[i].F;
	For(i,0,n-1) cin>>v[i].S;
	sort(all(v),cmp);
	int ans=0;
	for(auto i:v)
	{
		if(i.F-i.S<=0) break;
		ans+=i.F-i.S;
	}
	cout<<ans<<"\n";
	return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  int x=x1-x2;
  int y=y1-y2;
  cout<<x2+y<<" "<<y2-x<<" "<<x1+y<<" "<<y1-x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=100005;
int n, k;
int a[maxn];

int main()
{
    while(~scanf("%d%d", &n, &k)){
        int ans=0, g=0;
        for(int i=0;i<n;i++){
            scanf("%d", &a[i]);
            g=__gcd(g, a[i]);
        }
        sort(a, a+n);
        if(k<=a[n-1]&&k%g==0)cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
n = gets.to_i
chars = %w[a b c d e f g h i j]
list = []
n.times do
  next list << 'a' if list.empty?

  tmp = []
  list.each do |s|
    n = s.chars.uniq.size
    ts = chars[0..n]
    ts.each do |c|
      tmp << s + c
    end
  end
  list = tmp
end

list.each do |str|
  puts str
end

Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//d
int main(){
  
  int64_t A, B, N;
  cin >> A >> B >> N;
  
  if(B == 1){
    cout << "0" << endl;
    return 0;
  }
  
  int64_t x;
  if(N >= B-1) x = B-1;
  else x = N;
  
  int64_t ans = (A*x)/B - A*(x/B);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	a=b=c=0;
	char f[3];
	
	for(int i=0;i<3;i++){
		scanf("%c",&f[i]);
		if(f[i]=='a') a++;
		if(f[i]=='b') b++;
		if(f[i]=='c') c++;
	}
	if(a&&b&&c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(3,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    ll diff = B-A;
    bool ans = false;
    FORq(a,0,N-1){
        ll b = N - a - 1;
        if ((b * C - a * D <= diff) and (diff <= b * D - a * C)){
            ans = true;
        }
    }

    if (ans) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    /**
     *
     * k = 1
     *
     * 2^17+1  2^17     0
     * 1      2^17+1   1
     *
     * dp[2][2] = max(
     */

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int r = sc.nextInt();
        System.out.println(r*2.0*Math.PI);
    }

    private static void solve(int[] ans, int n, int[] arr) {

    }

    /**\
     *
     * 4
     * 2 3 4 5
     *
     *
     * 1 2 3 4 5 6 7 8
     * 2 6 3 7 4 8 5 9
     */

    // 1 1 1 0 0 0
    // 0 0 1 1 1 1


    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

/**
 * 7 3
 * 3 1 5
 * 9 6 5
 *
 * i = 1: 1
 * i = 2: 2
 * i = 3: 3
 *
 *
 * 1 2 3 3 3 3 3
 */


/**
 *
 *  1+1
 **/

Measured memory_bytes: 33248
abc=input("").split(" ")
a=int(abc[0])
b=int(abc[1])
c=int(abc[2])
k=int(input(""))
s=0
while(b<=a):
    s+=1
    b*=2
while(c<=b):
    s+=1
    c*=2
if(s<=k):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D) {
        cout << "Left" << endl;
    }else if(A+B == C+D){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;   
    }
}

Measured memory_bytes: 256
//Name: Petting Cats
//Level: 1
//Category: やるだけ
//Note:

/*
 * 点が矩形に含まれているか判定するだけ。
 *
 * オーダーは O(N)。
 */
#include <iostream>

using namespace std;

void solve() {
    int X, Y, W, H;
    cin >> X >> Y >> W >> H;
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        ans += (X <= x && x <= X+W && Y <= y && y <= Y+H);
    }
    cout << ans << endl;
}

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

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

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

int ans;
/*
int dp(int index,int arr[],int deja[])
{
    if(index>=n-1)
        return 0;

        if(deja[index])
            return deja[index];

        int choice1=INT_MAX,choice2=INT_MAX;
        if(index<n-1)
     choice1=dp(index+1,arr,deja)+abs(arr[index+1]-arr[index]);
     if(index<n-2)
     choice2= dp(index+2,arr,deja)+abs(arr[index+2]-arr[index]);
    //cout<<choice1<<" "<<choice2<<endl;
    deja[index] = min(choice1,choice2);
     return deja[index];

}*/
int main()
{

int n;
cin>>n;

int arr[n],dp[n+1];
for(int index=0;index<n;index++)
{
    cin>>arr[index];
    dp[index+1]=INT_MAX;
}
dp[0]=0;
for(int i=0;i<n;i++)
{

        dp[i+1]=min(dp[i]+abs(arr[i+1]-arr[i]),dp[i+1]);
        dp[i+2]=min(dp[i]+abs(arr[i+2]-arr[i]),dp[i+2]);

}
cout<<dp[n-1]<<endl;

    return 0;
}


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

int main(){
    int n;
    int a[100];
    double sum = 0;

    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum+=a[i];
    }

    int x = (int)round(sum/n);

    int ans = 0;
    for(int i = 0;i < n;i++){
        ans+=((a[i]-x)*(a[i]-x));
    }
    cout << ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  ll n;cin >> n;
  vector<ll> v(n);
  map<ll,ll> mp;
  for(ll i=0;i<n;++i){
    cin >> v[i];
    if(mp.find(v[i])!=mp.end()){
      ++mp[v[i]];
    } else {
      mp[v[i]] = 1;
    }
  }
  ll out = 0;
  for(const auto& ele : mp){
    out += ele.second*(ele.second-1)/2;
  }
  for(ll i=0;i<n;++i){
    cout << out - mp[v[i]]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 11008
#include<stdio.h>


int main()
{
	int a, b,i;
	scanf("%d%d", &a, &b);
	if (a <= b)
		for (i = 0; i < b; i++)
			printf("%d", a);
	else
		for (i = 0; i < a; i++)
			printf("%d", b);
}

Measured memory_bytes: 128
#!/usr/bin/env python
from collections import Counter


def main():
    ab = [
        [int(a) for a in input().split()]
        for _ in range(3)
    ]
    fl = [a for b in ab for a in b]

    c = Counter(fl)
    res = c.items()

    vvv = [v for k, v in res]

    if all(a in [1, 2] for a in vvv):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
/*----------------------------------------
			Author: kkkstra
----------------------------------------*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
inline int read()
{
	char ch = getchar();
	int f = 1, x = 0;
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int num[10] = {1, 10, 100, 1000, 10000, 100000, 1000000};
int ans[10] = {0, 9, 9, 909, 909, 90909, 90909};

int main()
{
	int n, x, last;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &x);
		if (x < last)
		{
			printf("No\n");
			return 0;
		}
		if (x - 1 >= last)
			--x;
		last = x;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
using namespace std;
const long long mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> sum(n);
  
  rep(i,n,0){
    int w;
    cin >> w;
    if(i == 0) sum[i] = w;
    else sum[i] = sum[i-1]+w;
  }
  
  int ans = sum[n-1];
  rep(i,n,0){
    if(ans > abs(sum[n-1] - sum[i]*2)) ans = abs(sum[n-1] - sum[i]*2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}Graph;

main(){
  int i,j,n;
  int a[100][100];
  Graph node[100];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&node[i].u);
    scanf("%d",&node[i].k);
    for(j=0;j<node[i].k;j++)scanf("%d",&node[i].v[j]);
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
    for(j=0;j<node[i].k;j++){
      a[i][node[i].v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
    if(j<n-1)printf(" ");
    }
    if(i<n)printf("\n");
  }

  return 0;
}

Measured memory_bytes: 680
#include<stdio.h>

int main(){
    int a[10];
    char s[10];
    int ans =0;

    scanf("%s", &s);

    for(int i=0; i<4; i++){
        for(int j=i+1; j<4; j++){
            if(s[i] == s[j]){
                ans +=1;
            }
        }
    }
    if(ans == 2){
        printf("Yes");
    }else{
        printf("No");
    }


    return 0;
}

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

int main(){
	int N;
	cin >> N;
	ll a[3*N];
	rep(i,3*N) cin >> a[i];
	sort(a,a+3*N);
	ll ans = 0;
	for (int i = N; i < 3*N; i+=2) {
		ans += a[i];	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5976
var
x,i:longint;
s:string;
begin
readln(s);
readln(x);
for i:=1 to length(s) do
 if s[i]='1' then
 begin
 dec(x);
  if x=0 then
  begin
  writeln(1);
  halt;
  end;
 end
 else
 begin
 writeln(s[i]);
 halt;
 end;
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  long long K;
  cin >> S >> K;
  K--;

  char ans;
  int not1 = -1;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) != '1')
    {
      not1 = i;
      break;
    }
  }
  
  if (not1 < 0) ans = '1';
  else if (K < not1) ans = '1';
  else ans = S.at(not1);
  
  cout << ans << endl;
}

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

int main() {
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    long long now = a;
    if ( b != 1 ) {
        ans = 1;
        while (now < b) {
            now += (a-1);
            ans++;
        }
    } 
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

inf = int(1e12)

def shortestPath(graph):
    n = len(graph)
    dist = [[inf for _ in range(n)] for _ in range(n)]
    for i in range(n):
        dist[i][i] = 0
    
    for v in range(n):
        for u, cost in graph[v]:
            dist[v][u] = cost

    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dist[i][k] != inf and dist[k][j] != inf:
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
                
    return dist

def main():
    v, e = map(int, input().split())
    
    graph = [[] for _ in range(v)]
    
    for i in range(e):
        a, b, cost = map(int, input().split())
        graph[a].append((b, cost))
            
    dist_mat = shortestPath(graph)

    for i in range(v):
        if dist_mat[i][i] < 0:
            print("NEGATIVE CYCLE")
            return

    for i in range(v):
        output = []
        for j in range(v):
            if dist_mat[i][j] >= inf:
                output.append("INF")
            else:
                output.append(str(dist_mat[i][j]))
        print(" ".join(output))

main()

Measured memory_bytes: 8084
x,a,b=input().split()
x=int(x)
a=int(a)
b=int(b)
if x<a:
 distance_xa=a-x
else:
 distance_xa=x-a

if x<b:
 distance_xb=b-x
else:
 distance_xb=x-b

if distance_xa > distance_xb:
 print("B")
else:
 print("A")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = (a < b) ? b : a;
		int answer = -1;

		for(int i = 0;i < max;i++) {
			if(Math.abs(a - i) == Math.abs(b - i)) {
				answer = Math.abs(i);
				break;
			}
		}

		System.out.println(answer == -1 ? "IMPOSSIBLE" : answer);

	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define maxn 200020
#define maxm 400020
#define ll long long int 
using namespace std;

int n, m, d[maxn];
struct edge{
	int id, next, to;
	edge(int id, int next, int to) : id(id), next(next), to(to){}
	edge(){}
}e[maxm << 1];
int cnt = 1, h[maxn];
int v[maxm];
void Add_Edge(int id, int x, int y){
	e[++cnt] = edge(id, h[x], y);
	h[x] = cnt;
	e[++cnt] = edge(id, h[y], x);
	h[y] = cnt;
}
struct point{
	int id, d;
	point(int id, int d) : id(id), d(d){}
	point(){}
	bool operator < (const point b) const{
		return (d == b.d) ? id < b.id : d < b.d;
	}
}p[maxn];

int c[maxn];

int main(){
	
		//freopen("E.in", "r", stdin);
		
	int x, y;
	scanf("%d%d", &n, &m);
	rep(i, 1, n) scanf("%d", &d[i]), p[i] = point(i, d[i]);
	sort(p + 1, p + 1 + n);
	rep(i, 1, m) scanf("%d%d", &x, &y), Add_Edge(i, x, y);
	rep(j, 1, n){ 
		int x = p[j].id;
		if (c[x]) continue;
		assert(p[j].d == d[x]);
		bool f = 0;
		erep(i, x){
			int op = e[i].to;
			if (c[op]){
				v[e[i].id] = d[x];
				c[x] = 3 - c[op];
				f = 1;
				break;
			}
		}
		if (!f){
			bool f2 = 0;
			erep(i, x){
				int op = e[i].to;
				if (!c[op] && d[op] == d[x]){
					c[op] = 1, c[x] = 2, v[e[i].id] = d[x];
					f2 = 1;
					break;
				}
			}
			if (!f2) {
				printf("-1");
				return 0;
			}
		}
	}
	rep(i, 1, n){
		if (c[i] == 1) printf("B");
		else printf("W");
	}
	printf("\n");
	rep(i, 1, m){
		if (!v[i]) printf("1000000000\n");
		else printf("%d\n", v[i]);
	}
	return 0;
}

Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vstring s(n);
  rep(i,n){
    cin>>s[i];
  }
  int m;
  cin>>m;
  vstring t(m);
  rep(i,m){
    cin>>t[i];
  }
  int count=0,max=0;
  rep(i,n){
    count=0;
    rep(j,n){
      if(s[i]==s[j]){
        count++;
      }
    }
    rep(j,m){
      if(s[i]==t[j]){
        count--;
      }
    }
    chmax(max,count);
  }
  cout<<max<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll n;
string s;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    map<pair<string,string>,ll> count;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i+n];
            }
            else{
                t1 += s[i+n];
            }
        }
        reverse(all(t1));
        count[make_pair(t1,s1)]++;
    }
    ll ans = 0;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i];
            }
            else{
                t1 += s[i];
            }
        }
        reverse(all(t1));
        ans += count[make_pair(s1,t1)];
    }
    PRINT(ans);
}


Measured memory_bytes: 87040
import java.util.Scanner;

public class Main {
    private static long calc(String s, boolean[] ifplus, int i) {
        if(i == s.length() - 1) {
            long ans = 0;
            int before = -1;
            for(int j = 0; j < s.length() - 1; j++) {
                if(ifplus[j]) {
                    ans += Long.parseLong(s.substring(before + 1, j + 1));
                    before = j;
                }
            }
            ans += Long.parseLong(s.substring(before + 1));
            return ans;
        }

        boolean[] next1 = new boolean[s.length() - 1];
        boolean[] next2 = new boolean[s.length() - 1];
        for(int j = 0; j < i; j++) {
            next1[j] = ifplus[j];
            next2[j] = ifplus[j];
        }
        next1[i] = true;
        next2[i] = false;
        return calc(s, next1, i + 1) + calc(s, next2, i + 1);
    }

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

        String s = sc.next();
        boolean[] tmp = new boolean[s.length() - 1];
        System.out.println(calc(s, tmp, 0));

        sc.close();
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

vector<ll>ba(51, 0), pa(51, 0);
ll n, x;

ll func(ll n, ll x) {




	return 0;
}



signed main() {
	int i, j;
	int n, k;
	vector<int>list;

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	int minn = 999999999;

	for (i = 0; i < n - (k-1); i++) {
		minn = min(minn, list[i] - list[i + (k - 1)]);
	}
	cout << minn << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, x[100000], l[100000], ans = 0, y = -2e9;
  pair<int, int> p[100000];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &l[i]);
    p[i] = {x[i] + l[i], x[i] - l[i]};
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    if (y <= p[i].second) {
      ans++;
      y = p[i].first;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
#define REP(i,n) for(int(i)=0;i<n;i++)

int main() {
    int n;
    cin >> n;
    int a = n / 100;
    int b = n % 10;
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

struct Node{
int key;
Node *next ,*prev;
};

Node*nil;

Node *listSearch(int key){
    Node *cur=nil->next;
    while(cur !=nil&&cur->key!=key){
        cur=cur->next;
    }return cur;
}

void init(){
    nil=(Node*)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
}

void printList(){
    Node *cur=nil->next;
    int isf=0;
    while(1){
        if(cur==nil)break;
        if(isf++>0)printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t==nil)return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x=(Node *)malloc(sizeof(Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
int key,n,i;
int size=0;
char com[20];
int np=0,nd=0;
scanf("%d",&n);
init();
for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){insert(key);np++;size++;}
    else  if(com[0]='d'){
        if(strlen(com)>6){
            if(com[6]=='F')deleteFirst();
            else if(com[6]=='L')deleteLast();
        }else {deleteKey(key);nd++;}
        size--;
    }

}
printList();


return 0;
}

Measured memory_bytes: 33912
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  int N, M;
  cin >> N >> M;
  auto a = vector<int>(N);
  auto b = vector<int>(N);
  REP(i, N) {
    cin >> a[i];
    b[i] = a[i] / 2;
  }
  ll cnt;
  if(N == 1) {
    cnt = M / b[0];
  } else {
    ll gcd_of_a = gcd(a[0], a[1]);
    REPS(i, 2, N) {
      gcd_of_a = gcd(gcd_of_a, a[i]);
      //
    }
    ll lcm_of_b = lcm(b[0], b[1]);
    REPS(i, 2, N) {
      lcm_of_b = lcm(lcm_of_b, b[i]);
      //
    }
    REP(i, N) {
      if((a[i] / gcd_of_a) % 2 == 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    cnt = M / lcm_of_b;
  }

  if(cnt % 2 == 1) {
    cout << cnt / 2 + 1 << endl;
  } else {
    cout << cnt / 2 << endl;
  }
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;
 class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in); 
		int t,i;
		String s=sc.next();
		if(s.equals("ABC"))
			System.out.println("ARC");
		else
			System.out.println("ABC");
			
	}
}

Measured memory_bytes: 35624
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int a, b, c, x; cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(500 * i + 100 * j + 50 * k == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  int deg_a = ((60*h+ 1*m) % 720);
  int deg_b = (12 * m) % 720;

  ld delta_deg = abs(deg_a - deg_b);
  delta_deg = min(delta_deg, 720 - delta_deg) * M_PI / 360;

  ld x = a * sin(delta_deg);
  ld y = b - a*cos(delta_deg);
  cout << fixed << setprecision(15) << sqrt(x*x + y*y) << endl;
}

Measured memory_bytes: 4152
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int n = line[0], m = line[1];

            var total = 0;
            var max = 0;
            var min = int.MaxValue;

            for (var i = 0; i < m; i++)
            {
                var tmp = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
                max = Math.Max(tmp[0], max);
                min = Math.Min(tmp[1], min);
            }

            foreach (var x in Enumerable.Range(1, n))
            {
                if (x >= max && x <= min) total++;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 17488
#include<stdio.h>
int main(void)
{
	int a,b,c,n;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<=b && b<=c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<=c && c<=b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a && a<=c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c && c<=a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<=b && b<=a){
		printf("%d %d %d\n",c,b,a);
	}
	
	return 0;
}



Measured memory_bytes: 2736
#include<iostream>
#include <iomanip>
using namespace std;
int main() {
    double r;
    cin >> r;
    double pi = 3.14159265358979323846;
    double a = r*r*pi;
    double b = 2.00000000*r*pi;
    std::cout << std::setprecision(100) << a << " " << b << endl;
    return 0;
}


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

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

  int head = 0;
  while (S[head] != 'A') head++;
  int tail = S.size() - 1;
  while (S[tail] != 'Z') tail--;
  cout << tail - head + 1 << endl;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KotoDistance solver = new KotoDistance();
        solver.solve(1, in, out);
        out.close();
    }

    static class KotoDistance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int W = in.nextInt();
            int H = in.nextInt();
            int[] wimos = new int[W + 10];
            int[] himos = new int[H + 10];
            for (int i = 0; i < N; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                int w = in.nextInt();
                wimos[Math.max(0, x - w)]++;
                wimos[Math.min(W, x + w)]--;
                himos[Math.max(0, y - w)]++;
                himos[Math.min(H, y + w)]--;
            }
            for (int i = 1; i <= W + 1; i++) {
                wimos[i] += wimos[i - 1];
            }
            for (int i = 1; i <= H + 1; i++) {
                himos[i] += himos[i - 1];
            }
            boolean wng = false;
            for (int i = 0; i < W; i++) {
                wng |= (wimos[i] == 0);
            }
            boolean hng = false;
            for (int i = 0; i < H; i++) {
                hng |= (himos[i] == 0);
            }
            out.println((hng && wng ? "No" : "Yes"));
        }

    }
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    string s;
    cin >> s;
    s = '.' + s;
    if ((s[1] != s[2]) and (s[3] == s[4]) and (s[5] == s[6])) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << (a != c) << endl;


}

Measured memory_bytes: 3632
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Mon Jan  7 01:51:47 2019
//
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	if A == B {
		fmt.Println(C)
	} else if A == C {
		fmt.Println(B)
	} else {
		fmt.Println(A)
	}
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
c = 0
while True:
    flag = False
    for i, x in enumerate(a):
        if x % 2 == 0:
            a[i] /= 2
        else:
            flag = True
            break
    if flag:
        break
    else:
        c += 1
print(c)


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"strings"
)

func dayDream(input string) string {
	rdream := Reverse("dream")
	rdreamer := Reverse("dreamer")
	rerase := Reverse("erase")
	reraser := Reverse("eraser")
	rinput := Reverse(input)
	for len(rinput) > 0 {
		if strings.HasPrefix(rinput, rdream) || strings.HasPrefix(rinput, rerase) {
			rinput = rinput[5:]
		} else if strings.HasPrefix(rinput, reraser) {
			rinput = rinput[6:]
		} else if strings.HasPrefix(rinput, rdreamer) {
			rinput = rinput[7:]
		} else {
			return "NO"
		}
	}

	return "YES"
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var input string
	fmt.Scan(&input)
	fmt.Println(dayDream(input))

}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int black[2'000][2'000];
int white[2'000][2'000];

int blackSum[2'000][2'000];
int whiteSum[2'000][2'000];

int rect(int tbl[][2'000], int x, int y, int w, int h, int k)
{
    if (w == 0 || h == 0)
    {
        return 0;
    }
    int s = 0;
    s += tbl[x + w - 1][y + h - 1];
    s -= y == 0 ? 0 : tbl[x + w - 1][y - 1];
    s -= x == 0 ? 0 : tbl[x - 1][y + h - 1];
    s += x == 0 || y == 0 ? 0 : tbl[x - 1][y - 1];

    return s;
}

int rectRepeat(int tbl[][2'000], int x, int y, int w, int h, int k)
{
    int ww = min(w, 2 * k - x);
    int hh = min(h, 2 * k - y);
    int lb = rect(tbl, x, y, ww, hh, k);
    int lt = rect(tbl, x, 0, ww, h - hh, k);
    int rt = rect(tbl, 0, 0, w - ww, h - hh, k);
    int rb = rect(tbl, 0, y, w - ww, hh, k);

    return lb + lt + rt + rb;
}

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

    for (int i = 0; i < 2 * k; i++)
        for (int j = 0; j < 2 * k; j++)
        {
            black[i][j] = white[i][j] = 0;
        }

    for (int i = 0; i < n; i++)
    {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W')
        {
            white[x % (2 * k)][y % (2 * k)]++;
        }
        else
        {
            black[x % (2 * k)][y % (2 * k)]++;
        }
    }

    for (int i = 0; i < 2 * k; i++)
    {
        for (int j = 0; j < 2 * k; j++)
        {
            blackSum[i][j] = 0;
            whiteSum[i][j] = 0;
            if (j != 0)
            {
                blackSum[i][j] += blackSum[i][j - 1];
                whiteSum[i][j] += whiteSum[i][j - 1];
            }
            if (i != 0)
            {
                blackSum[i][j] += blackSum[i - 1][j];
                whiteSum[i][j] += whiteSum[i - 1][j];
            }
            if (i != 0 && j != 0)
            {
                blackSum[i][j] -= blackSum[i - 1][j - 1];
                whiteSum[i][j] -= whiteSum[i - 1][j - 1];
            }
            blackSum[i][j] += black[i][j];
            whiteSum[i][j] += white[i][j];
        }
    }

    int result = 0;
    for (int i = 0; i < 2 * k; i++)
    {
        for (int j = 0; j < 2 * k; j++)
        {
            int s = 0;
            s += rectRepeat(blackSum, i, j, k, k, k);
            s += rectRepeat(blackSum, (i + k) % (2 * k), (j + k) % (2 * k), k, k, k);
            s += rectRepeat(whiteSum, (i + k) % (2 * k), j, k, k, k);
            s += rectRepeat(whiteSum, i, (j + k) % (2 * k), k, k, k);

            result = max(result, s);
        }
    }

    cout << result << endl;
    return 0;
}

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

int n,nw,x,k;

int main()
{
	scanf("%d",&n),nw=0;
	while (n--)
	{
		scanf("%d%d",&x,&k);
		while (x%k!=0)
		{
			if (x/k>30000) x-=(x/k+1);
			else x-=((x%k-1)/(x/k+1)+1)*(x/k+1);
		}
		nw^=(x/k);
	}
	puts(nw?"Takahashi":"Aoki");
	return 0;
}

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

int main() {

  int N, K;
  cin >> N >> K;

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

  int answer = 0;

  answer = ceil((double) (N - 1) / (K - 1));

  cout << answer << endl;

  return 0;

}

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

bool func(int node);
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int n, m;  cin >> n >> m;
    V H(n);  VECCIN(H);

    vector<bool> kp(n);  fill(ALL(kp), true);
    vector<vector<int>> edge(n);  //頂点iが持つ辺
    REP(i, m){
      int A, B;  cin >> A >> B;
      edge[A-1].push_back(B-1);
      edge[B-1].push_back(A-1);
    }

    int ans = 0;
    REP(i, n){
      if(kp[i] == false)  continue;

      bool is_highest = true;
      for(int j : edge[i]){
        if(H[i] <= H[j])  is_highest = false;
        else              kp[j] = false;
      }

      if(is_highest)  ans++;
    }

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


Measured memory_bytes: 8744
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
const int mod=1e9+7;
int n,k1;
int dp[51][51][2501];
int main(){
	scanf("%d%d",&n,&k1);

    dp[1][0][0]=1;
    dp[1][1][0]=1;

    for(int i=1;i<n;i++){
        for(int j=0;j<=n;j++){
         for(int k=0;k+2*j<=k1;k++){
            int val=dp[i][j][k];
            dp[i+1][j][k+2*j]=(dp[i+1][j][k+2*j]+1ll*(2*j+1)*val%mod)%mod;
            if(j>0)
            dp[i+1][j-1][k+2*j]=(dp[i+1][j-1][k+2*j]+1ll*j*j*val%mod)%mod;
            if(j<n)
            dp[i+1][j+1][k+2*j]=(dp[i+1][j+1][k+2*j]+val)%mod;
         }
        }
    }
    printf("%d\n",dp[n][0][k1]);
    return 0;
}


Measured memory_bytes: 28184
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int X;
	int sum = 0;
	
	cin>>X;
	
	for(int i = 1; i <= X; i++){
		sum += i;
		
		if(sum >= X){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// 連鎖行列積 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
#define ELE_NUM 2
// 無効な値の定義
const int INV = -1;

const int colNo = 0;
const int rowNo = 1;
const int IntMAX = 	2147483647;

int ChainedMatrixtMultiplication(int n, int m, int matrixData[][ELE_NUM]);

int main(void)
{

    int n, count;
    int matrix_data[MAX_N + 1][ELE_NUM];

    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        // 行
        cin >> matrix_data[i][colNo];
        // 列
        cin >> matrix_data[i][rowNo];
    }

    count = ChainedMatrixtMultiplication(n, ELE_NUM, matrix_data);
    printf("%d\n", count);

    return 0;
}

// 連鎖行列積の最小の乗算回数を演算する関数
// n : 積を求める行列の数
// m : 行列の情報 : 0 - 行の情報, 1 - 列の情報
// matrixData[][] : 各行列の行、列情報を保持する配列
int ChainedMatrixtMultiplication(int n, int m, int matrixData[][ELE_NUM])
{

    // 第1要素 : 演算開始のNo., 第2要素 : 演算終了のNo.
    int dp[MAX_N + 1][MAX_N + 1];
    int calcResult = 0;

    // 配列の初期化
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            dp[i][j] = INV;

            if( i == j )
            {
                // 同じ要素同士の積は演算することが不可能
                dp[i][j] = 0;
            }
        }
    }

    // 行列の演算回数の計算
    for(int l = 2; l <= n; l++)
    {
        for(int i = 1; i <= n - l + 1; i++)
        {
            int j = i + l - 1;

            dp[i][j] = IntMAX;

            for(int k = i; k <= j - 1; k++)
            {
                // 3つ以上の要素の積の時
                calcResult = dp[i][k] + dp[k + 1][j]
                            + ( matrixData[i][colNo] * matrixData[k][rowNo] * matrixData[j][rowNo]);

                dp[i][j] = min( dp[i][j], calcResult );
            }
        }
    }

    return dp[1][n];
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
char a[5005];
char b[5005];
set<string>s;
string p;
int main()
{
    int k;
    scanf("%s",a);
    scanf("%d",&k);
    int len=strlen(a),j;
    for(int i=0;i<len;i++)
    {
        j=0;
        b[j++]=a[i];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-1;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-2;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-3;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2],b[j++]=a[i+3];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-4;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2],b[j++]=a[i+3],b[j++]=a[i+4];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    int m=0;
    for(set<string>::iterator it=s.begin();it!=s.end();it++)
    {
        m++;
        if(m==k)
        {
            cout<<*it<<endl;
        }
    }
    return 0;
}


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


int main() {
  int n,x;
  cin >> n>>x;
  vector<long>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  long ans=0;
  rep(i,n-1){
    if(a.at(i)>x){
      ans+=a.at(i)-x;
      a.at(i)=x;
    }
    if(a.at(i)+a.at(i+1)>x){
      ans+=a.at(i)+a.at(i+1)-x;
      a.at(i+1)-=a.at(i)+a.at(i+1)-x;
    }
  }
    cout<<ans<<endl;
  
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod2 1000000007
#define mod 998244353
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}

int main(){
    int k;
    string s;
    cin >> k;
    cin >> s;
    int len=s.size();
    if(len<=k){
        cout << s << endl;
    }
    else{
        rep(i,k){
            cout << s[i];
        }
        cout <<"..." <<endl;
    }

    return 0;
}



Measured memory_bytes: 3632