akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll a[200005],pre[200005];
void solve(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	while(k){
		ll f=0;
		for(ll i=1;i<=n;i++){
			if(a[i]<n)
			f=1;
			pre[i]=0;
		}
		pre[0]=pre[n+1]=0;
		if(!f)
		break;
		for(ll i=1;i<=n;i++){
			pre[max(ll(0),i-a[i])]++;
			pre[min(n,i+a[i])+1]--;
		}
		for(ll i=1;i<=n;i++){
			pre[i]+=pre[i-1];
			a[i]=pre[i];
		}
		k--;
	}
	for(ll i=1;i<=n;i++)
	cout<<a[i]<<" ";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();		
}


Measured memory_bytes: 6704
n,y=map(int,input().split())
num10000=-1
num5000=-1
num1000=-1
for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if k*1000+j*5000+i*10000==y:
            num1000=k
            num5000=j
            num10000=i
            break
print(num10000,num5000,num1000)

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

int A, B, C;

int main() {
    cin >> A >> B >> C;
    if (A < C && C < B) cout << "Yes" << endl;
    else if (B < C && C < A) cout << "Yes" << endl;
    else cout << "No";

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


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


int main() {
    ll a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    if (abs(a - b)>1e18) {
        cout << "Unfair" << endl;
        return 0;
    }
    if (k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
}


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

int main(){
    i64 n;
    string s,t;
    cin>>n>>s>>t;
    for(i64 i=0;i<n;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}

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

int main() {
    //
    long long num;
    long long a, b, c, d, e;
    long long numA = 0;
    long long numB = 0;
    long long numC = 0;
    long long numD = 0;
    long long numE = 0;
    long long cnt = 0;
    long long Min;

    cin >> num >> a >> b >> c >> d >> e;
    numA = num;

    Min = min(min(min(min(a, b), c), d), e);

    cnt = (num+Min-1) / Min + 4;
    cout << cnt;
}

Measured memory_bytes: 3572
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()
    val ans = aList.fold(0L) { acc, a -> acc + countDiv(a, 2) }
    out.println(ans)
}

/** O(log(n)) */
tailrec fun countDiv(n: Long, divisor: Long, count: Long = 0L): Long =
    if (n % divisor == 0L) countDiv(n / divisor, divisor, count + 1) else count

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 39924
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
prev = -1
cnt = 0
for i in a:
  cnt += b[i-1]
  if i == prev+1:
    cnt += c[i-2]
  prev = i
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  int a[H+1][W+1];
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  vector<vector<int>> answer(H*W,vector<int>(4));
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      if(a[i][j] % 2 == 1){
        if(j != W){
          a[i][j+1]++;
          ++ans;
          answer[ans-1] = {i,j,i,j+1};
        }else if(i != H){
          a[i+1][j]++;
          ++ans;
          answer[ans-1] = {i,j,i+1,j};
        }
      }
    }
  }
  cout << ans << endl;
  for(int i = 0;i < ans;i++){
    cout << answer[i][0] << " " << answer[i][1] << " " << answer[i][2] << " " << answer[i][3] << endl;
  }
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
int main(void){


    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++) {
        cin >> x[i];
    }
    
    int max = *max_element(x.begin(), x.end());
    
    
    int min = 100000000;
    for(int i=1; i<=max; i++) {
        int total = 0;
        for(auto itr = x.begin(); itr != x.end(); itr++) {
            total += ((*itr) - i) * ((*itr) - i);
        }
        if(total < min) min = total;
    }
    
    cout << min << endl;
    
    return 0;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, long long>> v;
    for (int i = 0; i < n; i++) {
        int a; long long b; cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.rbegin(), v.rend());
    priority_queue<long long> q;
    long long ans = 0;
    for (int i = 1; i <= m; i++) {
        while (!v.empty() && v.back().first == i) {
            q.push(v.back().second);
            v.pop_back();
        }
        if (!q.empty()) {
            ans += q.top(); q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>
using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int lli;

int main()
{
    int n,m;
    cin>>n>>m;
    if(m>n)
    {
        int tmp=n;
        n=m;
        m=tmp;
    }
    string a="";
    char c=char(m+'0');
    for(int i=0;i<n;++i)
    {
        a.push_back(c);
    }
    cout<<a<<endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k,cnt=0;
  cin >> k;
  while (a>=b) {
    b*=2;
    k--;
  }
  while (b>=c){
    c*=2;
    k--;
  }
  if (k<0) cout << "No" << endl;
  else cout << "Yes" << endl;

}

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

int main(void){
    int n = 0, d = 0, x = 0;
    int a[101]; 
    int day = 0;
    int ans = 0;

    scanf("%d%d%d", &n, &d, &x);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for(int i = 0; i < n; i++){
        for(int day = 1; day <= d; day = day+a[i]){
            ans++;
        }
    }
    ans += x;
    printf("%d\n", ans);
    return 0;

} 


Measured memory_bytes: 256
def main():
    S = input()
    n = len(S)
    bit = 0
    total = 0
    for bit in range(1<<n-1):
        tmp_total = 0
        tmp = S[0]
        for i in range(n-1):
            # print(bin(bit))
            # print(i, (1<<i) & bit)
            if (1<<i) & bit:
                tmp_total += int(tmp)
                tmp = S[i+1]
            else:
                tmp += S[i+1]
        tmp_total += int(tmp)
        total += tmp_total
    print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<assert.h>

#define  N_MAX  60

int ans[2000];

/* ???????????????????¢????????????? */
int check(int p, int s[N_MAX]);

int main(void){

  int n = -1, p = -1;
  int st_num[N_MAX];
  int count = 0;
  int sum_st;
  int kill = 0;
  int i, j;
  
  while(1){

    /* ????????? */
    for(j = 0; j < 60; j++) {
      st_num[j] = 0;
    }
    i = 0;
    kill = 0;
    
    scanf("%d %d", &n, &p);

    if(n == 0 && p == 0) break;

    assert(n != 0 && p != 0);
    assert(n > 2);
    assert(p > 1);

    sum_st = p;
    
    while(1){

      if(p > 0){
	p--;
	st_num[i]++;
	
	/* ???????¢???? */
	if(check(p, st_num) != 0) break;
		
      }
      else if(p == 0 && st_num[i] > 0){
	p = st_num[i];
	st_num[i] = 0;
      }

      assert(p >= 0);

      /* ???????????? */
      //printf("p = %d ", p);
      //printf("st_num[%d] = %d ", i, st_num[i]);
      //printf("kill = %d\n", kill);

      int sum = p;      
      for(j = 0; j < n; j++){
	sum = sum + st_num[j];
      }
      //printf("sum = %d\n", sum);
      assert(sum == sum_st);
      
      /* ???????????¢?????? */
      if(kill > 1000000){
	i = 0;
	break;
      }
      
      i++;
      i = i % n;	

      kill++;
    }

    assert(count >= 0);

    ans[count++] = i;

    assert(ans[count-1] < n);

    /* ???????????? */
    //printf("test2\n");
  }

  /* ??????????????? */
  for(i = 0; i < count; i++){
    printf("%d\n", ans[i]);
  }
  
  return 0;
}

int check(int p, int s[N_MAX]){

  int flag = 0;
  int i;

  if(p != 0)
    flag = 334;
  
  for(i = 0; i < N_MAX; i++){
    if(s[i] != 0){
      flag++;
    }
  }
  
  if(flag == 1)
    return 1;
  else
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   char even[] = {'R','U','D'}, odd[] = {'L','U','D'};
   int chk = 1;
   cin >> s;
   int n = s.length();
   f(i,0,n){
      int cc = 0;
      f(j,0,3){
         if(even[j] == s[i]) cc = 1;
      }
      chk = chk*cc;
      i++;
      cc = 0;
      if(i==n) break;
      f(j,0,3){
         if(odd[j] == s[i]) cc = 1;
      }
      chk = chk*cc;
   }
   if(chk){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 1e5+7;

int app[500];
char str[N];

int main () {
	scanf(" %s", str);

	for (int i = 0; str[i]; i++) {
		app[str[i]] = 1;
	}

	for (int a = 'a'; a <= 'z'; a++) {
		if (!app[a]) {
			printf("%c\n", a);
			return 0;
		}
	}
	printf("None\n");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
bool XOR(int a,int b){ return !a != !b; }
int N,K;


int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N>> K;
    
    cout << (N%K ? 1 :0 ) <<"\n";
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.length();
  int dp[20][2] = {};
  for (int i = 0; i < n; i++) {
    dp[i + 1][0] = dp[i][0] + s[i] - '0';
    if (i == 0) {
      dp[i + 1][1] = dp[i][0] + s[i] - '0' - 1;
    } else {
      dp[i + 1][1] = max(dp[i][1] + 9, dp[i][0] + max(0, s[i] - '0' - 1));
    }
  }
  cout << max(dp[n][0], dp[n][1]) << endl;
  return 0;	
}

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

int main() {
  int a,b ;
  cin >>a >>b;
  if(a>b){
   cout <<"a > b"<< endl;
  } else if(a==b){
  cout << "a == b" << endl;} else if(a<b){cout << "a < b" << endl;}
 return 0;
}


Measured memory_bytes: 3116
from math import gcd
k=int(input());a=0
x=[]
for i in range(k):
    d=0
    for j in range(k):
        d+=gcd(i+1,j+1)
    x.append(d)
for i in range(k):
  for j in range(k):
      a+=x[gcd(i+1,j+1)-1]
print(a)   

Measured memory_bytes: 9200
#include<cstdio>
#include<algorithm>
#include<climits>
using namespace std;
static const int MAX_N = 100000;
static const int INF = INT_MAX;

int n, q;

int n_;
int dat[4 * MAX_N], laz[4 * MAX_N];

void init(){
	n_ = 1;
	while(n_ < n) n_ *= 2;
	for(int i = 0; i < 2 * n_ - 1; i++){
		dat[i] = INF;
		laz[i] = 0;
	}
	for(int i = n_ - 1; i < n_ - 1 + n; i++){
		dat[i] = 0;
		int k = i;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
}
void add(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l) return;
	if(a <= l && r <= b){
		laz[k] += x;
		return;
	}
	add(a, b, x, 2 * k + 1, l, (l + r) / 2);
	add(a, b, x, 2 * k + 2, (l + r) / 2, r);
	dat[k] = min(dat[2 * k + 1] + laz[2 * k + 1], dat[2 * k + 2] + laz[2 * k + 2]);
}
int find(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return INT_MAX;
	if(a <= l && r <= b) return dat[k] + laz[k];
	int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr) + laz[k];
}

int main(){
	scanf("%d %d", &n, &q);
	init();
	for(int i = 0; i < q; i++){
		int op;
		scanf("%d", &op);
		if(op == 0){
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);
			add(s, t + 1, x, 0, 0, n_);
		}else if(op == 1){
			int s, t;
			scanf("%d %d", &s, &t);
			printf("%d\n", find(s, t + 1, 0, 0, n_));
		}
	}
	return 0;
}


Measured memory_bytes: 4776
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint A,B;
    cin >> A >> B;
    lint ans=-1;
    for(int i=1;i<=1000000;i++){
        bool check=true;
        lint val=i;
        if((val*8)/100!=A) check=false;
        if((val*10)/100!=B) check=false;
        if(check){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int d,n,dp[201][201]={},t[201],a[201],b[201],c[201];
int main(){
	int ans=0;
	cin>>d>>n;
	for(int i=0;i<d;i++)
	cin>>t[i];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	
	for(int i=2;i<=d;i++){
		for(int j=0;j<n;j++){
			if(t[i-1]<=b[j] && t[i-1]>=a[j]){
				for(int k=0;k<n;k++){
					if(t[i-2]<=b[k] && t[i-2]>=a[k]){
					dp[i][j]=max(dp[i][j],abs(c[k]-c[j])+dp[i-1][k]);
					}
				}
			}
		}
	}
	
	for(int i=0;i<n;i++){
		if(ans<=dp[d][i])
		ans=dp[d][i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>

using namespace std;

bool sunuke[100];

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i< K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int A;
      cin >> A;
      sunuke[A-1] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (!sunuke[i]) {
      ++ans;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n, y;
  cin >> n >> y;
  int ans10000 = -1, ans5000 = -1, ans1000 = -1;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j + i <= n; j++){
      int k = n - i - j;
      int total = 10000 * i + 5000 * j + 1000 * k;
      if(total == y){
        ans10000 = i;
        ans5000 = j;
        ans1000 = k;
      }
    }
  }
  cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

typedef struct{
	char mark;
	int number;
}poker;

int main(void){
    poker N[100],A[100];
    int x,minj,c=0,flag;
	poker tmp,t;
    
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%*c%c%d",&N[i].mark,&N[i].number);
    	A[i]=N[i];
    }
	
	
	flag=1;
	while(flag==1){
		flag=0;
		for(int j=x-1;j>0;j--){
			if(N[j].number < N[j-1].number){
				t=N[j];
				N[j]=N[j-1];
				N[j-1]=t;
				c++;
				flag=1;
			}
		}
	}
	
	for(int i=0;i<x;i++){
		minj=i;
		for(int j=i;j<x;j++){
			if(A[j].number<A[minj].number){
				minj=j;
			}
		}
		if(i!=minj){
			tmp=A[i];
			A[i]=A[minj];
			A[minj]=tmp;
			c++;
		}
	}
	
	printf("%c%d",N[0].mark,N[0].number);
    for(int i=1;i<x;i++){
        printf(" %c%d",N[i].mark,N[i].number);
    }
	printf("\nStable\n");
	
	flag=0;
	printf("%c%d",A[0].mark,A[0].number);
    for(int i=1;i<x;i++){
        printf(" %c%d",A[i].mark,A[i].number);
    	if(A[i].mark!=N[i].mark){
    		flag=1;
    	}
    }
	printf("\n");
	if(flag==0){
		printf("Stable");
	}else{
		printf("Not stable");
	}
	printf("\n");
	
    return 0;
}




Measured memory_bytes: 2036
m, d = map(int, input().split())
count = 0
if d < 22:
  pass
else:
  for n in range(1, m+1): 
    for i in range(10, d+1):
      a, b = list(str(i))
      a = int(a)
      b = int(b)
      if n == a * b and a >= 2 and b >= 2:
        count += 1
print(count)


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

int main(){
    cin >> S;
    cout << ((S == "ARC")? "ABC" : "ARC") << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;




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

	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	vector<int> t(N);
	REP(i, N) {
		if (T[i] == 's') t[i] = 0;
		else if (T[i] == 'p') t[i] = 1;
		else t[i] = 2;
	}
	int hand[] = { R,S,P };

	int res = 0;
	REP(i, K) {
		int num = (N - i - 1) / K;
		vector<vector<int>> dp(num + 1, vector<int>(3));
		REP(k, 3) {
			dp[0][k] = (t[i] == k) * hand[k];
		}
		REP(j, num) {
			REP(k, 3) {
				int tmp = 0;
				REP(l, 3) {
					if (k == l) continue;
					tmp = max(tmp, dp[j][l] + (t[i + (j + 1) * K] == k) * hand[k]);
				}
				dp[j + 1][k] = tmp;
			}
		}
		res += max({ dp[num][0], dp[num][1], dp[num][2] });
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6224
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
 
    int w,n,left,right;
    scanf("%d",&w);
    int array[w+1];
    for(int i=0;i<w+1;i++)array[i]=i;
    scanf("%d",&n);
 
    for(int i=0;i<n;i++){
        scanf("%d,%d",&left,&right);
        swap(array[left],array[right]);
    }
 
    for(int i=1;i<=w;i++){
        printf("%d\n",array[i]);
    }
 
    return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();
        if(m1 < m2 && d1 > d2) System.out.println(1);
        else System.out.println(0);
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;
int maxh;

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  maxh = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 25244
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

const int mod = (int) 1e9 + 7;

int n, m, need;
int dp[105][105][305];

int getBit(int x, int pos) {
  return (x & (1 << pos)) > 0 ? 1 : 0;
}

bool checkMask(int mask) {
  for (int i = 0; i + 1 < (m - 1); i++) {
    if (getBit(mask, i) == 1 && getBit(mask, i + 1) == 1) {
      return false;
    }
  }
  return true;
}

int getNextPos(int mask, int pos) {
  if (pos < m - 1 && getBit(mask, pos) == 1) {
    return pos + 1;
  }
  if (pos - 1 >= 0 && getBit(mask, pos - 1) == 1) {
    return pos - 1;
  }
  return pos;
}

int main() { 

  scanf("%d %d %d", &n, &m, &need);
  need--;

  dp[0][0][0] = 1;
  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int pos = 0; pos < m; pos++) {
      for (int curMask = 0; curMask < (1 << (m - 1)); curMask++) {
        if (checkMask(curMask) == false) {
          continue;
        }
        // cerr << i << " " << pos << " " << curMask << " " << dp[i][pos][curMask] << endl;
        for (int mask = 0; mask < (1 << (m - 1)); mask++) {
          if (checkMask(mask) == false) {
            continue;
          }
          int nextPos = getNextPos(mask, pos);
          dp[i + 1][nextPos][mask] = (dp[i + 1][nextPos][mask] + dp[i][pos][curMask]) % mod;
          if (i + 1 == n && nextPos == need) {
            ans = (ans + dp[i][pos][curMask]) % mod;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10752
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,b:i64,c:i64
    }
    let ans = c - (a - b);
    println!("{}", max(0, ans));
}


Measured memory_bytes: 4352
k, n = map(int, input().split())
a = list(input().split())
a = list(map(int, a))

dif = []

for i in range(n - 1):
    dif.append(a[i + 1] - a[i])

dif.append(a[0] + k - a[n - 1])

print(k - max(dif))

Measured memory_bytes: 25840
import java.util.*;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] a = new double[n];
        double bunshi = 1;
        for (int i=0; i<n; i++) {
            a[i] = sc.nextDouble();
            bunshi *= a[i];
        }
        double bunbo = 0;
        for (int i=0; i<n; i++) {
            bunbo += bunshi / a[i];
        }
        System.out.print(bunshi / bunbo);
    }
}

Measured memory_bytes: 38044
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

    int sq(int a){
        int b;
        b = a * a;
        return b;
    }
 
	int x[100];

int main(){
    int n;
    cin >> n;
    int s = 0, a = 1e9;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    for(int p = 0; p < 100; p++){
        s = 0;
        for(int i = 0; i < n; i++){
            s += sq(x[i] - p);
        }
        a = min(a, s);
    }

   cout << a;

    return 0;
}

	

		


Measured memory_bytes: 256
N = input()

arr = []

for i in xrange(N):
    a,b = map(int,raw_input().split())
    arr.append([a,b])

arr.sort(key = lambda x : x[1])

time = 0
ans = 'Yes'


for i in xrange(N):
    time += arr[i][0]
    if arr[i][1]-time < 0:
        ans = 'No'
        break
    arr[i].append(time)

# print ''
# for i in xrange(N):
#     print arr[i]

print ans

Measured memory_bytes: 45304
N = gets.to_i
D,X = gets.split.map(&:to_i)
num = 0
N.times do |i|
    a = gets.to_i
    j = 0
    loop do
        day = j * a + 1

        if day <= D then
            j += 1
            num += 1
        else break
        end
    end
end
puts num + X

Measured memory_bytes: 1788
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int ans = (int)Math.ceil((double)(N-1) / (K-1));
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
#define df 0
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  string s; cin >>s;
  li k,n=s.size(); cin >>k;
  li sum=0,f=0,l=0,flag=1,temp=1;
  for(int i=1;i<n;i++){
    if(flag && s.at(i)!=s.at(0)){
      f=i;
      flag=0;
      if(df)printf("f:%d\n",f);
    }
    if(s.at(i)!=s.at(i-1)){
      if(df)printf("%c %ctemp:%d\n",s.at(i),s.at(i-1),temp);
      sum+=temp/2;
      temp=1;
    }else temp++;
  }
  sum+=temp/2;
  if(df)printf("sum:%ld",sum);

  if(flag){
    printf("%ld",(n*k)/2);
    return 0;
  }
  if(s.at(0)!=s.at(n-1)){
    if(df)printf("\n");
    printf("%ld",sum*k);
    return 0;
  }
  temp=0;
  for(int i=n-1;i>=0;i--){
    if(s.at(i)!=s.at(n-1)){
      l=temp;
      break;
    }
    temp++;
  }
  sum-=f/2+l/2;
  if(df)printf("->%ld\nl:%ld\n",sum,l);
  printf("%ld",f/2+sum*k+(f+l)/2*(k-1)+l/2);
}

/// confirm df==0 ///

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, i, j, k, l, cnt, m;
    while(scanf("%d", &n) != EOF){
        cnt = 0;
        for(i=0; i<10; i++){
            for(j=0; j<10; j++){
                for(k=0; k<10; k++){
                    for(l=0; l<10; l++){
                        m=i+j+k+l;
                        if(m==n) cnt++;
                    }
                }
            }
        }
    printf("%d\n", cnt);
    }
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << (n - 1 + k - 1 - 1) / (k - 1) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()

{

	int a, b, c, d;

	a = 0;
	b = 0;
	c = 0;
	d = 0;

	scanf("%d %d %d", &a, &b, &c);

	if ((a < b) && (b < c))
	{
		a = a;
		b = b;
		c = c;
	}
	else
	{
		if ((a < c) && (c < b))
		{
			a = a;
			d = b;
			b = c;
			c = d;
		}
		else
		{
			if ((b < a) && (a < c))
			{
				d = a;
				a = b;
				b = d;
				c = c;
			}
			else
			{
				if ((b < c) && (c < a))
				{
					d = a;
					a = b;
					b = c;
					c = d;

				}
				else
				{
					if ((c < a) && (a < b))
					{ 
						d = a;
						a = c;
						c = b;
						b = d;
					}
					else
					{
						if ((c < b) && (b < a))
						{
							d = a;
							a = c;
							c = d;
							b = b;
						}
						else
						{
							if ((a == b) && (b == c))
							{
								a = a;
								b = b;
								c = c;
							}
							else
							{
								if ((a == b) && (b < c))
								{
									a = a;
									c = c;
								}
								else
								{
									if ((a > b) && (b == c))
									{
										d = a;
										a = c;
										c = d;

									}
									else
									{
										if ((a == c) && (c < b))
										{
											d = b;
										    b = c;
											c = d;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	printf("%d %d %d\n", a, b, c);

	return(0);

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,V,W,T;
  cin >> A >> V >> B >> W >> T;
  
  if (A <= B){
    if (A + V * T >= B + W *T){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }  
  }else{
      if (A - V * T <= B - W *T){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }  
  }
}

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

typedef long long ll;
typedef pair<int,int> P;

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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int ans = INF;
    for(int i = 0; i + k <= n; i++){
        int z = a[i+k-1] - a[i] + min(abs(a[i]),abs(a[i+k-1]));
        if(ans > z) ans = z;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const int N = 2000006;
const ll MOD = 1e9+7;

ll a[N];
ll mx[N];
ll mn[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	for(int i=0;i<3*n;i++){
		cin>>a[i];
	}
	priority_queue<ll> mnn,mxx;
	ll sm = 0;
	for(int i=0;i<n;i++){
		sm += a[i];
		mnn.push(-a[i]);
		mx[i] = sm;
	}
	for(int i=n;i<3*n;i++){
		ll x = -mnn.top();
		mnn.pop();
		if(x < a[i]){
			sm -= x;
			sm += a[i];
			mnn.push(-a[i]);
			mx[i] = sm;
		}else{
			mnn.push(-x);
			mx[i] = sm;
		}
	}
	sm = 0;
	for(int i=3*n-1;i>=2*n;i--){
		sm += a[i];
		mxx.push(a[i]);
		mn[i] = sm;
	}
	for(int i=2*n-1;i>=0;i--){
		ll x = mxx.top();
		mxx.pop();
		if(x > a[i]){
			sm -= x;
			sm += a[i];
			mxx.push(a[i]);
			mn[i] = sm;
		}else{
			mxx.push(x);
			mn[i] = sm;
		}
	}
	ll ans = -1e18;
	for(int i=n-1;i<=2*n-1;i++){
		ans = max(ans,mx[i]-mn[i+1]);
		//cout<<mx[i]-mn[i+1]<<" ";
	}
	cout<<ans<<endl;;
	
	return 0;
}


Measured memory_bytes: 11844
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

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

  int cnt = 0;
  rep(i, n) {
    int sum = 0;
    vector<int> a(m);
    rep(j, m) cin >> a[j];

    rep(j, m) {
      sum += a[j]*b[j];
    }
    sum += c;
    if(sum > 0) cnt++;
  } 

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust\n";
	else cout<<"win\n";
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()
    d = defaultdict(int)
    for x in in_na():
        d[x] += 1

    ans = 'YES'
    for i in range(1, N + 1):
        if d[i] % 2 == 1:
            ans = 'NO'
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27416
#include <stdio.h>

int main(void){
    // Your code here!
    
    char s[110];
    float k;
    scanf("%s",s); 
    scanf("%f",&k);
    
    
    int i;
    char ans='1';
    
    for(i=0; i<k; ++i ){
        if( s[i] != ans ){
            ans=s[i];
            break;
        }
    }
    
    
    
    printf("%c",ans);
    
    return 0;
}


Measured memory_bytes: 128
import numpy as np
N = int(input())
p = [int(i) for i in input().split()] 
a = np.zeros(N-1)
b = a
c = 0
d = 0
for j in range(N-1):
  a[j] = p[j+1] - p[j]
b = sorted(a)
if b[0] > 0:
  print('YES')
elif b[2] > 0 and b[0] == b[1]:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 21660
using System;
using System.IO;
 
class MainClass {
    static void Main() {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
 		string output = "";
        string line;
        while ((line = Console.ReadLine()) != null) {
            string[] tokens = line.Split(' ');
            int a = int.Parse(tokens[0]);
          	switch(a){
              case 1:
                output = "Hello World";
                break;
              case 2:
                int outputInt = int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine());
                output = outputInt.ToString();
                break;
            }
            Console.WriteLine(output);
        }
 
        Console.Out.Flush();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <cstring>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
    return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
    return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
    return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
    return forall_a_in_P.second > forall_b_in_P.second;
}


int main()
{
    int n,k,s;
    cin>>n>>k>>s;
    int empty=1e9;
    if(s==1e9){
        empty=1;
    }
    vector<int>ans(n,empty);
    rep(i,k){
        ans[i]=s;
    }
    rep(i,n){
        cout<<ans[i];
        if(i!=n-1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }
   
   
}

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

using namespace std;

typedef long long ll;
ll n, A[200050], L[200050], R[200050];
inline ll rq(ll x, ll y){ return A[y]-A[x-1]; }
inline ll calc(ll a, ll b, ll c){ return abs(rq(a,b)-rq(b+1,c)); }
int main(){
//	freopen("equalcut.in", "r", stdin);
	cin >> n;
	for(ll i = 1; i<=n; i++){
		cin >> A[i];
		A[i] += A[i-1];
	}
	ll cur = 1;
	for(ll i = 2; i<=n-2; i++){
		while(cur<i and calc(1,cur+1,i) <= calc(1,cur,i)) cur++;
		L[i] = cur;
	}
	cur = n-1;
	for(ll i = n-1; i>=3; i--){
		while(cur>i and calc(i,cur-1,n) <= calc(i,cur,n)) cur--;
		R[i] = cur;
	}
//	for(ll i = 1; i<=n; i++) prllf("%d ", L[i]); prllf("\n");
//	for(ll i = 1; i<=n; i++) prllf("%d ", R[i]); prllf("\n");
	ll ans = INT_MAX;
	for(ll i = 2; i<=n-2; i++){
		ll a,b,c,d,cur=0;
		a=rq(1,L[i]);
		b=rq(L[i]+1,i);
		c=rq(i+1,R[i+1]);
		d=rq(R[i+1]+1,n);
		cur=max(cur,abs(a-b));
		cur=max(cur,abs(a-c));
		cur=max(cur,abs(a-d));
		cur=max(cur,abs(b-c));
		cur=max(cur,abs(b-d));
		cur=max(cur,abs(c-d));
		ans = min(ans, cur);
		assert(a+b+c+d==A[n]);
	}
	cout << ans;
}


Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    if(s[0] < 'a') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import java.lang.reflect.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        ArrayList<Character> str = new ArrayList<Character>();
        for(int i = 0; i < 4; ++i) {
            str.add(s.charAt(i));
        }
        Collections.sort(str);
        if(str.get(0) == str.get(1) && str.get(2) == str.get(3) && str.get(1) != str.get(2)){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 22740
/* 拡張ダイクストラ */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s, 2600);   /* 2500枚あれば足りるのでそれ以上のことは考えない */
    vector<int> a(m), b(m), c(n), d(n);

    vector<P> graph[n];    /* first: どこへ、second: 情報へのidx */
    REP(i, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        graph[u].push_back({v, i});
        graph[v].push_back({u, i});
        cin >> a[i] >> b[i];
    }
    REP(i, n) cin >> c[i] >> d[i]; 

    ll dist[n][2700];   /* d[i][j]: 頂点iでj枚金貨を持った状態で到達するための最短距離 */
    REP(i, n) REP(j, 2700) dist[i][j] = INF_LL;

    bool visited[n][2700];
    REP(i, n) REP(j, 2700) visited[i][j] = false;

    ll ans[n];
    REP(i, n) ans[i] = INF_LL;

    ll idx = 3000;
    int start = 0;

    /* dijkstra */
    priority_queue<P, vector<P>, greater<P>> que;
    dist[start][s] = 0;
    que.push({0, start * idx + s});

    while(!que.empty()) {
        P p = que.top(); que.pop();
        ll place = p.second / idx;
        ll okane = p.second % idx;

        if(visited[place][okane]) continue;
        visited[place][okane] = true;
        ans[place] = min(ans[place], p.first);
        
        for(auto e: graph[place]) {
            ll next_place = e.first;
            ll info = e.second;

            if(okane < a[info]) {
                /* お金足りないのでむり */
                continue;
            }

            ll next_okane = okane - a[info];  
            if(dist[next_place][next_okane] > p.first + b[info]) {              
                dist[next_place][next_okane] = p.first + b[info];
                que.push({dist[next_place][next_okane], next_place * idx + next_okane});
            }
        }
        /* お金の補充 */
        ll okane_ = okane + c[place];
        okane_ = min(okane_, (ll)2600);
        if(dist[place][okane_] > dist[place][okane] + d[place]) {
            dist[place][okane_] = dist[place][okane] + d[place];
            que.push({dist[place][okane_], place * idx + okane_});
        }
    }

    REPN(i, 1, n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 6444
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat mod = 1000000007;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = (x * x) % mod;
	if(e&1) x = (x * a) % mod;
	return x;
}

void count(cat ans[][51][51][101], cat sum[][101], int used, int p, int n, int x, auto &invf) {
	int x_prev = 2*x + n - p;
	if(p+n >= abs(x_prev))
		ans[used+p+n][p][n][50+x] = (ans[used+p+n][p][n][50+x] + sum[used][50+x_prev] * invf[p] % mod * invf[n]) % mod;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> fac(N+1, 1), inv(N+1, 1);
	for(int i = 1; i <= N; i++) {
		fac[i] = (i * fac[i-1]) % mod;
		inv[i] = pw(fac[i], mod-2);
	}

	cat ansF = 0;
	cat ans[51][51][51][101]; // i, p, n, x
	cat sum[51][101]; // i, x
	memset(ans, 0, sizeof(ans));
	memset(sum, 0, sizeof(sum));
	ans[1][1][0][50] = ans[1][1][0][51] = 1;
	for(int d = 0; d <= N; d++) {
		memset(sum, 0, sizeof(sum));
		for(int i = 0; i <= N; i++) for(int x = -i; x <= i; x++)
			for(int p = max(0, x); p <= i; p++) for(int n = max(0, -x); n <= i-p; n++) if(p+n > 0)
				sum[i][x+50] = (sum[i][x+50] + ans[i][p][n][x+50]) % mod;
		memset(ans, 0, sizeof(ans));
		ansF = (ansF + sum[N][50]) % mod;
		for(int i = 0; i <= N; i++)
			for(int p = 0; p <= N-i; p++) for(int n = 0; n <= N-p-i; n++) if(p+n > 0)
				for(int x = -n; x <= p; x++)
					count(ans, sum, i, p, n, x, inv);
	}
	memset(sum, 0, sizeof(sum));
	for(int i = 0; i <= N; i++) for(int x = -i; x <= i; x++)
		for(int p = max(0, x); p <= i; p++) for(int n = max(0, -x); n <= i-p; n++) if(p+n > 0)
			sum[i][x+50] = (sum[i][x+50] + ans[i][p][n][x+50]) % mod;
	ansF = (ansF + sum[N][50]) % mod;

	ansF = ansF % mod * fac[N] % mod;
	if(ansF < 0) ansF += mod;
	cout << ansF << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 104960
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
l=[[] for i in range(a)]
for j in range(b):
  x,y=mi()
  l[x-1].append(y-1)
  l[y-1].append(x-1)
lst=[-1]*a
q=deque([0])
while q:
  s=q.popleft()
  for j in l[s]:
    if lst[j]==-1:
      lst[j]=s
      q.append(j)
print("Yes")
for k in range(a-1):
  print(lst[k+1]+1)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; ++i) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<>());
  int ans = accumulate(l.begin(), l.begin() + K, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
ans = ""
for i in range(len(s)):
    if s[i] == "A":
        ans += "T"
    elif s[i] == "T":
        ans += "A"
    elif s[i] == "G":
        ans += "C"
    elif s[i] == "C":
        ans += "G"
print(ans)


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split(" ")))

a.insert(0,0)
a.append(0)

total = 0
for i in range(len(a)-1):
    total += abs(a[i] - a[i+1])

for j in range(1, len(a)-1):
    print(total - abs(a[j-1] - a[j]) - abs(a[j] - a[j+1]) + abs(a[j+1]- a[j-1]))

Measured memory_bytes: 14048