akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 206;
typedef long long ll;
const ll C = 1e12, inf = 1e18;
struct 
{
    struct edge
    {
        int v;
        ll r,f;
    };
    vector<edge> e;
    vector<int> g[N];
    int n,s,t, d[N], pr[N];
    bitset<N> inq;
    void init(int _n,int _s,int _t)
    {
        n=_n,s=_s,t=_t;
    }
    void addE(int u,int v,ll c)
    {
        g[u].push_back(e.size());
        e.push_back(edge{v,c,0});
        g[v].push_back(e.size());
        e.push_back(edge{u,0,0});
    }
    ll aug()
    {
        fill_n(pr,n,-1);
        fill_n(d,n,N);
        d[s] = 0;
        queue<int> q;
        inq.reset();
        q.push(s);
        while (q.size()) {
            int u = q.front();
            q.pop();
            inq[u] = false;
            for (int i : g[u]) {
                if (e[i].r) {
                    int w = d[u] + 1;
                    if (w < d[e[i].v]) {
                        d[e[i].v] = w;
                        pr[e[i].v] = i;
                        if (!inq[e[i].v]) {
                            q.push(e[i].v);
                            inq[e[i].v] = true;
                        }
                    }
                }
            }
        }
        ll f=inf;
        for (int u = t; pr[u] != -1; u = e[pr[u]^1].v)
            f = min(f, e[pr[u]].r);
        for (int u = t; pr[u] != -1; u = e[pr[u]^1].v) {
            e[pr[u]].r -= f;
            e[pr[u]].f += f;
            e[pr[u]^1].r += f;
            e[pr[u]^1].f -= f;
        }
        return f;
    }
} f;
int n,a[N];
int main()
{
    cin >> n;
    f.init(n+2,0,n+1);
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > 0) {
            ans += a[i];
            f.addE(i,f.t,a[i]);
        } else {
            f.addE(f.s,i,-a[i]);
        }
        for (int j = i * 2; j <= n; j += i)
            f.addE(i,j,inf);
    }
    ll w;
    while ((w = f.aug()) != inf)
        ans -= w;
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint n, k;
llint x[100005];
vector<llint> pvec, mvec;

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin>>x[i];
    
    for(int i = 0; i < n; i++){
        if(x[i] >= 0) pvec.push_back(x[i]);
        else mvec.push_back(-x[i]);
    }
    reverse(mvec.begin(), mvec.end());
    
    llint ans = inf;
    if(pvec.size() > k-1) ans = min(ans, pvec[k-1]);
     if(mvec.size() > k-1) ans = min(ans, mvec[k-1]);
    for(int i = 0; i < mvec.size(); i++){
        if(k-i-2 >= 0 && k-i-2 < pvec.size()) ans = min(ans, mvec[i] * 2 + pvec[k-i-2]);
        if(k-i-2 >= 0 && k-i-2 < pvec.size()) ans = min(ans, mvec[i] + 2 * pvec[k-i-2]);
    }
    cout << ans <<endl;
   return 0;
}

Measured memory_bytes: 2424
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
char s[100010];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    if (s[0]==s[len-1]){
        if (len%2){
            printf("Second\n");
        }
        else{
            printf("First\n");
        }
    }
    else{
       if (len%2==0){
            printf("Second\n");
        }
        else{
            printf("First\n");
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int a[15] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
ll mx;
int n, m, q;
ll sum;
struct node
{
    int a;
    int b;
    int c;
    int d;
};
node P[maxn];
bool cmp(const node &a, const node &b)
{
    return a.d > b.d;
}
void check()
{
    for (int i = 1; i <= q; i++)
    {
        if (a[P[i].b] - a[P[i].a] == P[i].c)
        {
            sum += P[i].d;
        }
    }
    mx = max(sum, mx);
    sum = 0;
    return;
}
void dfs(int x)
{
    if (x == (n + 1))
    {
        check();
        return;
    }
    for (int i = a[x - 1]; i <= m; i++)
    {
        a[x] = i;
        dfs(x + 1);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++)
    {
        cin >> P[i].a >> P[i].b >> P[i].c >> P[i].d;
    }
    dfs(2);
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>

int main(){
	int n,num,i;
	scanf("%d",&n);
	char a[n+1];
	scanf("%s",&a);
	for(i=0;i+2<n;i++){
		if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')num++;
	}
	printf("%d",num);
	return 0;
} 

Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j - i, abs(i - x) + 1 + abs(y - j))] += 1 
for i in range(1,n):
    print(ans[i])

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

int main() {
    int n;
    cin >> n;
    vector<P> jobs(n);
    rep(i,n) {
        cin >> jobs[i].second >> jobs[i].first;
    }
    sort(all(jobs));
    ll time = 0;
    rep(i,n) {
        time += jobs[i].second;
        if(jobs[i].first<time){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 998244353

int a[100];

int main() {
	LL n, x;
	cin >> n >> x;
	REP(i, n)scanf("%d", &a[i]);
	sort(a, a + n);
	int ret = 0;
	REP(i, n) {
		if (x >= a[i])ret++;
		x -= a[i];
	}
	if (x > 0)ret--;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a[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 k;
	cin>>k;
	cout<<a[k-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/

ll n,k;
ll fact[5*MAX];

int main(){FAST;
cin>>n>>k;
fact[0] = 1;
for(ll i=1;i<=500000;++i){
  fact[i] = fact[i-1]*i%MOD;
}
k = min(n-1,k);
ll ans = 0;
for(ll i=0;i<=k;++i){
  ans+=fact[n]*minv(fact[n-i],MOD)%MOD*minv(fact[i],MOD)%MOD*fact[n-1]%MOD*minv(fact[n-i-1],MOD)%MOD*minv(fact[i],MOD)%MOD;
  ans%=MOD;
} 
cout<<ans;
return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int,int> ii;

typedef pair<int,ii> iii;

int n,par[100005];
long long lz[100005];
vector<iii> edge;
long long ans[100005];
vector<int> st[100005];

int findSet(int u){
    if(u == par[u]) return u;
    return par[u] = findSet(par[u]);
}
void UnionSet(int u,int v,int val){
    int pu = findSet(u), pv = findSet(v);
    if(st[pu].size()>st[pv].size()) swap(pu,pv);
    for(int i = 0;i<st[pu].size();i++){
        ans[st[pu][i]]+=val*st[pv].size();
        ans[st[pu][i]]+=lz[pu];
        ans[st[pu][i]]-=val*st[pu].size();
        ans[st[pu][i]]-=lz[pv];
    }
    lz[pu] = 0;
    for(int i = 0;i<st[pu].size();i++)
        st[pv].pb(st[pu][i]);
    lz[pv]+=val*st[pu].size();
    par[pu] = pv;
}

int main(){
    cin.tie(0),ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1;i<=n;i++){
        par[i] = i;
        st[i].pb(i);
    }
    int u,v,w;
    for(int i = 1;i<=n-1;i++){
        cin >> u >> v >> w;
        edge.pb(mp(w,mp(u,v)));
    }
    sort(edge.begin(),edge.end());
    for(int i = edge.size()-1;i>=0;i--){
        u = edge[i].se.fi; v = edge[i].se.se;
        w = edge[i].fi;
        UnionSet(u,v,w);
    }
    for(int i = 1;i<=n;i++)
        cout<<ans[i]+lz[findSet(i)]<<"\n";
}


Measured memory_bytes: 14068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,N;
  cin >> N;
  A=0;
  B=0;
  C=0;
  D=0;
    int i = 0;
  
for (int i = 0; i < N; i++) {
  string result;
    cin >> result;
    if (result == "AC"){
      A++;}
    else if (result == "WA"){
      B++;
    }
    else if(result == "TLE"){
      ++C;
    }
    else if( result == "RE"){
      ++D;
    }
  
  }
    cout <<"AC x "<<A << endl;
    cout << "WA x "<<B << endl;
    cout << "TLE x "<<C << endl;
    cout << "RE x "<<D << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> works(n);
  for (int i = 0; i < n; i++) {
    int f,s;
    cin >> s >> f;
    works[i] = make_pair(f,s);
  }
  sort(works.begin(),works.end());
  int total_time = 0;
  for(int i = 0;i<n;i++){
    total_time += works[i].second;
    if(total_time>works[i].first){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main()
{
    int n,cnt=0;
    double q;
    cin >> n >> q;
    for(int i=1;i<=n;i++)
    {
        double x,y;
        cin >> x >> y;
        double dis = sqrt(x*x+y*y);
        if(dis<=q)  cnt++;
    }
    cout << cnt;
    return 0;
}

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


int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    bool ans = true;
    
    for (long long i = 0; i < n - 1; i++){
        if (a.at(i) == a.at(i + 1)){
            ans = false;
        }
    }
    
    if (ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 1792
n=int(input().rstrip())
s=input().rstrip()
t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

le=len(s)
ans=""
for i in range(0,le):
    u=0;
    for j in range(0,26):
        if(t[j]==s[i]):
            u=j
    ans+=t[(u+n)%26]
print(ans)
    

Measured memory_bytes: 3060
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto di1 = readln.split.map!(to!int).array;
  auto di2 = readln.split.map!(to!int).array;

  auto dice1 = new Dice(di1);
  auto dice2 = new Dice(di2);

  auto rollings = ["", "T", "TT", "TTT",
                   "N", "NT", "NTT", "NTTT",
                   "W", "WT", "WTT", "WTTT",
                   "E", "ET", "ETT", "ETTT",
                   "S", "ST", "STT", "STTT",
                   "NN", "NNT", "NNTT", "NNTTT"];

  foreach (r; rollings) {
    auto d1 = dice1;
    auto d2 = dice2.dup;
    d2.roll(r);

    if (d1.di == d2.di) {
      writeln("Yes");
      return;
    }
  }

  writeln("No");
}

class Dice
{
  int[] di;

  this(int[] di)
  {
    this.di = di;
  }

  int top()   { return di[0]; }

  auto dup()
  {
    return new Dice(di.dup);
  }

  void roll(string si)
  {
    foreach (c; si) roll(c);
  }

  void roll(char d)
  {
    auto rolled = ['N': [1, 5, 2, 3, 0, 4],
                   'E': [3, 1, 0, 5, 4, 2],
                   'S': [4, 0, 2, 3, 5, 1],
                   'W': [2, 1, 5, 0, 4, 3],
                   'T': [0, 2, 4, 1, 3, 5]];

    di = di.indexed(rolled[d]).array;
  }
}

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

using namespace std;

int n,cnt=0;
int a[50]={0};

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<n;i++)
	{
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]>a[i+1]&&a[i]<a[i-1]))
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

int h, w, k;

bool fall(vector<string>& s){

    bool fl = false;
    for(int j = 0; j < w; ++j){
        vector<int> t;
        for(int i = h - 1; i >= 0; --i){
            if(s[i][j] != '.')
                t.push_back(s[i][j]);
        }
        while(t.size() != h)
            t.push_back('.');
        for(int i = 0; i < h; ++i){
            s[i][j] = t[h - 1 - i];
        }
    }

    vector<pair<int,int>> v;
    for(int j = 0; j < w; ++j){
        int pre = '*';
        int st = 0;
        for(int i = 0; i <= h; ++i){
            if(i == h || s[i][j] != pre){
                if(i - st >= k && pre != '.'){
                    fl = true;
                    for(int ii = st; ii < i; ++ii)
                        v.emplace_back(ii, j);
                }
                st = i;
            }
            if(i != h)
                pre = s[i][j];
        }
    }
    for(int i = 0; i < h; ++i){
        int pre = '*';
        int st = 0;
        for(int j = 0; j <= w; ++j){
            if(j == w || s[i][j] != pre){
                if(j - st >= k && pre != '.'){
                    fl = true;
                    for(int jj = st; jj < j; ++jj)
                        v.emplace_back(i, jj);
                }
                st = j;
            }
            if(j != w)
                pre = s[i][j];
        }
    }
    for(auto p : v)
        s[p.first][p.second] = '.';

    return fl;
}

bool calc(vector<string> s){
    while(fall(s));

    bool fl = true;
    for(int i = 0; i < h && fl; ++i)
        for(int j = 0; j < w && fl; ++j)
            if(s[i][j] != '.')
                fl = false;
    return fl;
}

bool solve(){
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)
        cin >> s[i];
    for(int x1 = 0; x1 < h; ++x1)
        for(int y1 = 0; y1 < w - 1; ++y1){
            if(s[x1][y1] == s[x1][y1 + 1])
                continue;
            swap(s[x1][y1], s[x1][y1 + 1]);
            if(calc(s)){
                cout << "YES" << endl;
                return false;
            }
            swap(s[x1][y1], s[x1][y1 + 1]);
        }
    cout << "NO" << endl;
    return false;
}

signed main(){
    while(solve());
}



Measured memory_bytes: 3248
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
sum = 0

kn = [0 for i in range(n+1)]
for i in range(n):
    kn[a[i]] += 1
for i in range(n+1):
    sum += kn[i]*(kn[i]-1)//2

for i in range(n):
    x = kn[a[i]]
    print(sum-x+1)


Measured memory_bytes: 33932
#include<bits/stdc++.h>
using namespace std;
bool flg[1000000];
int main(void){
	int n;
	int i,j;
	int cnt=0;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		fill(flg,flg+n+1,0);
		for(i=2;i*i<=n;i++){
			//cout<<"I="<<i<<endl;
			for(j=2;i*j<=n;j++){
				//cout<<"J="<<j<<endl;
				flg[i*j]=1;
			}
		}
		cnt=0;
		for(i=2;i<=n;i++)	if(flg[i]==0)	cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 4068
#include <stdio.h>
#define MAX 500000

int n,A[MAX+1];

void swap(int*,int*);
void Max(int);



void  swap(int *x, int *y)
{
    int  work;        /* 作業用 */

    work = *x;        /* xの値を一時保存 */
    *x = *y;          /* xの値をyの値に書き換える */
    *y = work;        /* yの値をxの値に書き換える */
}

void Max(int i){
    int l,r,large;
    l=2*i;
    r=2*i+1;

    if(l<=n&&A[l]>A[i])
       large=l;
    else large=i;
    if(l<=n&&A[r]>A[large])
       large=r;
       
       if(large!=i){
           swap(&A[i],&A[large]);
           Max(large);
       }
}

int main(){
    int i;
    scanf("%d",&n);
    
    for(i=1;i<=n;i++)
       scanf("%d",&A[i]);
       
    for(i=n/2;i>=1;i--)Max(i);
    
    for(i=1;i<=n;i++)   {
       printf(" %d",A[i]);
    }
    printf("\n");
    return 0;

}


Measured memory_bytes: 3668
n = int(input())
top = n
top_count = 0
for i in range(n,0,-1):
    current = i
    count = 0
    while current % 2 == 0:
        current = current / 2
        count = count + 1
    if (count >= top_count):
        top_count = count
        top = i
    #print(i, count)

print(top)


Measured memory_bytes: 3060
def count_area(h,w):
	count = 0
	if (h>0) and (s[h-1][w]== "."):
		s[h-1][w] = "#"
		count += count_area(h-1,w)
	if (h<H-1) and (s[h+1][w]== "."):
		s[h+1][w] = "#"
		count += count_area(h+1,w)
	if (w>0) and (s[h][w-1]== "."):
		s[h][w-1] = "#"
		count += count_area(h,w-1)
	if (w<W-1) and (s[h][w+1]== "."):
		s[h][w+1] = "#"
		count += count_area(h,w+1)
	return count+1

while(True):
	W, H = map(int, input().split())
	if H==0&W==0:break

	s = [list(input()) for i in range(H)]
	
	for h in range(H):
		for w in range(W):
			if s[h][w] == "@":
				s[h][w] = "#"
				print(count_area(h,w))
				break




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

int main(){
    long long N;
    std::cin >> N;
    
    if(N == 0){
        std::cout << 0 << std::endl;
    }
    
    long long dec = -1;
    std::string ans;
    while(N != 0){
        if(N > 0){
            long long cur = 1;
            long long plus = 0;
            while(N > cur){
                plus += 2;
                cur = cur + ((long long)1 << plus);
            }
            N -= 1 << plus;
            if(dec == -1){
                ans = "1";
                dec = plus - 1;
            }else{
                while(dec != plus){
                    ans = ans + "0";
                    dec--;
                }
                ans = ans + "1";
                dec--;
            }
        }else{
            long long cur = -2;
            long long plus = 1;
            while(N < cur){
                plus += 2;
                cur = cur + -1 * ((long long)1 << plus);
            }
            N -= -1 * (1 << plus);
            if(dec == -1){
                ans = "1";
                dec = plus - 1;
            }else{
                while(dec != plus){
                    ans = ans + "0";
                    dec--;
                }
                ans = ans + "1";
                dec--;
            }
        }
    }
    while(dec >= 0){
        ans = ans + "0";
        dec--;
    }
    
    std::cout << ans << std::endl;
    
    
    return 0;
    
}


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

void insertionSort(int *,int);
int main(){
  int n,num,i,j;
  int a[110];
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  insertionSort(a,n);
  return 0;
}

void insertionSort(int *a, int n){
  int v,i,j;
  if(n > 1){
    for(j = 0; j < n; j++){
        if(j)printf(" ");
	printf("%d",a[j]);
    }
    printf("\n");
    for(i = 1; i < n; i++){
      v = a[i];
      j = i -1;
      while(j >= 0 && a[j] > v){
	a[j + 1] = a[j];
	j--;
      }
      a[j+1] = v;

      for(j = 0; j < n; j++){
        if(j)printf(" ");
	printf("%d",a[j]);
      }
      printf("\n");
    }
  }
  else printf("%d\n",a[0]);
  return;
}




Measured memory_bytes: 2144
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj])minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if (i != minj)sw++;
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;

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

	sw = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);

	return 0;
}

Measured memory_bytes: 2720
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(ABCD: str):
    A, B, C, D = map(int, ABCD)
    for op1 in [1, -1]:
        for op2 in [1, -1]:
            for op3 in [1, -1]:
                if A+op1*B+op2*C+op3*D == 7:
                    op1 = "+" if op1 == 1 else "-"
                    op2 = "+" if op2 == 1 else "-"
                    op3 = "+" if op3 == 1 else "-"
                    print("{}{}{}{}{}{}{}=7".format(A, op1, B, op2, C, op3, D))
                    return
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = str(next(tokens))  # type: int
    solve(ABCD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
/* ==================== */ 
const ll MOD = (ll)1e9 + 7;
const int N = 300010;

ll mulMod (ll a, ll b) {
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll addMod (ll a, ll b) {
	return (a + b) % MOD;
}

ll n, a[N], c[100];

ll solve() {
	memset(c, 0, sizeof c);
	for (int i = 0; i < 60; i++) {
		for (int j = 0; j < n; j++)
			c[i] += ((a[j] & (1LL << i)) > 0);
	}
	ll ans = 0;
	for (int i = 0; i < 60; i++)
		ans = addMod(ans, mulMod((1LL << i), mulMod(c[i], n - c[i])));
	return ans;
}

int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	printf("%lld\n", solve());
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	string str;
	cin >> a >> str;
	b = str.length();
	if(b <= a){
		cout << str;
    } else {
		for(int i = 0; i < a; i++){
			cout << str[i];
        }
		cout << "...";
    }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int T = scanner.nextInt();

        int cost = Integer.MAX_VALUE;

        for(int i=0; i<N; i++){
            int c = scanner.nextInt();
            int t = scanner.nextInt();

            if(t <= T){
                cost = Math.min(cost, c);
            }
        }

        if(cost != Integer.MAX_VALUE) {
            System.out.println(cost);
        }else{
            System.out.println("TLE");
        }
    }

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll x;
  cin>>x;
  
  auto f = [](ll n){return n*n*n*n*n;};
  for(ll i=-500;i<=500;++i){
    for(ll j=-500;j<=500;++j){
      if(f(i)-f(j)==x){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int main()
{
	//fopen();
	string s;int n;
	cin>>n>>s;
	//if(n<3) {cout<<0; return 0;}
	int c=0;
	//cout<<s;
	rep(i,n-2)
	{
		//cout<<s[i];
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		{
			//cout<<s[i]<<endl;
			c++;
		}
	}
	cout<<c<<endl;
	//cout<<(k*500>=x?"Yes":"No");
 
	
}


Measured memory_bytes: 256
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
m+=d,
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 129464
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int n;
  int ans = 0;
  scanf("%d", &n);
  while(n > 0) {
    if(n % 10 == 2) ++ans;
    n /= 10;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a;
  b = a / 100;
  c = (a - b * 100) / 10;
  d = (a - b * 100 - c * 10);
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N;
	cin>>N;
	vector<int> p(N);
	REP(i, N) cin>>p[i];
	vector<int> a(N, 0);
	vector<int>	b(N, 0);
	REP(i, N) {
		a[p[i] - 1] += i + 1;
		b[0] += i + 1;
		if(p[i] < N) b[p[i]] -= i + 1;
	}
	REP(i, N - 1) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}
	REP(i, N){
		cout<<a[i] + i + 1;
		if(i != N - 1) cout<<" ";
		else cout<<endl;
	}
	REP(i, N){
		cout<<b[i] + N - i;
		if(i != N - 1) cout<<" ";
		else cout<<endl;
	}
}


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

using namespace std;

constexpr int MAX = 114;

int v;
int deg[MAX], dv[MAX];
vector<int> res[MAX];

void dfs(size_t& idx, int depth, const vector<int>& q)
{
    deg[v] += q[idx];
    dv[depth] = v;
    
    int nv = v++;
    
    while (idx < q.size() && deg[nv] > 0) {
        const int val = q[++idx];
        if (val > 0) {
            deg[nv]--; deg[v]--;
            res[nv].emplace_back(v);
            res[v].emplace_back(nv);
            dfs(idx, depth + 1, q);
        } else {
            int u = dv[depth + val];
            deg[u]--; deg[nv]--;
            res[u].emplace_back(nv);
            res[nv].emplace_back(u);
        }
    }
}

void init(int N)
{
    v = 0;
    for (int i = 0; i < N; i++) {
        res[i].clear();
        deg[i] = 0;
    }
}

int main()
{
    int Tc;
    cin >> Tc;
    while (Tc--) {        
        int x, N = 0;
        vector<int> q;
        while (cin >> x, x != 0) {
            N += (x > 0);
            q.emplace_back(x);
        }
        
        init(N);
        size_t idx = 0;
        dfs(idx, 0, q);

        for (int i = 0; i < N; i++) {
            cout << i + 1;
            sort(res[i].begin(), res[i].end());
            for (const auto& r : res[i]) {
                cout << " " << r + 1;
            }
            cout << endl;;
        }
    }
    return 0;
}

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



int main() {
  int N,A,B,C,D;
  cin >> N;
  A = N/1000;
  B = (N - A*1000)/100;
  C = (N - A*1000 - B*100)/10;
  D = N - A*1000 - B*100-C*10;
  vector<int> suuji(4);
   
 suuji.at(0) = A;
 suuji.at(1) = B;
 suuji.at(2) = C;
 suuji.at(3) = D;
  
  
  vector<vector<int>> data(8, vector<int>(3,0));
  
  if(A + B + C + D == 7){    }
   int decimal = 7;
  int binary = 0;
  int base = 1;
  
  int count=0;
  for(int i=0;i<2;i++){
  for(int j=0;j<2;j++){
  for(int k=0;k<2;k++){
    data.at(count).at(0)=i;
    data.at(count).at(1)=j;
    data.at(count).at(2)=k;
    count++;
  }
  }  
  }
  int kotaei=0;
  int kotaej=0;
  for(int i=0;i<data.size();i++){
    int total=suuji.at(0);
    for(int j=0;j<data.at(0).size();j++){
    if(data.at(i).at(j) ==0){ total+= suuji.at(j+1); }
    if(data.at(i).at(j) ==1){ total-= suuji.at(j+1); }
    if(total==7 && j==data.at(0).size()-1){ 
    kotaei = i;
    
    }
    }
    
  }
  
  vector<char> kigou(3);
  for(int i=0;i<kigou.size();i++){
    if(data.at(kotaei).at(i)==0) {kigou.at(i) = '+';}
    if(data.at(kotaei).at(i)==1) {kigou.at(i) = '-';}
  }
  
  
  cout <<  suuji.at(0) << kigou.at(0) << suuji.at(1) << kigou.at(1)<<suuji.at(2)<< kigou.at(2)<< suuji.at(3) << "=7"<<endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    // bool operator==(const mint a) { return x == a.x; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n; cin >> n;
    mint ten = (mint)10;
    mint nine = (mint)9;
    mint eight = (mint)8;
    mint ans = ten.pow(n) - (nine.pow(n)+nine.pow(n)-eight.pow(n));
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	set<char> s;
	char c;
	for (int i = 0; i < n; i++)
		cin >> c, s.insert(c);
	cout << (s.size() > 3 ? "Four" : "Three") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), D(N);
    cin >> A >> B;
    REP(i, N) D[i] = A[i] - B[i];
    int r = N - 1;
    sort(ALL(D));
    vector<bool> changed(N);
    REP(i, N) {
        if (D[i] >= 0) break;
        changed[i] = 1;
        while (1) {
            if (D[r] <= 0) {
                cout << "-1" << endl;
                return 0;
            }
            if (D[r] >= -D[i]) {
                D[r] -= -D[i];
                changed[r] = 1;
                break;
            } else {
                D[i] += D[r];
                D[r] = 0;
                changed[r] = 1;
                r--;
            }
        }
    }
    int ans = count(ALL(changed), 1);
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;


int c[1010][1010],g[1010][1010];

int main(){
  int H,W,N;
  while(true){
    memset(c,0,sizeof(c));
    memset(g,0,sizeof(g));
    ///配列初期化

    scanf("%d%d%d",&H,&W,&N);
    ///printf("%d%d%d\n",H,W,N); 
    if(H==0 && W==0 && N==0){break;}
    
    for(int i=1;i<=H;i++){
      for (int j=1;j<=W;j++)
	{
	  scanf("%d",&c[i][j]);///初期ステ読み込み
	  ///printf("%d",c[i][j]);
	}///printf("\n");
    }
    
    for(int i=1;i<=H;i++){
      for (int j=1;j<=W;j++)
	{
	  if(g[i-1][j]%2==1){
	    g[i][j]=g[i][j]+(g[i-1][j]-1)/2;	    
	    if(c[i-1][j]==0){
	    g[i][j]=g[i][j]+1;
	    }
	  }
	  else{
	    g[i][j]=g[i][j]+g[i-1][j]/2;
	  }
	  
	  if(g[i][j-1]%2==1){
	    g[i][j]=g[i][j]+(g[i][j-1]-1)/2;
	    if(c[i][j-1]==1){
	    g[i][j]=g[i][j]+1;
	    }
	  }
	  else{
	    g[i][j]=g[i][j]+g[i][j-1]/2;
	  }
	  if(i==1&&j==1){g[1][1]=N-1;}
	  ///回数判定fin
	}
    }
    for(int i=1;i<=H;i++){
      for (int j=1;j<=W;j++)
	{
	  c[i][j]=(c[i][j]+g[i][j])%2;
	  /// printf ("%d ",c[i][j]);
	}
      ///  printf("\n");
    }///目的のマップ
    
    int x,y;///Let's walking
    x=1;
    y=1;
    while(x<=H&&y<=W)      
      {
	if(c[x][y]==1)
	  {y=y+1;}
	else
	  {x=x+1;}
      }
    



    printf("%d %d\n",x,y);
  }
}

Measured memory_bytes: 9164
#include<stdio.h>
int main()
{
	int a,b;
	char op;
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+')
		printf("%d\n",a+b);
	else if(op=='-')
		printf("%d\n",a-b);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    ll sum=0,ans=0;
    if(b==1){
        cout<<ans<<endl;
        return 0;
    }
    sum+=a;
    ans++;
    if(sum>=b){
        cout<<ans<<endl;
        return 0;
    }
    for(;;){
        sum+=a-1;
        ans++;
        if(sum>=b){
            cout<<ans<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
        public static void main(String[] args){
           Scanner sc = new Scanner(System.in);
           int n = sc.nextInt();
           int[] a = new int[n];
           
           for(int i=0;i<n;i++){
           a[i] = sc.nextInt();    
           }
           int ans = a[0];
           for(int i=1;i<n;i++){
           ans ^= a[i]; 
           }
           if(ans==0) System.out.println("Yes");
           else System.out.println("No");
        }
    }							

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

int main(){
  int n;
  double t, a;
  cin >> n >> t >> a;
  double min_value = 100000;
  int min_index = -1;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  for(int i = 0; i < n; i++){
    double diff = abs((t - h[i] * 0.006) - a);
    if(diff < min_value){
      min_value = diff;
      min_index = i + 1;
    }
  }
  cout << min_index << endl;
  return 0;
}

Measured memory_bytes: 3804
package main

import (
	"fmt"
)

func solve(r, d, x2000 int64) [10]int64 {
	var a [10]int64
	x := x2000
	for i := 0; i < len(a); i++ {
		x = r*x - d
		a[i] = x
	}
	return a
}

func main() {
	var r, d, x2000 int64
	fmt.Scanln(&r, &d, &x2000)
	ans := solve(r, d, x2000)
	for _, a := range ans {
		fmt.Println(a)
	}
}


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

int h,w;
char grid[20][20];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int bfs(int x,int y){
    vector<vector<bool>> vis(h,vector<bool>(w));
    queue<pair<int,int>> q;
    q.push({x,y});
    vis[x][y] = 1;
    int ans = 0;
    vector<vector<int>> dist(h,vector<int>(w));
    while(!q.empty()){
      int a = q.front().first,b = q.front().second;
      q.pop();
      for(int i = 0; i < 4; i++){
          if(a+dx[i]<h && a+dx[i]>=0 && b+dy[i]<w && b+dy[i]>=0){
              if(vis[a+dx[i]][b+dy[i]]) continue;
              if(grid[a+dx[i]][b+dy[i]] == '#') continue;
              q.push({a+dx[i],b+dy[i]});
              dist[a+dx[i]][b+dy[i]] = dist[a][b]+1;
              ans = max(ans, dist[a][b]+1);
              vis[a+dx[i]][b+dy[i]] = 1;
          }
      }
    }
    return ans;
}

int main(){
    cin>>h>>w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin>>grid[i][j];
        }
    }
    
    int res = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0;  j < w; j++){
            if(grid[i][j] == '#') continue;
            res = max(res,bfs(i,j));
        }
    }
    cout<<res;

}


Measured memory_bytes: 256
#include<stdio.h>

int check(char c) {

	char str[]="qwertasdfgzxcvb";
	int i;
	for(i=0;i<15;i++) {
		if(c==str[i])
			return 1;
	}
		return 0;
}

int main() {

	char c[33];
	int i,count,Answer[1000],a=0;

	for(;;) {
		scanf("%s",c);
		if(c[0]=='#') break;
		count=0;
		for(i=0;c[i+1]!='\0';i++) {
			if(check(c[i])!=check(c[i+1]))
				count++;
		}
		Answer[a]=count;
		a++;
	}
	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);
	return 0;
}

Measured memory_bytes: 540
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
ll ss = 1e9+7;

int main() {
	int W, a, b;
	cin >> W >> a >> b;

	if (a < b && a + W < b) {
		cout << b - (a + W) << endl;
	}
	else if (b < a && b + W < a) {
		cout << a - (b + W) << endl;
	}
	else
		cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    p x(n);
    p y(n);
    for(ll i=0;i<n;++i){
        cin>>x[i].first>>x[i].second;
        y[i].first = x[i].first + x[i].second;
        y[i].second = x[i].first - x[i].second;
    }

    sort(y.begin(), y.end());
    ll e = y[0].first;
    ll ans = 1;
    for(ll i=1;i<n;++i){
        if(y[i].second >= e){
            e = y[i].first;
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=5e3+10,mod=1e9+7;
ll dp[N][N][2];
ll par[N][N][2];
ll pd[N];
int32_t main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if (a>b) swap(a,b);
    ll ans=1;
    for (int i=1;i<=n;i++){
        ans*=2;
        ans%=mod;
    }
    dp[0][0][0]=1;
    dp[0][0][1]=1;
    par[0][0][1]=1;
    par[0][0][0]=1;
    pd[0]=1;
    /// par[i][j] ehtelaf i ta andis j
    for (int i=1;i<=n;i++){
        for (int j=1;j<min(i+1,b);j++){
            for (int p=0;p<=1;p++){
                if (p==0){
                    if (j<a) continue;
                    dp[i][j][0]=par[i-j][i-a][1];
                }
                else{
                    dp[i][j][1]=par[i-j][i-1][0];
                }
                dp[i][j][p]%=mod;
             //   cout << i << " " << j << " " << p << " " << dp[i][j][p] << endl;;
            }
        }
        for (int j=i-1;j>max((ll)-1,i-a);j--){
            dp[i][0][0]+=pd[j];
            dp[i][0][0]%=mod;
        }
        for (int j=1;j<b;j++){
            pd[i]+=dp[i][j][1];
            pd[i]%=mod;
        }
        for (int j=0;j<min(i+1,b);j++){
            par[i-j][i][0]=par[i-j][i-1][0]+dp[i][j][0];
            par[i-j][i][1]=par[i-j][i-1][1]+dp[i][j][1];
            par[i-j][i][0]%=mod;
            par[i-j][i][1]%=mod;
        }
    }
    for (int i=0;i<b;i++){
        ans-=dp[n][i][0]+dp[n][i][1];
        ans+=mod*2;
        ans%=mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 433396
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int max_n = 1000001, inf = 9999999;
pair<int, int>ans[1000000];
vector<int>adj[max_n];
int dp[max_n], depath[max_n], from[max_n], to[max_n];
bool vis[max_n];
int rt;
void dfs(int v, int de, int p){
	depath[v] = de;
	vis[v] = 1;
	for (int e : adj[v]){
		int a = from[e] ^ to[e] ^ v;
		if (e == p)
			continue;
		if (vis[a])
			dp[v] = min(dp[v], depath[a]);
		else{
			dfs(a, de + 1, e);
			dp[v] = min(dp[a], dp[v]);
		}
	}
	if (dp[v] >= de  &&p != -1)
		ans[rt] = { min(from[p], to[p]), max(from[p], to[p]) },rt++;
}
int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < max_n; i++)
		dp[i] = inf;
	for (int i = 1; i <= m; i++){
		cin >> from[i]>> to[i];
		from[i];
		to[i];
		adj[from[i]].push_back(i);
		adj[to[i]].push_back(i);
	}
	dfs(0, 0, -1);
	sort(ans, ans + rt);
	for (int i = 0; i < rt; i++)
		cout << ans[i].first << ' ' << ans[i].second << endl;
	int z;
	cin >> z;
}

Measured memory_bytes: 32388
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    int[] hs;
    foreach (_; 0..N) hs ~= readln.chomp.to!int;
    sort(hs);
    int min_d = int.max;
    foreach (i; 0..N-K+1) {
        min_d = min(min_d, hs[i+K-1] - hs[i]);
    }
    writeln(min_d);
}

Measured memory_bytes: 1788
import itertools
N,M=map(int,input().split())
A=list(map(int,input().split()))
sum=sum(A)
A=sorted(A)
cnt=0
for i in A:
  if i>=sum/(4*M):
    cnt+=1
if cnt>=M:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int m=0,f=0,b=0;
	cin>>m;
	cin>>f;
	cin>>b;
	if(m>b){
		cout<<0<<endl;
	}
	else if(m<b){
		if(m+f>b){
			cout<<b-m<<endl;
		}
		else if(m+f<b){
			cout<<"NA"<<endl;
		}
                else if(m+f==b){
			cout<<f<<endl;
		}
	}
	return (0);
}


Measured memory_bytes: 3104