akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef priority_queue<int> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 200000;
const int MAX_M = 200000;

int main() {
  int N, ans = INF;
  string S;
  cin >> N >> S;
  vi sum_l, sum_r;
  int tlsum = 0, trsum = 0;
  sum_l.pb(tlsum); sum_r.pb(trsum);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W') tlsum++;
    if (S[N-i-1] == 'E') trsum++;
    sum_l.pb(tlsum);
    sum_r.pb(trsum);
  }
  for (int i = 0; i < N; i++) {
    // cout << sum_l[i] << ", " << sum_r[N-i-1] << endl;
    ans = min(ans, sum_l[i]+sum_r[N-i-1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3960
# include <iostream>
# include <cstdio>

using namespace std;

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if (a<=b){
        for (int i=1;i<=b;i++) printf("%d",a);
    }
    else{
        for (int i=1;i<=a;i++) printf("%d",b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CS_AtCoder {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
		public Calc() { }
		public void Solve() {
			int N = Utils.ReadInt();
			int[] TiAi;
			long Ts = 1;
			long As = 1;
			long k = 1;
			for (int i = 0; i < N; i++) {
				TiAi = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				k = Math.Max((Ts - 1) / TiAi[0] + 1, (As - 1) / TiAi[1]+1);
				Ts = TiAi[0] * k;
				As = TiAi[1] * k;
			}
			(Ts + As).WL();
			return;
		}
	}
	public static class Utils {
		public static int ReadInt() => int.Parse(Console.ReadLine());
		public static void WL(this object obj) {
			Console.WriteLine(obj);
		}
	}
}


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

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

    cout << (*max_element(a,a+n) - *min_element(a,a+n)) << endl;

    return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n)
  ll ans=1;
  ll law=1;
  vll A(n);
  FOR(i,0,n){
	ci(A[i])
  }
  SORT(A);
  FOR(i,1,n){
	if(A[i-1]==A[i]){      
      ans-=1;
      law+=1;
    }
    else{
      if(law%2==0){
        ans+=(law-2);
        ans+=1;
        law=1;
      }
      else{
        ans+=(law-1);
        ans+=1;
        law=1;
      }
    }
  }
	if(law%2==0){
        ans+=(law-2);
	}
    else{
      ans+=(law-1);
    }
  co(ans)
  } 

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

int count_factors(int N) {
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (N % i == 0) {
      cnt++;
    }
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    if (count_factors(i) == 8) {
      ++ans;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<int64_t> list(87);
  list.at(0)=2,list.at(1)=1;
  for(int i=2;i<87;i++){
    list.at(i)=list.at(i-1)+list.at(i-2);
  }
  cout<<list.at(N)<<endl;
  
}


Measured memory_bytes: 256
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();

    if ($height == 0 && $width == 0) {
        break;
    }

    $edge = setRectangleEdgePart($width);
    $middle = setRectangleMiddlePart($height, $width);

    echo $edge.$middle.$edge, PHP_EOL;
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function setRectangleEdgePart($width)
{
    return sprintf('%s%s', str_repeat('#', $width), PHP_EOL);
}

function setRectangleMiddlePart($height, $width)
{
    $middle  = sprintf('%s%s', '#'.str_repeat('.', $width - 2).'#', PHP_EOL);
    return str_repeat($middle, $height - 2);
}

Measured memory_bytes: 15424
import copy
import itertools
h, w, k = map(int,input().split())
masu = []
for _ in range(h):
    masu.append(list(input()))

cnt = 0
for i in range(2**h):
    for j in range(2**w):
        masu_copy = copy.deepcopy(masu)

        for ii in range(h):
            if 1 & (i >> ii):
                for y in range(w):
                    masu_copy[ii][y] = '.'

        for jj in range(w):
            if 1 & (j >> jj):
                for x in range(h):
                    masu_copy[x][jj] = '.'
        tmp_masu = list(itertools.chain.from_iterable(masu_copy))
        if tmp_masu.count('#') == k:
            cnt += 1
print(cnt)

Measured memory_bytes: 9364
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string S, T;
    cin >> S >> T;

    string sub = T.substr(0, T.size() - 1);
    cout << (S == sub ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
import scala.io._

object Main {
  def main(args: Array[String]): Unit = {
    val n: Int = readLine.toInt
    val lst =  (1 to n).map((_) => readLine.toInt).toList.sorted
    var elem = lst.head
    var count = 0
    var ans = 0
    for {
      l <- lst
    } {
      if (elem ==  l) count += 1
      else {
        ans += count % 2
        elem = l
        count = 1
      }
    }
    ans += count % 2
    println(ans)
  }
}


Measured memory_bytes: 38744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

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

  int Ccount=0,count=0;
  bool flag=true;
  if(S.at(0)!='A')  flag=false;

  for(int i=2;i<=S.size()-2;i++){
    if(S.at(i)=='C')  Ccount++;
  }
  if(Ccount !=1)  flag=false;

  for(int i=0;i<S.size();i++){
    if(isupper(S.at(i))!=0)  count++;
  }
  if(count!=2)  flag=false;

  if(flag)  cout << "AC" << endl;
  else cout << "WA" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define PI (acos(-1))
#define M_E (2.718281828459045)
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005

ll st[4*asz];
ll lz[4*asz];
void update(ll node,ll ss,ll sf,ll qs,ll qe,ll val)
{
    if(lz[node])
    {
        st[node]+=(sf-ss+1)*lz[node];
        if(ss!=sf)
        {
            lz[2*node]+=lz[node];
            lz[2*node+1]+=lz[node];
        }
        lz[node]=0;
    }
    if(qs>sf||qe<ss||sf<ss)return;
    if(qs<=ss&&qe>=sf)
    {
        st[node]+=(sf-ss+1)*val;
        if(ss!=sf)
        {
            lz[2*node]+=val;
            lz[2*node+1]+=val;
        }
        return;
    }
    ll mid=(ss+sf)/2;
    update(2*node,ss,mid,qs,qe,val);
    update(2*node+1,mid+1,sf,qs,qe,val);
    st[node]=st[2*node]+st[2*node+1];
}

ll query(ll node,ll ss,ll sf,ll qs,ll qe)
{
    if(lz[node])
    {
        st[node]+=(sf-ss+1)*lz[node];
        if(ss!=sf)
        {
            lz[2*node]+=lz[node];
            lz[2*node+1]+=lz[node];
        }
        lz[node]=0;
    }
    if(qs>sf||qe<ss||sf<ss)return 0;
    if(qs<=ss&&qe>=sf)return st[node];
    ll mid=(ss+sf)/2;
    return query(2*node,ss,mid,qs,qe)+query(2*node+1,mid+1,sf,qs,qe);
}
int main()
{
    fastread;
    ll n,d,a;
    cin>>n>>d>>a;
    vii v(n);
    for(auto &x:v)cin>>x.fi>>x.se;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)update(1,0,n-1,i,i,v[i].se);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ll x=max(query(1,0,n-1,i,i),0LL);
        ll y=(x+a-1)/a;
        ll z=upper_bound(v.begin()+i,v.end(),ii(v[i].fi+2*d,INF))-v.begin();
        z--;
        update(1,0,n-1,i,z,-a*y);
        ans+=y;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15616
#include <iostream>
#include <cmath>
using namespace std;
#define MOD 1000000007
long long kaijo(int a){
  long long kek = 1;
  for(int i = a; i > 0; i--){
    kek = (kek * i) % MOD;
  }
  return kek;
}
int main(){
  int n,m;cin>>n>>m;
  int kekka;
  if(abs(n-m) == 1){
    kekka = kaijo(m)*kaijo(n) % MOD;
  }else if(abs(n-m) == 0){
    kekka = kaijo(m)*kaijo(n) % MOD * 2 % MOD;
  }
  cout << kekka << endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;

  vector<int> A={1,3,5,7,8,10,12};
  vector<int> B={4,6,9,11};
  
  if(x==2 || y==2){
    cout << "No" <<endl;
    return 0;
  }

  if(count(A.begin(), A.end(), x)==count(A.begin(), A.end(), y)){
    cout << "Yes" << endl;
  }
  else if(count(B.begin(), B.end(), x)==count(B.begin(), B.end(), y)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
return 0;  
}

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

int main(){
  int N,count;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  count=0;
  for(int i=0;i<N;i++){
    for(int j=i+2;j<N;j++){
      for(int k=i+1;k<j;k++){
        if(vec.at(j)-vec.at(i)<vec.at(k)){
          if(vec.at(j)+vec.at(i)>vec.at(k)){
            count++;
          }
        }
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    limit = k ** 0.5
    while 1 < k and i <= limit:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
            else:
                break
        i += 2
    if k > 1:
        f[k] = 1
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx - 1, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1]
    ans %= MOD
    ans *= r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)


Measured memory_bytes: 11380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  vi a(N);
  cin >> a[0];
  rep2(i,1,N){
    int x; cin >> x;
    a[i] = a[i-1] + x;
  }
  
  
  int ans = 1e15;
  rep(i,N-1){
    ans = min(ans, abs(a[N-1]-a[i]*2));
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 4844
package main

import "fmt"

func main() {
	var r1, c1, r2, c2 int64
	fmt.Scan(&r1)
	fmt.Scan(&c1)
	fmt.Scan(&r2)
	fmt.Scan(&c2)

	const M = 1000000007

	f := make([]int64, c2+r2+3, c2+r2+3)
	f[0] = 1
	for i := int64(1); i <= c2+r2+2; i++ {
		f[i] = (f[i-1] * i) % M
	}

	s0 := (f[c2+r2+2] * modinv(f[r2+1], M) % M) * modinv(f[c2+1], M) % M
	s1 := (f[c2+r1+1] * modinv(f[r1], M) % M) * modinv(f[c2+1], M) % M
	s2 := (f[c1+r2+1] * modinv(f[r2+1], M) % M) * modinv(f[c1], M) % M
	s3 := (f[c1+r1] * modinv(f[r1], M) % M) * modinv(f[c1], M) % M

	fmt.Println((s0 - s1 - s2 + s3 + 2*M) % M)
}

func modpow(a int64, n int64, m int64) int64 {
	if n == 0 {
		return 1
	}
	tmp := modpow(a, n/2, m)
	if n%2 == 0 {
		return tmp * tmp % m
	}
	return tmp * tmp % m * a % m
}

func modinv(a int64, m int64) int64 {
	return modpow(a, m-2, m)
}


Measured memory_bytes: 18036
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int n, x, y;
int a[N], f[2][N];

int dfs(int dep, int now) {
  if(~f[now][dep]) 
    return f[now][dep];
  f[now][dep] = abs(a[dep] - a[n]);
  for(int i = 1; i < n - dep; ++i) {
    if(now) 
      f[now][dep] = min(f[now][dep], dfs(i + dep, now ^ 1));
    else 
      f[now][dep] = max(f[now][dep], dfs(i + dep, now ^ 1));
  }
  return f[now][dep];
}

int main() {
  cin >> n >> x >> y;
  for(int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  memset(f, -1, sizeof f);
  a[0] = y;
  printf("%d\n", dfs(0, 0));
  return 0;
}

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

using namespace std;

string n;

int main()
{
	cin >> n;
	for(char c : n)
	{
		if(c == '1') putchar('9');
		else if(c == '9') putchar('1');
		else putchar(c);
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

typedef long long                       ll;
typedef unsigned long long              ull;
typedef long double                     ld;


#define      PI                         3.141592654


int main()
{
    string a,b,c;
    int n,l=0,i,k;
    cin>>a;
    k = a.size();
    for(i=0; i<k; i++)
    {
        if(a[i]==a[i+1])
            l++;
    }
    if(k-1==l)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 350
int cnt[maxn];
int n,m;
int a[maxn][maxn];
int now[maxn];
bool ban[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;++i) 
	{
		now[i]=1;
		++cnt[a[i][1]];
	}
	int ans=n;
	for(int tim=1;tim<=m;++tim)
	{
		int mx=0,id=0;
		for(int i=1;i<=m;++i)
			if(!ban[i]&&cnt[i]>mx)
			{
				mx=cnt[i];
				id=i;
			}
		ans=min(ans,mx);
		ban[id]=true;
		for(int i=1;i<=n;++i)
			while(now[i]<=m&&ban[a[i][now[i]]])
			{
				--cnt[a[i][now[i]]];
				++now[i];
				++cnt[a[i][now[i]]];
			}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  if(abs(n-m)>1){
    co(0)
  }
  else{
    ll ans=1;
    rFOR(i,n,0){
      ans*=i;
      ans%=1000000007;
    }
    rFOR(i,m,0){
      ans*=i;
      ans%=1000000007;
    }
    if(n==m){
      ans*=2;
      ans%=1000000007;
    }
    co(ans)
  }
}

Measured memory_bytes: 256
using AtCoderBeginnerContest116.Questions;
using AtCoderBeginnerContest116.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest116.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var edges = inputStream.ReadIntArray();
            var a = edges[0];
            var b = edges[1];
            yield return a * b / 2;
        }
    }
}


namespace AtCoderBeginnerContest116
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest116.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest116.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11348
#include<iostream>
using namespace std;
long int a, b, k;
int main() {
    cin >> a >> b >> k;
    if (a > k) {
        cout << a - k << " " << b << endl;
    } else {
        long int rest = b - (k - a);
        if (rest > 0) {
            cout << 0 << " " << rest << endl;
        } else {
            cout << 0 << " " << 0 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

double eps = 1e-9;
int main(){
	double a, b; cin >> a >> b;
	for(int i = a*10; i<(b+1)*10; i++){
		double x = double(i)*0.08;
		double y = double(i)*0.10;
		if (x<a-eps or y<b-eps) continue;
		if (x-a<1.00 && y-b<1.00) {
			cout << i << endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    for i in range(N-1): ##i駅からスタート
        t = 0
        for j in range(i,N-1):
            if t > S[j]:
                t = (S[j]+(math.ceil((t-S[j])/F[j]))*F[j]) + C[j]
            else:
                t = S[j] + C[j]
        print(t)
    print(0)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N - 1)  # type: "List[int]"
    S = [int()] * (N - 1)  # type: "List[int]"
    F = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()


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

int main(){
  int id = 0, N, s = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i], s += A[i];
  for(int i = 0; i < N; ++i){
    if(abs(A[i]*N - s) < abs(A[id]*N - s)) id = i;
  }
  cout << id << endl;
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  bool f = false;
  for (int i = 0; i < 1001; ++i) {
    if (100*i <= x && x <= 105*i) f = true;
  }
  cout << (f ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i;
	double num[12]={0},sum=0;
	while(scanf("%lf",&num[0])!=EOF){
		for(i=1;i<10;i++){
			if(i%2!=0)	num[i]=2*num[i-1];
			else		num[i]=num[i-1]/3;
		}
		for(i=0;i<10;i++){
			sum+=num[i];
		}
		printf("%lf\n",sum);
		sum=0;
	}
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<bool> v(n, false);
    ll mi = 0, ma = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a < 3200) {
            ll index = a / 400;
            if(v[index] == false) {
                v[index] = true;
                ma++;
                mi++;
            }
        } else {
            ma++;
        }
    }
    if(mi == 0)
        mi = 1;
    if(ma > n)
        ma = n;

    cout << mi << ' ' << ma << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int dep(int n){
    int ret = 0;
    while(n >= 2){
        n /= 2;
        ret++;
    }
    return ret;
}

int func(int n,int j){
    n /= (1 << j);
    return n;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input
    int n; cin >> n;
    int v[n+1],w[n+1];
    REPS(i,n) cin >> v[i] >> w[i];
    int q; cin >> q;
    int M_L = 0;
    int t[q], l[q];
    REP(i,q){
        cin >> t[i] >> l[i];
        chmax(M_L,l[i]);
    }
    //半分全列挙
    int V = min((1ll << 9)-1, n);
    vector<vector<int>> dp(V+1,vector<int>(M_L+1,0));
    REPS(i,V) REP(j,M_L+1){
        chmax(dp[i][j], dp[i/2][j]);
        if(j - w[i] > -1) chmax(dp[i][j], dp[i/2][j-w[i]] + v[i]);
    }
    int z, o, ans, sumw, sumv, hoge[9];
    REP(i,q){
        if(t[i] <= V) cout << dp[t[i]][l[i]] << '\n';
        else{
            z = dep(t[i]) - 8;
            o = func(t[i],z);
            ans = 0;
            REP(j,z) hoge[j] = func(t[i],j);
            for(int b = 0; b < (1ll << z); b++){
                sumw = 0;
                sumv = 0;
                REP(j,z) if((b >> j) & 1){
                    sumw += w[hoge[j]];
                    sumv += v[hoge[j]];
                }
                if(l[i]-sumw > -1) chmax(ans, dp[o][l[i]-sumw] + sumv);
            }
            cout << ans << '\n';
        }
    }
}


Measured memory_bytes: 410980