akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}

int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    ll tmp=0;
    rep(i,0,n){cin>>a[i]; tmp=tmp^a[i];}
    for(ll i=0;i<n;i++)
    {
        ll ans=tmp^a[i];
        cout<<ans<<" ";
    }


    return 0;
}


Measured memory_bytes: 5172
n,*a=map(int,open(0).read().split())
r=[400,800,1200,1600,2000,2400,2800,3200]
b=[0]*8
c=0
for i in range(n):
    for j in range(8):
        if a[i]<r[j]:
            b[j]=1
            break
    if a[i]>=3200:    
        c+=1
print(max(1,sum(b)),c+sum(b))   

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	string result = "No";

	if (a == b || b == c || a == c) result = "Yes";
	if (a == b && b == c) result = "No";
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vp;
typedef set<ll> si;
typedef map<string, ll> msi;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
ll mod =1e9+7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int T;
  T=1;
  while(T--)
  {
      ll n,i,j,k,l,m;
      cin>>n>>k;
      string s;
      vector<ll> v,pos,neg;

      REP(i,0,n-1){
        cin>>j;
        v.pb(j);
        if(j>=0)pos.pb(j);
        else{
          neg.pb(j);
        }
      }
      sort(v.begin(),v.end());
      sort(pos.begin(),pos.end());
      sort(neg.begin(),neg.end());
      stack<ll> s1,s2;
      REP(i,0,pos.size()-1)s1.push(pos[i]);
      DEP(i,neg.size()-1,0)s2.push(neg[i]);
      ll cnt=0;
      vector<ll> resp,resn;
      ll p1=-1,n1=1;
      while(!s1.empty()&&!s2.empty()&&k--){
        ll x=s1.top(),y=s2.top();
        if(abs(x)>=abs(y)){
          resp.pb(x);
          s1.pop();
          p1=x;
        }
        else{
          cnt++;
          resn.pb(y);
          s2.pop();
          n1=y;
        }
      }
      while(k>0&&!s1.empty()){
        resp.pb(s1.top());
        p1=s1.top();
        s1.pop();
        k--;

      }

      while(k>0&&!s2.empty()){
        resn.pb(s2.top());
        n1=s2.top();
        s2.pop();
        k--;
        cnt++;
      }
      if(cnt%2!=0){
        if(s2.empty()&&!s1.empty()&&n1<0){
          resn.pop_back();
          resp.pb(s1.top());
        }
        else if(s1.empty()&&!s2.empty()&&p1>=0){
          resp.pop_back();
          resn.pb(s2.top());
        }
        else if(!s1.empty()&&!s2.empty()){
          if((p1==-1)||(p1*s1.top()>=n1*s2.top())){
            resn.pop_back();
            resp.pb(s1.top());
          }
          else {
            resp.pop_back();
            resn.pb(s2.top());
          }
        }
        else{
          resn.clear();
          DEP(i,neg.size()-1,0){
            if(cnt<=0)break;
            resn.pb(neg[i]);
            cnt--;
          }
        }
      }
      ll ans=1;
      REP(i,0,resp.size()-1){
        ans=(ans*((resp[i]+mod)%mod))%mod;
      }

      REP(i,0,resn.size()-1){
        ans=(ans*((resn[i]+mod)%mod))%mod;
      }
      cout<<ans;
  }

  return 0;
}

Measured memory_bytes: 11124
import Control.Monad
import Control.Applicative
import Data.List

data Circle = Circle {getX::Double, getY::Double, getR::Double}

dist :: Circle -> Circle -> Double
dist ca cb = sqrt $ (getX ca - getX cb) ^ 2 + (getY ca - getY cb) ^ 2

intsect :: Circle -> Circle -> Int
intsect ca cb | d - getR ca - getR cb > eps = 0
              | getR ca - getR cb - d > eps = 2
              | getR cb - getR ca - d > eps = -2
              | otherwise = 1
  where d = dist ca cb

eps :: Double
eps = 0.0000000001

main = do
  n <- readLn :: IO Int
  xs <- input n (map read . words) :: IO [[Double]]
  mapM_ print $ solve xs

solve :: [[Double]] -> [Int]
solve = map f
  where f :: [Double] -> Int
        f [xa, ya, ra, xb, yb, rb] = intsect (Circle xa ya ra) (Circle xb yb rb)

input :: Int -> (String -> a) -> IO [a]
input n f = map f <$> replicateM n getLine

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pii;

int main() {
    std :: ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //-------------------------------------------------------------------------------------------------------
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 8; i++)
        cout << s[i];
    //-------------------------------------------------------------------------------------------------------
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int ab = sc.nextInt();
    	int bc = sc.nextInt();
    	int ca = sc.nextInt();

    	int ans = ab * bc / 2;
    	
    	// 出力
    	System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#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 mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
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;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>b(n);
    vector<ll>c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    rep(i,n){
        vector<ll>::iterator ite_a=lower_bound(a.begin(),a.end(),b[i]);
        ll count_a=ite_a-a.begin();
        vector<ll>::iterator ite_c=upper_bound(c.begin(),c.end(),b[i]);
        ll count_c=c.end()-ite_c;
        ans+=count_a*count_c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
N, K = map(int, input().split())
p = list(map(int, input().split()))
ex_vals = [(pi+1) / 2 for pi in p]
cumsum = [0]
for i,e in enumerate(ex_vals):
    cumsum.append(cumsum[i] + e)
ans = 0
for i in range(N-K+1):
    ans = max(ans, cumsum[i+K] - cumsum[i])
print(ans)

Measured memory_bytes: 79112
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;



int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0 << endl;
	}
	else if  (a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
}



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

int main(void){
    int A,B,K,i=1;
    cin>>A>>B>>K;
    
    vector<long long> a;
    while(i<=max(A,B)){
        if(A%i==0&&B%i==0)a.push_back(i);
        i++;
    }
    
    int ans=a[a.size()-K];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    for j in range(h):
        for i in range(w):
            if i == 0 or i == w-1 or j == 0 or j == h-1:
                print("#", end = (""))
            else:
                print(".", end=(""))
        print()
    print()


Measured memory_bytes: 7004
N=int(input())
S=str(input())

r=S.count('R')
g=S.count('G')
b=S.count('B')


ans=r*g*b
dib=0
m=0

for i in range(N-2):
    m=(N+i)//2+1
    for j in range(i+1,m):
            dib=j-i
            if j+dib<=N-1:
                if S[i]!=S[j] and S[i]!=S[j+dib] and S[j]!=S[j+dib]:
                    ans=ans-1
            
print(ans)


Measured memory_bytes: 9148
import sys
input = sys.stdin.readline

from bisect import bisect

inf = float('inf')

A,B,Q = map(int,input().split())
S = [-inf] + [int(input()) for _ in range(A)] + [inf]
T = [-inf] + [int(input()) for _ in range(B)] + [inf]
X = [int(input()) for _ in range(Q)]

for x in X:
    ans = inf
    si = bisect(S,x)
    ti = bisect(T,x)
    for s in [S[si-1],S[si]]:
        for t in [T[ti-1],T[ti]]:
            res = abs(s-t) + min(abs(x-s),abs(x-t))
            ans = min(ans,res)
    print(ans)

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int n;
vvl dp;
vl A;
ll f(int l, int r) {
    if(l > r) return 0;
    if(dp[l][r] != INF) return dp[l][r];
    int flg = (l + n - r) % 2;
    if(flg) dp[l][r] = max(f(l + 1, r) + A[l], f(l, r - 1) + A[r]);
    else dp[l][r] = min(f(l + 1, r) - A[l], f(l, r - 1) - A[r]);
    return dp[l][r];
}


int main(){
    cin >> n;
    A = vl(n);
    rep(i, n) cin >> A[i];
    dp.resize(n, vl(n, INF));
    co(f(0, n - 1));
}



Measured memory_bytes: 74024
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

t = [[0] * w for _ in range(h)]
n = 0
rows = []
for i in range(h):
    if s[i].count("#") == 0:
        rows.append(i)
    else:
        if s[i][0] == "#":
            for j in range(w):
                if s[i][j] == "#":
                    n += 1
                t[i][j] = n
        else:
            n += 1
            f = 0
            for j in range(w):
                if f and s[i][j] == "#":
                    n += 1
                elif s[i][j] == "#":
                    f = 1
                t[i][j] = n

if rows != [] and rows[-1] == h-1:
    for k in range(h)[::-1]:
        if t[k][j] != 0:
            for j in range(w):
                t[rows[-1]][j] = t[k][j]
            break
        
for i in rows:
    for k in range(i+1, h):
        if t[k][j] != 0:
            for j in range(w):
                t[i][j] = t[k][j]
            break

for i in range(h):
    print(*t[i])

Measured memory_bytes: 70016
#include<stdio.h>

int main (void){
  int n,k;
  scanf("%d\n",&n );
  k=n%10;

  if (k==2||k==4||k==5||k==7||k==9) {
    printf("hon" );
  }
  else if (k==0||k==1||k==6||k==8) {
    printf("pon" );
  }
  else if (k==3) {
    printf("bon" );
  }
}


Measured memory_bytes: 1732
void main(){
	
	auto ABCD = readLine!long();
	
	foreach( i ; 0..102 ){
		ABCD[2] -= ABCD[1];
		if( ABCD[2] <= 0 ){	writeln("Yes");return;	}
		ABCD[0] -= ABCD[3];
		if ( ABCD[0] <= 0 ){	writeln("No");return;	}
	}
	
	
}


import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import std.regex;

T[] readLine( T = size_t )( string sp = " " ){
	T[] ol;
	foreach( string elm ; readln().chomp().split(sp) ){
		ol ~= elm.to!T();
	}
	return ol;
}

Measured memory_bytes: 3160
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    for s in "KIHBR":
        if S.count(s) != 1:
            print("NO")
            exit()

    A = S.count("A")
    if len(S) - A != 5:
        print("NO")
        exit()

    K = S.find("K")
    I = S.find("I")
    H = S.find("H")
    B = S.find("B")
    R = S.find("R")
    if not (K < I < H < B < R):
        print("NO")
        exit()
    if K > 1:
        print("NO")
        exit()
    if I - K != 1:
        print("NO")
        exit()
    if H - I != 1:
        print("NO")
        exit()
    if B - H > 2:
        print("NO")
        exit()
    if R - B > 2:
        print("NO")
        exit()
    if len(S) - 1 - R > 1:
        print("NO")
        exit()

    print("YES")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
#include <stdio.h>
int main(){
	int a, b, r;
	int i=0;
	while(scanf("%d%d",&a,&b) != EOF){
		r = a+b;
		for(i = 0; r>0; i++){
			r = r/10;
		}
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 600
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int main(){
    int r;cin >> r;
    cout << r*r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int N, K;
	while( cin >> N >> K ){
		int n[10000], i;
		for(i=0; K; K--){
			n[i++] = N/K;
			N = N-n[i-1];
		}
		sort(n, n+i);
		cout << n[i-1]-n[0] << endl;
	}	
	return 0;
}

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

ll mod = 1e9 + 7;

void StronglyConnectedComponents(ll n,vector<ll> v[]){
    bool visited[n];
    ll ans = 0, cnt = 0;
    for(ll i = 0; i < n; i++)
        visited[i] = false;
    for(ll i = 0; i < n; i++){
        if(!visited[i]){
            ll node = i + 1, k = 1;
            queue <ll> q;
            q.push(node);
            visited[node - 1] = true;
            while(!q.empty()){
                for(ll i = 0; i < v[q.front() - 1].size(); i++){
                    if(!visited[v[q.front() - 1][i] - 1]){
                        q.push(v[q.front()- 1][i]);           
                        visited[v[q.front()- 1][i]- 1] = true; 
                        k++;
                    }
                }
                q.pop();
                cnt++;
            }
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1; 
    //cin >> t;
    for(ll T = 0; T < t ; T++){
         ll n;                       
        cin >> n;
        ll m;                     
        cin >> m;
        ll x, y;
        vector<ll> v[n];         
        for(ll i = 0; i < m; i++){
            cin >> x >> y;
            v[x - 1].push_back(y);
            v[y - 1].push_back(x);
        }
        StronglyConnectedComponents(n, v);
    }
    return 0;
}

Measured memory_bytes: 17360
#include <iostream>

using namespace std;

int main(){
	int h, w;

	while(1){
		cin >> h >> w;

		if(h==0 && w==0){
			break;
		}

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(i==0 || i==h-1) cout << '#';
				else if(j==0 || j==w-1) cout <<'#';
				else cout << '.' ;
			}
			cout << endl;
		}

		cout << endl;
	}
}

Measured memory_bytes: 1152
n = int(input())
cards = {'S': [0 for _ in range(13)],
         'H': [0 for _ in range(13)],
         'C': [0 for _ in range(13)],
         'D': [0 for _ in range(13)]}
for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    cards[suit][rank-1] = 1

for s in ['S', 'H', 'C', 'D']:
    for r in range(1, 14):
        if cards[s][r-1] == 0:
            print(' '.join([s, str(r)]))



Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
bool dp[100005];

void solve()
{   
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
        for(int i=1;i<=k;i++){
            for(auto x:v)
            if(i>=x && !dp[i-x])
                dp[i]=1;
    }
    
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}

Measured memory_bytes: 384
k = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
s = 0
a = []
s += B[A[0]-1]
a.append(A[0])
for i in range(1,k):
    if((A[i]-1)==a[-1]):
        s += (B[A[i]-1]+C[A[i]-2])
        a.append(A[i])
    else:
        a.append(A[i])
        s += B[A[i]-1]
print(s)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-8;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

P calc(int lhs,int rhs){
  int sum = lhs + rhs;
  int carry = 0;
  int cost = 0;
  for(int i = 0; i < 9; i++){
    cost += (lhs % 10) * (rhs % 10) + carry;
    carry = (lhs % 10 + rhs % 10 + carry >= 10 ? 1 : 0);
    lhs /= 10;
    rhs /= 10;
  }
  return P(sum,cost);
}

int main(){
  int N;
  while(~scanf("%d",&N)){
    vector<int> numbers;
    for(int i = 0; i < N; i++){
      int number;
      scanf("%d",&number);
      numbers.push_back(number);
    }
    P dp[301][301];
    for(int i = 0; i < numbers.size(); i++) {
      dp[i][i].first = numbers[i];
      dp[i][i].second = 0;
    }

    int sum = 0;
    for(int d = 1; d < numbers.size(); d++){
      for(int i = 0; i < numbers.size() - d; i++){
        int j = i + d;
        dp[i][j].second = INF;
        for(int k = i; k < j; k++){
          P tmp = calc(dp[i][k].first,dp[k+1][j].first);
          dp[i][j].first = tmp.first;
          dp[i][j].second = min(dp[i][j].second,
                                tmp.second + dp[i][k].second + dp[k+1][j].second);
        }
      }
    }

    cout << dp[0][numbers.size()-1].second << endl;
  }
}

Measured memory_bytes: 1936
/*

    HARSH KHATRI
    DA-IICT     

		 */

           	 

#include <bits/stdc++.h>

#define LOCAL 0
bool debug = true;

using namespace std;

int main(void) {
	
	if(LOCAL) {
    	freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	}

	int i, j, k, n;
	long long x, ans = 0;

	scanf("%d", &n);
	for(i=0; i<n; i++) { scanf("%lld", &x); ans += --x; }

	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main(){
  int N, K; cin >> N >> K;
  vector<mint> mae(N+1);
  mae[0]=0;
  vector<mint> usiro(N+1);
  usiro[N]=N;
  for(int i=1;i<=N;i++){
    mae[i]=mae[i-1]+i;
    usiro[N-i]=usiro[N-i+1]+(N-i);
  }
  mint ans=0;
  for(int64_t i=K;i<=N+1;i++){
    ans+=usiro[N-i+1]-mae[i-1]+1;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 6320
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
w = ni()

i = 0
while i < len(s):
    print(s[i], end="")
    i += w

print()

Measured memory_bytes: 3188
#include<stdio.h>
int main(void)
{
        int sec, min, hour;
        scanf("%d", &sec);
        if(sec<0 || 86400<sec) return -1;
        hour = sec / (60*60);
        min = (sec % (60*60)) / 60;
        sec = sec % 60;

        printf("%d:%d:%d\n" , hour, min, sec);
        return 0;
}

Measured memory_bytes: 592
c = input()
list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
if c != 'y':
    print(list[list.index(c) + 1])
else:
    print('z')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
char s0[200007];
int t[417];
int main(){
	scanf("%s",s0+1);
	int n=strlen(s0+1);
	long long ans=1ll*n*(n+1)/2+1;
	for(int i=1;i<=n;++i)++t[s0[i]-'a'];
	for(int i=0;i<26;++i)ans-=1ll*t[i]*(t[i]+1)/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,a,b;cin>>n>>a>>b;
    vll x(n);rep(i,n)cin>>x[i];
    ll sum=0;
    rep(i,n-1)sum+=min(a*(x[i+1]-x[i]),b);
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, a; vector <pair<int,int>> v;

void solve()
{
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a; v.pb({a,i});
    }
    sort(v.begin(),v.end());
    for (int i=0; i<n; i++) {sout(v[i].second + 1);}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main(){
	double w;
	
	while(cin >> w){
		if(w > 91) cout << "heavy";
		else if(w > 81) cout << "light heavy";
		else if(w > 75) cout << "middle";
		else if(w > 69) cout << "light middle";
		else if(w > 64) cout << "welter";
		else if(w > 60) cout << "light welter";
		else if(w > 57) cout << "light";
		else if(w > 54) cout << "feather";
		else if(w > 51) cout << "bantam";
		else if(w > 48) cout << "fly";
		else cout << "light fly";
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CAllGreen {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int d = in.nextInt(), g = in.nextInt() / 100;
            int[] p = new int[d];
            int[] c = new int[d];
            for (int i = 0; i < d; i++) {
                p[i] = in.nextInt();
                c[i] = in.nextInt() / 100;
            }

            int answer = Integer.MAX_VALUE;
            for (int s = 0; s < (1 << d); s++) {
                int problems = 0;
                int points = 0;
                for (int i = 0; i < d; i++) {
                    if (((s >> i) & 1) > 0) {
                        problems += p[i];
                        points += p[i] * (i + 1);
                        points += c[i];
                    }
                }
                if (points >= g) {
                    answer = Math.min(answer, problems);
                    continue;
                }
                for (int i = d - 1; i >= 0; i--) {
                    if (((s >> i) & 1) == 0) {
                        if (p[i] * (i + 1) + points >= g) {
                            problems += (g - points + i) / (i + 1);
                            answer = Math.min(answer, problems);
                            break;
                        }
                    }
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 32948
OK = 0
BRO = 1
MOD = 1000000007

N,M=map(int, input().split())
Broken=[int(input()) for i in range(M)]
#K = "".join(list(BRO if i in Broken else OK for i in range(N+1)))
K = list(0 for i in range(N+1))
for i in range(M):
  K[Broken[i]] = 1
  
dp=[0 for i in range(N+1)]
dp[0]=1
for i in range(N):
  for j in range(i+1,min(i+2+1,N+1)):
    if K[j]==OK:
      dp[j]+=dp[i]
      dp[j]%=MOD
      
print(dp[N])


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, sum;
VL a;

signed main() {
    cin >> N;
    REP(i, N) {
        a.emplace_back(IN());
        sum += a[i];
    }
    ll ave = round((double)sum / N);
    ll ans = 0;
    REP(i, N) ans += abs(ave - a[i]) * abs(ave - a[i]);
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;
int main()
{
    // 文字列の入力
	int N, D;
	cin >> N >> D;
	
	int count = 0;
	for(int i = 0; i < N; i++) {
		int X, Y;
		cin >> X >> Y;
		
		double dist = sqrt((double)X * (double)X + (double)Y * (double)Y);
		if(dist <= D) {
			count++;
		}
	}
	
	printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
using namespace std;
int main (void){
    int a,b,c;
    int now_point   =0;
    int day         =0;
    cin >> a >> b >> c;
    for (;now_point < c;){
        day++;
        now_point+=a;
        if (day % 7 == 0) now_point +=b;
    }
    cout << day << endl;
    return 0;
}


Measured memory_bytes: 3116
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
       
        int d, t, s; cin >> d >> t >> s;
        int xx = d%s;
        int ans = d/s;
        if(xx)
            ans++;
        if(ans <= t)
            cout << "Yes\n";
        else cout << "No\n";
        return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>

#define MAXNUM 1000001
#define MAX 100
using namespace std;

int all[MAXNUM], odd[MAXNUM], fourall[MAXNUM], fourodd[MAXNUM];

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

	//配列の初期化
	for (int i = 1; i < MAXNUM; i++){
		all[i] = MAX;
		odd[i] = MAX;

	}

	//1からMAXNUMまでの中に存在する正四面体数を洗い出す．
	long long int now = 0;
	long long int allcounter = 1, oddcounter = 1;
	while (1){
		now++;

		int four = now * (now + 1) * (now + 2) / 6;
		//cout << four << endl;
		if (four > MAXNUM)
			break;
		
		all[four] = 1;
		fourall[allcounter++] = four;

		if (four % 2 == 1){
			odd[four] = 1;
			fourodd[oddcounter++] = four;
		}
	}

	//cout << allcounter << ", " << oddcounter << endl;

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i < allcounter; i++){
		const int num_all = fourall[i];

		for (int j = 1; j < (MAXNUM - num_all); j++){
			all[j + num_all] = min(all[j + num_all], 1 + all[j]);
		}
	}

	for (int i = 1; i < oddcounter; i++){
		const int num_odd = fourodd[i];

		for (int j = 1; j < (MAXNUM - num_odd); j++){
			odd[j + num_odd] = min(odd[j + num_odd], 1 + odd[j]);
		}
	}


	/*
	for (int i = 1; i < MAXNUM; i++){
		for (int j = 1; fourall[j] < i; j++){
			all[i] = min(all[i], 1 + all[i - fourall[j]]);
			cout << all[i];
		}
		for (int j = 1; fourodd[j] < i; j++){
			odd[i] = min(odd[i], 1 + odd[i - fourodd[j]]);
		}

	}

	*/

	//cout << "a";
	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}

Measured memory_bytes: 12696
<?php
  fscanf(STDIN,"%d %d %d %d %d",$a,$b,$c,$x,$y);
  $cost = 0;
  if(($a+$b)/2 > $c){
    $cost += $c*min($x,$y)*2;
    $n = abs($x-$y);
    $n_c = $c*$n*2;
    if($x>$y){
      $n_ab = $n*$a;
    }else{
      $n_ab = $n*$b;
    }
    $cost += min($n_c,$n_ab);
  }else{
    $cost += $a*$x;
    $cost += $b*$y;
  }
  echo $cost."\n";
  

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
//    vector<ll> a(n);

    ll a;
    int cou=0;
    for(int i=0;i<n;i++){
        cin >> a;
        while(!(a%2)){
            cou++;
            a/=2;
        }
    }
    cout << cou << endl;
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
	
int N, V;
int x[200005];
int nodeInd;

struct Node{
	int l, r;
	int v;
	vector<Node> children;
	int ind;

	Node(int _l, int _r, int _v){
		ind=nodeInd++;
		l=_l;
		r=_r;
		v=_v;
		if(!v)
			return;
		int L=l;
		rep(i,l+1,r){
			if(x[i] > x[i-1]+v){
				children.push_back(Node(L, i, v/2));
				L=i;
			}
		}
		children.push_back(Node(L, r, v/2));
	}
};

bool ans[200005];
map<vector<int>, bool> cache;

bool rec(vector<Node*> nodes, int stepsLeft, bool init){
	vector<int> key;
	rep(i,0,nodes.size()){
		key.push_back(nodes[i]->ind);
	}
	if(cache.count(key))
		return cache[key];
	if(nodes.empty())
		return true;
	if(nodes[0]->v == 0)
		return nodes.size() == 1;
	vector<Node*> newNodes;
	rep(i,0,nodes.size()){
		if(newNodes.size()+nodes[i]->children.size() > stepsLeft)
			return 0;
		rep(j,0,nodes[i]->children.size())
			newNodes.push_back(&(nodes[i]->children[j]));
	}
	/*bool hasUrgent=false;
	rep(i,0,newNodes.size())
		if(newNodes[i]->children.size() > 1)
			hasUrgent = true;*/
	rep(i,0,newNodes.size()){
		vector<Node*> newNewNodes = newNodes;
		newNewNodes.erase(newNewNodes.begin()+i);
		if(rec(newNewNodes, stepsLeft-1, 0)){
			if(init){
				rep(j,newNodes[i]->l,newNodes[i]->r)
					ans[j]=true;
			}
			else{
				cache[key]=true;
				return true;
			}
		}
	}
	cache[key]=false;
	return false;
}

int main(){
	scanf("%d%d", &N, &V);
	rep(i,0,N)
		scanf("%d", x+i);
	Node start(0, N, V);
	vector<Node*> v;
	v.push_back(&start);
	int stepsLeft=19;
	rec(v,stepsLeft,1);
	rep(i,0,N){
		puts(ans[i]?"Possible":"Impossible");
	}
}

Measured memory_bytes: 29568
import java.util.Scanner;

/**
 * Yamanote-line Game
 */
public class Main {

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

		int N, d;
		N = sc.nextInt();
		d = sc.nextInt();

		int ans = 0;

		for (int i = 0; i < N; i++) {
			ans += Math.max(sc.nextInt() - d, 0);
		}

		System.out.println(ans > 0 ? ans : "kusoge");
	}
}

Measured memory_bytes: 30024
def solve():
    from sys import stdin
    m = 1000000007
    f_i = stdin
    
    while True:
        N = int(f_i.readline())
        if N == 0:
            break
        
        w = list(range(N))
        R = int(f_i.readline())
        for i in range(R):
            s, t = map(int, f_i.readline().split())
            s -= 1
            t -= 1
            w[s], w[t] = w[t], w[s]
        
        s = [(i, c) for i, c in enumerate(w) if i != c]
        s.sort(reverse=True)
        
        a = 1
        f = 1
        cnt = 0
        for c1, i in zip(w[::-1], range(N - 1, -1, -1)):
            if c1 > i:
                l = c1
                n = c1 - i - 1
            else:
                l = i
                n = 0
            for j, c2 in s:
                if j <= i:
                    break
                else:
                    if j < l:
                        n -= 1
                    if c2 < c1:
                        n += 1
            cnt = (cnt + (n * a) % m) % m
            a = (a * f) % m
            f += 1
        
        print(cnt)

solve()


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

int main() {
  int n;
  cin >> n;
  auto ask = [&](int l) {
	       cout << '?';
	       for (int i = 0; i < n; i++) {
		 cout << ' ' << l + i;
	       }
	       cout << endl;
	       string res;
	       cin >> res;
	       return res.front();
	     };
  char ml = ask(1);
  int l = 1, r = n + 1;
  vector<char> ans(2 * n + 1);
  while (r - l > 1) {
    int mid = l + (r - l) / 2;
    if (ask(mid) == ml) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ans[l] = ml;
  ans[l + n] = ml == 'R' ? 'B' : 'R';
  vector<int> r_index, b_index;
  if (ml == 'B') {
    b_index.push_back(l);
    r_index.push_back(l + n);
  } else {
    b_index.push_back(l + n);
    r_index.push_back(l);
  }
  auto ask2 = [&](int pos) {
		cout << '?';
		for (int i = 1; i < n; i++) {
		  cout << ' ' << l + i;
		}
		cout << ' ' << pos << endl;
		string res;
		cin >> res;
		return res.front();
	      };
 
  for (int i = 1; i <= 2 * n; ++i) {
    if (i < l ||  i > l + n) {
      ans[i] = ask2(i);
      if (ans[i] == 'B') {
	b_index.push_back(i);
      } else {
	r_index.push_back(i);
      }
    }
  }
  auto ask3 = [&](int pos) {
		cout << '?';
		for (int i = 0; i < (n - 1) / 2; ++i) {
		  cout << ' ' << b_index[i];
		  cout << ' ' << r_index[i];
		}
		cout << ' ' << pos << endl;
	        string res;
		cin >> res;
		return res.front();
	      };
  for (int i = l + 1; i < l + n; ++i) {
    ans[i] = ask3(i);
  }
 
  cout << "! ";  
  for (int i = 1; i <= 2 * n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

    


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int Answer;
  vector<int> vec(N);
  for ( int i = 0 ; i < N ; i++ ) {
    cin >> vec.at(i);
    int X = 0;
    for ( int j = 0 ; j < i ; j++ ) {
      if ( vec.at(i) != vec.at(j) ) {
        X++;
      }
    }
    if ( X == i ) {
      Answer++;
    }
  }
  cout << Answer << endl;   
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

const int N = 100100;

int n, m, x[N], c[N], d[N], q, rez[N], lastu[N];
vector<int> v[N];

void df(int nod, int d, int c) {
    if(!rez[nod]) {
        rez[nod] = c;
        lastu[nod] = d;

        if(!d)
            return;

        for(auto it: v[nod]) {
            df(it, d - 1, c);
        }
    }
    else {
        if(d > lastu[nod]) {
            lastu[nod] = d;
            for(auto it: v[nod]) {
                df(it, d - 1, c);
            }
        }
    }
}

int main() {
    int i, j;
//    freopen("ttt", "r", stdin);

    cin >> n >> m;

    for(i = 1; i <= m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
cin >> q;
    for(i = 1; i <= q; ++i) {
        scanf("%d%d%d", &x[i], &d[i], &c[i]);
    }

    for(i = q; i; --i) {
        df(x[i], d[i], c[i]);
    }

    for(i = 1; i <= n; ++i)
        printf("%d\n", rez[i]);

    return 0;
}


Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const int mod=1e9+7;

int n,m,c,vis[N];
vector<int>g[N];

void dfs(int n){
    vis[n]=1;
    c++;
    for(auto x:g[n]){
        if(!vis[x]){
            dfs(x);
        }
    }
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            c=0;
            dfs(i);
            ans=max(ans,c);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 21496
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, k, A[MAXN]; ll ans,c;
ll f(ll x)
{
	ll ans = 0;
	for(ll i = 0; i < n; i++) ans += (x^A[i]);
	return ans;
}
int main()
{
	FAST
	cin>>n>>k;
	FOR(i,0,n)cin>>A[i];
	for(ll i = 40;i>=0;i--)
	{
		if( k & (1ll<<i) )
		{
			ll kk = k;
			kk ^= (1ll<<i);
			kk |= (1ll<<i)-1;
			if(f((kk&((1ll<<(i+1))-1))) > f( (k&((1ll<<(i+1))-1)) ) )
			{
				k = kk;
			}
		}
	}
	cout<<f(k)<<'\n';
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<pair<int,int>> P(N);
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
	}
	sort(ALL(P),[](pair<int,int>& l,pair<int,int>& r){return l.second==r.second ? l.first>r.first : l.second<r.second;});
	auto start=P.begin(),end=P.end();
	int num=1;
	int prev=start->second;
	while(start!=end){
		auto res = lower_bound(ALL(P),make_pair(0,start->second+1),[](const pair<int,int>& l,const pair<int,int>& r){return l.second<r.second;});
		if(res!=end && res->first>prev){
			num++;
			prev = res->second;
		}
		start = res;
	}
	
	out(num);
	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 10000000
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

int a, b, c, r=MAX;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c;
    if(a+b<r)r=a+b;
    if(a+c<r)r=a+c;
    if(b+c<r)r=b+c;
    cout<<r<<endl;



}


Measured memory_bytes: 256
<?php

// 読み取り
fscanf(STDIN, "%d %d", $N, $K );

// 商を計算
$r = (int)($N / $K);

//余り算出
$q = $N % $K;

$min_num = 0;

if ($q!=0) {
  $min_num = abs($q - $K);
  if ($q <= $min_num ) {
    $min_num = $q;
  }
}

echo $min_num;

?>


Measured memory_bytes: 4856