akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int n,N,k=-1;
vector<int> vo,ve,pos;
vector<vector<int>> path;
vector<pp> m;

void init(){
    N=1;
    while(N<n) N*=2;
    vo.assign(2*N-1,inf); //変更点
    ve.assign(2*N-1,inf);
}

void init_u(){
    for(int i=N-2;i>=0;i--)
    vo[i]=min(vo[2*i+1],vo[2*i+2]); //変更点
    for(int i=N-2;i>=0;i--)
    ve[i]=min(ve[2*i+1],ve[2*i+2]);
}

//query(a,b,0,0,N);
int query_o(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return inf; //変更点
    if(a<=l && r<=b) return vo[k];
    int vl=query_o(a,b,k*2+1,l,(l+r)/2);
    int vr=query_o(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr); //変更点
}

int query_e(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return inf; //変更点
    if(a<=l && r<=b) return ve[k];
    int vl=query_e(a,b,k*2+1,l,(l+r)/2);
    int vr=query_e(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr); //変更点
}

void dfs(int a,int b,int K){
    if(a>b) return;
    int l,r;
    k++;
    if(a%2==0){
        l=query_o(a/2,b/2+1,0,0,N);
        r=query_e(pos[l]/2,b/2+1,0,0,N);
    }
    else{
        l=query_e(a/2,b/2,0,0,N);
        r=query_o((pos[l]+1)/2,b/2+1,0,0,N);
    }
    m[k]=mk(l,r);
    if(K!=-1){
        path[K].push_back(k);
        path[k].push_back(K);
    }
    K=k;
    dfs(a,pos[l]-1,K);
    dfs(pos[r]+1,b,K);
    dfs(pos[l]+1,pos[r]-1,K);
}

int main(){
    cin>>n; n/=2;
    path.assign(n,vector<int>(0));
    m.assign(n,mk(0,0));
    pos.assign(2*n+1,0);
    init();
    rep(i,2*n){
        if(i%2){
            cin>>ve[i/2+N-1];
            pos[ve[i/2+N-1]]=i;
        }
        else{
            cin>>vo[i/2+N-1];
            pos[vo[i/2+N-1]]=i;
        }
    }
    init_u();
    dfs(0,2*n-1,-1);
    priority_queue<pp> que;
    vector<int> visited(2*n,0);
    que.push(mk(-m[0].first,0));
    while(!(que.empty())){
        int num,s;
        tie(num,s)=que.top();
        que.pop();
        printf("%d %d ",m[s].first,m[s].second);
        visited[s]=1;
        for(auto to:path[s]){
            if(visited[to]) continue;
            que.push(mk(-m[to].first,to));
        }
    }
}

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

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

// the code that we provide requires everything above this line to compile

#define MAX_V 1000
int N, W;
ll dpa[100001][100], dpw[100001];
int w[100], v[100];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    
    for (int i = 0; i <= MAX_V * N; i++)
        dpw[i] = INT_MAX;
    
    dpw[0] = 0;
    for (int i = 1; i <= MAX_V * N; i++) {
        for (int j = 0; j < N; j++) {
            if (v[j] <= i && !dpa[i - v[j]][j] && dpw[i - v[j]] != INT_MAX 
                && dpw[i - v[j]] + w[j] < dpw[i] && dpw[i - v[j]] + w[j] <= W) {
                memcpy(dpa[i], dpa[i - v[j]], N * sizeof(ll));
                dpa[i][j] = 1;
                dpw[i] = dpw[i - v[j]] + w[j];
            }
        }
    }
    
    for (int i = MAX_V * N; i >= 0; i--) {
        if (dpw[i] != INT_MAX) {
            cout << i;
            break;
        }
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        string s = cin.next();
        string t = cin.next();

        int[,] dp = new int[s.Length + 1, t.Length + 1];

        for (int si = 1; si <= s.Length; ++si)
        {
            for (int ti = 1; ti <= t.Length; ++ti)
            {
                if (s[si - 1] == t[ti - 1])
                {
                    dp[si, ti] = Math.Max(dp[si, ti], dp[si - 1, ti - 1] + 1);
                }
                dp[si, ti] = Math.Max(dp[si, ti], dp[si - 1, ti]);
                dp[si, ti] = Math.Max(dp[si, ti], dp[si, ti - 1]);
            }
        }


#if false
        Console.Write("\n");
        for (int ti = 0; ti <= t.Length; ++ti)
        {
            for (int si = 0; si <= s.Length; ++si)
            {
                Console.Write(dp[si, ti]);
                Console.Write(" ");
            }
            Console.Write("\n");
        }
        Console.Write("\n");
#endif


        string str = string.Empty;
        {
            int si = s.Length;
            int ti = t.Length;

            while (dp[si, ti] != 0)
            {
                if (dp[si, ti] == dp[si - 1, ti]) { --si; }
                else if (dp[si, ti] == dp[si, ti - 1]) { --ti; }
                else if (dp[si, ti] == dp[si - 1, ti - 1] + 1)
                {
                    str = s[si - 1] + str;
                    --si;
                    --ti;
                }
                //else { break; }
            }
        }

        Console.WriteLine(str);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 50104
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
typedef double db;
const int N=2e5+7;
int n,T,t[N];
ll ans=0;

int main(){
	scanf("%d%d",&n,&T);
	int last=1;scanf("%d",&t[1]);
	rep(i,2,n){
		scanf("%d",&t[i]);
		if(t[i-1]+T < t[i]){
			ans+=T;
		}
		else ans+=t[i]-t[i-1];
	}
	ans+=T;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

from functools import reduce

a = sorted(A)
d = reduce(gcd, a)

if (a[-1] >= K) and (a[-1] - K) % d == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 14224
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF            1e9
#define INFLL          1e18
#define EPS            1e-9
#define REP(i,n)       for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)      for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(ll i=(n);i>0;--i)
#define REPC(i,obj)    for(auto i:obj)
#define ALL(obj)       (obj).begin(),(obj).end()
#define SETP(n)        cout<<fixed<<setprecision(n)
#define VV(T,h,w)      move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i)   move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T, ll h, ll w>using vec2 = vector<vector<T>>;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

vector<ll>r;
vector<vector<double>>dp;
ll w;
unsigned n;
void init(const string&str)
{
	r.clear();
	stringstream ss(str);
	ss >> w;
	ll foo; while (ss >> foo)r.push_back(foo);
	n = r.size();
	dp = VVI(double, 1 << n, n, -1);
}
double pack(unsigned state, ll lastcake)
{
	if (state == (1 << n) - 1) return r[lastcake];
	else if (dp[state][lastcake] != -1)return dp[state][lastcake];
	else {
		double ret = INFLL;
		REP(i, n) {
			if ((state >> i & 1) == 0) {
				if (state == 0)ret = min(ret, r[i] + pack(state | (1 << i), i));
				else ret = min(ret, pack(state | (1 << i), i) + 2 * sqrt(r[lastcake] * r[i]));
			}
		}
		return dp[state][lastcake] = ret;
	}
}
signed main()
{
	string str;
	while (getline(cin, str)) {
		init(str);
		cout << (pack(0, 0) <= w ? "OK" : "NA") << endl;
	}
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, X;
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> X;
  rep(i, N) {
    cin >> A[i];
  }
  long long m = 0;
  rep(i, N-1) {
    int s = A[i] + A[i+1];
    if (s > X) {
      int d = min(A[i+1], s-X);
      A[i+1] -= d;
      m += d;
      if (A[i] > X) {
        m += A[i]-X;
        A[i] -= A[i]-X;
      }
    }
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,K;cin >> N >> K;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    LL dp[62][2];
    rep(i,62)dp[i][0] = dp[i][1] = -1;
    dp[61][1] = 0;

    for(int i = 60;i >= 0;--i){
        LL mask = 1LL << i;
        LL num = 0;
        rep(j,N) if(A[j] & mask) ++num;
        LL cost0 = mask * num;
        LL cost1 = mask * (N-num);

        if(dp[i+1][1] >= 0){
            // ぴったり　→　ぴったり
            if(K & mask)chmax(dp[i][1],dp[i+1][1] + cost1);  // X の i桁目が 1 の時
            else chmax(dp[i][1],dp[i+1][1] + cost0);         // X の i桁目が 0 の時
            // ぴったり　→　ゆるい
            if(K & mask)chmax(dp[i][0],dp[i+1][1] + cost0);
        }

        if(dp[i+1][0] >= 0){
            // ゆるい　→　ゆるい
            chmax(dp[i][0],dp[i+1][0] + max(cost0,cost1));
        }
    }

    LL ans = max(dp[0][0],dp[0][1]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();
        int min = Integer.MAX_VALUE;
        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i != 0)
                continue;
            long j = n / i;
            min = Math.min(calc(i, j), min);
        }
        System.out.println(min);
    }

    public static int calc(long i, long j) {
        int digitI = Long.toString(i).length();
        int digitJ = Long.toString(j).length();
        return Math.max(digitI, digitJ);
    }
}


Measured memory_bytes: 23252
import decimal
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, *x = map(int, read().split())
ave = int(my_round(sum(x) / len(x)))
l = [(y - ave) ** 2 for y in x]
print(sum(l))

Measured memory_bytes: 5076
#include<iostream>
#include<algorithm>

using namespace std;

long long floor_function(long long a, long long b, long long n) {
  long long x = min(b-1, n);

  long long c = (a*x)/b;
  long long d = a * (x/b);
  return c-d;
}

int main() {
  long long a, b, n;
  cin >> a;
  cin >> b;
  cin >> n;
  cout << floor_function(a, b, n);
}

Measured memory_bytes: 3576
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = input()
a = list(a)
k = int(input())

c = a[k - 1]
s = ''
for i in a:
    if i == c:
        s += i
    else:
        s += '*'
print(s)


Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5;
vi g[N];
ll a[N] ,cnt[N];

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
ll n, L;
vector<ll> ans;

bool go(int lo, int hi, ll sum){
	if (sum<L)return false;
	if (lo+1 == hi){
		ans.pb(lo+1);
		return true;
	}
	ll x = a[lo];
	ll y = a[hi];
	
	if (x<=y and go(lo+1, hi, sum-x)){
		ans.pb(lo+1);
		return true;
	} 
	if (x>y and go(lo, hi-1, sum-y)){
		ans.pb(hi);
		return true;
	} 
	return false;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string no = "Impossible\n";
	string yes = "Possible\n";
	cin>>n>>L;
	int i;
	ll sum = 0;
	int lo = -1, hi = -1;
	fo(i, n) 
		cin>>a[i];
	sum = 0;
	
	Fo(i, 0, n-1){
		sum = a[i]+a[i+1];
		if (sum>=L){
			lo = i;
			hi = lo+1;
			break;
		}
	}
	if (lo==-1){
		cout<<no;
		return 0;
	}
	cout<<yes;
	int pos = 0;
	while(pos!=lo)cout<<++pos<<endl;
	pos = n-2;
	while(pos!=lo){
		cout<<pos+1<<endl;
		pos--;
	}
	cout<<lo+1<<endl;
	return 0;
} 

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 6272
#include <stdio.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
            //if(i%3==0)
		if(i%3==0||i%10==3||i%100/10==3||i%1000/100==3||i%10000/1000==3)
		{
			printf(" %d",i);
	    }
	}
	printf("\n");
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] mens = new int[n];
		for(int i = 0; i < n; i++) {
			mens[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(k <= mens[i]) {
				ans++;
			}
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 49356
#define LOCAL0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    double a,b,n;
    cin>>a>>b>>n;
    cout<<floor(a*min(n,b-1)/b);
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>

using namespace std;
vector<long long> v;

void num(int x){




}

int main() {
int n;
cin>>n;
cout<<n+n*n+n*n*n<<endl;



    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  int N,K; cin >>N>>K;
  vector<long long>h(N);
  vector<long long>sa(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
    //cout<<"値"<<h.at(i)<<endl;
  }
  sort(all(h));
  for(int i=0;i<N-1;i++){
    sa.at(i)=h.at(i+1)-h.at(i);
    //cout<<"差"<<sa.at(i)<<endl;
  }  
  long long sum=0;
  long long kotae=INT_MAX;
  for(int i=0;i<K-1;i++){
    sum=sum+sa.at(i);
    //cout<<"差の和"<<sum<<endl;
  }
  //cout<<"差の和"<<sum<<endl;
  kotae=min(kotae,sum);
  rep2(i,1,N-K+1){
    sum=sum-sa.at(i-1)+sa.at(i+K-2);
    //cout<<"差"<<sa.at(i-1)<<" "<< sa.at(i+K-2)<<" "<<sum<<endl;
    //cout<<sum<<endl;
    kotae=min(kotae,sum);
  }
  cout <<kotae<<endl;
}

Measured memory_bytes: 1792
local n=io.read("n")
local t={}
while n>0 do
    local mod=n%26
    if mod==0 then
        mod=26
    end
    table.insert(t,mod+96)
    n=n-mod
    n=n//26
end

local answer={}
for i=#t,1,-1 do
    table.insert(answer,string.char(t[i]))
end
print(table.concat(answer,""))

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,q,t,l,r,i;
    char ch;
    vector<set<int>> v(26);
    string str;
    cin>>n>>str;
    for(int i=0;i<n;i++)
    {
        ch=str[i];
        v[(int)ch-97].insert(i);
    }
    cin>>q;
    for(int k=1;k<=q;k++)
    {
        cin>>t;
        if(t==1)
        {
            cin>>i>>ch;
            if(str[i-1]==ch) continue;
            else{
                v[str[i-1]-97].erase(i-1);
                v[(int)ch-97].insert(i-1);
            }
            str[i-1]=ch;
        }
        else
        {
            cin>>l>>r;
            int c=0;
            for(int i=0;i<26;i++)
            {
                
                auto it = v[i].lower_bound(l-1);
                if(it!=v[i].end() && *it<=r-1) c++;
                
            }
            cout<<c<<"\n";
        }
    }
    return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a[4] = {};
  int b;
  cin >> b;
  a[b] = 1;
  cin >> b;
  a[b] = 1;
  for ( int i = 1; i <= 3; i++ ) {
    if ( !a[i] ) cout << i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

vector<int> bfs(vector<vector<int>> adj, vector<int> visited, int r){
    queue<int> que;
    que.push(r);
    visited[r]=1;

    while(!que.empty()){
        int s=que.front();
        que.pop();
        //cout<<s<<endl;
        for(int i=0; i<adj[s].size(); i++){
            if(visited[adj[s][i]]==0){
                que.push(adj[s][i]);
                visited[adj[s][i]]=s;
            }
        }
    }

    return visited;
}

int main(){
    int n,m;

    cin>>n>>m;

    vector<vector<int>> adj(n+1);
    vector<int> visited(n+1,0);    

    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
  

    visited=bfs(adj,visited,1);


    for(int i=2; i<=n; i++){
        if(visited[i]==0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    for(int i=2; i<=n; i++){
        cout<<visited[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 16260
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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; }
string a, b, c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    int i = 0;
    int j = 0;
    int k = 0;
    int turn = 0;
    while (true)
    {
        if (turn == 0)
        {
            if (a.size() == i)
                return cout << "A"
                            << "\n",
                       0;
            if (a[i] == 'a')
            {
                turn = 0;
            }
            else if (a[i] == 'b')
            {
                turn = 1;
            }
            else
            {
                turn = 2;
            }
            i++;
        }
        else if (turn == 1)
        {
            if (b.size() == j)
                return cout << "B"
                            << "\n",
                       0;
            if (b[j] == 'a')
            {
                turn = 0;
            }
            else if (b[j] == 'b')
            {
                turn = 1;
            }
            else
            {
                turn = 2;
            }
            j++;
        }
        else
        {
            if (c.size() == k)
                return cout << "C"
                            << "\n",
                       0;
            if (c[k] == 'a')
            {
                turn = 0;
            }
            else if (c[k] == 'b')
            {
                turn = 1;
            }
            else
            {
                turn = 2;
            }
            k++;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
using namespace std;
struct E{int t,c,d;E(int t,int c,int d):t(t),c(c),d(d){}};
vector<E>e[30];
struct S{double t;int cur,last,s;S(double t,int cur,int last,int s):t(t),cur(cur),last(last),s(s){}};
struct Cmp{bool operator()(const S&a,const S&b){return a.t>b.t;}};
double F(int s,int g)
{
	double time[31][30][30];
	int i,j,k;
	fill_n(&time[0][0][0],sizeof(time)/sizeof(double),1e99);
	priority_queue<S,vector<S>,Cmp>q;
	q.push(S(0,s,s,1));
	while(!q.empty())
	{
		S s=q.top();q.pop();
		if(time[s.s][s.cur][s.last]<=s.t)continue;
		time[s.s][s.cur][s.last]=s.t;
		if(s.cur==g&&s.s==1)return s.t;
		for(i=0;i<e[s.cur].size();++i)
		{
			E&r=e[s.cur][i];
			if(s.last==r.t)continue;
			if(s.cur==s.last)
				q.push(S(s.t+r.d/double(s.s),r.t,s.cur,s.s));
			else
				for(j=(s.s-1?-1:0);j<2;++j)
					if(s.s+j<=r.c&&time[s.s+j][r.t][s.cur]>s.t+r.d/double(s.s+j))
						q.push(S(s.t+r.d/double(s.s+j),r.t,s.cur,s.s+j));
		}
	}
	return -1;
}
int main()
{
	int n,m,s,g,x,y,d,c,i;
	while(scanf("%d%d",&n,&m),n)
	{
		for(i=0;i<n;++i)e[i].clear();
		scanf("%d%d",&s,&g);
		while(m--)
		{
			scanf("%d%d%d%d",&x,&y,&d,&c);
			--x,--y;
			e[x].push_back(E(y,c,d));
			e[y].push_back(E(x,c,d));
		}
		double r=F(s-1,g-1);
		if(r<0)puts("unreachable");
		else printf("%f\n",r);
	}
	return 0;
}

Measured memory_bytes: 7808
s = input()
n = len(s)
s0 = s[0]
numr = 1
numl = 0
ans = [0 for _ in range(n)]
for i in range(1, n):
    s1 = s[i]
    if s1 == 'R':
        numr += 1
    elif s1 == 'L':
        numl += 1

    if s0 == 'R' and s1 == 'L':
        ir = i - 1
        il = i
        ans[ir] += (numr + 1) // 2
        ans[il] += numr // 2
        numr = 0
    if (s0 == 'L' and s1 == 'R') or i == n - 1:
        ans[ir] += numl // 2
        ans[il] += (numl + 1) // 2
        numl = 0
    s0 = s1
print(*ans)


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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int res = 0;
  res += min(a, 0) * -1 * c;
  res += (a < 0 ? d : 0);
  res += (b - max(a, 0)) * e;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

ll n,t;
vint a,b;
vector<vint> d;


int dp(int p, int wa){
	if(wa >= t){debug("test1\n");return 0;}
	if(p == n){debug("test2\n");return 0;}
	if(d[p][wa] != -1){
		return d[p][wa];
	}
	
	int res = 0;
	chmax(res, b[p]+dp(p+1, wa+a[p]));
	chmax(res, dp(p+1, wa));
	debug("test000 %d\n", res);
	return d[p][wa] = res;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
	cin>>n>>t;a = vint(n);b = vint(n);
	initvv(d, 3010, 3010, -1);
	vector<P> p;
	rep(i, n){
		cin>>a[i]>>b[i];
		p.push_back(P(a[i], -1*b[i]));
	}
	sort(all(p));
	rep(i, n){
		a[i] = p[i].first;
		b[i] = -1*p[i].second;
	}
	debug("n %d\n", n);
	cout << dp(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 36096
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
  for(int n, a, b; cin >> n >> a >> b && n;) {
	vector<int> ok(b, false);

	int ans = 0;
	int i = 0;
	for(int x = 1; x <= n; ++x) {
	  while(i * a <= x) {
		ok[(i * a) % b] = true;
		++i;
	  }

	  if(!ok[x % b]) ++ans;
	}

	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
n,k,q = map(int,input().split())
a = []
for _ in range(q):
    a.append(int(input()))
#
point_get = [0] * n
for i in range(q):
    point_get[a[i]-1] += 1
#
for j in range(n):
    if k - q + point_get[j] >= 1:
        print('Yes')
    else:
        print('No')


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(), (s).end())
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

long long x[10000010], y[10000010];

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n, a, b, ans = 0;
   double cnt = 0;
   string s, v;

   cin >> s;

   if (s == "SUN")
      cout << 7 << '\n';
   else if (s == "MON")
      cout << 6 << '\n';
   else if (s == "TUE")
      cout << 5 << '\n';
   else if (s == "WED")
      cout << 4 << '\n';
   else if (s == "THU")
      cout << 3 << '\n';
   else if (s == "FRI")
      cout << 2 << '\n';
   else
      cout << 1 << '\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=2e5+500;
const ll inf=4e10;

vector<ll> child[maxn];
ll par[maxn];
ll v[maxn];

vector<pii> dp[maxn];

void dfs(ll a,ll mid){
	dp[a].clear();
	if(child[a].empty()){
		dp[a].pb(mp(0,0));
		return ;
	}
	ll l=child[a][0];
	ll r=child[a][1];
	dfs(l,mid);
	dfs(r,mid);
	if(dp[l].size()>dp[r].size())swap(l,r);
	vector<pii> vec;
	vec.reserve(dp[l].size());
	for(auto e:dp[l]){
		ll w=lower_bound(dp[r].begin(),dp[r].end(),mp(mid-e.S-v[l]-v[r]+1,-1LL))-dp[r].begin()-1;
		if(w!=-1){
			vec.pb(mp(e.F+v[l],dp[r][w].S+v[r]));
			vec.pb(mp(dp[r][w].S+v[r],e.F+v[l]));
		}
	}
	sort(vec.begin(),vec.end());
	for(ll i=0;i<vec.size();i++){
		if(dp[a].empty() || dp[a].back().S>vec[i].S){
			dp[a].pb(vec[i]);
		}
	}
	
}
bool is_good(ll n,ll mid){
	dfs(1,mid);
	if(dp[1].size())return 1;
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n;
	cin>>n;
	for(ll i=2;i<=n;i++){
		cin>>par[i]>>v[i];
		child[par[i]].pb(i);
	}
	ll b=-1;
	ll e=inf;
	while(e-b>1){
		ll mid=(e+b)/2;
		if(is_good(n,mid)){
			e=mid;
		}else{
			b=mid;
		}
	}
	cout<<e;
}




















Measured memory_bytes: 40452
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>

#include <iomanip>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

int main () {
  string s;
  cin >> s;
  string sorg = s;
  reverse(all(s));
  cout << (sorg == s ? "Yes" : "No") << endl;
}

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

int main() {
    map <string, int> m;
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        string s; cin >> s;
        m[s] ++;
    }
    int ans = 0;
    for(auto x:m) ans = max(ans, x.second);

    for(auto x:m) {
        if(x.second == ans) cout << x.first << "\n";
    }
    return 0;
}

Measured memory_bytes: 25216
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = S()
    if s[0] == "W":
        print(0)
        return
    lis = [0] * (2 * n)
    l = [0] * (2 * n)
    l[0] = 1
    for i in range(1, 2 * n):
        lis[i] = (lis[i-1] ^ (s[i] == s[i-1]))
        l[i] += l[i - 1] + (lis[i] == 0)
    ans = 1
    if l[-1] != n or s[0] == "W":
        print(0)
        return
    k = 1
    for i in range(2 * n):
        if lis[i]:
            ans *= l[i] - (k - 1)
            ans %= mod
            k += 1
    print(ans * math.factorial(n) % mod)
    return

#D
def D():
    n = II()
    l = len(bin(n)) - 2
    for i in range(n - 1):
        ans = []
        for j in range(i + 2, n + 1):
            for k in range(l):
                if (j >> k) & 1 != ((i + 1) >> k) & 1:
                    ans.append(str(k + 1))
                    break
        print(" ".join(ans))
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 45020
using System;
class Program
{
	static void Main(string[] args)
	{
       int N = int.Parse(Console.ReadLine());
       int K = int.Parse(Console.ReadLine());
       int X = int.Parse(Console.ReadLine());
       int Y = int.Parse(Console.ReadLine());
       int result = 0;
       if(K < N)
       {
          result += (K * X + (N-K) * Y);
       }
       else
       {
          result += (N * X);
       }
       Console.WriteLine(result);
	}
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

class segtree {
    int n = 1; VL dat;
#define def LLINF
public:
    segtree(int _n) {
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
    }
    segtree(VL a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
        FOR(i, 0, _n)dat[i + n - 1] = a[i];
        rFOR(i, 0, n - 1)dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
    }
    void Chmin(int i, ll a) {
        i += n - 1;
        if (!chmin(dat[i], a))return;
        while (i > 0) {
            --i /= 2;
            dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    ll Min(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return def;
        if (a <= l && r <= b)return dat[k];
        ll s = Min(a, b, 2 * k + 1, l, (l + r) / 2);
        ll t = Min(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(s, t);
    }
    ll Min(int a, int b) { return Min(a, b, 0, 0, n); }

    ll operator[](int k) { return dat[k + n - 1]; }
};

struct P {
    int l, r; ll c;
    P(int _l, int _r, ll _c) :l(_l), r(_r), c(_c) {};
    bool operator<(P x) { return l < x.l; }
};

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<P> info;
    FOR(i, 0, m) {
        int l, r; ll c; cin >> l >> r >> c;
        --l, --r;
        info.emplace_back(l, r, c);
    }

    SORT(info);
    segtree seg(n);
    seg.Chmin(0, 0);
    FOR(i, 0, m) {
        int l = info[i].l, r = info[i].r;
        ll c = info[i].c;
        seg.Chmin(l, seg.Min(l, n));
        seg.Chmin(r, min(seg.Min(r, n), seg[l] + c));
    }
    cout << (seg[n - 1] == LLINF ? -1 : seg[n - 1]) << "\n";
}


Measured memory_bytes: 3952
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        

        while(true){
            char[] c = new char[1200];
            int[] flag = new int[1200];
            String str;
            int Flag = 0, error = 0;

            str = br.readLine();
            int l = str.length();

            for(int i = 0; i<l; i++){
                c[i] = str.charAt(i);

                if(l == 1 && c[0] == 46) break;
                //System.out.println(c[i]);
                
                if(c[i] == 40){ 
                    flag[i] = 1;
                }else if(c[i] == 41) {
                    flag[i] = 2;

                    for(int j = i-1; j >= 0; j--){
                        
                        if(flag[j] == 3){
                            error = 1;
                            break;
                        }else if(flag[j] == 1){
                            flag[j] = 0;
                            flag[i] = 0;
                            break;
                        }
                    }

                }else if(c[i] == 91){
                     flag[i] = 3;
                }else if(c[i] == 93){
                    flag[i] = 4;

                    for(int j = i-1; j >= 0; j--){

                        if(flag[j] == 1){
                            error = 1;
                            break;
                        }else if(flag[j] == 3){
                            flag[j] = 0;
                            flag[i] = 0;
                            break;
                        }
                    }
                }else{
                    flag[i] = 0;
                }
                //System.out.println(flag[i]);
                if(error == 1) break;
            }
            

            if(l == 1 && c[0] == 46) break;

            for(int i = 0; i < l; i++){
                if(flag[i] != 0){
                    Flag = 1;
                }
                //System.out.println(flag[i]);
                //System.out.println(Flag);
            }

            if(Flag == 0 && error == 0){
                System.out.println("yes");
            }else if(Flag == 1 || error == 1){
                System.out.println("no");
            }
        }

   
    }
}


Measured memory_bytes: 54844
N=int(input())
V1,V2={},{}
ans = N-1
for n,i in enumerate(list(map(int,input().split(' ')))):
    if n%2==0:
        V1.setdefault(i,0)
        V1[i]+=1
    else:
        V2.setdefault(i,0)
        V2[i]+=1
V1=sorted(V1.items(),key=lambda x:x[1],reverse=True)
V2=sorted(V2.items(),key=lambda x:x[1],reverse=True)
cut = max(V1[0][1],V2[0][1])
for i in V1[:2]:
    for j in V2[:2]:
        if i[0]!=j[0]:
            ans = min(ans,N-i[1]-j[1])
        else:
            ans = min(ans,N-max(i[1],j[1]))
print(ans)

Measured memory_bytes: 16928
m, f, r = map(int,input().split())
while(not((m==-1)and(f==-1)and(r==-1))):
    sum = m+f
    if ((m==-1)or(f==-1)):
        print('F')
    elif (80<=sum):
        print('A')
    elif (65<=sum and sum<80):
        print('B')
    elif (50<=sum and sum<65):
        print('C')
    elif (30<=sum and sum<50):
        if (50<=r):
            print('C')
        else:
            print('D')
    else:
        print('F')
    m, f, r = map(int,input().split())



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

int N,M;
vector<vector<pair<int,int>>> Graph;
vector<int> A;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>N>>M;
    Graph.resize(N);
    A.assign(N,-1);
    rep(i,M){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        z %= 2;
        Graph[x].push_back({y,z});
        Graph[y].push_back({x,z});
    }
    queue<int> Q;
    int cnt = 0;
    rep(i,N){
        if(A[i]==-1){
            Q.push(i);
            cnt++;
            while(!Q.empty()){
                auto xi = Q.front();
                Q.pop();
                A[xi] = 1;
                for(auto nx:Graph[xi]){
                    int cost = nx.second;
                    if(A[nx.first]!=-1)continue;
                    A[nx.first] =1;
                    Q.push(nx.first);
                }
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 7284
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  ll N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  ll cnt = 0;
  ll res = 0;
  rep(i, N){
    cnt += A[i];
    if(i % 2){
      if(cnt >= 0){
        res += cnt+1;
        cnt = -1;
      }
    }else{
      if(cnt <= 0){
        res += 1-cnt;
        cnt = 1;
      }
    }
  }
  ll ans = res;

  cnt = 0;
  res = 0;
  rep(i, N){
    cnt += A[i];
    if(i % 2){
      if(cnt <= 0){
        res += 1-cnt;
        cnt = 1;
      }
    }else{
      if(cnt >= 0){
        res += cnt+1;
        cnt = -1;
      }
    }
  }
  ans = min(ans, res);
  cout << ans << endl;

}


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

namespace AtCoder179
{
    class Program
    {
        static int[] RI()
        {
            return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }

        static long[] RL()
        {
            return Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        static string RS()
        {
            return Console.ReadLine();
        }

        static void W(object msg)
        {
            Console.WriteLine(msg);
        }

        static void Main(string[] args)
        {
            QB();
        }

        private static void QA()
        {
            string line = RS();
            W(line + (line.EndsWith("s") ? "es" : "s"));
        }

        private static void QB()
        {
            int N = int.Parse(RS());
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                int[] nums = RI();
                if (nums[0] == nums[1])
                {
                    cnt++;
                } else
                {
                    cnt = 0;
                }

                if (cnt >= 3) break;
            }

            W((cnt >= 3) ? "Yes" : "No");
        }

        private static void QC()
        {
 
        }

        private static void QD()
        {

        }

        private static void QE()
        {

        }
    }
}


Measured memory_bytes: 19136
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static const ll INF = 1e+15;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<ll> x(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }

    ll ans = INF;
    for (int i = 0; i < N-K+1; ++i) {
        ll t = min(abs(x[i]), abs(x[i+K-1])) + abs(x[i]-x[i+K-1]);
        ans = min(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")


N=int(input())
V = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
C = [int(i) for i in input().split()]	# 1 2 3 4 5 ...


p(N)
p(V)
p(C)

ans=0
for i in range(N):
	a = V[i]-C[i]
	if a>0: ans+=a

print(ans)


Measured memory_bytes: 3064