akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ld long double
const ld pi=acos(-1);ld ans;int a1,a2,b1,b2,f1,f2,n,m,s[200005];
struct P{int x,y;friend bool operator<(P a,P b){return a.x<b.x;}}a[200005];
int main()
{
	read(a1);read(b1);read(a2);read(b2);f1=a1>a2?-1:1;f2=b1>b2?-1:1;a1*=f1;a2*=f1;b1*=f2;b2*=f2;read(n);
	for(int i=1;i<=n;i++)
	{
		read(a[i].x);read(a[i].y);a[i].x*=f1;a[i].y*=f2;
		if(a[i].x<a1||a[i].x>a2||a[i].y<b1||a[i].y>b2) i--,n--;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) if(!m||s[m]<a[i].y) s[++m]=a[i].y;else s[lower_bound(s+1,s+m+1,a[i].y)-s]=a[i].y;
	ans=100.0*(a2-a1+b2-b1)-(20.0-5.0*pi)*m+5.0*pi*(m==min(a2-a1+1,b2-b1+1));
	printf("%.15lf\n",(double)ans);
}

Measured memory_bytes: 4608
N,P = gets.split(" ").map { |e| e.to_i }

max = (P**(1.0/N)).round
for i in 0..max-1 do
  waru = max - i
  if P % waru == 0
    if P % waru**N == 0
      puts waru
      break
    end
  end
end


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

using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> nums;

    int now = 1;
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        if(s[i]==(char)('0'+now)){
            cnt++;
        }
        else{
            nums.push_back(cnt);
            now = 1 - now;
            cnt=1;
        }
    }
    if(cnt!=0) nums.push_back(cnt);

    if(nums.size()%2==0) nums.push_back(0);
    
    int range = 2*k+1;

    int ans=0;
    int tmp=0;
    int left = 0, right = 0;

    for (int i = 0; i < nums.size(); i+=2)
    {
        int NextLeft = i;
        int NextRight = min((int)nums.size(), i+range);

        while (NextLeft>left)
        {
            tmp-=nums[left];
            left++;
        }
        while (NextRight>right)
        {
            tmp+=nums[right];
            right++;
        }
        ans = max(ans, tmp);

    }
    cout << ans << endl;

}

Measured memory_bytes: 1020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan
 */
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);
        FDivisionOrSubtraction solver = new FDivisionOrSubtraction();
        solver.solve(1, in, out);
        out.close();
    }

    static class FDivisionOrSubtraction {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.readLong();
            // no of divisors of n-1
            // if k(simulate 2 to sqrt n) divisible by n , add +1

            int n1 = (n == 2) ? 0 : 1;

            for (long i = 2L; i*i <= (n - 1); i++)
                if ((n - 1) % i == 0) {
                    if (i*i == (n - 1))
                        n1++;
                    else
                        n1 += 2;
                }


            int n2 = 1;
            for (long i = 2L; i*i <= (n); i++) {
                if (n % i == 0) {
                    long tmp = n;
                    while (tmp % i == 0) {
                        tmp /= i;
                    }
                    if (tmp % i == 1) n2++;
                }
            }

            System.out.println(n1 + n2);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22996
s=input()
K=int(input())
 
ans=[]
ans.append(s)
 
 
for i in range(len(s)):
 for j in range(len(s)-i):
  cut_s=s[i:i+j+1]
  ans.append(cut_s)
  ans=sorted(set(ans))
  if len(ans)>K:
   if cut_s==ans[K]:
     ans.pop()
     break;
   ans.pop()
 
answer=ans[K-1]
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << 60 * c + d - 60 * a - b - e << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;

/*------------------------------------------------------------------*/
int dp[5010][5010];

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

    int n; cin >> n;
    string s; cin >> s;

    for(int i = n - 1; i >= 0; i--){
        for(int j = n - 1; j >= 0; j--){
            if(s[i] == s[j]){
                dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
            }
        }
    }
    int ans = 0;
    rep(i, n)rep(j, n) if(j - i >= dp[i][j]) ans = max(ans, dp[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 101480
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N= 200005;
const ll lmod = 1e9+7;

int n,m;
int t[MAX_N];
map<int,int> mp;

int main(){
  cin >> n ;
  rep(i,n){
    int d;
    scanf("%d",&d);
    if(EXIST(mp,d)){
      mp[d]++;
    }else{
      mp[d]=1;
    }
  }
  cin >> m ;
  rep(i,m) scanf("%d",t+i);
  if(m>n){
    cout << "NO" << endl;
    return 0;
  }
  bool ans = true;
  rep(i,m){
    if(EXIST(mp,t[i])){
      if(mp[t[i]]<=0){
        ans=false;
      }else{
        mp[t[i]]--;
      }
    }else{
      ans = false;
    }
    if(!ans){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 10368
using System;
using System.Linq;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var c = Console.ReadLine();
            var v = new string[] { "a", "e", "i", "o", "u" };
            Console.WriteLine(v.Contains(c) ? "vowel" : "consonant");
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int initPoint = sc.nextInt();
    int nQuestion = sc.nextInt();
    int participant[] = new int[N];
    
    for(int i=0; i<N; i++){
      participant[i] = initPoint - nQuestion;
    }
    
    for(int i=0; i<nQuestion; i++){
      sc.nextLine();
      int correctNum = sc.nextInt();
      participant[correctNum-1]++;
    }
      
    for(int i=0; i<N; i++){
      if(participant[i] > 0)
        System.out.println("Yes");
      else
        System.out.println("No");
    }
  }
}

Measured memory_bytes: 154556
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C; cin >> A >> B >> C;
    long long X, Y; cin >> X >> Y;

    ll ans = INF;
    ans = min(ans, A*X + B*Y);
    ans = min(ans, max(X, Y) * C * 2);
    if (X >= Y) ans = min(ans, min(X, Y)*C*2 + (X-Y)*A);
    else ans = min(ans, min(X, Y)*C*2 + (Y-X)*B);

    cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  ll n,k; cin >> n >> k;
  
  ll ans=pow(n/k,3);
  
  if(k%2 == 0){
    ans+=pow(n/(k/2)-n/k,3);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break
    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>

string s;
ll k;
int work(string s){
	int ans=0;
	repeat(i,0,s.length()-1)
	if(s[i]==s[i+1])
		ans++,s[i+1]='#';
	return ans;
}
int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	{
		cin>>s;
		cin>>k;
		if(k%2==0){
			int a=work(s+s),b=work(s+s+s+s);
			cout<<(b-a)*k/2+2*a-b<<endl;
		}
		else{
			int a=work(s),b=work(s+s+s);
			//cout<<a<<' '<<b<<endl;
			cout<<((b-a)*k+(a-b)+a*2)/2<<endl;
		}
	}
	return 0;
}


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

const int MOD =1e9+7;

int main(){

	long long int n ; 
	cin>>n; 
	long long  count=1; int p=0; int exp=1; 

	vector<bool> prime(n+1,true); 
	for(int i=2;i*i<=n;i++)
	{
		if(prime[i])
		{
			for(int j=i*i;j<=n;j+=i)
				prime[j]=false; 
		}
	}

	for(int i=2;i<=n;i++)
	{	
		
		if(prime[i])
		{	exp=1; p=0; 
			while(floor(n/pow(i,exp))>0){
			p+=floor(n/pow(i,exp));	
			exp++; 	
			} 
			p++; 
			count=(count*p)%MOD;
		}

		

	}

	cout<<count<<endl;
}

Measured memory_bytes: 256
from collections import Counter
S = input()
S = S[::-1]
N = len(S)
counter = Counter()
counter[0] = 1
prev = 0
MOD = 2019
for i in range(N):
  c = (int(S[i]) * pow(10, i, MOD) )%MOD
  prev = (prev+c)%MOD
  counter[prev] += 1

ans = 0
for k,v in counter.items():
  ans += (v * (v-1))//2


print(ans)

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

typedef long long ll;

ll N;
vector<ll> L;
ll R;

int main() {
  cin >> N;
  L.resize(N);
  for (ll i = 0; i < N; ++i) cin >> L[i];
  sort(L.begin(), L.end());
  R = N * (N - 1) * (N - 2) / 6;
  for (ll i = 0; i < N; ++i)
    for (ll j = i + 1; j < N; ++j)
      R -= L.end() - lower_bound(L.begin(), L.end(), L[i] + L[j]);
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

int n,k;
ll ans;
int get(int p){ return n/k+(n%k>=p)-(p==0); }

int main(){
	scanf("%d%d",&n,&k);
	rep(i,0,k-1){
		int x=i,y=(k-i)%k,z=(k-i)%k;
		if (y+z!=k && y+z!=0) continue;
		ans+=1ll*get(x)*get(y)*get(z);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  vector<int> prices(3);
  for (int i = 0; i < 3; ++i)
    cin >> prices[i];
  sort(prices.begin(), prices.end());
  cout << prices[0] + prices[1] << "\n";

  return 0;
}


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

typedef long long int int64;

#define MIN(a,b) ((a)<(b)?(a):(b))

#define POS(i,j) ((i)*5+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(5*2,sizeof(int64));
  int now=0;
  for(i=0;i<n;i++){
    int next=now^1;
    int v=a[i];
    if(v>0){
      dp[POS(next,0)]=dp[POS(now,0)]+v;
      dp[POS(next,1)]=MIN(dp[POS(now,0)],dp[POS(now,1)])+(v&1);
      dp[POS(next,2)]=MIN(dp[POS(now,0)],MIN(dp[POS(now,1)],dp[POS(now,2)]))+((v+1)&1);
      dp[POS(next,3)]=MIN(dp[POS(now,2)],dp[POS(now,3)])+(v&1);
      dp[POS(next,4)]=MIN(dp[POS(now,1)],MIN(dp[POS(now,2)],MIN(dp[POS(now,3)],dp[POS(now,4)])))+v;
    } else {
      dp[POS(next,0)]=dp[POS(now,0)]+v;
      dp[POS(next,1)]=MIN(dp[POS(now,0)],dp[POS(now,1)])+2;
      dp[POS(next,2)]=MIN(dp[POS(now,0)],MIN(dp[POS(now,1)],dp[POS(now,2)]))+1;
      dp[POS(next,3)]=MIN(dp[POS(now,2)],dp[POS(now,3)])+2;
      dp[POS(next,4)]=MIN(dp[POS(now,1)],MIN(dp[POS(now,2)],MIN(dp[POS(now,3)],dp[POS(now,4)])))+v;
    }
    now=next;
  }
  int64 res=dp[POS(now,0)];
  for(i=1;i<5;i++) res=MIN(res,dp[POS(now,i)]);
  printf("%lld\n",res);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int n,K,ans,x[100005];
int main()
{
	scanf("%d%d",&n,&K);
	for(RI i=1;i<=n;++i) scanf("%d",&x[i]);
	ans=1e9;
	for(RI i=1;i+K-1<=n;++i) {
		int kl;
		if(x[i]<=0&&x[i+K-1]<=0) kl=abs(x[i]);
		else if(x[i]>=0&&x[i+K-1]>=0) kl=x[i+K-1];
		else kl=min(abs(x[i]),x[i+K-1])*2+max(abs(x[i]),x[i+K-1]);
		ans=min(ans,kl);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
        unsigned int i = 0, j = 0;
        long n = 0;
        int count=0;




        while(scanf("%ld", &n) != EOF)
        {
                short flag[n];
                for(i = 1; i <= n; i++)
                {
                        flag[i] = 1;
                }
                flag[1]=0;
                        for(i = 2; i <= sqrt(n); i++)
                        {
                                for(j = 2; j*i <= n ; j++)
                                {

                                        flag[i*j]=0;
                                }
                        }

                for(i = 1; i <= n; i++)
                {
                        if(flag[i] == 1)
                        {
                                count++;
                        }
                }
                printf("%d\n",count);
                count = 0;
        }

        return 0;
}

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

int main(){
   int a[3];
   cin >> a[0] >> a[1] >> a[2];
   int p = a[1]*10 + a[2];
   if (p%4==0){
     cout << "YES" << endl;
   }
   else {
      cout << "NO" << endl;
   }
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, k;
ll a[maxN], b[maxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, n)
    {
        cin >> a[i];
    }
    uin(k, 20000000 / n);
    while (k--)
    {
        fill(b + 1, b + n + 1, 0);
        for1(i, n)
        {
            int l = max(i - a[i], 1LL), r = min(i + a[i], (ll)n);
            ++b[l];
            if (r < n)
            {
                --b[r + 1];
            }
        }
        for1(i, n)
        {
            b[i] += b[i - 1];
            a[i] = b[i];
        }
    }
    for1(i, n)
    {
        cout << a[i] << ' ';
    }
    return 0;
}


Measured memory_bytes: 6700
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,dt[33][33],now[555][555],a[33],b[33],c[33],ans=1e9;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>dt[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>now[i][j];
		}
	}
	for(int t=1;t<=m;t++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if((i+j)%3==0)
				{
					a[t]+=dt[now[i][j]][t];
				}
			}
		}
	}
	for(int t=1;t<=m;t++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if((i+j)%3==1)
				{
					b[t]+=dt[now[i][j]][t];
				}
			}
		}
	}
	for(int t=1;t<=m;t++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if((i+j)%3==2)
				{
					c[t]+=dt[now[i][j]][t];
				}
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=1;k<=m;k++)
			{
				if(i==j || j==k || i==k)
				{
					continue;
				}
				ans=min(a[i]+b[j]+c[k],ans);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define inf 10000000000000000
#define int long long
 main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	vi dp(n,inf);
	dp[0] = 0;
	rep(i,1,n)
	{
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i]);
		if(i>1) dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i]);
	}
	cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int A,B,i,ans=0;
  scanf("%d%d",&A,&B);
  if((A+B)%2==1)printf("IMPOSSIBLE");
  else printf("%d\n",(A+B)/2);

  //printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, M;

int root(int x, vector<int>& par) {
    if (par[x] == x) return x;
    return par[x] = root(par[x], par);
}

void unite(int x, int y, vector<int>& par, vector<int>& group) {
    x = root(x, par);
    y = root(y, par);
    if (x == y) return;
    par[x] = y;
    group[y] += group[x];
}

int main() {
    cin >> N >> M;
    vector<int> group(N + 1, 1);
    vector<int> par(N + 1);
    for (int i = 0; i < N + 1; i++) {
        par[i] = i;
    }
    vector<pair<int, int>> edge(M);
    for (int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        edge[M - i] = make_pair(a, b);
    }
    vector<long long> ans(M + 1);
    ans[M] = 1ll * N * (N - 1) / 2;
    for (int i = 0; i < M; i++) {
        int x = edge[i].first, y = edge[i].second;
        long long gx = group[root(x, par)], gy = group[root(y, par)];
        unite(x, y, par, group);
        long long gxy = group[root(x, par)];
        if (gx == gxy) {
            ans[M - i - 1] = ans[M - i];
        } else {
            ans[M - i - 1] = ans[M - i] - gxy * (gxy - 1) / 2 + gx * (gx - 1) / 2 + gy * (gy - 1) / 2;
        }
    }
    for (int i = 1; i < M + 1; i++) {
        cout << ans[i] << endl;
    }
}




Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  } else if (a * b % 2 != 0) {
    cout << "Odd" << endl;
  }
}

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

ans=[]

while True:
  if N%2==0:
    ans.append("0")
    N//=(-2)
  else:
    ans.append("1")
    N=(N-1)//(-2)
    
  if N==-1:
    ans.append("11")
    break
  elif N==1:
    ans.append("1")
    break
  elif N==0:
    break

ans.reverse()
print("".join(ans))

Measured memory_bytes: 3064
private fun readInts() = readLine()!!.split(" ").map(String::toInt)

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val W = readInts()

    println((0 until N).map { split -> Math.abs(W.take(split).sum() - W.drop(split).sum()) }.min()!!)
}

Measured memory_bytes: 37820
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let s=ts(),o={}
  for(let i=0;i<s.length;i++){
    if(!o[s[i]])o[s[i]]=1
    else o[s[i]]++
  }
  for(const k in o){
    if(o[k]%2==1){
      to('No')
      return
    }
  }
  to('Yes')
}
main()


Measured memory_bytes: 7372
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

int n,m;
void init(vector<int>& par,vector<int>& height,int n){
    REP(i,n){
        par[i]  = i;
        height[i] = 0;
    }
}
int root(vector<int>& par,vector<int>& height,int x){
    if(par[x]==x){
        return x;
    }else{
        par[x] = root(par,height,par[x]);
        return par[x];
    }
}
bool same(vector<int>& par,vector<int>& height,int x,int y){
    return root(par,height,x)==root(par,height,y);
}
void unite(vector<int>& par,vector<int>& height,int x,int y){
    x = root(par,height,x);
    y = root(par,height,y);
    if(x==y)return;
    if(height[x]<height[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(height[x]==height[y])height[x]++;
    }
}

int main(){
    cin >> n >> m;
    vector<int> p(m);
    vector<int> a(m);
    vector<int> b(m);
    
    vector<int> par(n);
    vector<int> height(n);
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    init(par,height,n);
    map<int,ll> mp;
    REP(i,n){
        mp[i]=(ll)1;
    }
    vector<ll> res(m);
    res[m-1] = (ll)n*(n-1)/2;
    for(int i=m-1;i>=1;--i){
        
        int r1 = root(par,height,a[i]);
        int r2 = root(par,height,b[i]);
        if(r1!=r2){
            res[i-1]=res[i]-(ll)mp[r1]*mp[r2];
            unite(par,height,a[i],b[i]);
            int r3 = root(par,height,a[i]);
            mp[r3] = (ll)mp[r1]+mp[r2];
        }else{
            res[i-1] = res[i];
        }
    }
    REP(i,m){
        put(res[i]);
    }
    return 0;
}


Measured memory_bytes: 10368
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S,T;
  cin>>S>>T;
  cout<<T+S<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>

int sgn(double val)
{
    if(val==0)return 0;
    if(val>0)return 1;
    if(val<0)return -1;
    return -0x7fffffff-1;
}

bool inSameSide(double lx1,double ly1,double lx2,double ly2,
                double tx1,double ty1,double tx2,double ty2)
{
    double nvec[2]={ly1-ly2,lx2-lx1};// 法線vector
    double tp1=tx1*nvec[0]+ty1*nvec[1],
    tp2=tx2*nvec[0]+ty2*nvec[1],
    lp=lx1*nvec[0]+ly1*nvec[1];
    return sgn(tp1-lp)==sgn(tp2-lp);
}

int main(void)
{
    double x1,x2,x3,xp,y1,y2,y3,yp;
    while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)
          ==8)
    {
        bool result=inSameSide(x1,y1,x2,y2,x3,y3,xp,yp)
        &&inSameSide(x2,y2,x3,y3,x1,y1,xp,yp)
        &&inSameSide(x3,y3,x1,y1,x2,y2,xp,yp);
        printf("%s\n",result?"YES":"NO");
    }
    return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (D, T, S) = Scanner.Scan<int, int, int>();
            Console.WriteLine(D <= T * S ? "Yes" : "No");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &s[i]);
        scanf("%lld", &c[i]);
    }

    vector<int> ans(N, -1);

    for (int j = 0; j < M; j++)
    {
        // invalid input
        if ((ans[s[j] - 1] != -1 && ans[s[j] - 1] != c[j]) || (s[j] == 1 && c[j] == 0 && N != 1))
        {
            cout << -1 << endl;
            return 0;
        }
        ans[s[j] - 1] = c[j];
    }

    if (ans[0] == -1) {
        ans[0] = N == 1 ? 0 : 1;
    }

    for (int i = 0; i < N; i++)
    {
        cout << (ans[i] == -1 ? 0 : ans[i]);
    }
    cout << endl;

    return 0;
}


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

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n; cin >> n;
    if(n&1) cout << 0 << endl;
    else{
        ll sol = 0; n >>= 1;
        for(ll k = 5; k <= n; k *= 5){
            sol += n/k;
        }
        cout << sol << endl;
    }
    return 0;
}

//cikisir



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int a,b,x,i;
	scanf("%d %d %d",&a,&b,&x);
	for(i=0;i<=b;i++){
		if(a+i==x){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

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

const int N = 100010;
const ll MOD = ll(1e9 + 7);
const ll INF = 1e18;

struct Node {
	Node* l = nullptr;
	Node* r = nullptr;
	int sz;
	bool zero = false;
	int ad = 0;
	ll sum = 0;

	Node(int _sz) : sz(_sz) {
		if (sz > 1) {
			l = new Node(sz / 2);
			r = new Node(sz - sz / 2);
		}
	}

	void clear() {
		ad = 0;
		sum = 0;
		zero = true;
	}

	void apply(ll d) {
		ad = (ad + d) % MOD;
		sum = (sum + d * sz) % MOD;
	}

	void push() {
		if (zero) {
			l->clear();
			r->clear();
			zero = false;
		}
		l->apply(ad);
		r->apply(ad);
		ad = 0;
	}

	void add(int k, ll d) {
		if (sz == 1) {
			apply(d);
		} else {
			push();
			if (k < sz / 2)
				l->add(k, d);
			else
				r->add(k - sz / 2, d);
			sum = (l->sum + r->sum) % MOD;
		}
	}

	ll get(int a, int b) {
		if (b <= 0 || sz <= a)
			return 0;
		if (a <= 0 && sz <= b)
			return sum;
		push();
		return (l->get(a, b) + r->get(a - sz / 2, b - sz / 2)) % MOD;
	}
};

int n;
ll A, B;
ll a[N];

int main() {
	scanf("%d %lld %lld", &n, &A, &B);
	a[0] = -INF;
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);

	Node* tx = new Node(n + 1);
	Node* ty = new Node(n + 1);
	tx->add(0, 1);
	ty->add(0, 1);

	int pa = 0, pb = 0;
	for (int i = 2; i <= n; ++i) {
		for (; a[i] - a[pa] >= A; ++pa);
		for (; a[i] - a[pb] >= B; ++pb);
		ll sa = tx->get(0, pb);
		ll sb = ty->get(0, pa);
		if (a[i] - a[i - 1] < A)
			tx->clear();
		if (a[i] - a[i - 1] < B) 
			ty->clear();
		ty->add(i - 1, sa);
		tx->add(i - 1, sb);
	}

	ll ans = (tx->sum + ty->sum) % MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 19840
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

int main(){

	string str;
	cin >> str;
	int p_counter = 0;
	int n = str.size();
	rep(i,n){
		if(str[i] == 'p') p_counter++;
	}
	printf("%d\n", (int)std::floor((double)n/2) - p_counter);
	return 0;
}


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

int main(){
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;
    bool flag = false;
    for (int i=1; i<=1000; ++i){
        if (K * i >= A && K * i <= B){
            flag = true;
        }
    }
    
    if (flag == true) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pub push_back
#define ll long long
					  
using namespace std;

int n, m, k;
int a[1000000];
int q[111][111];

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("seating.in", "r", stdin);
	//freopen("seating.out", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> k;
	for (int i = 0; i < k; i++) cin >> a[i];
	int uk = 0;
	
	for (int i = 0; i < n; i++){
		if (i % 2 == 0){
			for (int j = 0; j < m; j++){
				q[i][j] = uk + 1;
				a[uk]--;
				if (a[uk] == 0) uk++;
			}
		} else {
			for (int j = m - 1; j >= 0; j--){
				q[i][j] = uk + 1;
				a[uk]--;
				if (a[uk] == 0) uk++;
			}
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cout << q[i][j] << ' ';
		}
		cout << endl;
	}
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, s=0, c=0, l;
    string a;
    cin >> n>> a;
    if(a.size()<=n)
        cout << a << endl;
    else
    {
        for(i=0; i<n; i++)
            cout << a[i];
        cout << "...\n";
    }
    
}


Measured memory_bytes: 3628
/**
 * You Are the Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int T, P, R;
			StringTokenizer st = new StringTokenizer(line);
			T = parseInt(st.nextToken());
			P = parseInt(st.nextToken());
			R = parseInt(st.nextToken());
			if ((T | P | R) == 0) break;

			Team[] teams = new Team[T + 1];
			for (int i = 0; i <= T; i++) {
				teams[i] = new Team(i, P);
			}
			teams[0].passed = -1;

			for (int i = 0; i < R; i++) {
				int t, p, m;
				String j;
				st = new StringTokenizer(br.readLine());
				t = parseInt(st.nextToken());
				p = parseInt(st.nextToken());
				m = parseInt(st.nextToken());
				j = st.nextToken();
				teams[t].submit(m, p, j);
			}
			Arrays.sort(teams);

			for (int i = 0; i < T; i++) {
				System.out.println(teams[i].toString());
			}
		} //end while
	} //end main
}

class Team implements Comparable<Team> {
	int id;
	int elapsed = 0;
	int passed = 0;
	int[] penalty;

	Team(int id, int problems) {
		this.id = id;
		penalty = new int[problems + 1];
	}

	void submit(int m, int p, String j) {
		if (j.equals("CORRECT")) {
			elapsed += m + penalty[p] * 1200;
			passed++;
		} else {
			penalty[p]++;
		}
	}

	public String toString() {
		return String.format("%d %d %d", id, passed, elapsed);
	}

	@Override
	public int compareTo(Team o) {
		int ret = 0;
		if (this.passed != o.passed) {
			ret = -(this.passed - o.passed);
		} else {
			if (this.elapsed != o.elapsed) {
				ret = this.elapsed - o.elapsed;
			} else {
				ret = this.id - o.id;
			}
		}
		return ret;
	}
}

Measured memory_bytes: 38408
#include<iostream>

using namespace std;

int main()
{
	int N,M;
	pair<int,int> studentPoint[50];
	pair<int,int> checkPoint[50];

	cin >> N >> M;

	for(int i=0;i<N;i++)
	{
		cin >> studentPoint[i].first >> studentPoint[i].second;
	}

	for(int i=0;i<M;i++)
	{
		cin >> checkPoint[i].first >> checkPoint[i].second;
	}

	for(int i=0;i<N;i++)
	{
		int min = 1000000000;
		int checkP = 0;
		for(int j=0;j<M;j++)
		{
			int dx = abs(studentPoint[i].first - checkPoint[j].first);
			int dy = abs(studentPoint[i].second - checkPoint[j].second);

			int dir = dx + dy;

			if(min > dir)
			{
				min = dir;
				checkP = j+1;
			}

		}
		cout << checkP << endl;
	}

	return 0;
}

Measured memory_bytes: 384
/*
[diverta2019-2] D - Squirrel Merchant
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int P = 2;
const int Q = 3;
const int MAX_N = 5000;
const int MAX_C = 5000;

int N;
int c[P][Q];
ll dp[MAX_N * MAX_C + 1];

ll solve() {
    ll W = N;
    for (int p = 0; p < P; p++) {
        int w[3], v[3];
        for (int q = 0; q < Q; q++) {
            w[q] = c[p][q];
            v[q] = c[p ^ 1][q] - c[p][q];
        }

        memset(dp, 0, sizeof(dp));
        for (int q = 1; q <= Q; q++) {
            for (int i = 0; i <= W; i++) {
                if (i >= w[q - 1]) {
                    dp[i] = max(dp[i], dp[i - w[q - 1]] + v[q - 1]);
                }
            }
        }
        W += dp[W];
    }

    return W;
}

int main() {
    cin >> N;
    for (int p = 0; p < P; p++) {
        for (int q = 0; q < Q; q++) {
            cin >> c[p][q];
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    bool ok=true;
    rep(i,3){
        if(s[i] == s[i+1])ok = false;
    }
    if(ok)cout<<"Good";
    else cout<<"Bad";
    return 0;
}

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

using namespace std;

int sumOfDigit(int n){
  int sum = 0;
  while ((n / 10) != 0) { 
    sum+= n % 10;
    n /= 10;
  }
  sum +=n;
  return sum;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for(int i=1;i<=n;i++) {
    int digitssum = sumOfDigit(i);
    if(digitssum >=a && digitssum <= b) {
      sum += i;
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int t[n],d[n];
  rep(i,n)cin >> t[i] >> d[i];
  vector<P> v;
  rep(i,n){
    v.push_back(make_pair(t[i],d[i]));
  }
  sort(v.begin(),v.end(),[](P a,P b) { return a.second > b.second; });
  map<int,int> mp;
  ll sum = 0;
  rep(i,k){
    chmax(mp[v[i].first],v[i].second);
    sum += v[i].second;
  }
  priority_queue<int,vector<int>,greater<int>> nmx;
  vector<int> mx(n+1);
  rep(i,k){
    if(mp[v[i].first]==v[i].second&&mx[v[i].first]==0)mx[v[i].first]=1;
    else nmx.push(v[i].second);
  }
  priority_queue<int> left;
  map<int,int> mp_left;
  for(int i=k;i<n;i++){
    if(!mp.count(v[i].first))chmax(mp_left[v[i].first],v[i].second);
  }
  for(auto p:mp_left){
    left.push(p.second);
  }
  ll sz = mp.size();
  ll ans = sum+sz*sz;
  int m = left.size();
  rep(i,m){
    sz++;
    if(sz>k)break;
    sum-=nmx.top();nmx.pop();
    sum+=left.top();left.pop();
    chmax(ans,sum+sz*sz);
  }
  cout << ans << endl;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int w,h,n;
    cin >> w >> h >> n;
    int nx=w,ny=h;
    int mx=0,my=0;
    for(int i=0;i<n;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            mx=max(mx,x);
        }
        if(a==2){
            nx=min(nx,x);
        }
        if(a==3){
            my=max(my,y);
        }
        if(a==4){
            ny=min(ny,y);
        }
    }
    int W=max(nx-mx,0);
    int H=max(ny-my,0);
    cout << W*H << endl;

}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int k[11], s[11][11];
int p[11];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < M; i++) cin >> p[i];
	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		bool on[11] = { false };
		int tmp = bit;
		for (int i = 0; i < N; i++) {
			if (tmp % 2 == 1) on[i] = true;
			else on[i] = false;
			tmp /= 2;
		}
		bool plus = true;
		for (int i = 0; i < M; i++) {
			int cnt = 0;
			for (int j = 0; j < k[i]; j++) {
				if (on[s[i][j]]) cnt++;
			}
			if (cnt % 2 != p[i]) plus = false;
		}
		if (plus) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
import sys
i = 0
x, y = input().split()
x, y =  int(x), int(y)

for count in range(0, x):
    i += 4

for count in range(0, x):
    if i > y:
        i -= 2

    if i == y:
        print("Yes")
        sys.exit()

print("No")

Measured memory_bytes: 9140