akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		ArrayList<ArrayList<ArrayList<String>>> itiKaiso = new ArrayList<ArrayList<ArrayList<String>>>();
		ArrayList<ArrayList<String>> niKaiso = new ArrayList<ArrayList<String>>();
		ArrayList<String> sanKaiso = new ArrayList<String>();
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (j == 3 && i == 3) {
					break;
				}
				if (j == 3 && i < 3) {
					for (int l = 0; l < 20; l++) {
						sanKaiso.add("#");
					}
				} else {
					for (int l = 0; l < 10; l++) {
						sanKaiso.add(" 0");
					}
				}
				niKaiso.add(sanKaiso);
				sanKaiso = new ArrayList<String>();
			}
			itiKaiso.add(niKaiso);
			niKaiso = new ArrayList<ArrayList<String>>();
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer infoCount = Integer.parseInt(br.readLine());
		for (int i = 0; i < infoCount; i++) {
			String[] strIndexs = br.readLine().split(" ");
			Integer addNum = Integer.parseInt(itiKaiso.get(Integer.parseInt(strIndexs[0]) - 1)
					.get(Integer.parseInt(strIndexs[1]) - 1).get(Integer.parseInt(strIndexs[2]) - 1)
					.substring(
							itiKaiso.get(Integer.parseInt(strIndexs[0]) - 1)
							.get(Integer.parseInt(strIndexs[1]) - 1).get(Integer.parseInt(strIndexs[2]) - 1)
							.length() - 1)) + Integer.parseInt(strIndexs[3]);
			if (addNum < 0) {
				itiKaiso.get(Integer.parseInt(strIndexs[0]) - 1).get(Integer.parseInt(strIndexs[1]) - 1)
				.set(Integer.parseInt(strIndexs[2]) - 1, " 0");
			} else {
				itiKaiso.get(Integer.parseInt(strIndexs[0]) - 1).get(Integer.parseInt(strIndexs[1]) - 1)
				.set(Integer.parseInt(strIndexs[2]) - 1, " " + String.valueOf(addNum));
			}
			addNum = 0;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (j == 3 && i == 3) {
					break;
				}
				if (j == 3) {
					for (int k = 0; k < 20; k++) {
						if (k == 19) {
							System.out.println(itiKaiso.get(i).get(j).get(k));
						} else {
							System.out.print(itiKaiso.get(i).get(j).get(k));
						}
					}
				} else {
					for (int k = 0; k < 10; k++) {
						if (k == 9) {
							System.out.println(itiKaiso.get(i).get(j).get(k));
						} else {
							System.out.print(itiKaiso.get(i).get(j).get(k));
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 19576
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){
	
	fastio;
	int n;
	cin >> n;

	vi arr(n);
	fo(n) cin >> arr[i];


	bool poss = true;

	for(int i = 1;i < n;i++){
		if(arr[i] < arr[i-1]){
			poss = false;
			break;
		}

		if(arr[i] > arr[i-1]) arr[i] -= 1;
	}

	if(poss) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
 }	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2e5+5,OO=1e18;
int a[N],p[N];
int n,mxp;
int g(int len){
    if(len>mxp)return OO;
    return p[len];
}
int f(vector<pii>&v){
    for(int i=sz(v)-1;i>=0;--i){
        ++v[i].s;
        if(v[i].s<g(v[i].f))return 1;
        v[i].s=0;
    }
    return 0;
}
int check(int m){
    p[0]=1;mxp=0;
    for(int i=1;i<=n;++i){
        p[i]=p[i-1]*m;
        mxp=i;
        if((double)p[i]*m>OO)break;
    }
    vector<pii> v;//{len,ord}
    v.pb(a[0],0);
    for(int i=1;i<n;++i){
        if(a[i]>a[i-1]){
            v.pb(a[i]-a[i-1],0);
        }else if(a[i]==a[i-1]){
            if(!f(v))return 0;
        }else{
            int d=a[i-1]-a[i];
            while(d-v.back().f>=0){
                d-=v.back().f;
                v.pop_back();
            }
            if(d){
                v.back().f-=d;
                v.back().s/=g(d);
            }
            if(!f(v))return 0;
        }
    }
    return 1;
}
int32_t main(){
    cin>>n;
    forn(i,n)cin>>a[i];
    int l=0,r=n;
    while(r-l>1){
        int m=(l+r)/2;
        if(check(m))r=m;
        else l=m;
    }
    cout<<r<<'\n';
    return 0;
}


Measured memory_bytes: 13500
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[y-1]-c, minP)
print(minP)

Measured memory_bytes: 29556
#include<stdio.h>
#include<string.h>
main(){
  char n[1000]={0},n_new[1000]={0},initial[1000]={0};
  int m,h,i,j,k,count;
  while(1){
    scanf("%999s",n);
    if(n[0]=='-')
      break;
    scanf("%d",&m);
    count=strlen(n);
    for(k=0;k<m;k++){
      scanf("%d",&h);
      for(i=h,j=0;i<count;i++,j++)
        n_new[j]=n[i];
      for(i=0;i<h;i++,j++)
        n_new[j]=n[i];
      strcpy(n,n_new);
    }   
    for(i=0;i<count;i++)
      printf("%c",n_new[i]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 580
lst = [int(x) for x in input().split()]
lst.sort()
sum = 0
for i in lst:
    sum += i
cnt = 0
if max(lst)%2 != sum%2:
    lst[2] += 1
    lst[1] +=1
    cnt += 1
cnt += (lst[2] - lst[1] + lst[2] - lst[0]) // 2
print(cnt)


Measured memory_bytes: 3060
#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;
	static ll a[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%lld",&a[i]);
	
	vector<ll> A;
	rep(i,n)A.pb(a[i]);
	sor(A);
	
	static ll s[100010];
	s[0] = A[0];
	for(int i = 1 ; i < n ; i++){
		s[i] = s[i-1] + A[i];
	}
	
	for(int i = n-2 ; i >= 0 ; i --){
		if(s[i]*2 < A[i+1]){
			cout << n-i-1 << endl;
			return 0;
		}
	}
	cout << n << endl;
}



Measured memory_bytes: 2676
function main(input) {
  var a = input.split(" ")[0]-0, b = input.split(" ")[1]-0, c = input.split(" ")[2]-0;
  if(a*c<=b) console.log(c);
  else{
    console.log(~~(b/a));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

int n, k;
int hight[MAXN];
long long dp[MAXN];


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    cin >> n >> k;

    cin >> hight[0];
    dp[0] = 0;

    for(int i = 1; i < n; i++){
        cin >> hight[i];
        dp[i] = INF;
        for(int j = max(0, i - k); j < i; j++){
            int diff = hight[i] > hight[j] ? hight[i] - hight[j] : hight[j] - hight[i];
            dp[i] = min(dp[i], diff + dp[j]);
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}



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

signed main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    //長さaの辺が何本あるか調べる
    vector<int> l(1001);
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        l.at(a) ++;
    }

    //無駄な部分は消す
    while(l.at(l.size()-1) == 0){
        l.pop_back();
    }
    int m = l.size();

    //累積和。長さi以下の辺の本数を調べる。
    vector<int> r(m);
    for(int i = 1;i < m;i ++){
        r.at(i) = r.at(i-1) + l.at(i);
    }

    ll ans = 0;

    //すべての辺の長さが異なるとき。
    //iは一番短い辺。jは二番目に短い辺。
    //(iの本数)×(jの本数)×(j+1 ~ i+j-1の本数の合計)
    for(int i = 2;i < m-2;i ++){
        for(int j = i+1;j < m-1;j ++){ 
            ans += l.at(i) * l.at(j) * (r.at(min(m-1,j+i-1)) - r.at(j));
        }
    }

    //長さの同じ辺が２本あるとき。
    //同じ２辺の選び方× 1~2*i-1までの本数。(iは除く)
    for(int i = 2;i < m;i ++){
        if(l.at(i) > 1){
            ans += (l.at(i) * (l.at(i)-1) / 2) * (r.at(min(m-1,2*i-1)) - l.at(i));
        }
    }

    //すべて同じ長さの時。
    for(int i = 1;i < m;i ++){
        if(l.at(i) > 2){
            ans += (l.at(i) * (l.at(i)-1) * (l.at(i)-2)) / 6;
        }
    }

    cout << ans << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  rep(y, h) rep(x, w) {
    if (grid[y][x] == '.') grid[y][x] = '0';
    if (grid[y][x] != '#') continue; 
    srep(dx, -1, 2) srep(dy, -1, 2) if (dx != 0 || dy != 0) {
      int nx = x+dx, ny = y+dy;
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if (grid[ny][nx] == '#') continue;
      if (grid[ny][nx] == '.') grid[ny][nx] = '1';
      else grid[ny][nx]++;
    }
  }
  rep(i, h) std::cout << grid[i] << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

inline int convert(int idx, int n) {
  if (n % 2 == 0) {
    if (idx % 2 == 0) {
      return n / 2 + idx / 2;
    } else {
      return n / 2 - idx / 2 - 1;
    }
  } else {
    if (idx % 2 == 0) {
      return n / 2 - idx / 2;
    } else {
      return n / 2 + idx / 2 + 1;
    }
  }
}

int main() {
  int n;
  std::scanf("%d", &n);
  std::vector<std::pair<int, int>> data;
  for (int i = 0; i < n; ++i) {
    int tmp;
    std::scanf("%d", &tmp);
    data.push_back(std::make_pair(convert(i, n), tmp));
  }
  std::sort(data.begin(), data.end());
  std::printf("%d", data[0].second);
  for (auto itr = data.begin() + 1; itr != data.end(); ++itr) {
    std::printf(" %d", itr->second);
  }
  std::printf("\n");

  return 0;
}


Measured memory_bytes: 3824
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
#define int             long long
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n, a[100100], b[100100];
pii sum[100100];

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, n) sum[i] = mp(a[i] + b[i], i);
	sort(sum, sum + n);
	reverse(sum, sum + n);
	int ans = 0ll;
	rep(i, n){
		if(i & 1) ans -= b[sum[i].S];
		else ans += a[sum[i].S];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  long double n, k;
  cin >> n >> k;
  long double ans = 0;
  FOR(i, 1, n+1) {
    long double b = n;
    long double score = i;
    rep(j, 20) {
      if (score >= k) break;
      b *= 2;
      score *= 2;
    }
    ans += 1 / b;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str1,str2;
  int cnt = 0;
  cin >> str1 >> str2;
  for(int i=0; i < 3; i++){
    if(str1.at(i) == str2.at(i)){
      cnt++;
    }
  }
  cout << cnt <<endl;
}
  
  

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {

    let n: f32 = read();

    println!("{}", (n / 2.0).ceil() / n);
    
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>

int main(int argc, char const *argv[]){
  int largeH,largeW,h,w;
  scanf("%d %d %d %d",&largeH,&largeW,&h,&w);
  printf("%d\n",(largeH-h)*(largeW-w));
  return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
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; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll X, Y; cin >> X >> Y;
    ll now = X;
    ll count = 0;
    while (now <= Y) {
        now *= 2;
        count += 1;
    }
    cout << count << endl;
}

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

int best, max = 0;
int N, A, B, C, *D, *flg;

void topping(int cal, int top, int num) {
	int total = (cal + top)/(A + B*num);
	if(total > best) {
		best = total;
	}
	
	if(num < N) {
		int i, max_i, newmax = 0;
		for(i = 0; i < N; i ++) {
			if(flg[i] == 0 && newmax < D[i]) {
				newmax = D[i];
				max_i = i;
			}
		}
		flg[max_i] = 1;
		topping(cal + top, newmax, num + 1);
	}
	else {
		return;
	}
} 

int main() {	
	scanf("%d %d %d %d", &N, &A, &B, &C);
	
	int i;
	D = (int *)calloc(N, sizeof(int));
	flg = (int *)calloc(N, sizeof(int));
	for(i = 0; i < N; i ++) {
		scanf("%d", &D[i]);
	}
	
	best = C/A;
	int max_i;
	for(i = 0; i < N; i ++) {
		if(max < D[i]) {
			max = D[i];
			max_i = i;
		}
	}
	
	flg[max_i] = 1;
	topping(C, max, 1);
	
	printf("%d\n", best);
	
	free(D);
	free(flg);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 1000
int main(){
  int i,inputnumber,key,j,k;
  int A[N];
  scanf("%d",&inputnumber);
  for(i=0;i<inputnumber;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<inputnumber;i++){
    for(k=0;k<inputnumber;k++) {
      if(k!=inputnumber-1) printf("%d ",A[k]);
      else printf("%d\n",A[k]);
    }
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
  }
  for(k=0;k<inputnumber;k++) {
    if(k!=inputnumber-1) printf("%d ",A[k]);
    else printf("%d\n",A[k]);
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  int d = min(a, b) + 1;
  while (k--) {
    d--;
    while ((a % d) or (b % d)) d--;
  }

  cout << d << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
q=int(input())

from collections import deque
d = deque()
d.append(s)

count = 1
for i in range(q):
#     print(s)
    q_y_i = input().split()
#     print(q_y_i)
#     print(count)
#     print(d)
    if q_y_i[0] == '1':
        count +=1
    else:
        if count % 2 == 1:
            if q_y_i[1] == '1':
                d.appendleft(q_y_i[2])
#                 print('p1')
#                 print(d)
            elif q_y_i[1] == '2':
                d.append(q_y_i[2])
#                 print('p2')
        elif count % 2 == 0:
            if q_y_i[1] == '1':
                d.append(q_y_i[2])
#                 print('p3')
            elif q_y_i[1] == '2':
                d.appendleft(q_y_i[2])
#                 print('p4')

ans = ''
for v in d:
    ans = ans + v
if count % 2 == 0:
    print(ans[::-1])
else:
    print(ans)

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool flg = false;
    if (s[0] == s[1] && s[1] == s[2])
    {
        flg = true;
    }
    if (s[1] == s[2] && s[2] == s[3])
    {
        flg = true;
    }
    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ahp = A, bhp = C;
  int i = 0;
  for (i = 0;; i++)
  {
    if(i % 2 == 0)
      bhp -= B;
    else
      ahp -= D;
    
    if(ahp <= 0 || bhp <= 0){

      break;
    }
  }

    if(i % 2 == 0)
      cout << "Yes";
    else
      cout << "No";
  
    return 0;
}

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

using namespace std;

int main(void)
{
    int A, B, i, n, judge=1;
    string S;

    cin >> A >> B;
    cin >> S;

    n = S.size();

    for(i=0; i<n; i++){
        if(i == A){
            if(S[i] != '-'){
                judge = 0;
            }
        }

        else{
            if(S[i] == '-'){
                judge = 0;
            }
        }
    }

    if(judge == 1){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* Made by Takauov Yerzhan - 31/01/2020 */
#include <bits/stdc++.h>
#define enter endl
#define LL long long
#define LD long double
#define UL unsigned long long
#define Okoshka ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define F first
#define S second

using namespace std;

const LL MXN = 3e5 + 7;
const LL MOD = 1e9 + 7;
const LL INF = 1e18 + 7;

int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, -1, +1};

LL n, d, a;

LL sum;

pair <int, int> p[MXN];

map <int, int> f;

void upd(LL x, LL val){
    while(x <= 1e9){
        f[x] += val;
        x = (x | (x + 1));
    }
}

LL s(LL x){
    LL sum = 0;
    while(x > 0){
        sum += f[x];
        x = (x & (x + 1)) - 1;
    }
    return sum;
}

int main()
{
    ///Okoshka;
    cin >> n >> d >> a;
    d *= 2;
    for(int i = 1; i <= n; i++){
        cin >> p[i].F >> p[i].S;
    }
    cout << '\n';
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++){
        LL cnt = p[i].S - s(p[i].F), ans = 0;
        if(cnt > 0){
            ans += (cnt / a) + (cnt % a ? 1 : 0);
            upd(p[i].F, (ans * a));
            upd(p[i].F + d + 1, (-ans * a));
        }
        sum += ans;
    }
    cout << sum;
}


Measured memory_bytes: 118784
#include<iostream>
using namespace std;
int q1,b,c1,c2,q2;
main()
{
	while(cin>>q1,q1)
	{
		cin>>b>>c1>>c2>>q2;
		bool flag=1;
		for(;q2;q2--)
		{
			int now=b-q2*c1,x;
			if(now>=0)x=now/c2;
			else x=0;
			if(x+q2>=q1&&now>=0)
			{
				cout<<q2<<" "<<x<<endl;
				flag=0;
				break;
			}
		}
		if(flag)cout<<"NA"<<endl;
	}
}



Measured memory_bytes: 2976
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

void bou(int x) {
	string a = to_string(x);
	rep(i, 6 - a.size()) {
		cout << '0';
	}
	cout << a;
}

signed main() {
	int n, m;
	cin >> n >> m;
	vector<P>vec[100005];
	int t[100005];
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		t[i] = a;
		a--;
		vec[a].push_back({ b, i });
	}
	rep(i, n) {
		sort(vec[i].begin(), vec[i].end());
	}
	vector<P>ans;
	rep(i, n) {
		rep(j, vec[i].size()) {
			ans.push_back({ vec[i][j].second, j + 1 });
		}
	}
	sort(ans.begin(), ans.end());
	rep(i, m) {
		bou(t[i]);
		bou(ans[i].second);
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 9456
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    m = INF
    ans = 0
    for i in range(N):
        if P[i] <= m:
            ans += 1
        m = min(m, P[i])
    return ans


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


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

using namespace std;

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

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

const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

bool square[100][100] = {false};

int main(){

	int w, h, n, a, b, c, d;
    cin>>w>>h>>n;
    a = 0, b = w, c = 0, d = h;
    while( n-- )
    {
        int x, y, m;
        cin>>x>>y>>m;
        if( m == 1 ) a = max( a, x );
        if( m == 2 ) b = min( b, x );
        if( m == 3 ) c = max( c, y );
        if( m == 4 ) d = min( d, y );
    }
    w = (b-a<0?0:b-a);
    h = (d-c<0?0:d-c);
    cout<<w*h<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
struct Coord {
	Coord(const int &a = 0, const int &b = 0) :x{ a }, y{ b } {};
	int x, y;
	bool is_valid() const {
		return x >= 0 && 10 > x && y >= 0 && 10 > y;
	}
	void set_val(const int &a, const int &b) { x = a; y = b; }
};
class Map {
public:
	Map(const int &s) :map(10, std::vector<int>(10, 0)), position(s + 1), size{ s } {};
	void set_start(const int &x, const int &y) {
		position.at(0).set_val(x, y);
		map.at(x).at(y) |= 1;
	}
	void set_sprinter(const int &i, const int &x, const int &y) {
		position.at(i).set_val(x, y);
		for (const auto &neigh : neighbor(x, y)) {
			map.at(neigh.x).at(neigh.y) |= (1 << i);
		}
	}
	bool can_move() {
		return search(0).size() != 0;
	}
private:
	std::vector<Coord> next(const int &x, const int &y) const {
		std::vector<Coord> res{};
		for (auto i = -1; i < 2; ++i) {
			for (const auto &j : { 2, -2 }) {
				if (Coord(i + x, j + y).is_valid()) {
					res.push_back(Coord(i + x, j + y));
				}
				if (Coord(j + x, i + y).is_valid()) {
					res.push_back(Coord(j + x, i + y));
				}
			}
		}
		return res;
	}
	std::vector<Coord> next(const Coord &c) const {
		return next(c.x, c.y);
	}
	std::vector<Coord> neighbor(const int &x, const int &y) const {
		std::vector<Coord> res;
		for (auto i = -1; i < 2; ++i) {
			for (auto j = -1; j < 2; ++j) {
				if (Coord(i + x, j + y).is_valid()) {
					res.push_back(Coord(x + i, y + j));
				}
			}
		}
		return res;
	}
	std::vector<Coord> neighbor(const Coord &c) const {
		return neighbor(c.x, c.y);
	}
	std::vector<Coord> search(const int &i) {
		if (i == size) {
			return neighbor(position.at(i));
		}
		else {
			std::vector<Coord> res;
			for (const auto &c : search(i + 1)) {
				for (const auto &n : next(c)) {
					if ((map.at(n.x).at(n.y) & (1 << i)) != 0) {
						map.at(n.x).at(n.y) -= (1 << i);
						res.push_back(n);
					}
				}
			}
			return res;
		}
	}
	std::vector<std::vector<int>> map;
	std::vector<Coord> position;
	const int size;
};
int main() {
	int x, y;
	while (std::cin >> x && std::cin >> y && x != 0 && y != 0) {
		int s;
		std::cin >> s;
		Map map(s);
		map.set_start(x, y);
		for (auto i = 1; i <= s; ++i) {
			std::cin >> x >> y;
			map.set_sprinter(i, x, y);
		}
		if (map.can_move()) {
			std::cout << "OK\n";
		}
		else {
			std::cout << "NA\n";
		}
	}
	return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <stdlib.h>
#define MAX 100001
int partition(int *,int ,int);

int main() {
  int A[MAX],n,i,q,x;

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

  q = partition(A,0,n-1);
  
 for(i=0;i < q;i++){
    printf("%d",A[i]);
    printf(" ");
  }
 
 printf("[%d] ",A[q]);
   
  for(i=q+1;i < n;i++){
    printf("%d",A[i]);
    if(i < n-1){
    printf(" ");
}
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r) {
  int x,i,j,tmp;
  x = A[r];
  i = p-1;
  for(j = p;j < r;j++) {
    if(A[j] <= x) {
      i = i+1;
      tmp = A[i]; 
      A[i] = A[j];
      A[j] = tmp;
    }
  }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
	  
  return i+1;
     }

Measured memory_bytes: 992
#include <stdio.h>

int main() {

	int a;
	int ans = 0;
	int n;
	scanf("%d", &n);


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

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())

    flag1, flag2, flag3 = 0, 0, 0
    if s[0] == "A":
        flag1 = 1

    c_site = 0
    if s[2:-1].count("C") == 1:
        flag2 = 1
        c_site = list(s[2:-1]).index("C") + 2

    if flag2 == 1:
        check = s[1:c_site] + s[c_site+1:]
        if check.islower():
            flag3 = 1

    if (flag1, flag2, flag3) == (1, 1, 1):
        print("AC")
    else:
        print("WA")


if __name__ == "__main__":
    main()


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

int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }
    
    // 累積和
    vector<int> s(MAX, 0);
    for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];
    
    int Q;
    cin >> Q;
    for (int i = 0; i<Q; i++) {
        int l, r;
        cin >> l >> r;
        r++;
        
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool ok(string s) {
    for(int i=0; i<(int)s.size()-1; i++) {
        if(s.substr(i, 2)=="##")
            return false;
    }
    return true;
}

int main() {
    int N, A, B, C, D;
    string S;

    cin >> N >> A >> B >> C >> D;
    cin >> S;

    bool clear_sunuke = ok(S.substr(A-1, C-A+1));
    bool clear_funuke = ok(S.substr(B-1, D-B+1));
    if(!clear_funuke || !clear_sunuke)
        cout << "No" << endl;
    else if(C < D) {
        cout << "Yes" << endl;
    } else {
        bool f = false;
        for(int i=B-1; i<=D-1; i++) {
            if(S.substr(i-1, 3)=="...") {
                f = true;
                break;
            }
        }
        if(f)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main()
{
  stack<int> st;
  string c;

  while (cin >> c)
    if (c == "+" || c == "-" || c == "*")
    {
      int v1 = st.top(); st.pop();
      int v2 = st.top(); st.pop();

      if (c == "+") st.push(v1 + v2);
      else if (c == "-") st.push(v2 - v1);
      else if (c == "*") st.push(v1 * v2);
    }
    else
      st.push(stoi(c));

  cout << st.top() << endl;
  return 0;
}

Measured memory_bytes: 3204
package main

import (
	"fmt"
)

func main() {

	var (
		n, q int
		s    string
	)
	fmt.Scan(&n, &q, &s)

	count := make([]int, len(s))

	for i := 1; i < len(s); i++ {
		count[i] = count[i-1]
		if s[i-1] == 'A' && s[i] == 'C' {
			count[i]++
		}
	}

	for i := 0; i < q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(count[r-1] - count[l-1])
	}

}


Measured memory_bytes: 6016
l, r = map(int, input().split())

if r-l>2019:
    print(0)
    exit()

numbers = list(range(l, r+1))


amari = list(set([x%2019 for x in numbers]))
#print(amari)


cnt = 2019
for i in range(len(amari)):
    for j in range(len(amari)):
        if i == j:
            continue
        if amari[i]*amari[j]%2019 < cnt:
            cnt = amari[i]*amari[j]%2019


print(cnt)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x,y;
int n,m,a[104],b[104],ma=-1000,mb=1000;
int main() {
	scanf("%d%d%d%d",&n,&m,&x,&y);
	++x;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]),ma=max(ma,a[i]);
	for (int i=1;i<=m;++i) scanf("%d",&b[i]),mb=min(mb,b[i]);
	++ma;
	if (ma>mb) {
		puts("War");
		return 0;
	}
	if (ma>y||mb<x) puts("War");
	else puts("No War");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a+b < 24){
            System.out.println(a+b);
        }else{
            System.out.println((a+b) % 24);
        }
    }   
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    cnt=0
    flag=0
    for _ in range(N):
        a,b=MI()
        if a==b:
            cnt+=1
        else:
            cnt=0
            
        if cnt==3:
            flag=1
            break
        
    if flag==1:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 62064
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n)  for(int i=0;i<n;i++)
#define per(i,n)  for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,A,B;
    cin >> N >> A >> B;
    ll res = (N / (A + B)) * A;
    if (N % (A + B) > A) res += A;
    else res += N % (A + B);
    cout << res;
    return 0;
}


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

using namespace std;


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

	int n = s.length() - 1;
	long long sum = 0;

	for (int mask = 0; mask < (1 << n); mask++) {
		long long temp = 0;
		for (int i = 0; i <= n; i++) {
			temp *= 10;
			temp += (s[i] - '0');
			if (mask & (1 << i)) {
				sum += temp;
				temp = 0;
			}
		}

		sum += temp;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2e5 + 5;
ll a[N];

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

    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
    	a[i % k]++;
    }

    ll ans = 0;

    for (int i = 0; i < k; i++) {
    	if ((i + i) % k == 0)
    		ans += a[i] * a[i] * a[i];
    }

    cout << ans;

    return 0;   
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>

int main(int argc, char *args[])
{
	char mojiretsu_in[2401];
	int alpha[26];
	int i;

	for( i=0; i<26; i++ ) {
		alpha[i] = 0;
	}

	for( i=0; i<2401; i++ ) {
		if( scanf("%c", &mojiretsu_in[i]) == EOF ) {
			mojiretsu_in[i] = 0;
			break;
		}
	}

	i=0;

	while( mojiretsu_in[i] != 0 ) {
		if( (0x41 <= mojiretsu_in[i] && mojiretsu_in[i] <= 0x5a) |
			(0x61 <= mojiretsu_in[i] && mojiretsu_in[i] <= 0x7a) ) {
			alpha[tolower(mojiretsu_in[i]) - 'a']++;
		}
		i++;
	}

	for( i=0; i<26; i++ ) {
		printf("%c : %d\n", i+'a', alpha[i]);
	}


	return 0;

}

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  vector<ll> x(n), y(n), h(n);
  ll base = 0;
  REP(i, n) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] != 0) {
      base = i;
    }
  }

  auto calcH = [&](ll i, ll cx, ll cy){
    return -abs(x[i] - cx) - abs(y[i] - cy);
  };

  auto check = [&](ll cx, ll cy, ll H) {
    REP(i, n) {
      if (max(H + calcH(i, cx, cy), 0ll) != h[i]) return false;
    }
    return true;
  };

	REP(cy, 100 + 1) REP(cx, 100 + 1) {
    ll H = h[base] - calcH(base, cx, cy);
    if (check(cx, cy, H)) {
      print(cx, cy, H);
      break;
    }
	}
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b,sum;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0) cout<<abs(a-b)/2<<endl;
    else{
        sum=min((abs(1-a)+abs(1-b)),(abs(n-a)+abs(n-b)));
        if(sum%2==0) cout<<sum/2<<endl;
        else cout<<sum/2+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>
#include <cmath>

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<double> v(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans=0.0;
    ans=(v[1]+v[0])/pow(2.0,N-1);
    for(int i=2;i<N;i++){
        ans+=v[i]/pow(2.0,N-i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll x,y,a,b,c,p;
	cin>>x>>y>>a>>b>>c;
	Vpll v;
	rep(i,0,a)	cin>>p, v.pb({p,1});
	rep(i,0,b)	cin>>p, v.pb({p,2});
	rep(i,0,c)	cin>>p, v.pb({p,3});
	sort(allr(v));
	ll i=0,j=0,k=0;
	ll ans=0;
	for(auto p:v){
		if(((x-i)+(y-j))==k)
			break;
		if( i < x and p.sd == 1){
			i++;
			ans+=p.ft;
		}
		if( j < y and p.sd == 2){
			j++;
			ans+=p.ft;
		}
		if(p.sd == 3){
			k++;
			ans+=p.ft;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int a = Integer.valueOf(temp[0]);
		int b = Integer.valueOf(temp[1]);
		int c = Integer.valueOf(temp[2]);


		if (c >= a && c <= b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 22612
using System;
class MainClass{
    public static void Main(string[] args){
        int cnt = 0;
        int num =int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 1; i < num; i++){
            if (int.Parse(input[i]) == int.Parse(input[i - 1])){
                cnt++; i++;
            }
        }
        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 13140
program main
    implicit none
    integer a, b, c, d
    integer life_t, life_a
    integer i
    read(*,*) a, b, c, d


    life_t = a
    life_a = c

    do i = 1, 1000
        if (mod(i,2) == 0) then
            life_t = life_t - d
        else 
            life_a = life_a - b
        end if

        if (life_a <= 0) then
            write(*,*) "Yes"
            exit
        end if
        if (life_t <= 0) then
            write(*,*) "No"
            exit
        end if
    end do

end program

Measured memory_bytes: 2804
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	
	int X,A,B;
	scanf("%d%d%d",&X,&A,&B);

	X -= A;
	X %= B;
	
	printf("%d\n",X);
	
		
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n) {
		ans *= a[i];
		if (ans > 1000000000000000000) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (ans < 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3984
judge = 'Yes'
n = int(input())
txy_l = [[0,0,0]]
for _ in range(n):
    txy_l.append(list(map(int,input().split())))

for i in range(n):
    t_dif = txy_l[i+1][0] - txy_l[i][0]
    x_dif = txy_l[i+1][1] - txy_l[i][1]
    y_dif = txy_l[i+1][2] - txy_l[i][2]
    spare_time = t_dif - (abs(x_dif)+abs(y_dif))
    if spare_time < 0 or spare_time%2 != 0:
        judge = 'No'

print(judge)

Measured memory_bytes: 27380
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

#define rep(i,j) for(int i = 0;i<(j);i++)

int num_len(int n){
  int res = 0;
  while(n){
    n /= 10;
    res++;
  }
  return res;
}

int count(vector<char> &cs, int cnt){
  if(cs.size() == 0 or cnt == 0) return 0;
  
  if(cs.size() == 1){
    if(cnt > 1) return 3;
    else return 1;
  } else if(cnt > 1){
    return cs.size() * 2 - 1 + 2 + num_len(cnt) + 1;
  } else {
    return cs.size() * 2 - 1;
  }
}

int main(){
  int N; cin >> N;
  string s; cin >> s;
  vector<int> c_cnt('z'-'a' + 1, 0);
  for(char c : s){
    if('a' <= c and c <= 'z') c_cnt[c-'a']++;
  }
  map<int, vector<char>> i_cnt;
  rep(i, c_cnt.size()){
    if(c_cnt[i] > 0){
      i_cnt[c_cnt[i]].push_back(i + 'a');
    }
  }
  bool flg = false;
  int ans  = 0;
  for(auto& p : i_cnt){
    int cnt = p.first;
    vector<char> cs = p.second;
    // cerr << cnt << " " ;
    // rep(j, cs.size()) cerr << cs[j] << " ";
    // cerr << endl;
    if(flg){
      ans++;
    }
    flg = true;
    ans += count(cs, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3200