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

struct RollingHash{
    vector<int64_t> hash;
    vector<int64_t> base_pow;
    int64_t base, mod;
    const int64_t DEFAULT_BASE = 1000, DEFAULT_MOD = 1e9+7;

    RollingHash(string S="", int64_t base_=-1, int64_t mod_=-1){
        base = base_ > 0 ? base_ : DEFAULT_BASE;
        mod = mod_ > 0 ? mod_ : DEFAULT_MOD;
        if(S.size() > 0) initialize(S);
    }

    void initialize(string& S){
        int N = S.size();
        vector<int> s(N);
        for(int i=0; i<N; i++) s[i] = S[i];
        initialize(s);
    }

    void initialize(vector<int>& S){
        hash.resize(S.size()+1);
        base_pow.resize(S.size()+1);
        hash[0] = 0;
        base_pow[0] = 1;
        for(int i=1; i<=S.size(); i++){
            hash[i] = (hash[i-1] * base + S[i-1]) % mod;
            base_pow[i] = base_pow[i-1] * base % mod;
        }
    }

    // 0-indexed, [a, b)
    int64_t between(int a, int b){
        return (mod + hash[b] - hash[a] * base_pow[b-a] % mod) % mod;
    }
};

int main(){
    int N;
    string T;
    cin >> N >> T;
    RollingHash hash(T);
    reverse(T.begin(), T.end());
    RollingHash hash_rev(T);

    for(int n=2; n<=N; n++){
        int64_t h = hash.between(0, n);
        bool ok = true;
        for(int i=1; ; i++){
            int s = i*(n-1);
            int t = s + n;
            if(s >= N) break;

            if(t <= N){
                int64_t h2 = (i%2==0 ? hash.between(s, t) : hash_rev.between(N-t, N-s));
                if(h != h2){
                    ok = false;
                    break;
                }
            }else{
                int l = N-s;
                if(i%2 == 0){
                    if(hash.between(0, l) != hash.between(N-l, N)) ok = false;
                }else{
                    if(hash.between(n-l, n) != hash_rev.between(0, l)) ok = false;
                }
            }

        }
        if(ok){
            cout << n << endl;
            return 0;
        }
    }
}



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


int main() {
  int N ; 
  cin >> N ; 
  
  map<string , int> M ; 
  
  for(int i = 0 ; i < N ; i++){
    string S ; 
    cin >> S ; 
    sort(S.begin(),S.end()) ; 
    M[S]++ ;   
  }
  int64_t T = 0 ; 
    
for (auto p : M) {
  auto v = p.second;
    for( int i = 0 ; i < v ;i++){
      T += i ; 
    }
}

  cout << T << endl ; 
}

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

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    int ans=0;
    if(x==w/2&&y==h/2)ans=1;
    cout<<w*h/2<<" "<<ans<<endl;
    return 0;
}

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

typedef long long LL;

const int N=10000;

int n,a[N+9];
struct side{
  int y,next;
}e[N*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

int deg[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<n;++i){
	int x,y;
	scanf("%d%d",&x,&y);
	Ins2(x,y);
	++deg[x];++deg[y];
  }
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int ans0,ans[N+9];
queue<int>q;

void Get_ans(){
  sort(a+1,a+n+1);
  for (int i=1;i<=n;++i)
	if (deg[i]==1) q.push(i);
  for (int i=1;!q.empty();++i){
	int t=q.front();q.pop();
	ans[t]=a[i];
	for (int i=lin[t];i;i=e[i].next){
	  if (!ans[e[i].y]) ans0+=ans[t];
	  if (--deg[e[i].y]==1) q.push(e[i].y);
	}
  }
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans0);
  for (int i=1;i<=n;++i)
	printf("%d ",ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int N; cin >> N;
	
	int s2 = 0;
	vector<int> a( N );
	REP( i, N ) {
		cin >> a[i];
		s2 += a[i];
	}

	int s1 = 0, ans = INF;
	REP( i, N - 1 ) {
		s1 += a[i];
		s2 -= a[i];
			
		chmin( ans, abs( s1 - s2 ) );
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll keta(ll i){
    ll t=0;
    while(i){
        i/=10;
        t++;
    }
    return t;
}
int main(){
    int n,ans=0;cin>>n;
    vector<ll> height(n);
    For(i,n){
        cin>>height.at(i);
    }
    vector<ll> after(n);
    after.at(0)=height.at(0)-1;
    For1(i,n){
        if(height.at(i)>after.at(i-1)){
            after.at(i)=height.at(i)-1;
        }
        else if(height.at(i)==after.at(i-1)){
            after.at(i)=height.at(i);
        }
        else if(height.at(i)<after.at(i-1)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<iomanip>
#include<unordered_map>
#define deg(x) cerr<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,string> pss;
typedef unsigned long long ull;
const ll mod=998244353;
const ll inf=1e16+7;
const double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return (r+m)%m;}
//const double pi=acos(-1);



int main()
{
    TB
    int t;
    cin>>t;
    while(t--)  cout<<"ACL";
    return 0;

}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

public class Main{
    public static void main(String[] args) throws Exception{
        new Main().run();
    }
    void run() throws Exception{
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        boolean multiple = false;
        for(int tc = 1, tt = (multiple)?ni(in):1; tc<=tt; tc++)solve(in,out,tc);
        out.flush();
        out.close();
    }
    void solve(FastReader in, PrintWriter out, int TC) throws Exception{
        HashMap<Long, Integer> map = new HashMap<>();
        int n = ni(in);
        long m = nl(in);
        long ans = 0, sum = 0;
        long[] a = new long[n];
        for(int i = 0; i< n; i++){
            a[i] = nl(in)%m;
            sum = (sum+a[i])%m;
            map.put(sum, map.getOrDefault(sum,0)+1);
        }
        sum = 0;
        for(int i = 0; i< n; i++){
            ans+=map.getOrDefault(sum, 0);
            sum = (sum+a[i])%m;
            map.put(sum, map.getOrDefault(sum, 0)-1);
        }
        pn(out,ans);
    }
    void p(PrintWriter out, Object o){out.print(o);}
    void pn(PrintWriter out,Object o){out.println(o);}
    int ni(FastReader in){return Integer.parseInt(in.next());}
    long nl(FastReader in){return Long.parseLong(in.next());}
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

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


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w;
char s[25][21];

bool used[25];
int g[25][21];
int cnt;

bool ok[1<<12];

int match(){
  fill(ok,ok+(1<<w),false);
  ok[0] = true;
  REP(i,w)ok[1<<i] = true;
  REP(msk,1<<w)if(ok[msk]){
    int id1 = 0;
    REP(i,w)if(~msk>>i&1)id1=i;
    REP(id2,w)if((~msk>>id2&1) && id1!=id2 && g[id1][id2] >= cnt){
      ok[msk + (1<<id1) + (1<<id2)] = true;
    }
  }
  return ok[(1<<w)-1];
}

bool dfs(int rest){
  if(rest == 0){
    return match();
  }
  if(rest%2==1){
    REP(id,h){
      used[id] = true;
      REP(i,w)REP(j,w)if(s[id][i]==s[id][j])g[i][j]++;
      cnt++;
      if(dfs(rest-1))return true;
      used[id] = false;
      REP(i,w)REP(j,w)if(s[id][i]==s[id][j])g[i][j]--;
      cnt--;
    }
    return false;
  }
  int id1 = 0;
  REP(i,h)if(!used[i])id1=i;
  REP(id2,h)if(!used[id2] && id1!=id2){
    used[id1] = used[id2] = true;
    REP(i,w)REP(j,w){
      if(s[id1][i] != s[id2][j])continue;
      if(s[id1][j] != s[id2][i])continue;
      g[i][j]++;
    }
    cnt++;
    if(dfs(rest-2))return true;
    used[id1] = used[id2] = false;
    REP(i,w)REP(j,w){
      if(s[id1][i] != s[id2][j])continue;
      if(s[id1][j] != s[id2][i])continue;
      g[i][j]--;
    }
    cnt--;
  }
  return false;
}

int main(){
  scanf("%d%d",&h,&w);
  REP(i,h)scanf("%s",s[i]);
  if(dfs(h)){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


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

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define PII         pair<ll int, ll int>
#define pi          pair<ll, int>
#define fast_io     ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define loop_in     for(int i=0; i<n; i++)
#define INF         100000000000000


string str;

int main()
{
    fast_io

    ll t, ac=0, wa=0, tle=0, re=0;
    cin>>t;
    while(t--)
    {
        cin>>str;
        if(str == "AC")
        {
            ac++;
        }
        else if(str == "WA")
        {
            wa++;
        }
        else if(str == "TLE")
        {
            tle++;
        }
        else if(str == "RE")
        {
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}




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

int main(void) {
  long long int a = 0;
  long long int n = 0;
  cin >> n;
  
  for(int i=1; i<=n; i++){
    if(i%15 == 0) continue;
    else if(i%3 == 0) continue;
    else if(i%5 == 0) continue;
    else a = a + i;
  }

  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 3612
NM = list(map(int,input().split()))
N=NM[0]
M=NM[1]
KA = [list(map(int,input().split())) for l in range(N)]
for i in range(N):
      KA[i].pop(0)

jandjplu1=set(KA[0])
for j in range(1,N):
    jandjplu1=jandjplu1 & set(KA[j-1]) & set(KA[j])

print(len(jandjplu1))


Measured memory_bytes: 3060
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import Control.Monad
import Data.Tuple
import Data.Char
import Data.IORef

inter :: VUM.IOVector Bool -> Int -> Int -> IO ()
inter it a b
    | a == 1 = VUM.write it b True
    | b == 1 = VUM.write it a True
    | otherwise = return ()

dest :: VUM.IOVector Bool -> VUM.IOVector Bool -> Int -> Int -> Int -> IO ()
dest it ds a b n
    | a == n = VUM.write ds b True
    | b == n = VUM.write ds a True
    | otherwise = return ()

main = do
    [n, m] <- Prelude.map read . Prelude.words <$> Prelude.getLine :: IO [Int]
    (it :: VUM.IOVector Bool) <- VUM.replicate (n+1) False
    (ds :: VUM.IOVector Bool) <- VUM.replicate (n+1) False
    res <- newIORef False
    forM_ [1..m] $ \_ -> do
        bs <- B.getLine
        let
            Just (a, bs') = B.readInt bs
            Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
        inter it a b
        dest it ds a b n
    forM_ [1..n] $ \i -> do
        r <- VUM.read it i
        when r $ do
            r' <- VUM.read ds i 
            when r' $ modifyIORef' res (||True)
    
    readIORef res >>= \r -> putStrLn $ if r then "POSSIBLE" else "IMPOSSIBLE"

Measured memory_bytes: 1404
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

//s.find_by_order(index);
//s.order_of_key(value);
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    ll a; cin>>a;
    ll n = a%10;
    if(n==2 or n==4 or n==5 or n==7 or n==9){
        cout<<"hon";
    } else if(n==0 or n==1 or n==6 or n==8){
        cout<<"pon";
    } else cout<<"bon";
    return 0;
}

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

Measured memory_bytes: 3680
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(int(n/l[2])+1):
    for j in range(int(n/l[1])+1):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y) >= 0 and (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, sum = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0;
	cin >> n;
	vector<ll> v(3 * n);
	for (ll i = 0; i < 3 * n; i++) {
		cin >> v.at(i);
		cnt1++;
	}
	sort(v.begin(), v.end(), greater<ll>());
	while (cnt2 < n) {
		cnt3++;
		sum += v[cnt3];
		cnt3++;
		cnt2++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2560
program test
implicit none

integer(8) :: h,w,k,i,j,ans,big=1d9+7
integer(8) :: go(0:10,3)=0,br_a(0:10),br_b(0:10),dp(0:200,0:10)=0

read(*,*) h,w,k

!最後に橋あり→a,なし→b

br_a(0)=0
br_b(0)=0

br_a(1)=0
br_b(1)=1

do i=2,w
	br_a(i) = br_b(i-1)
	br_b(i) = mod(br_b(i-1) + br_a(i-1),big)
enddo

!左に行く
do i=1,w
	if(i==1) then
		go(i,1) = 0
	else
		go(i,1) = mod(br_b(i-1) * br_b(w-i+1),big)
	endif
enddo

!右に行く
do i=1,w
	go(i,3) = go(w+1-i,1)
enddo

!どちらでもない
do i=1,w
	go(i,2) = mod((br_a(w)+br_b(w)) - go(i,1) - go(i,3),big)
enddo

!とりあえずDPっしょ
dp(0,1)=1
do i=1,h
	do j=1,w
		dp(i,j) = mod(dp(i-1,j-1)*go(j-1,3) +dp(i-1,j)*go(j,2) +dp(i-1,j+1)*go(j+1,1),big)
	enddo
enddo

write(*,*) dp(h,k)

end program


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	int k, a, b;
	cin >> k >> a >> b;
	if(b/k != (a-1)/k)
	cout << "OK";
	else
	cout << "NG";	
	return 0;
}

Measured memory_bytes: 3656
N, K = map(int, input().split())
p = [list(map(int, input().split())) for i in range(N)]
t, b, l, r = 0, 0, 0, 0
area = []


for i in range(N):
  t = p[i][1]
  p1 = [a for a in p if a[1] <= t]
#  print(t, p1)
  for j in range(len(p1)):
    b = p1[j][1]
    p2 = [a for a in p1 if a[1] >= b]
#    print(b, p2)
    for k in range(len(p2)):
      r = p2[k][0]
      p3 = [a for a in p2 if a[0] <= r]
#      print(r, p3)
      for m in range(len(p3)):
        l = p3[m][0]
        p4 = [a for a in p3 if a[0] >= l]
#        print(l, p4)   
        if len(p4) >= K:
          tmp = (l-r)*(t-b)
          area.append(abs(tmp))
print(min(area))

Measured memory_bytes: 14204
n=int(input())
s=list(input())
temp=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in range(len(s)):
    s[i]=temp[((temp.index(s[i]))+n)%26]
print(*s,sep='')

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;

int main(){
    int N, C; cin >> N >> C;
    vector<vector<pair<int, int>>> st(31, vector<pair<int, int>>());
    rep(i,N){
        int s, t, c; cin >> s >> t >> c;
        st[c].emplace_back(s, t);
    }

    rep(i,31){
        sort(st[i].begin(), st[i].end());
    }

    vector<vector<pair<int,int>>> st2(31, vector<pair<int, int>>());
    
    rep(i,31){
        rep(j,st[i].size()){
            if (j == 0) st2[i].emplace_back(st[i][j].first, st[i][j].second);
            else{
                if(st[i][j-1].second != st[i][j].first){
                    st2[i].emplace_back(st[i][j].first, st[i][j].second);
                }else{
                    st2[i].back().second = st[i][j].second;
                }
            }
        }
    }


    vector<int> cum(maxv+1,0);
    rep(i,31){
        rep(j,st2[i].size()){
            cum[st2[i][j].first]++;
            cum[++st2[i][j].second]--;
        }
    }

/*
    rep(i,N){
        cum[s[i]]++;
        cum[t[i]]--;
    }
*/

    int ans = 0;
    rep(i,maxv){
        cum[i+1] += cum[i];
        ans = max(ans, cum[i+1]);
    }

    cout << ans << endl;


}

Measured memory_bytes: 5716
a, b, k = map(int, input().split())
li = []
for i in range(a, a+k):
    if a <= i <= b:
        li.append(i)
for j in range(b-k+1, b+1):
    if a <= i <= b:
        li.append(j)
s = set(li)
d = sorted(s)
for x in d:
    print(x)

Measured memory_bytes: 38288
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define rep0(_i, _n) for(int _i = 0; (_i)<(_n) ;++_i)
#define rep1(_i, _n) for(int _i = 1; (_i)<=(_n) ;++_i)
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multi int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T a){while(n--)cin >> *a, ++a;}
template<typename T1, typename T2> void read(int n, T1 a, T2 b){while(n--)cin >> *a >> *b, ++a, ++b;}
template<typename T> void write(int n, T a){while(n--)cout << *a << " \n"[n==0], ++a;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
const ll inf = 1ll << 58;
int n, m;
vector<pair<int,int>> edge[maxn];
ll dp[maxn];
struct sgt{
	ll v[maxn<<1], tag[maxn<<1];
	sgt(){
		fill(v, v+(maxn<<1), inf);
		fill(tag, tag+(maxn<<1), inf);
	}
	void push(int i){
		v[i] = min(v[i], tag[i]);
		tag[i<<1] = min(tag[i<<1], tag[i]);
		v[i<<1] = min(v[i<<1], tag[i]);
		v[i<<1|1] = min(v[i<<1|1], tag[i]);
		tag[i<<1|1] = min(tag[i<<1|1], tag[i]);
	}
	void modify(int ml, int mr, ll nv, int l = 1, int r = 100000, int i = 1){
		if(ml > r || mr < l)return;
		push(i);
		if(ml <= l and mr >= r)tag[i] = min(tag[i], nv);
		else{
			int mid = l+r>>1;
			modify(ml, mr, nv, l, mid, i<<1);
			modify(ml, mr, nv, mid+1, r, i<<1|1);
			v[i] = min(v[i<<1], v[i<<1|1]);
		}
	}
	ll query(int p, int l = 1, int r = 100000, int i = 1){
		if(l > p || r < p)return inf;
		push(i);
		if(l == r and l == p)return v[i];
		return min(query(p, l, (l+r)>>1, i<<1), query(p, ((l+r)>>1)+1, r, i<<1|1));
	}
}mt;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	fill(dp, dp+maxn, inf);
	cin >> n >> m;
	mt.modify(n, n, 0);
	rep0(i, m){
		int l, r, c;
		cin >> l >> r >> c;
		edge[r].emplace_back(l, c);
	}
	for(int i = n;i > 0;--i){
		dp[i] = mt.query(i);
		for(auto j : edge[i]){
			mt.modify(j.first, i-1, dp[i]+j.second);
		}
	}
	if(dp[1] == inf)rout(-1);
	cout << dp[1] << '\n';
}

Measured memory_bytes: 22016
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                if (a == b && b == c) {
                        System.out.println(1);
                } else if(a == b || b == c || a== c) {
                        System.out.println(2);
                } else {
                        System.out.println(3);
                }
        }
}

Measured memory_bytes: 9676
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();

	int n,x=0,t=0;
	char s;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		if (s =='I')
		{
			x++; 
			if (x>t)
				t = x;
		}
		if (s == 'D')
		{
			x -= 1;
		}

	}
	if (t > x)
		cout << t << endl;
	else
		cout << x << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    std::deque<int> deq;
    for (int i=0;i<3;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end(),greater<int>());
    cout<<deq[0]*10+deq[1]+deq[2]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int a, d = 0, s = 1, n, dta[251];
  
  scanf("%d", &n);
  for(a=1;a<=n;a++) scanf("%d", &dta[a]);
  for(a=1;a<=n;a++){
    printf("node %d: key = %d, ", a, dta[a]);
    
    if(a/2) printf("parent key = %d, ", dta[a/2]);
    if(2*a<=n) printf("left key = %d, ", dta[2*a]);
    if(2*a+1<=n) printf("right key = %d, ", dta[2*a+1]);
    
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  cout << (a*b%2==0?"Even":"Odd") << endl;
}

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

typedef long long ll;
ll n, s, a[5];
int main()
{
    int i;
//    freopen ("input.txt", "r", stdin);
    for (i = 0; i < 4; i++) {
       scanf ("%lld", &a[i]);
    }
    for (i = 1; i < 4; i++) {
        a[i] = min(a[i - 1] * 2, a[i]);
    }
    cin >> n;
    s += (n / 2) * a[3];
    s += (n % 2) * a[2];
    cout << s;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
print((h - 2) * (w - 2) - sum(k.values()))
for i in range(1, 10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    string ans;
    if (S == "ABC")
    {
        ans = "ARC";
    }
    else
    {
        ans = "ABC";
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	double t, a;
	double h[100010];
	cin >> n >> t >> a;
	int ans;
	double mem;
	rep(i, n)cin >> h[i];
	ans = 1;
	mem = t - (h[0] * 0.006);
	mem = abs(a - mem);
	for (int i = 1;i < n;i++) {
		if (mem > abs(a - (t - (h[i] * 0.006)))) {
			mem = abs(a - (t - (h[i] * 0.006)));
			ans = i + 1;
		}
	}
	cout << ans << endl;
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                int mult = i * j;
                System.out.println(i+"x"+j+"="+mult);
            }
        }
    }
}

Measured memory_bytes: 16852
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
int N;
cin>>N;
vector<int> X(N);
vector<int> Y(N);
for(size_t i=0;i<X.size();i++){
  cin>>X[i];
  Y[i]=X[i];
}
sort(X.begin(),X.end());
int med_low=X[(X.size())/2];
int med_high=X[(X.size())/2-1];
for(size_t i=0;i<X.size();i++){
  if(Y[i]<med_low) cout<<med_low<<endl;
  else cout<<med_high<<endl;
}

  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f,g,h,i,x;
	scanf("%d%d%d",&a,&b,&e);
	x=3*e;
	c=x-a-b;
	h=x-b-e;
	g=x-c-e;
	i=x-a-e;
	d=x-a-g;
	f=x-c-i;
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,c,d,e,f,g,h,i);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
isp = []
S = []
P = []
for _ in range(n):
    s, p = input().split()
    p = int(p)
    S.append(s)
    P.append(p)
for i in range(n):
    isp.append([i+1, S[i], P[i]])
isp = sorted(isp, key=lambda x: x[2], reverse=True)
isp = sorted(isp, key=lambda x: x[1])
for i in range(n):
    print(isp[i][0])

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		if (A[i] % 2 == 1) ok = false;
	}
	cout << (ok ? "second" : "first") << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define int long long

int32_t main()
{
    int n,x;cin>>n>>x;
    vector<int> v(n+1);
    fill(v.begin(),v.end(),0);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        v[i]+=v[i-1];
    }
    int t=upper_bound(v.begin(),v.end(),x)-v.begin();
    cout<<t;
    return 0;
}


Measured memory_bytes: 256
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 2020):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 66244
#include<bits/stdc++.h>
using namespace std;
int G[9],n,a,c;
int main(){
	cin>>n;for(int i=0;i<n;i++){cin>>a;G[min(8,a/400)]++;}
	for(int i=0;i<8;i++){if(G[i]>=1)c++;}
	if(c>=1)cout<<c<<endl<<c+G[8]<<endl;
	else cout<<1<<endl<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect
 
# from operator import mul
 
sys.setrecursionlimit(100001)
 
 
# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)
 
# ===FUNCTION===
 
def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]
 
    return outputDataList
 
 
def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)
 
    return outputDataList
 
 
def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)
 
    return outputDataList
 
 
# ===CODE===
 
r = float(input())
 
ans = math.pi*2*r
print(ans)
 

Measured memory_bytes: 10484
H,W = list(map(int, input().split()))
cArray = [list(map(int, input().split())) for _ in range(10)]
Aarray = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            cArray[i][j] = min(cArray[i][j], cArray[i][k] + cArray[k][j])

#print(cArray)

ans = 0
for i in Aarray:
    for j in i:
        if(j != -1):
            ans += cArray[j][1]

print(ans)

Measured memory_bytes: 9560
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n,k;
	int ans=0;
	cin >>n>>k;
	n = n % k;
	cout<<min(n,k-n)<<endl;
}


Measured memory_bytes: 3508
// E - Max-Min Sums
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

vector<long long> fact, finv;

void init_fact(int n = 1000000)
{
	fact.resize(n); finv.resize(n);
	fact[0] = finv[n - 1] = 1;
	for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
	for (long long x = MOD - 2, a = fact[n - 1]; x > 0; a = a * a % MOD, x >>= 1)
		if (x & 1) finv[n - 1] = finv[n - 1] * a % MOD;
	for (int i = n - 2; i >= 0; i--) finv[i] = finv[i + 1] * (i + 1) % MOD;
}

long long cnr(int n, int r)
{
	if (r < 0 || r > n) return 0;
	if (r == 0 || r == n) return 1;
	return fact[n] * finv[r] % MOD * finv[n - r] % MOD;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<long long> a(n), c(n + 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	if (k > 1) {
		init_fact(n + 1);
		sort(a.begin(), a.end());
		for (int i = 0; i < n; i++) c[i + 1] = c[i] + a[i];
		for (int l = k; l <= n; l++) {
			long long d = (c[n] - c[l - 1] - c[n - l + 1]) % MOD;
			int n = l - 2, r = k - 2;
			long long t = cnr(n, r);
			ans = (ans + d * t % MOD) % MOD;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int odw[1005][1005];
int a;
void rek(int pocz,int ile,int st)
{
    if(pocz+ile>a)
        return;
    for(int x=pocz;x<=a;x+=ile)
        for(int y=x+ile;y<=a;y+=2*ile)
            odw[x][y]=st;
    rek(pocz,ile*2,st+1);
    rek(pocz+ile,ile*2,st+1);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    cin>>a;
    rek(1,1,1);
    for(int x=1;x<=a;x++)
    {
        for(int y=x+1;y<=a;y++)
            cout<<odw[x][y]<<" ";
        cout<<'\n';
    }

	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long


using namespace std;

int main()
{

    ll a,b,c,x,y,z,cnt=0;
    cin>>a>>b>>c;



    while(a%2==0 && b%2==0 && c%2==0)
    {
        if(a==b && b==c)
            {
                cout<<"-1"<<endl;
                return 0;
            }



            x=b/2 + c/2;
            y=a/2 + c/2;
            z=a/2 + b/2;

            a=x;
            b=y;
            c=z;

            cnt++;





    }
    cout<<cnt<<endl;

    return 0;
}





Measured memory_bytes: 256
N, H = [int(_) for _ in input().split()]
max_a = 0
B = []
for i in range(N):
    a, b = [int(_) for _ in input().split()]
    max_a = max(a, max_a)
    B.append(b)

ans = 0
B.sort(reverse=True)

for i in range(N):
    if B[i] > max_a:
        H -= B[i]
        ans += 1
    else:
        break
    if H <= 0:
        break

if H > 0:
    ans += (H // max_a)
    H -= (H // max_a) * max_a
    if H > 0:
        ans += 1
print(ans)


Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
char verdict[2][10] = {"First", "Second"};
const int N(111111);
int n, a[N];
void solve(bool reverse = false) {
	int cnt[2] = {};
	for(int i(0); i < n; i++)
		cnt[a[i] % 2] ++;
	if(cnt[0] % 2) {
		printf("%s\n", verdict[reverse]);
		exit(0);
	}else if(cnt[1] >= 2) {
		printf("%s\n", verdict[1 ^ reverse]);
		exit(0);
	}else {
		for(int i(0); i < n; i++)
			if(a[i] % 2) {
				if(a[i] == 1) {
					printf("%s\n", verdict[1 ^ reverse]);
					exit(0);
				}else {
					a[i]--;
					break;
				}
			}
		int d(a[0]);
		for(int i(1); i < n; i++)
			d = __gcd(d, a[i]);
		for(int i(0); i < n; i++)
			a[i] /= d;
		solve(reverse ^ 1);
	}
}
int main() {
	cin >> n;
	for(int i(0); i < n; i++) {
		cin >> a[i];
	}
	solve(false);
}


Measured memory_bytes: 640
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e50)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    S = input()

    N = len(S)
    ans = [0] * N

    rl_ind = 0
    lr_ind = 0

    cnt = 1
    for i in range(N-1):
        if S[i] == "L" and S[i+1] == "R":
            lr_ind = i
            if cnt % 2 == 0:
                ans[rl_ind] = cnt//2
                ans[rl_ind+1] = cnt//2
            else:
                if (i-rl_ind) % 2 == 1:
                    ans[rl_ind] = cnt//2
                    ans[rl_ind+1] = cnt//2 + 1
                else:
                    ans[rl_ind] = cnt//2 + 1
                    ans[rl_ind+1] = cnt//2
            cnt = 0
        elif S[i] == "R" and S[i+1] == "L":
            rl_ind = i
        cnt +=1
    if cnt % 2 == 0:
        ans[rl_ind] = cnt//2
        ans[rl_ind+1] = cnt//2
    else:
        if (i-rl_ind) % 2 == 0:
            ans[rl_ind] = cnt//2
            ans[rl_ind+1] = cnt//2 + 1
        else:
            ans[rl_ind] = cnt//2 + 1
            ans[rl_ind+1] = cnt//2
    ans = [ str(i) for i in ans]
    print(" ".join(ans))
if __name__ == "__main__":
    main()


Measured memory_bytes: 49136
w, h, n = map(int,input().split())
s = [0,w,0,h]
for i in range(n):
  x, y ,a = map(int,input().split()) 
  if a==1:
    s[0]=max(x, s[0])
  elif a==2:
    s[1]=min(x, s[1])
  elif a==3:
    s[2]=max(y, s[2])
  elif a==4:
    s[3]=min(y, s[3])
if s[1]-s[0] >=0 and s[3]-s[2] >=0:
  print((s[1]-s[0])*(s[3]-s[2]))
else:
  print(0)

Measured memory_bytes: 3064
n, k  = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] * (k + 1)

for i in range(1, k + 1):
  if all(dp[i - a] == 1 for a in A if i >= a):
    dp[i] = 0
  else:
    dp[i] = 1

print("First" if dp[k] == 1 else "Second")

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main() {
	long long  a, b, k;
	cin >> a >> b >> k;
	if (k > (b - a + 1) / 2) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << a + i << endl;
		}
		for (int i = b - k + 1; i <= b; i++) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static void Main(string[] args)
        {
            var values = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".Replace(" ", "").Split(',');
            int K = ReadInt();
            Console.WriteLine(values[K - 1]);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (n >= m) {
			System.out.println(0);
			return;
		}

		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		int[] l = new int[x.length - 1];
		for (int i = 0; i < l.length; i++) {
			l[i] = x[i + 1] - x[i];
		}

		Arrays.sort(l);
		int answer = x[x.length - 1] - x[0];

		int j = l.length - 1;
		for (int i = 0; i < n - 1; i++) {
			answer -= l[j--];
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 47000
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
ans = 0
for i in range(H):
  ans += Gd[i].count('.')
INF = -1
direc = [[1,0,-1,0],[0,1,0,-1]]
Dis = [[INF]*W for _ in range(H)]
from collections import deque
def dfs(start,goal):
  q = deque([])# スタック
  Dis[start[0]][start[1]]=1
  q.append(start)
  while len(q)!=0:
    h,w = q.popleft()# スタック取りだし（先頭）
    for i in range(4):
      hs = h+direc[0][i]
      ws = w+direc[1][i]
      if 0<=hs<H and 0<=ws<W and Dis[hs][ws]==INF:
        if Gd[hs][ws]=='.':
          q.append([hs,ws])
          Dis[hs][ws]=Dis[h][w]+1
  return Dis[goal[0]][goal[1]]
minpath = dfs([0,0],[H-1,W-1])
if minpath == INF:
  ans = INF
else:
  ans = ans - minpath
print(ans)

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

int main(){
    map<int, int> ball;
    
    int n,k,a; cin>>n>>k;
    
    rep(i,n){
        cin>>a;
        ball[a]++;
    }
    
    if(ball.size()<=k){
        cout << 0 << endl;
        return 0;
    }
    
    vector<int> count;
    
    for(auto p: ball){
        count.push_back(p.second);
    }
    sort(count.begin(), count.end());
    
    int ans = 0;
    
    rep(i,count.size()-k){
        ans += count[i];
    }
    
    cout << ans << endl;
    return 0;
}

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

int a,b;

int main()
{
    scanf("%d%d",&a,&b);
    if(a == 0 || b == 0)printf("Zero\n");
    else if((a > 0) ^ (b > 0))printf("Zero\n");
    else if(a > 0 && b > 0)printf("Positive\n");
    else
    {
        if(abs(a - b) % 2)printf("Positive\n");
        else printf("Negative\n");
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

def isPalindrome(s):
  n = len(s)
  re_s = s[::-1]
  for i in range(n // 2):
    if re_s[i] != s[i]:
      break
  else:
    return True
  return False

if isPalindrome(S) and isPalindrome(S[:N // 2]) and isPalindrome(S[(N + 1) // 2:]):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9068
#include <bits/stdc++.h>
#include<stdio.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e9+18
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=105;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.14159265359
#define mod 1000000007
ll dp[1005][1005];
ll possibleways(ll i,ll j,char a[][1004],ll n,ll m)
{

 // cout<<0;
  if(i==n-1&&j==m-1)
    return 1;
  if(i>=n||j>=m||a[i][j]=='#')
    return 0;
 
  if(dp[i][j]!=-1)
    return dp[i][j];
  ll ans=(possibleways(i+1,j,a,n,m)%mod+possibleways(i,j+1,a,n,m)%mod)%mod;
  dp[i][j]=ans;
  return ans;
}
int main()
{
  
 int n,m,i,j;;
 cin>>n>>m;
   char  a[1004][1004];
 f0(i,n)
 f0(j,m)
 cin>>a[i][j];
 memset(dp,-1,sizeof(dp));
 cout<<possibleways(0,0,a,n,m);

}

Measured memory_bytes: 9216
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;


auto nCoin(int m) {
	int ans;
	while(m >= 500) {
		m -= 500;
		++ans;
	}
	while(m >= 100) {
		m -= 100;
		++ans;
	}
	while(m >= 50) {
		m -= 50;
		++ans;
	}
	while(m >= 10) {
		m -= 10;
		++ans;
	}
	return ans;
}

void main(){
	int t;
	while(true) {
		auto n = readInt();
		if(n == 0) return;
		if(t > 0) {
			writeln();
		}
		++t;
		auto m = readInts();
		auto k = new int[](4);
		auto l = m[0] * 10 + m[1] * 50 + m[2] * 100 + m[3] * 500 - n;
		k[3] = l/500;
		l %= 500;
		k[2] = l/100;
		l %= 100;
		k[1] = l/50;
		l %= 50;
		k[0] = l/10;
		auto c = [10, 50, 100, 500];
		for(int i; i < 4; ++i) {
			if(m[i] > k[i]) {
				writeln(c[i], " ", m[i]-k[i]);
			}
		}
	}
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll x, y;
  scanf("%lld %lld", &x, &y);
  cout << (x + y / 2) << endl;
}


Measured memory_bytes: 3784