akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    long long a, b;
    cin >> a >> b;
    // a = llabs(a);
    // b = llabs(b);
    if (a == 0 || b == 1 || a % b == 0) {
        cout << 0 << endl;
        return 0;
    }
    long long gc = __gcd(a, b);
    long long na = a / gc;
    long long nb = b / gc;
    cout << gc * min(na % nb, nb - na % nb) << endl;
}

Measured memory_bytes: 256
import java.util.LinkedList

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val edges = List(n) { mutableListOf<Pair<Int, Int>>() }
    for (i in 0 until n - 1) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        edges[a - 1].add(Pair(b - 1, i))
        edges[b - 1].add(Pair(a - 1, i))
    }
    var ret = 0
    val colors = Array(n - 1) { -1 }
    val queue = LinkedList(listOf(Triple(0, -1, -1)))
    while (queue.size > 0) {
        val (current, parent, pcolor) = queue.pop()
        var color = 1
        for ((next, index) in edges[current]) {
            if (color == pcolor) {
                color = color + 1
            }
            if (next != parent) {
                colors[index] = color
                queue.push(Triple(next, current, color))
                color = color + 1
            }
        }
        ret = Math.max(ret, color - 1)
    }

    println(ret)
    for (i in 0 until n - 1) {
        println(colors[i])
    }
}
    


Measured memory_bytes: 82048
#include <stdio.h>
int main(){
    int i, k, answer;
    
    for (i = 1; i<10; i++) {
        for(k = 1; k <10; k++){
            answer= i*k;
            printf("%dx%d=%d\n", i, k, answer);
        }
    }
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      if(a+b>=10)Cout("error");
      else Cout(a+b);
     

       
return 0;
}


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

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>=22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

/* originally written by SugarDragon5 */
struct UnionFind{
    vi data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main() {
    cout << (ri()*ri()%2?"Odd":"Even") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }else {
        cout << n - k << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int ans=0;
  REP(i,4){
    int tmp;
    cin>>tmp;
    ans += tmp;
  }
  int s = ans%60;
  ans /= 60;
  int m = ans;
  cout<<m<<endl;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = INT_MAX;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//区間更新・区間最小クエリ
struct LazySegmentTree {
    int n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;
    
    LazySegmentTree(vector<ll> v) {
        int sz=sz(v);
        n=1;
        while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, LINF);
        lazyFlag.resize(2*n-1, false);
        
        rep(i,sz) node[i+n-1]=v[i];
        rrep(i,n-1) node[i]=min(node[i*2+1], node[i*2+2]);
    }
    
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k]=lazy[k];
            if(r-l>1) {
                lazy[k*2+1]=lazy[k];
                lazy[k*2+2]=lazy[k];
                lazyFlag[k*2+1]=true;
                lazyFlag[k*2+2]=true;
            }
            lazyFlag[k]=false;
        }
    }
    
    void update(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r<0) r=n;
        lazyEvaluate(k, l, r);
        if(b<=l || r<=a) return;
        
        if(a<=l && r<=b) {
            lazy[k]=x;
            lazyFlag[k]=true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k]=min(node[2*k+1], node[2*k+2]);
        }
    }
    
    ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r<0) r=n;
        lazyEvaluate(k, l, r);
        
        if(b<=l || r<=a) return LINF;
        if(a<=l && r<=b) return node[k];
        
        ll vl=getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr=getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};


int main() {
    int n,q;
    cin>>n>>q;
    vector<ll> v(n,LINF);
    LazySegmentTree segt(v);
    while(q--) {
        int query;
        cin>>query;
        if(query==0) {
            int s,t;
            ll x;
            cin>>s>>t>>x;
            segt.update(s,t+1,x);
        }
        else {
            int i;
            cin>>i;
            cout<<segt.getmin(i,i+1)<<endl;
        }
    }
}



Measured memory_bytes: 8712
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    cnt = [0]*n
    p = 0
    ans = 0
    for _ in range(1, n):
        ans += a[p]
        cnt[p] += 1
        if p == 0 and 1 <= cnt[p]:
            p += 1
        elif 0 < p and 2 <= cnt[p]:
            p += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31428
a,b,c,d = map(int,input().split())

kekka1 = a*b
kekka2 = c*d

if kekka1 == kekka2:
    print(int(kekka1))
elif kekka1 > kekka2:
    print(int(kekka1))
else:
    print(int(kekka2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int n,cnt=0;
    cin>>n;
    int arr[n+5];
    for(int i=1;i<=n;++i)
    {
        cin>>arr[i];
        if(i%2 and arr[i]%2)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}




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

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	if (s.size() <= k) cout << s << endl;
	else {
		for (int i=0; i<k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int a[4][4],b[4][4];
int n;
int x;

int32_t main()
{
    IOS
    for (int i=0;i<3;i++)
        for (int j=0;j<3;j++) cin>>a[i][j];
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>x;
        for (int j=0;j<3;j++)
            for (int k=0;k<3;k++)
                if (a[j][k]==x) b[j][k]=1;
    }
    if ((b[0][0]&b[0][1]&b[0][2])||(b[1][0]&b[1][1]&b[1][2])||(b[2][0]&b[2][1]&b[2][2])
        ||(b[0][0]&b[1][0]&b[2][0])||(b[0][1]&b[1][1]&b[2][1])||(b[0][2]&b[1][2]&b[2][2])
        ||(b[0][0]&b[1][1]&b[2][2])||(b[0][2]&b[1][1]&b[2][0])) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
}



Measured memory_bytes: 256
n = input()
l = int(n[-1])

if l == 2 or l == 4 or l == 5 or l == 7 or l == 9:
    print('hon')
elif l == 0 or l == 1 or l == 6 or l == 8:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9168
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
            String str=scan.next();
            if(str.charAt(0)!='A'){
                System.out.println("WA");
                return;
            }
            else{
                int Ccount=0;
                int i;
                int length=str.length();
                for(i=2;i<length-1;i++){
                    if(str.charAt(i)=='C'){
                        Ccount++;
                    }
                    if(Ccount>1){
                        System.out.println("WA");
                        return ;
                    }
                }
                if(Ccount==0){
                    System.out.println("WA");
                    return ;
                }
                int big=0;
                for(i=0;i<length;i++){
                    if(Character.isUpperCase(str.charAt(i))){
                        big++;
                        if(big>2){
                            System.out.println("WA");
                            return ;
                        }
                    }
                }
            }
            System.out.println("AC");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ll long long
#define lb(x) ((x)&(-x))
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define de(x) cout<<x<<" x"<<endl
#define LCAFA rep(i,1,20)rep(j,1,n+1)fa[j][i]=fa[fa[j][i-1]][i-1]
#define all(x) x.begin(),x.end()
#define ls(x) x<<1
#define rs(x) x<<1|1
using namespace std;
const int N=2e6+9;
const ll mod=998244353;
char s[N];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	if(n&1){
		cout<<"No";
		return 0;
	}
	rep(i,0,n){
		if(i&1){
			if(s[i]!='i'){
				cout<<"No";
				return 0;
			}
		} 
		else{
			if(s[i]!='h'){
				cout<<"No";
				return 0;
			}
		} 
	}
	cout<<"Yes";
}

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

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
B = list(map(int,input().split()))
ans = 0
#list = []

if len(B) == 1:
    B.append(0)

for i in range(n-1):
    if i == 0:
        ans = ans + B[0]
#        list.append(B[0])
    else:
        ans = ans + min(B[i-1],B[i])
#        list.append(min(B[i-1],B[i]))

#list.append(B[n-2])
#print(list)
print(ans+B[n-2])


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

int main()
{
  int n,x,tmp,sum=0;
  cin >> n >> x;
  for(int i=0;i<n;i++){
    cin >> tmp;
    sum += tmp;
    if (sum > x){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    string S, ans;
    int A, B;
    cin >> S;
    A = stoi(S.substr(0,2));
    B = stoi(S.substr(2,2));
    if(A<=12&&A>=1&&B<=12&&B>=1)ans = "AMBIGUOUS";
    else if(A<=12&&A>=1&&B<=99&&B>=0)ans = "MMYY";
    else if(A<=99&&A>=0&&B<=12&&B>=1)ans = "YYMM";
    else ans = "NA";
    cout<< ans <<endl;
}

Measured memory_bytes: 256
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    SUMA = [0]
    for a in A:
        if SUMA[-1] + a > K: break
        SUMA.append(SUMA[-1] + a)
    SUMB = [0]
    for b in B:
        if SUMB[-1] + b > K: break
        SUMB.append(SUMB[-1] + b)

    if len(SUMA) == 1:
        ans = len(SUMB) - 1
    elif len(SUMB) == 1:
        ans = len(SUMA) - 1
    else:
        ans = 0
        i = len(SUMA)
        j = 1
        while i:
            i -= 1
            while SUMA[i] + SUMB[j] <= K:
                j += 1
                if j == len(SUMB): break
            j -= 1
            ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()

exit()


Measured memory_bytes: 131284
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  if(      10 > a){
    printf("%d",a);
  }else if(100 > a){
    printf("%d",9);
  }else if(1000 > a){
    printf("%d",a - 90);
  }else if(10000 > a){
    printf("%d",909);
  }else if(100000 > a){
    printf("%d",a - 9090);
  }else{
    printf("90909");
  }
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define pb push_back
vector<int>v[100001],vis(100001);
void dfs(int i)
{
    vis[i]=1;
    for(auto x:v[i])
    {
        if(!vis[x])
        {
            dfs(x);
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    rep(i,m)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt++;
            dfs(i);
        }
    }
    cout<<cnt-1;
}

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

using namespace std;
using ll = long long;


int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  
  for(int i=0; i<n; i++) cin>> p[i], p[i]--;
  for(int i=0; i<n; i++) cin>> q[i], q[i]--;
  
  map<vector<int>, int> ord;
  int iter = 0;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) v[i] = i;
  
  do {
    ord[v] = iter++;
  }while (next_permutation(v.begin(), v.end()));
  
  cout << abs(ord[p] - ord[q]) << endl;
  
  return 0;
}

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

using namespace std;
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
typedef tuple<LL,LL> T;
typedef vector<LL> VL;
typedef vector<T> VT;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)


LL getlen(set<LL>& event,VL& point,VT& seg,LL prev){
    priority_queue<LL,vector<LL>,greater<LL>> on,off;
    int n=point.size();
    int m=seg.size();
    int i=0,j=0;
    LL res=0;
    range(it,event){
	
	res+=((LL)on.size())*(it-prev);
	prev=it;
	//	cout<<it<<" "<<res<<endl;
	if(i<n&&point[i]==it){
	    swap(on,off);
	    i++;
	}
	else {
	    if(on.empty()==false&&on.top()==it){
		on.pop();
	    }
	    else if(off.empty()==false&&off.top()==it){
		off.pop();
	    }
	    else{
		LL s,t;
		tie(s,t)=seg[j++];
		on.push(t);
	    }
	}
    }
    return res;
}
int main(){
    int N,M;
    cin>>N>>M;
    VT st;
    set<LL> e;
    rep(i,N){
	int s,t;
	cin>>s>>t;
	if(s<t){
	    st.push_back(T(s,t));
	    e.insert(t);
	    e.insert(s);
	}
	else {
	    st.push_back(T(-s,-t));
	    e.insert(-t);
	    e.insert(-s);
	}
    }
    sort(st.begin(),st.end());
    VL point;
    rep(i,M){
	LL it;
	cin>>it;
	point.push_back(it);
	point.push_back(-it);
	e.insert(it);
	e.insert(-it);
    }
    sort(point.begin(),point.end());
    cout<<getlen(e,point,st,-11*4*51*4*1919)<<endl;
    
    return 0;
}

Measured memory_bytes: 25740
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

struct edge{
    LL a;
    LL b;
    LL c;
};

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

    LL l;
    cin >> l;

    vector<LL> vertex(22,0);
    vertex[1] = 1;
    for(int i = 2; i < 22; i++){
        vertex[i] = vertex[i-1]*2;
    }

    LL ind = -1;
    for(int i = 0; i < 22; i++){
        if(vertex[i] > l){
            ind = i;
            break;
        }
    }
    LL maxn = ind-1;
    ind--;
    LL usel = vertex[ind];
    l -= vertex[ind];
    vector<edge> addedge;
    for(int i = ind; i >= 1 && l > 0; i--){
        if(l - vertex[i] >= 0){
            addedge.push_back(edge{i,maxn,usel});
            usel += vertex[i];
            l -= vertex[i];
        }
    }
    
    cout << maxn << " ";
    cout << (maxn-1)*2 + addedge.size() << endl;

    for(int i = 1; i < maxn; i++){
        cout << i << " ";
        cout << i+1 << " ";
        cout << 0 << endl;
        cout << i << " ";
        cout << i+1 << " ";
        cout << vertex[i] << endl;
    }
    for(int i = 0; i < addedge.size(); i++){
        cout << addedge[i].a << " ";
        cout << addedge[i].b << " ";
        cout << addedge[i].c << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	//init
	int n;
	cin >> n;


	//calc
	vector<int> a;
	for (int i = 0; i < n; i++){
		int ai;
		cin >> ai;

		a.push_back(ai);
	}

	std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());



	//ans
	string ans = "";
	if (a.size() == n){
		ans = "YES";
	}
	else{
		ans = "NO";
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int k,x;

    cin>>k>>x;

    if(500*k>=x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
from itertools import permutations
N=int(input())
xy=[tuple(map(int,input().split(' '))) for i in range(N)]
ans = 0
cnt = 0
for i in permutations([i for i in range(N)]):
    cnt += 1
    for j in range(N-1):
        ans += ((xy[i[j+1]][0]-xy[i[j]][0])**2+(xy[i[j+1]][1]-xy[i[j]][1])**2)**0.5
print(ans/cnt)

Measured memory_bytes: 3188
n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
cnt_d = [0] * (max_a + 1)

for ai in a:
    for multi in range(ai, max_a + 1, ai):
        cnt_d[multi] += 1

print(sum(cnt_d[ai] == 1 for ai in a))

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

using namespace std;

#define int long long

const int maxw = 1e12;

int root(int x) {
    int ans = sqrt(x);
    while (ans * ans < x) ans++;
    while (ans * ans > x) ans--;
    return ans;
}

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

    int n;
    cin >> n;
    map<int, int> d;
    map<int, int> cnt;
    for (int t = 0; t < n; t++) {
        int x; cin >> x;
        int inv = 1;
        int y = 1;
        for (int i = 2; i * i * i <= x; i++) {
            int k = 0;
            while (x % i == 0) {
                x /= i;
                k++;
            }
            k %= 3;
            for (int j = 0; j < k; j++) y *= i;
            for (int j = 0; j < (3 - k) % 3; j++) inv = min(maxw, inv * i);
        }
        y *= x;
        int r = root(x);
        if (r * r == x) {
            inv *= r;
        } else {
            if (inv > maxw / x / x) inv = maxw;
            else inv *= x * x;
        }
        d[y] = inv;
        cnt[y]++;
    }

    int ans = 0;
    for (auto p: d) {
        if (p.second == p.first) {
            ans += 2;
        } else if(d.find(p.second) == d.end()) {
            ans += 2 * cnt[p.first];
        } else {
            ans += max(cnt[p.first], cnt[p.second]);;
        }
    }

    cout << ans / 2 << '\n';
}


Measured memory_bytes: 12800
#include <cstdio>
using namespace std;
#define abs(_x) ((_x) >= 0 ? (_x) : -(_x))
int fastin(){
	register int i; register char ch;
	while (ch = getchar(), ch < '0' || ch > '9');
	i = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9') i = i * 10 + ch - '0' ;
	return i;
}
int main(){
	register int n, i, prex, prey, pret, nowx, nowy, nowt, sum;
	n = fastin();
	prex = prey = pret = 0;
	for (i = 1; i <= n; ++i) {
		nowt = fastin(), nowx = fastin(), nowy = fastin();
		sum = abs(nowx - prex) + abs(nowy - prey);
		if (sum <= nowt - pret && ((sum & 1) == (nowt - pret & 1))) {
			prex = nowx, prey = nowy, pret = nowt;
		}
		else break;
	}
	if (i <= n) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;

ll dist(ll a, ll b, ll c)
{
    ll ar[3]={a, b, c};
    sort(ar, ar+3);
    return ar[2]-ar[0];
}

int main()
{
    ll h, w;
    cin >> h >> w;
    ll h_ = h/3;
    ll ans = 100000000000;
    for(int hh=1; hh<=h; hh++){
        ll h1=(h-hh)/2;
        ll h2=h-hh-h1;
        ll ar[3]={h1, h2, hh};
        sort(ar, ar+3);
        ans = min(ans, (ar[2]-ar[0])*w);

        ll s1=hh*w;
        ll s2=(h-hh)*(w/2);
        ll s3=(h-hh)*(w-w/2);
        ll br[3]={s1, s2, s3};
        sort(br, br+3);
        ans=min(ans, br[2]-br[0]);
    }
    for(int ww=1; ww<=w; ww++){
        ll w1=(w-ww)/2;
        ll w2=w-ww-w1;
        ll ar[3]={w1, w2, ww};
        sort(ar, ar+3);
        ans=min(ans, (ar[2]-ar[0])*h);

        ll s1=ww*h;
        ll s2=(w-ww)*(h/2);
        ll s3=(w-ww)*(h-h/2);
        ll br[3]={s1, s2, s3};
        sort(br, br+3);
        ans=min(ans, br[2]-br[0]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 632
N, X = map(int, input().split())

burgersize, pnum = [1], [1]
for i in range(N):
    burgersize.append(burgersize[-1] * 2 + 3)
    pnum.append(pnum[-1] * 2 + 1)

def count_p(level, X):
    if X == 0:
        return 0
    if X == burgersize[level]:
        return pnum[level]
    if level == 0:
        return 1
    Xmid = (burgersize[level] - 1) // 2 + 1
    if X < Xmid:
        return count_p(level - 1, X - 1)
    else:
        return pnum[level - 1] + 1 + count_p(level - 1, X - Xmid)

print(count_p(N, X))

Measured memory_bytes: 3064
N = gets.to_i
def sum_digits(number)
  sum = 0
  while number > 0
    sum += number % 10
    number /= 10
  end
  sum
end
min = 46
(1..(N - 1)).each do |number|
  sum  = sum_digits(number) + sum_digits(N - number)
  min = sum if sum <= min
end
puts min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 200020
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = acos(-1.0);
const int BLOCK = 333;

int dp[MAXN], N, nums[MAXN];

int solve(int K)
{
	if(dp[K] != -1) return dp[K];

	int ans = 0;

	for(int i = 1; i <= N; i++)
		if(nums[i] <= K)
			ans = max(ans, 1 - solve(K - nums[i]));

	return dp[K] = ans;
}

int main(int argc, char const *argv[])
{
	optimize;

	memset(dp, -1, sizeof dp);
	
	int K;

	cin >> N >> K;

	for(int i = 1; i <= N; i++)
		cin >> nums[i];

	cout << (solve(K) ? "First" : "Second") << endl;

	return 0;
}


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  ll H,W; cin >> H >> W;

  if(H%3 == 0 || W%3 == 0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = min(H,W);

  ll h = H/2;

  for(ll w = 1; w < W; w++) {
    vl v = {H*w,h*(W-w),(H-h)*(W-w)};
    sort(all(v));
    chmin(ans, v[2]-v[0]);
  }

  swap(H,W);
  h = H/2;

  for(ll w = 1; w < W; w++) {
    vl v = {H*w,h*(W-w),(H-h)*(W-w)};
    sort(all(v));
    chmin(ans, v[2]-v[0]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int n, k, a[100010];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int basho;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			basho = i;
			break;
		}
	}
	if (n == k) {
		cout << 1 << endl;
		return 0;
	}
	if (n <= k * 2) {
		cout << 2 << endl;
		return 0;
	}
	int ans = 100000;
	for (int i = 0; i < k; i++) {
		int ans2 = (basho + k - 1 - 1 - i) / (k - 1) + (n - basho - 1 + (k - 1) - 1 - k + i + 1) / (k - 1) + 1;
		if (ans > ans2)ans = ans2;
	}
	cout << ans<< endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
W = list(map(int, input().split())) 
min_diff = 1000
for i in range(N):
    s1 = sum(W[0:i+1])
    s2 = sum(W) - s1
    if min_diff > abs(s1-s2):
        min_diff = abs(s1-s2)
print(min_diff)

Measured memory_bytes: 3060
n, k = (int(x) for x in input().split())

ans = ''

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x2 = Base_10_to_n(n, k)

ans = (len(x2))

print(ans)

Measured memory_bytes: 3060
import sys
import os

OK = 'APPROVED'
NG = 'DENIED'


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    A = list(map(int, sys.stdin.buffer.readline().split()))

    ret = OK
    for a in A:
        if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
            ret = NG

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define d(x) cerr << #x << ":" << x << endl;
#define da(x) cerr << #x << ":\n"; for(auto i: x) cerr << i << " ";cout << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	int n;
	cin >> n;
	int a[4] = {0};
	string s;
	for(int i=0;i<n;i++) {
		cin >> s;
		if(s == "AC")	a[0]++;
		else if(s == "WA")	a[1]++;
		else if(s == "TLE")	a[2]++;
		else	a[3]++;
	}
	cout << "AC x " << a[0] << "\nWA x " << a[1] << "\nTLE x " << a[2] << "\nRE x " << a[3] << "\n";
	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
typedef long long ll;

int n,m,Ans;
int f[100005],v[100005];
const int p=1000000007;

ll Pow(ll a,ll b){ll s=1;for(;b;b>>=1,a=a*a%p)if(b&1)s=s*a%p;return s%p;}
inline ll C(const int n,const int m){return (ll)f[n]*v[m]%p*v[n-m]%p;}

int main()
{
    for(int i=f[0]=1;i<=100000;++i)f[i]=(ll)f[i-1]*i%p;
    v[100000]=Pow(f[100000],p-2);
    for(int i=100000;i>=1;--i)v[i-1]=(ll)v[i]*i%p;
    scanf("%d%d",&n,&m),Ans=n+1;
    for(int i=1;i<m;++i)
        if(m-i<=n)
            for(int j=1;j<=m-i;++j)
                if(m-i+m-i-j<=n)
                    Ans=(Ans+C(m-1,i-1)*C(m-i-1,j-1)%p*C(n-(m-i+m-i-j)+2,2))%p;
    printf("%d\n",Ans);
    return 0;
}

Measured memory_bytes: 896
//#pragma warning(disable:4996)
#include<stdio.h>
#define llint long long int

int main() {
	llint n, a, b;
	llint min = 0, max = 0;
	scanf("%lld %lld %lld", &n, &a, &b);
	if (a > b) {
		printf("0\n");
	}
	else
	if (n == 1 && a == b) {
		printf("1\n");
	}
	else
	if (n == 1) {
		printf("0\n");
	}
	else {
		for (int i = 0; i < n - 1; i++) {
			min += a;
		}
		min += b;
		for (int i = 0; i < n - 1; i++) {
			max += b;
		}
		max += a;
		printf("%lld\n", max - min + 1);
	}
	
	//while (1);
}

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

int main(){
  int N;
  cin >> N;
  int D[110][2];
  bool flag = false;
  int x = 0;
  for (int i=0;i<N;i++){
    cin >> D[i][1] >> D[i][2];
    if(D[i][1]==D[i][2]){
      x++;
    }
    else{
      x = 0;
    }
    if(x==3){
      cout << "Yes" << endl;
      flag = true;
      break;
    }
  }
  if (!flag){
    cout << "No" << endl;
  }  
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>


int main()
{
    int w,a,b;
    scanf("%d %d %d",&w,&a,&b);
    if(a<b)printf("%d\n",b-(a+w)>=0?b-(a+w):0);
    else printf("%d\n",a-(b+w)>=0?a-(b+w):0);
}

Measured memory_bytes: 128
M,z,s=998244353,1,0
N,*A=open(0)
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 a=int(a);s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
print((z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M)

Measured memory_bytes: 143948
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i,j,k=0,c=0,f=0;
	string s;
	cin>>s;
	for(i=0;i<s.length();i++)
	for(j=i+1;j<s.length();j++)
	{
		if(s[i]=='C')c=1;
		if(s[j]=='F'&&c==1)f=1;
	}
		if(c==1&&f==1)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	return 0;
}

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

int stoi(string s){
  stringstream ss;
  ss << s;
  int res;
  ss >> res;
  return res;
}

int main(){
  int n,x,y,t,z[1000][5];
  string s,name[1000];

  while(cin >> n, n){
    cin >> s;
    t = 0;
    for(int i=1;i<(int)s.size();i++){

      if(s[i] != '/'){
	string tmp = "";
	while(i<(int)s.size() && s[i] != '>'){
	  tmp += s[i];
	  i++;
	}
	name[t] = tmp;
	for(int j=0;j<4;j++){
	  i++;
	  tmp = "";
	  while(s[i] != ',' && s[i] != '<'){
	    tmp += s[i];
	    i++;
	  }
	  z[t][j] = stoi(tmp);
	}
	t++;
      }else{
	while(i<(int)s.size() && s[i]!='<')i++;
      }
    }

    for(int i=0;i<n;i++){
      cin >> x >> y;

      int m = -1;
      for(int j=0;j<t;j++){
	if(z[j][0]<=x && x<=z[j][2] && z[j][1]<=y && y<=z[j][3]){
	  if(m<0 || (z[m][0]<z[j][0] && z[j][2]<z[m][2] && z[m][1]<z[j][1] && z[j][3]<z[m][3]) )m = j;
	} 
      }
      
      if(m<0)cout << "OUT OF MAIN PANEL 1" << endl;
      else{
	int num = 0;
	for(int j=0;j<t;j++){
	  if(z[m][0]<z[j][0] && z[j][2]<z[m][2] && z[m][1]<z[j][1] && z[j][3]<z[m][3]){
	    bool f = true;
	    for(int k=0;k<t;k++){
	      if(z[m][0]<z[k][0] && z[k][2]<z[m][2] && z[m][1]<z[k][1] && z[k][3]<z[m][3]){
		if(z[k][0]<z[j][0] && z[j][2]<z[k][2] &&  z[k][1]<z[j][1] && z[j][3]<z[k][3]){
		  f = false;
		  break;
		}
	      }
	    }
	    if(f)num++;
	  }
	}
	
	cout << name[m] << " " << num << endl;
      }
    }
  }
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{  int i,n,t,j,flag,a[200000];
   scanf("%d",&n); 
   for(i=0;i<n;i++)
   scanf("%d",&a[i]);
   flag=1;
   j=0;
   while(flag)
   {  flag=0;
      for(i=n-1;i>0;i--)
      {  if(a[i]<a[i-1]) //不符合条件的两两交换 
         {  t=a[i];
            a[i]=a[i-1];
            a[i-1]=t;
            j++;
            flag=1;
         }
      }
   }
   for(i=0;i<n;i++)
   {  if(i>0)  printf(" ");
      printf("%d",a[i]);
   }
   printf("\n");
   printf("%d\n",j);
   return 0; 
}


Measured memory_bytes: 2108
#include<stdio.h>
int main(){
  int n,k,i,min=0;
  scanf("%d%d",&n,&k);
  int x[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&x[i]);
  for(i=0;i<n;i++){
    if(x[i]<k-x[i])
      min+=2*x[i];
    else
      min+=2*(k-x[i]);
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 1700
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n,i,s[1000];
	double a,m,b;

	while(1)
	{
		scanf("%d",&n);
		if(n==0)
		{
			break;
		}
		a=0;
		m=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&s[i]);
			m += s[i];
		}
		m /= n;
		for(i=0;i<n;i++)
		{
			a += (s[i] -m)*(s[i]-m);
		}
		a /= n;
		printf("%f\n",sqrt(a));
	}
return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define M 5005
#define N 10005
#define K 12
int p[K] = {0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6};
int q[K] = {};
int r[K] = {};
int t[M][N]={};

int main(){
	int n, m; scanf("%d%d", &n, &m);
	int a; REP(i, m) scanf("%d", &a), LAR(q[p[a]], a);
	REP(i, K) r[q[i]]=i;
	REP(i, K) t[1][i]=q[i];
	FOR(i, 1, M-1){
		REP(j, N) {
			if(!t[i-1][j]) continue;
			REP(k, K) {
				if(j+k >= N) continue;
				if(!q[k]) continue;
				LAR(t[i][j+k], q[k]);
			}
		}
	}
	REP(j, 25) DEBUG("%2d ", j); DEBUG("\n");
	REP(i, 8){
		DEBUG("%2d | ", i);
		REP(j, 25) DEBUG("%2d ", t[i][j]); 
		DEBUG("\n");
	}
	int i = M-1;
	while(!t[i][n]) i--;
	for(int j=i; j>=1; j--){
		printf("%d", t[j][n]);
		n -= r[t[j][n]];
	}
	printf("\n");
}


Measured memory_bytes: 193152
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int n;

bool check(char data[8][8],int x,int y) {
	if (x >= 0 && x < 8 && y >= 0 && y < 8) {
		if (data[x][y] == '1') {
			return true;
		}
		else {
			return false;
		}

	}
	else {
		false;
	}
}

void bomb(char data[8][8], int x, int y) {
	if (check(data,x,y)== true) {
		data[x][y] = '0';
		if (check(data, x + 1, y)) {
			bomb(data, x+1, y);
		}
		if (check(data, x + 2, y)) {
			bomb(data, x + 2, y);
		}
		if (check(data, x + 3, y)) {
			bomb(data, x + 3, y);
		}
		if (check(data, x - 1, y)) {
			bomb(data, x - 1, y);
		}
		if (check(data, x - 2, y)) {
			bomb(data, x - 2, y);
		}
		if (check(data, x - 3, y)) {
			bomb(data, x - 3, y);
		}
		if (check(data, x, y + 1)) {
			bomb(data, x, y + 1);
		}
		if (check(data, x, y + 2)) {
			bomb(data, x, y + 2);
		}
		if (check(data, x, y + 3)) {
			bomb(data, x, y + 3);
		}
		if (check(data, x, y - 1)) {
			bomb(data, x, y - 1);
		}
		if (check(data, x, y - 2)) {
			bomb(data, x, y - 2);
		}
		if (check(data, x, y - 3)) {
			bomb(data, x, y - 3);
		}
	}
	else {
		return;
	}
}

int main() {
	cin >> n;
	char data[8][8];
	int x, y;
	getchar();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 8; j++) {
			cin >> data[j];
		}
		cin >> y;
		cin >> x;
		getchar();
		bomb(data, x - 1, y - 1);
		cout << "Data " << i + 1 << ":" << endl;
		for (int h = 0; h < 8; h++) {
			for (int g = 0; g < 8; g++) {
				cout << data[h][g];
			}
			cout << endl;
		}

	}

}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define    fios ios_base::sync_with_stdio(false); cin.tie(0);
#define    sf(x) scanf("%d",&x)
#define    sfl(x) scanf("%lld",&x)
#define    pf(x) printf("%d\n",x)
#define    pfl(x) printf("%lld\n",x)
#define    ll long long
#define    nl "\n"
#define    PB(x) push_back(x)
#define    For(i,n) for(int i=0; i<n; i++)
#define    PI acos(-1)
using namespace std;


int main()
{
    int a,z;

    for(int i=1; i<=5; i++)
    {
        cin>>a;

        if(a==0)
            z=i;
    }

    cout<<z<<nl;


    return 0;
}


Measured memory_bytes: 3644
num_terms, max_value = map(int, input().split())
coef = [int(a) for a in input().split()]

res = 0
for i in range(40, -1, -1):
    num_bits = 0
    for a in coef:
        num_bits += ((a >> i) & 1)
    cand = 2**i
    if (num_terms-num_bits) > num_bits and cand <= max_value:
        res += (num_terms - num_bits)*cand
        max_value -= cand
    else:
        res += num_bits*cand

print(res)


Measured memory_bytes: 14308
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Control.Monad (replicateM)

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,x] <- readInts
  ms    <- replicateM n readInt
  print $ f n x ms

sumMin :: [Int] -> (Int, Int)
sumMin = (,) <$> sum <*> minimum

f :: Int -> Int -> [Int] -> Int
f n x ms = n + (x - sms) `div` minms
  where
    (sms, minms) = sumMin ms

Measured memory_bytes: 508
using System;
class Program{
  static void Main(string[] args){
    string[] tmp = Console.ReadLine().Split(' ');
    int n = int.Parse(tmp[0]);
    int m = int.Parse(tmp[1]);
    int c = int.Parse(tmp[2]);
    tmp = Console.ReadLine().Split(' ');
    int[] b = new int[m];
    int p=0;
    for(int i=0;i<m;i++){b[i]=int.Parse(tmp[i]);}
    for(int j=0;j<n;j++){
    tmp = Console.ReadLine().Split(' ');
      int t=0;
      for(int i=0;i<m;i++){
        t+=int.Parse(tmp[i])*b[i];
      }
      if(t+c>0){p++;}
    }
    Console.WriteLine(p);
  }
}

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

template<class T>
T gcd(T a, T b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

// 素数列挙
// nまでの素数をEratosthenesの篩で列挙する
// 計算量O(nloglogn)
template<class T>
vector<T> prime_list(T n){
    vector<T> ret;
    vector<T> isPrime(n+1,1);
    isPrime[0] = isPrime[1] = 0;
    for(long long i = 2; i <= n; ++i){
        if(isPrime[i] == 0) continue;
        ret.push_back(i);
        for(long long j = i*i; j <= n; j += i) isPrime[j] = 0;
    }
    //return ret;
    return isPrime;  // 状況によってはこっちを返す
}

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

    int q; cin >> q;
    vector<int> isPrime = prime_list(100001);
    vector<int> psum(100002, 0);
    for(int i = 1; i <= 100000; ++i){
        if(isPrime[i] && isPrime[((i+1)/2)]) psum[i+1] = psum[i]+1;
        else psum[i+1] = psum[i];
    }
    int l,r;
    rep(i,q){
        cin >> l >> r;
        cout << psum[r+1]-psum[l-1] << "\n";
    }
}

Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a < b && b < c) {
		printf("Yes\n");
	}
	if (!(a < b && b < c)) {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

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

	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	int a;
	vint ans={};
	
	FOR(i,0,n){
		cin>>a;
		FOR(j,0,a){
			ans.pb(i+1);
		}
	}
	
	int i=0;
	while (i<h*w){
		if(i%(2*w)<w-1) {
			cout<<ans[i]<<' ';
		}else if(i%(2*w)==w-1){
			cout<<ans[i]<<endl;
		}else if(w<=i%(2*w) && i%(2*w)<2*w-1){
			cout<<ans[2*w*(i/w)+w-1-i]<<' ';
		}else if (i%(2*w)==2*w-1){
			cout<<ans[2*w*(i/w)+w-1-i]<<endl;
		}
		i++;

	}

}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int k = -1;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x == 1) k = i;
  }
  --m;
  int L = (k + m - 1) / m;
  int R = (n - k - 1 + m - 1) / m;
  int ret = L + R;
  ret -= ((L * m - k) + (R * m - (n - k - 1)) >= m);
  printf("%d\n", ret);
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }       
    cout << dp[n-1] << endl;
    return 0;
}

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

using namespace std;
const int N = 366666 ; 
int n,k,arr[N];
int dp[N];
struct Node{
	int l,r;
	int maxn;
}tr[N<<2];
void pushup(int u){
	tr[u].maxn=max(tr[u<<1].maxn,tr[u<<1|1].maxn);
	return ;
}
void build(int u,int l,int r){
	tr[u].l=l,tr[u].r=r;
	if(l==r){
		tr[u].maxn=0;
		return ;
	}
	int mid=(l+r)/2;
	build(u<<1,l,mid),build(u<<1|1,mid+1,r);
	pushup(u);
}
int querymax(int u,int l,int r){
    if(l<=tr[u].l&&tr[u].r<=r){
        return tr[u].maxn;
    }
    int mx=0;
    int mid=(tr[u].l+tr[u].r)>>1;
    if(l<=mid) mx=max(mx,querymax(u<<1,l,r));
    if(r>mid)  mx=max(mx,querymax(u<<1|1,l,r));
    return mx;
}
void modify(int u,int x,int y){
	if(tr[u].l==x&&tr[u].r==x){
		tr[u].maxn=max(tr[u].maxn,y);
		return ;
	}
	int mid=(tr[u].l+tr[u].r)>>1;
	if(x<=mid) modify(u<<1,x,y);
	else modify(u<<1|1,x,y);
	pushup(u);
}
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>arr[i];
	build(1,0,300001);
	int ans=1;
	for(int i=1;i<=n;i++){
		int l=max(0,arr[i]-k);
		int r=min(300001,arr[i]+k);
		dp[i]=querymax(1,l,r)+1;
		ans=max(ans,dp[i]);
		modify(1,arr[i],dp[i]);
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18228