akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N; cin >> N;
    vector<int>A(N),B(N),C(N - 1);
    for(auto& e : A) cin >> e;
    for(auto& e : B) cin >> e;
    for(auto& e : C) cin >> e;
    int ans = 0;
    int lst = INF;
    for(auto e : A){
        ans += B[e - 1];
        if(e - lst == 1)
            ans += C[lst - 1];
        lst = e;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c; cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;

#define MOD 1000000007
#define HALF 500000004

int n, m, x[3005];
long long f[3005][3005], ans, mul = 1;

int ta, tb;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			f[i][j] = x[i] < x[j];
	while (m--) {
		mul = (mul << 1) % MOD;
		scanf("%d%d", &ta, &tb);
		ta--;
		tb--;
		f[ta][tb] = f[tb][ta] = HALF * (f[ta][tb] + f[tb][ta]) % MOD;
		for (int i = 0; i < n; i++)
			if (i != ta && i != tb) {
				f[i][ta] = f[i][tb] = HALF * (f[i][ta] + f[i][tb]) % MOD;
				f[ta][i] = f[tb][i] = HALF * (f[ta][i] + f[tb][i]) % MOD;
			}
	}
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			ans += f[j][i];
	printf("%lld\n", ans % MOD * mul % MOD);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;
string s,t;

main()
{
        cin>>s>>t;
        int l=s.size();

        map<char,int> v,w;
        rep(i,26)
        {
                v['a'+i]=0;
                w['a'+i]=0;
        }

        rep(i,l)
        {
                v[s[i]]++;
                w[t[i]]++;
        }

        vector<int> a,b;
        rep(i,26)
        {
                a.push_back(v['a'+i]);
                b.push_back(w['a'+i]);
        }
        sort(ALL(a));
        sort(ALL(b));

/*
        rep(i,26)
        {
                cout<<v['a'+i];
        }
        cout<<endl;
        rep(i,26)
        {
                cout<<w['a'+i];
        }
        cout<<endl;

        for(auto it : a)cout<<it;
        cout<<endl;
        for(auto it : b)cout<<it;
        cout<<endl;
        */

        cout<<(a==b?"Yes":"No")<<endl;
}

Measured memory_bytes: 776
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <cstdio>

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> p(N);
	vector<long long> a(N);
	vector<long long> b(N);
	
	for(int i=0;i<N;i++){
		cin>>p[i];
		a[i]=N*(i+1);
	}
	for(int i=0;i<N;i++){
		b[i]=a[N-i-1];
	}

	for(int i=0;i<N;i++){
		int ind=p[i]-1;
		a[ind]+=(i+1);
	}
	for(int i=0;i<N;i++) cout<<a[i]<<" ";
	cout<<endl;
	for(int i=0;i<N;i++) cout<<b[i]<<" ";
	cout<<endl;
	return 0;	
}


Measured memory_bytes: 1024
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var L = one[1];
	var list = nextIntArray();
	var max = 0;
	var maxIndex = -1;
	for(var i = 0; i < N - 1; i++){
		if(max < list[i] + list[i + 1]){
			max = list[i] + list[i + 1];
			maxIndex = i;
		}
	}
	if(max < L){
		myout("Impossible");
	}else{
		var output = ["Possible"];
		
		for(var i = N - 2; maxIndex < i; i--){
			output.push(i + 1);
		}
		for(var i = 0; i < maxIndex; i++){
			output.push(i + 1);
		}
		output.push(maxIndex + 1);
		myout(myconv(output,9));
	}
}


Measured memory_bytes: 48316
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int N;
	int a[102];
	scanf("%d",&N);
	for(int i = 0 ; i < N ; i ++){
		scanf("%d",&a[i]);
	}
	
	int sum = 0 ;
	for(int i = 0 ; i < N ; i ++){
		sum += a[i];
	}
	
	int MIN = 1000000;
	int ret = -1;
	for(int i = 0 ; i < N ; i ++){
		if(MIN > abs(a[i]*N-sum)){
			MIN = abs(a[i]*N-sum);
			ret = i;
		}
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int n, m;
const int dx[] = {0, 1};
const int dy[] = {1, 0};
bool ok(int i, int j) {
	return (i >= 0 && i < n && j >= 0 && j < m);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	vector<vector<char>>v(n + 1, vector<char>(m + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> v[i][j];
		}
	}
	vector<vector<int>>dp((n + 1), vector<int>(m + 1, 1e9));
	dp[0][0] = (v[0][0] == '#');
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < 2; k++) {
				int nx = i + dx[k];
				int ny = j + dy[k];
				if (ok(nx, ny)) {
					dp[nx][ny] = min(dp[nx][ny], (v[i][j] == '.' && v[nx][ny] == '#') + dp[i][j]);
				}
			}
		}
	}
	cout << dp[n - 1][m - 1] << endl;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000




int main(){
    
	long long N;
	cin>>N;
	
	vector<long long> Y;
	
	for(long long i=1;i*i<=N;i++){
		if(N%i==0){
			Y.push_back(i);
			Y.push_back(N/i);
		}
	}
	
	long long ans = Inf;
	
	for(int i=0;i<Y.size();i++){
		long long a = Y[i];
		long long b = N/Y[i];
		ans = min(ans,a-1+b-1);
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c[225816],b[225816]={1ll};

int main(void){
	int n,i;
	ll ans = 0ll,tmp;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> c[i];
		b[i+1] = b[i]*2%MOD;
	}
	sort(c,c+n);
	for(i=0; i<n; ++i){
		if(i==n-1){
			tmp = c[i];
			mul_mod(tmp,b[i]);
			add_mod(ans,tmp);
			break;
		}
		tmp = b[n-i-2];
		mul_mod(tmp,n-i-1);
		add_mod(tmp,b[n-i-1]);
		mul_mod(tmp,c[i]);
		mul_mod(tmp,b[i]);
		add_mod(ans,tmp);
	}
	mul_mod(ans,b[n]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
use proconio::{input};
fn main() {
    input!{
        n : usize,
        m : usize,
        ai: [usize;m]
    }
    let mut sum = 0;
    for i in ai.iter() {
        sum += i;
    }
    if sum > n {
        println!("-1");
    } else {
        println!("{}", n - sum);
    }
}


Measured memory_bytes: 2220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int a,b,c,x,y;
  cin >> a>>b>>c>>x>>y;
  int price1 = a*x + b*y;
  int price2 = 0;
  if(x==y){
    price2 = c*(x+y);
  }
  if(price2 == 0) price2 = price1;

  int price3;
  int c_count = abs(x-y);
  price3 += c*min(x,y)*2; 
  if(max(x,y) == x){
    price3 += a*c_count;
  }else{
    price3 += b*c_count;
  }
  int price4 = c*max(x,y)*2;
  //cout << price1 << " " <<  price2 << " " << price3 << " " << price4 << endl;
  cout << min(min(min(price1, price2),price3),price4) << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;


int main(void) {
  bool flag = false;
  int num = 0;
  int N;

  int A, B;

  cin >> A >> B;

  
  if (A == B) flag = true;
  else if (A + B < 16) {
    int max = std::max(A, B);
    int min = std::min(A, B);
    int empty = std::max(16 - A - B, 0);
    if (max -1 <= min + empty) flag = true;
  }
  else flag = false;
  
  if (flag) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  // cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a[101],i,s=0,t,m=0,j,p;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&p);
		t=1;
		for(j=0;j<m;j++)
		{
			if(a[j]==p)
			{
				t=0;
				break;
			}
		}
		if(t)
		{
			a[m++]=p;
			s++;
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
n,m=[int(x) for x in input().rstrip().split()]
l=[[] for x in range(n)]
for i in range(m):
  a,b=[int(x) for x in input().rstrip().split()]
  l[a-1].append(b-1)
  l[b-1].append(a-1)

done=[False for i in range(n)]
ans=[0 for i in range(n)]
def bfs():
  stack=[0]
  done[0]=True
  while(stack):
    now=stack.pop(0)
    done[now]=True
  
    for i in l[now]:
      if done[i]==True:
        continue
      ans[i]=now+1
      done[i]=True
      stack.append(i)

bfs()
print("Yes")
print(*ans[1:])

Measured memory_bytes: 38628
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  std::vector<int64_t> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int64_t minus = 0, plus = 0;
  for (int i = 0; i < n; i++) {
    int64_t diff = b[i] - a[i];
    if (diff > 0) {
      plus += diff / 2;
    } else {
      minus += diff;
    }
  }
  cerr << "\033[93m" << plus << "\033[m" << endl;
  cerr << "\033[93m" << minus << "\033[m" << endl;
  plus += minus;
  cerr << "\033[93m" << plus << "\033[m" << endl;
  if (plus >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
 
    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[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);
    }
};

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, q; cin >> n >> q;
  vector<int> s(n), t(n), x(n), ad(q), d(q);
  vector<pair<int, pair<int, int>>> p(n);
  map<int, int> mp;
  for(int i=0;i<n;++i) {
    cin >> p[i].second.first >> p[i].second.second >> p[i].first;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  for(int i=0;i<n;++i) {
    s[i] = p[i].second.first;
    t[i] = p[i].second.second;
    t[i]--;
    x[i] = p[i].first;
    s[i] -= x[i];
    t[i] -= x[i];
  }

  for(int i=0;i<q;++i) {
    cin >> d[i];
    ad[i] = d[i];
    mp[d[i]] = i;
  }
  sort(d.begin(), d.end());
  // printv(d);
  vector<int> v(300000, INF + 5);
  LazySegmentTree seg(v);
  for(int i=0;i<n;++i) {
    int l = lower_bound(d.begin(), d.end(), max(0, s[i])) - d.begin();
    int r = upper_bound(d.begin(), d.end(), max(0, t[i])) - d.begin();
    // cout << l << " " << r << " " << x[i] << endl;
    seg.update(l, r, x[i]);
  }

/*   for(int i=0;i<10;++i) {
    cout << seg.find(i, i+1) << " ";
  } */

  for(int i=0;i<q;++i) {
    int tmp = seg.find(mp[ad[i]], mp[ad[i]]+1);
    if(tmp >= INF) {
      cout << -1 << endl;
    } else {
      cout << tmp << endl;
    }
  }
}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define MOD 1000000007
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    ll n = vec.size();
    for (ll i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}
#define PI 3.14159265
void solve()
{
    ll n;
    cin>>n;
    if(n==0)
      cout<<1<<endl;
  	else 
      cout<<0<<endl;
}
int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3632
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  string s; readV(s);

  auto c = 0, m = 0;
  foreach (i; 0..n) {
    c += s[i] == '(' ? +1 : -1;
    m = min(m, c);
  }

  writeln('('.repeat.take(-m), s, ')'.repeat.take(c-m));
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    V vec;
    vec.push_back(0);
    rep3(i,1,n + 1){
        ll x;
        cin>>x;
        vec.push_back(x);
    }
   // sort(all(vec));
    rep3(i,1,n + 1) vec[i] += vec[i - 1];
    V sum;
    rep(i, n)
    {
        rep3(j, i + 1, n + 1)
        {
            sum.push_back(vec[j] - vec[i]);
        }
    }
  //  sort(all(sum));
    ll res = 0;
    vector<bool> have(sum.size(),true);
    for (ll t = pow(2, 60); t >= 1; t /= 2)
    {
        ll temp=0;
        V kesu;
        rep(j,sum.size()){
            if((sum[j]&t)&&(have[j])){
               temp++; 
            }else{
                kesu.push_back(j);
            }
        }
        
        if(temp>=k){
            res+=t;
            rep(j,kesu.size()){
                have[kesu[j]]=false;
            }
        }
    }
    cout << res << endl;
}


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

using namespace std;

int main()
{
  int A, B, N;

  cin >> A >> B;
  cin >> N;

  for(int i = 0; i < N; i++) {
    int S, F;
    cin >> S >> F;
    if(min(F, B) - max(A, S) > 0) {
      cout << 1 << endl;
      return (0);
    }
  }

  cout << 0 << endl;
}

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

using namespace std;
int32_t  main(){
     string s,t; cin>>s>>t;
    int  mega =INT_MAX ;
    int tt=0;;
    for(int i=0;i<= s.length()- t.length();++i){
        tt =  0;
        for(int o=i,j=0;j<t.length();++j,++o){
            if(s[o]!=t[j]){
                tt++;
            }
        }
        mega = min(mega,tt);
    }
    cout<<mega;
   return 0;
}



Measured memory_bytes: 3572
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	return 0;
}





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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

string X;
int main(){
   cin >> X;
   ll N = X.size();
   ll temp = 0, ans = 0;
   REP(i, N){
      (X[i] == 'T') ?  temp++ : temp--;
      chmax(ans, temp);
   }
   cout << 2 * ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    int ct=0;
    for(int i=0;i<n;i++){
        int sum=c;
        for(int j=0;j<m;j++){
            int a;
            cin >> a;
            sum+=a*b[j];
        }
        if(sum>0){
            ct++;
        }
    }
    cout << ct << endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;

struct Edge {
	int to, cost, num;
	Edge(int _to, int _cost, int _num) : to(_to), cost(_cost), num(_num) {}
};

bool operator > (const Edge& a, const Edge& b) {
	return a.cost > b.cost;
}

int n, m, c;
vector< vector< Edge > > edges;

int dist[110][1010];

void solve() {
	for_(i,0,110) fill(dist[i], dist[i] + 1010, iINF);
	
	priority_queue< Edge, vector< Edge >, greater< Edge > > q;
	q.push(Edge(0, 0, 0));
	dist[0][0] = 0;
	
	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		
		if (e.num >= m) continue;
		if (dist[e.to][e.num] < e.cost) continue;
		//cout << "Edge(" << e.to << "," << e.cost << "," << e.num << ")" << endl;
		
		int e_size = size_of(edges[e.to]);
		for_(i,0,e_size) {
			Edge ei = edges[e.to][i];
			
			if (e.cost + ei.cost > c) continue;
			if (dist[ei.to][e.num + ei.num] > e.cost + ei.cost) {
				dist[ei.to][e.num + ei.num] = e.cost + ei.cost;
				q.push(Edge(ei.to, e.cost + ei.cost, e.num + ei.num));
			}
		}
	}
	
	for_(i,0,m + 1) {
		if (dist[n - 1][i] < iINF) {
			cout << i << endl;
			return;
		}
	}
}

int main() {
	while (cin >> n >> m >> c, n) {
		edges.assign(n, vector< Edge >());
		for_(i,0,m) {
			int f, t, cost; cin >> f >> t >> cost;
			--f; --t;
			edges[f].push_back(Edge(t, cost, 0));
			if (cost > 0) edges[f].push_back(Edge(t, 0, 1));
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 3112
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

def main():
    N, M = map( int, input().split())
    U = [ i for i in range(N)]
    AB = [ tuple( map( lambda x: int(x)-1, input().split())) for _ in range(M)]
    for a, b in AB:
        union(U, a, b)
    T = [0]*N
    for i in range(N):
        T[find(U, i)] += 1
    print(max(T))
if __name__ == '__main__':
    main()


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

#define ll long long

int n;

void solve() {
    cin >> n;
    int o=n%1000;
    if(o!=0)
        cout << abs(o-1000) << "\n";
    else
        cout << o << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
X = list(map(int, input().split()))
Sorted = sorted(X)
Med1 = Sorted[N//2 - 1]
Med2 = Sorted[N//2]
for i in range(N):
    if X[i] <= Med1:
        print(Med2)
    else:
        print(Med1)

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),K=sc.nextInt();
        int res = 0;
        for(int i=1;i<=n;i+=2) res++;
        String ans = res>=K?"YES":"NO";
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
n=int(input())
a = [[int(i) for i in input().split()] for i in range(n)]
#print(a)

b=[['','','']for i in range(n)]
for i in range(n):   
    b[i][0]=a[i][1]
    b[i][1]=a[i][0]
    b[i][2]=a[i][1]
    
#print(b)
b.sort()
val1=0
flag=0

for i in range(n):
    val1+=b[i][1]
    if val1 > b[i][2]:
        flag=1
        
print('Yes' if flag==0 else 'No')
    

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

int main()
{ 
  int n, h, w ;
  cin >> n >> h >> w ;
  vector< pair<int64_t, int64_t> > data(n) ;
  for(int i = 0 ; i < n ; i++)
  {
    int64_t a, b ;
    cin >> a >> b ;
    data.at(i) = make_pair(a, b) ;
  }

  int count = 0 ;
  for(int i = 0 ; i < n ; i++)
  {
    int64_t a, b ;
    tie(a, b) = data.at(i) ;
    if(a >= h && b >= w)
    {
      count++ ;
    }
  }

  cout << count << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void f(int n) {
    
    if (n != 0) {
        int remainder = n % -2;
        n /= -2;
        if (remainder < 0) {
            remainder += 2;
            n+=1;
        }
        f(n);
        cout << remainder;
    }
}
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n == 0) {
        cout << "0\n";
        return 0;
    }
    f(n);
    return 0;
}





Measured memory_bytes: 256
open Batteries
(* 組み合わせ *)
let rec combination k list =
    if k <= 0 then [ [] ]
    else match list with
         | [] -> []
         | h :: tl ->
            let with_h = List.map (fun l -> h :: l) (combination (k-1) tl) in
            let without_h = combination k tl in
            with_h @ without_h
let rec sum lst =
  match lst with
  | [] -> 0
  | first :: rest -> first + sum rest

let n = read_int ()
let d = read_line () |> String.split_on_char ' ' |> List.map int_of_string
let a = List.map (fun a -> List.nth a 0 * List.nth a 1) @@ combination 2 d
let _ = Printf.printf "%d\n" @@ (sum a) 

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int h, w;
const int max_n = 200;
string a[max_n];
int cnt[26];

bool checkee(){
	rep(i, 26){
		if(cnt[i] % 2 == 1 || cnt[i] % 4 == 2) return false;
	}
	return true;
}

bool checkeo(){
	int cnt2 = 0;
	rep(i, 26) {
		if(cnt[i] % 2 == 1) return false;
		if(cnt[i] % 4 == 2) cnt2++;
	}

	if(cnt2 <= h/2) return true;
	return false;
}

bool checkoe(){
	int cnt2 = 0;
	rep(i, 26) {
		if(cnt[i] % 2 == 1) return false;
		if(cnt[i] % 4 == 2) cnt2++;
	}

	if(cnt2 <= w/2) return true;
	return false;
}

bool checkoo(){
	int cnt1 = 0;
	int cnt2 = 0;
	rep(i, 26) {
		if(cnt[i] % 2 == 1) {
			cnt1++;
			if(cnt1 >= 2) return false;
			if((cnt[i]-1) % 4 == 2) cnt2++;
		}else if(cnt[i] % 4 == 2) cnt2++;
	}

	if(cnt1 != 1) return false;
	if(cnt2 <= h/2 + w/2) return true;
	return false;
}

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

	cin >> h >> w;
	rep(i, h) cin >> a[i];

	rep(i, 26) cnt[i] = 0;

	rep(i, h) rep(j, w) cnt[a[i][j] - 'a']++;

	if(h % 2 == 0 && w % 2 == 0){
		cout << (checkee() ? "Yes" : "No") << endl;
	}else if(h % 2 == 0){
		cout << (checkeo() ? "Yes" : "No") << endl;
	}else if(w % 2 == 0){
		cout << (checkoe() ? "Yes" : "No") << endl;
	}else{
		cout << (checkoo() ? "Yes" : "No") << endl;
	}	
}

Measured memory_bytes: 256
class PriorityQueue():
    def __init__(self,arr,op=min):
        self.arr = arr
        self.op = op
        for i in range(len(arr)//2)[::-1]:
            self._siftup(i)

    def push(self,item):
        self.arr.append(item)
        self._siftdown(0,len(self.arr)-1)

    def pop(self):
        lastelt = self.arr.pop()
        if self.arr:
            returnitem = self.arr[0]
            self.arr[0] = lastelt
            self._siftup(0)
            return returnitem
        return lastelt

    def _siftdown(self,startpos,pos):
        newitem = self.arr[pos]
        while pos > startpos:
            parentpos = (pos - 1) >> 1
            parent = self.arr[parentpos]
            if self.op(newitem,parent) == newitem:
                self.arr[pos] = parent
                pos = parentpos
                continue
            break
        self.arr[pos] = newitem

    def _siftup(self,pos):
        endpos = len(self.arr)
        startpos = pos
        newitem = self.arr[pos]
        childpos = 2*pos + 1
        while childpos < endpos:
            rightpos = childpos + 1
            if rightpos < endpos and not self.op(self.arr[childpos],self.arr[rightpos])==self.arr[childpos]:
                childpos = rightpos
            self.arr[pos] = self.arr[childpos]
            pos = childpos
            childpos = 2*pos + 1
        self.arr[pos] = newitem
        self._siftdown(startpos,pos)

N,M = map(int,input().split())
A = list(map(int,input().split()))

P = PriorityQueue(A,max)

for i in range(M):
    x = P.pop()
    x //= 2
    P.push(x)

print(sum(P.arr))

Measured memory_bytes: 14484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define pb push_back
#define fi first
#define se second



int main(){
    ll i,j;

    ll n;
    cin>>n;
    vector<P> v;

    ll x,y;
    for(i=0;i<n;i++){
        cin>>x>>y;
        v.push_back(P(x+y,x));
    }


    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    ll ans=0;
    for(i=0;i<n;i++){
        if(i%2==0) {
            ans+=v[i].se;
        }
        else 
        ans-=(v[i].fi-v[i].se);
    }
    cout<<ans<<endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VL b(a);
	SORT(b);
	int Q; cin >> Q;
	VL x(Q), y(Q);
	FOR(i, 0, Q) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
	}
	// 完成形は定まる
	VL oks(N, 0);
	FOR(i, 0, N) {
		oks[i] = (a[i] == b[i]);
	}
	LL oksum = accumulate(ALL(oks), 0LL);
	if (oksum == N) {
		cout << 0 << endl; return 0;
	}

	FOR(i, 0, Q) {
		oksum -= oks[x[i]];
		oksum -= oks[y[i]];

		swap(a[x[i]], a[y[i]]);
		oks[x[i]] = (a[x[i]] == b[x[i]]);
		oks[y[i]] = (a[y[i]] == b[y[i]]);

		oksum += oks[x[i]];
		oksum += oks[y[i]];

		if (oksum == N) {
			cout << i + 1 << endl; return 0;
		}
	}

	//
	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 14504
using System;
using static System.Console;
using static MyUtil;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        int input = int.Parse(ReadLine());
        WriteLine(input * 2 * Math.PI);

#if DEBUG
        ReadKey();
#endif
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 27464
fun main(args: Array<String>) {
    val N = readInt()
    val a = readIntList()
    var ans = 0
    for (i in 0 until N step 2) {
        if (a[i] % 2 != 0) ans++
    }
    println(ans)


}


private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readStringList(): MutableList<String> = read().split(" ").toMutableList()

private fun readIntList(): MutableList<Int> = readStringList().map { it.toInt() }.toMutableList()

private fun readLongList(): MutableList<Long> = readStringList().map { it.toLong() }.toMutableList()

private fun readDoubleList(): MutableList<Double> = readStringList().map { it.toDouble() }.toMutableList()

private fun readStringMatrix(n: Int): MutableList<MutableList<String>> {
    val matrix = mutableListOf<MutableList<String>>()
    for (i in 0 until n) {
        val list = readStringList()
        matrix.add(list)
    }
    return matrix
}

private fun readIntMatrix(n: Int): MutableList<MutableList<Int>> {
    val matrix = mutableListOf<MutableList<Int>>()
    for (i in 0 until n) {
        val list = readIntList()
        matrix.add(list)
    }
    return matrix
}

private fun readDoubleMatrix(n: Int): MutableList<MutableList<Double>> {
    val matrix = mutableListOf<MutableList<Double>>()
    for (i in 0 until n) {
        val list = readDoubleList()
        matrix.add(list)
    }
    return matrix
}

private fun readLongMatrix(n: Int): MutableList<MutableList<Long>> {
    val matrix = mutableListOf<MutableList<Long>>()
    for (i in 0 until n) {
        val list = readLongList()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 36768
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>
#include<algorithm>


using namespace std;
using State = string::iterator;

string s;

string parse_cipher(State& begin);

char parse_letter(State& begin) {
    char ret;
    if (*begin == '+') {
        begin++;
        char c = parse_letter(begin);
        ret = c == '?' ? '?' : ((c - 'A') + 1) % 26 + 'A';
    } else if (*begin == '-') {
        begin++;
        char c = parse_letter(begin);
        ret = c == '?' ? '?' : ((c - 'A') + 25) % 26 + 'A';
    } else {
        ret = *begin;
        begin++;
    }
    return ret;
}

string parse_string(State& begin) {
    string ret;
    if (*begin == '[') {
        begin++;
        ret = parse_cipher(begin);
        begin++;
        reverse(ret.begin(), ret.end());
    } else {
        ret = parse_letter(begin);
    }
    return ret;
}

string parse_cipher(State& begin) {
    string ret;
    while (begin != s.end() && *begin != ']') {
        ret += parse_string(begin);
    }
    return ret;
}

int main()
{
    while(1) {
        cin >> s;
        if (s == ".") break;
        State begin = s.begin();
        string ret = parse_cipher(begin);
        REP(i, ret.size()) ret[i] = ret[i] == '?' ? 'A' : ret[i];
        cout << ret << endl;
    }
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
  int k;
  cin>>k;
  cout<<arr[k-1];
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
using namespace std;

int Zeller(int month, int day) {
	int year = 2004;
	if (month == 1 || month == 2) {
		year--;
		month += 12;
	}
	return (year + year / 4 - year / 100 + year / 400 + (13 * month + 8) / 5 + day) % 7;
}

int main() {

	int month, day;
	while (true) {
		scanf("%d %d", &month, &day);
		if (month == 0)break;

		switch (Zeller(month, day)) {
		case 0:
			printf("Sunday\n");
			break;
		case 1:
			printf("Monday\n");
			break;
		case 2:
			printf("Tuesday\n");
			break;
		case 3:
			printf("Wednesday\n");
			break;
		case 4:
			printf("Thursday\n");
			break;
		case 5:
			printf("Friday\n");
			break;
		case 6:
			printf("Saturday\n");
			break;
		}

	}

	return 0;
}


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

 int main() {
   int R;
   cin >> R;
   if(R < 1200){
     cout << "ABC" << endl;
   }else if(R >= 1200 && R < 2800){
     cout << "ARC" << endl;
   }else if(R >= 2800){
     cout << "AGC" << endl;
   }
 }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		abProblem();

	}
	
	public static void abProblem() {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(a / b + " " + a % b + " " + String.format("%.8f", (double) a / b));
	}
}


Measured memory_bytes: 26560
/*
# C++
clang++ -std=c++17 filename.cpp -o outname
# C
clang filename.c -o outname
*/

#ifdef __linux__
    #define gcd __gcd
#endif

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main() {
    int a, hasil;
    scanf("%d", &a);
    hasil = 3*a*a;
    printf("%d\n", hasil);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int F(int x){
  if (x=1) return 1;
  else return x+F(x-1);
}
int main(){
  int a,b;
  cin>>a>>b;
  int ans=(b-a)*(b-a+1)/2-b;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		if(s.equals("zyxwvutsrqponmlkjihgfedcba")) {
			System.out.println(-1);
			return;
		}
		if(n == 26) {
			for(int i = 25 ; i >= 1 ; i--) {
				if(s.charAt(i - 1) < s.charAt(i)) {
					String temp = s.substring(i);
					char c = 'z';
					for(int j = 0 ; j < temp.length() ; j++) {
						if(s.charAt(i - 1) < temp.charAt(j) && c > temp.charAt(j)) c = temp.charAt(j);
					}
					System.out.println(s.substring(0, i - 1) + c);
					return;
				}
			}
		} else {
			for(char c = 'a' ; c <= 'z' ; c++) {
				boolean ok = true;
				for(int i = 0 ; i < n ; i++) {
					if(c == s.charAt(i)) ok = false;
				}
				if(ok) {
					System.out.println(s + c);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 22612
N, K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
a = 0
sum1 = 0
sumMax = 0
for i in range(N):
    a += p[i]
    S.append(a)
for i in range(N-K+1):
    sum1 = S[i+K] - S[i]
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)

Measured memory_bytes: 24804
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

    if(c <= b+a)cout << b+c;
    else cout << b*2+a + 1;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int n, t;
    in >> n >> t;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        in >> a[i] >> b[i];
    }

    vector<int> dp1(2 * 3000 + 1);
    vector<int> dp2(2 * 3000 + 1);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j + a[i] < t; ++j) {
            dp2[j] = max(dp2[j], dp2[j + a[i]] + b[i]);
        }

        for (int j = 0; j < t; ++j) {
            dp2[j] = max(dp2[j], dp1[t - 1 - j] + b[i]);
        }

        for (int j = t - 1; j >= a[i]; --j) {
            dp1[j] = max(dp1[j], dp1[j - a[i]] + b[i]);
        }
    }

    int res1 = *max_element(dp1.begin(), dp1.end());
    int res2 = *max_element(dp2.begin(), dp2.end());
    int res = max(res1, res2);
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int i,n,x;
  cin>>n;
  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      cout<<" "<<i;
    }else{
      while(x>0){
        if(x%10==3){
          cout<<" "<<i;
          break;
        }else{
          x/=10;
        }
      }
    }
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main (){
	int N,L;
	vector<pair<string, int> > names;
	int ans;
	scanf("%d %d",&N,&L);
	for (int i = 0; i < N; ++i)
	{
		string tmps;
		cin >> tmps;
		names.push_back(make_pair(tmps,i));
	}
	sort(names.begin(),names.end());
	for (int i = 0; i < N; ++i)
	{
		cout << names[i].first;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

	int a,b;
	cin >> a >> b;
	if (a>b)
	{
		cout << "-1" << endl;
	}
	else
	{
		int flag=0;
		for (int i=0;i<=b*20;i++)
		{
			int alpha=floor((i*8)/100);
			int beta=floor((i*10)/100);
			if ((alpha==a)&&(beta==b))
			{
				flag=1;
				cout << i << endl;
				break;
			}
		}

		if (flag==0)
		{
			cout << "-1" << endl;
		}
	}

	return 0;
    
}


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


Measured memory_bytes: 2084