akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //Mo's Algorithm
    int n;
    cin>>n;
    int a[n+1];
    long long ans=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	ans+=a[i]-1;
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i;
	string s;
	cin>>a>>b>>s;
	for(i=0;i<a;i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No"<<endl;
			return 0;
		}
	//i++;kwehtihwrtjiwerhtue4wytue
	if(s[i]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	b+=i++;
	for(i=i;i<b;i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

string s;
cin>>s;
if(s[s.sz-1]=='s'){
    cout<<s<<"es"<<endl;
}else if(s[s.sz-1]!='s'){
    cout<<s<<"s"<<endl;
}
}



Measured memory_bytes: 3660
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val d = Math.log10(N.toDouble()).toInt() + 1
    val ans = when (d) {
        1 -> N
        2 -> 9
        3 -> 9 + (N - 99)
        4 -> 9 + 900
        5 -> 9 + 900 + (N - 9999)
        6 -> 9 + 900 + 90000
        else -> -1
    }
    println(ans)
}

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

#define int long long
#define fi first
#define se second
#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 repo(i,o,n) for(int i=o;i<(int)(n);i++)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a[100000],hoge,Fhsum[100001],Shsum[100001],ans=-1000000000000000000;
priority_queue<int,vector<int>,greater<int>> Fh;
priority_queue<int> Sh;

main() {
    cin >> n;
    rep(i,n) cin >> hoge,Fhsum[0] += hoge,Fh.push(hoge);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> hoge,Shsum[n] += hoge,Sh.push(hoge);
    rep(i,n) {
        Fh.push(a[i]);
        Fhsum[i+1] += a[i]+Fhsum[i];
        Fhsum[i+1] -= Fh.top();
        Fh.pop();
    }
    repm(i,n) {
        Sh.push(a[i]);
        Shsum[i] += a[i]+Shsum[i+1];
        Shsum[i] -= Sh.top();
        Sh.pop();
    }
    rep(i,n+1) ans = max(ans,Fhsum[i]-Shsum[i]);
    cout << ans << endl;
}

Measured memory_bytes: 4340
n = int(input())
a = list(map(int, input().split()))
b = sum(a)
c = 0
for i in range(n):
  c += a[i]
  if c >= b / 2:
    k = i
    break
cut1 = c - (b - c)
cut2 = b - c + a[k] - (c - a[k])
ans = min(cut1, cut2)
print(ans)

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



ll SOLVE(){
    ll N=200005;
    ll n,m;cin>>n>>m;
    vector<ll>v[N];
    rep(q,1,n){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
    }
    ll ans=0;
    priority_queue<ll>q;
    for(ll day=1;day<=m;day++){
        for(auto x:v[day]){
            q.push(x);
        }
        if(!q.empty()){
            ans+=q.top();q.pop();
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using Int = uint64_t;
using Float = double;

int main()
{
  Int N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  if (P==2 || P==5) {
    uint64_t ans = 0;
    for(int i=0; i<N; i++) {
      if (Int(S[i]-'0') % P == 0) {
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  
  auto ms = vector<Int>(N+1,0);
  int mul = 1;
  for(int i=N-1; i>=0; i--) {
    ms[i] = (Int(S[i]-'0') * mul + ms[i+1]) % P;
    mul = (mul*10) % P;
  }
  
  auto d = unordered_map<int, int>();
  for(auto&& m : ms) {
    if (d.find(m) == d.end()) {
      d[m] = 1;
    } else {
      d[m]++;
    }
  }
  
  uint64_t ans = 0;
  for(auto&& kv : d) {
    if (kv.second >= 2) {
      ans += uint64_t(kv.second) * uint64_t(kv.second - 1) / 2; 
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 2436
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        
        if(B - A <= 0) {
            System.out.println("delicious");
        } else if(B - A <= X) {
            System.out.println("safe"); 
        } else {
            System.out.println("dangerous"); 
        }
    }
}


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

sys.setrecursionlimit(10000)


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, K, A):

    sa = [0]
    sa0 = [0]
    for a in A:
        sa.append(sa[-1]+a)
        sa0.append(sa0[-1]+max(0, a))

    ans = 0
    for i in range(N-K+1):
        l = sa0[i]
        r = sa0[-1] - sa0[i+K]
        c = sa[i+K] - sa[i]
        ans = max(ans, l + r)
        ans = max(ans, l + c + r)

    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 93020
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,t;
  cin>>n>>t;

  vector<int> as(n),bs(n);
  for(int i=0;i<n;i++) cin>>as[i]>>bs[i];

  using P = pair<int, int>;
  vector<P> vp;
  for(int i=0;i<n;i++) vp.emplace_back(as[i],bs[i]);
  sort(vp.begin(),vp.end());
  for(int i=0;i<n;i++) tie(as[i],bs[i])=vp[i];

  const int INF = 1e9;
  vector<int> dp(t,-INF);
  dp[0]=0;
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=t-1;j>=0;j--){
      chmax(ans,dp[j]+bs[i]);
      if(j+as[i]<t)
        chmax(dp[j+as[i]],dp[j]+bs[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int n, p[20], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> p[i];
	for (int i = 0; i < n - 2; ++i) {
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])cnt = cnt + 1;
		if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])cnt = cnt + 1;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int A, B; // A: whiteNum, B: blackNum
	int aCount = 0, bCount = 0;
	boolean[][] grid; // white = true, black = false
	final int W = 100, H = 100;

	private Main() {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		A = Integer.parseInt(tokens[0]);
		B = Integer.parseInt(tokens[1]);
		in.close();
		grid = new boolean[H][W];
		for (int i = 0; i < H / 2; ++i) {
			Arrays.fill(grid[i], true);
		}
		for (int i = H / 2; i < H; ++i) {
			Arrays.fill(grid[i], false);
		}
	}

	private void calc() {
		for (int i = 0; i < A - 1; ++i) {
			drawWhite(i);
		}
		for (int i = 0; i < B - 1; ++i) {
			drawBlack(i);
		}
	}

	private void drawBlack(int blackIndex) {
		int step = W / 2;
		int w = (blackIndex % step) * 2;
		int h = Math.floorDiv(blackIndex, step) * 2;
		grid[h][w] = false;
	}

	private void drawWhite(int whiteIndex) {
		int step = W / 2;
		int w = whiteIndex % step * 2;
		int h = (H - 1) - (Math.floorDiv(whiteIndex, step) * 2);
		grid[h][w] = true;
	}

	private void show() {
		System.out.println("100 100");
		for (int h = 0; h < H; ++h) {
			for (int w = 0; w < W; ++w) {
				if (grid[h][w]) {
					System.out.print(".");
				} else {
					System.out.print("#");
				}
			}
			System.out.println("");
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}
}

Measured memory_bytes: 25044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;

int main() {
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, x, l;
    cin >> n;
    vector<pair<ll, ll>> a(n);
    rep(i, n) {
        cin >> x >> l;
        a[i] = {x + l, x - l};
    }
    sort(all(a));
    ll ans = 0, cm = -2e9;
    for (auto &pp : a)
        if (pp.second >= cm) {
            ans++;
            cm = pp.first;
        }
    cout << ans;
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				a[i][j] = Integer.parseInt(sa[j]);
			}
		}
		br.close();

		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				boolean need = true;
				int r1 = a[i][j];
				for (int k = 0; k < n; k++) {
					if (i == k || j == k) {
						continue;
					}
					int r2 = a[i][k] + a[k][j];
					if (r1 > r2) {
						System.out.println(-1);
						return;
					}
					if (r1 == r2) {
						need = false;
					}
				}
				if (need) {
					ans += r1;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 34392
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string s;
    cin >> s;
    //if (s.compare("2019/05/30") <= 0)
    if (s <= "2019/04/30")
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	int minX=1001;
	int maxX=-1;
	int a;
	for (i=0;i<N;i++){
		cin>>a;
		minX=min(minX,a);
		maxX=max(maxX,a);
	}
	cout<<maxX-minX<<endl;

	return 0;
}

Measured memory_bytes: 384
import Control.Monad (replicateM)
 
main :: IO ()
main = do
  [n,m] <- map (read :: String -> Int) . words <$> getLine
  am <- map (read :: String -> Int) <$> getNLine_ m
  print $ ans am n

ans :: [Int] -> Int -> Int
ans am n = (\(a,b,c) -> a `mod` (10^9+7)) $ foldl func (0,1,1) (am ++ [n+1]) where
  func (a,b,k) l
    | k == l = (b,0,k+1)
    | otherwise = func (b,(a+b) `mod` (10^9+7),k+1) l

getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine


Measured memory_bytes: 36220
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let x = v[0];
    let y = v[1];
    println!("{}", x + y / 2);
}


Measured memory_bytes: 4352
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll N,K,Q;
	cin >> N >> K >> Q;

	vector<ll> A(N);

	fi(N) {
		A[i] = K - Q;
	}

	fi(Q) {
		int t;
		cin >> t;
		t -= 1;
		A[t] += 1;
	}

	fi(N) {
		if (A[i] > 0) {
			ce("Yes")
		}
		else {
			ce("No")
		}
	}




}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> T(N);
    for (int i = 0; i < N; i++) {
        std::cin >> T[i];
    }

    int M;
    std::cin >> M;

    std::vector<int> P(M), X(M);
    for (int i = 0; i < M; i++) {
        std::cin >> P[i] >> X[i];
    }

    std::vector<int> ans;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += T[i];
    }

    for (int i = 0; i < M; i++) {
        int temp = sum;
        temp -= T[P[i] - 1];
        temp += X[i];
        ans.push_back(temp);
    }

    for (int i = 0; i < M; i++) {
        std::cout << ans[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader =
            new BufferedReader(new InputStreamReader(System.in));

        String[] line = reader.readLine().split(" ");
        int[] num = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            num[i] = Integer.parseInt(line[i]);
        }

        for (int i = 0; i < num.length - 1; i++) {
            for (int j = i + 1; j < num.length; j++) {
                if (num[i] > num[j]) {
                    int w = num[i];
                    num[i] = num[j];
                    num[j] = w;
                }
            }
        }
        System.out.println(num[0] + " " + num[1] + " " + num[2]);
    }
}

Measured memory_bytes: 24376
#include<cstdio>
#include<algorithm>
struct r{
	int p,c;
}a[15];
int sum,dp[1050],d,g;
int main(){
	scanf("%d%d",&d,&g);
	for (int i=1;i<=d;i++)scanf("%d%d",&a[i].p,&a[i].c),sum+=a[i].p;
	for (int j=1;j<=d;j++)
		for (int i=sum;i>=1;i--){
			if (i>=a[j].p)dp[i]=std::max(dp[i-a[j].p]+a[j].c+a[j].p*j*100,dp[i]);
			for (int k=1;k<a[j].p;k++)if (i>=k)dp[i]=std::max(dp[i-k]+k*j*100,dp[i]);
		}
	for (int i=1;i<=sum;i++)if (dp[i]>=g){
		printf("%d\n",i);
		return 0;
	}
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

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

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    ll s;
    cin >> s;

    ll x = floor(sqrt(s));
    while (x * x < s) x++;

    // (a, b), (c, d)
    // a * d - b * c = s;
    ll a = x;
    ll d = x;
    ll b = 1;
    ll c = x * x - s;

    cout << 0 << " " << 0 << " " << a << " " << b << " " << c << " " << d << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = LIST()
cnt = 0
tmp = 0
i = 0
# for i, a in enumerate(L):
while i < N:
    if L[i] == i + 1:
        cnt += 1
        i += 1
    i += 1
print(cnt)
    



Measured memory_bytes: 21868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

const int maxn = 200005;
vector<int> col(maxn, -1);
vector<vector<pii> > g(maxn);

void dfs(int now) {
    for (pii nxt : g[now]) {
        if (col[nxt.F] == -1) {
            col[nxt.F] = col[now] ^ (nxt.S % 2);
            dfs(nxt.F);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    rep(i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        
        g[u].eb(pii(v, w));
        g[v].eb(pii(u, w));
    }
    col[0] = 0;
    dfs(0);
    
    rep(i, n) cout << col[i] << endl;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    dump(s[2] == s[3] and s[4] == s[5] ? "Yes" : "No");
    return 0;
}

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

using namespace std;

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

int adjMat[10][10];
main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<10;++i) for(int j=0;j<10;++j){
        scanf("%d",&adjMat[i][j]);
    }
    int p[10][10];
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            p[i][j] = i;
        }
    }
    for(int k=0;k<10;k++)
        for(int i=0;i<10;++i)
            for(int j=0;j<10;++j)
                adjMat[i][j] = min(adjMat[i][j],adjMat[i][k] + adjMat[k][j]);
    ll sum = 0;
    int val;
    for(int i=0;i<n;++i) for(int j=0;j<m;++j){
        scanf("%d",&val);
        if(val!=-1 and val!=1) sum+= adjMat[val][1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{  
   int k;
   scanf("%d",&k);
   int total=0;
   for(int i=1;i<=(1e7);i++){
     total=(total*10+7)%k;
     if(total==0){
     printf("%d\n",i);
     return 0;}
   }
  printf("-1\n");

}

Measured memory_bytes: 1716
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}
func main() {
	N := readInt()
	M := readInt()
	Q := readInt()
	data := make([][]int, 510)
	for i := 0; i < len(data); i++ {
		data[i] = make([]int, 510)
	}
	for i := 0; i < M; i++ {
		l, r := readInt(), readInt()
		data[l][r]++
	}

	for i := N; i >= 1; i-- {
		for j := 1; j <= N; j++ {
			data[i][j] += data[i+1][j]
			data[i][j] += data[i][j-1]
			data[i][j] -= data[i+1][j-1]
		}
	}

	for i := 0; i < Q; i++ {
		p, q := readInt(), readInt()
		println(data[p][q])
	}
	stdout.Flush()
}

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

int main(){
    ll n, t; cin >> n >> t;
    vector<ll> lis(n, 0);
    priority_queue<ll, vector<ll>, greater<ll>>  pq;
    ll a; cin >> a;
    pq.push(a);
    ll dif = 0, count = 0;
    for(int i = 1; i < n; i++){
        ll mid; cin >> mid;
        ll k = pq.top();
        if(dif < mid - k){
            dif = mid - k;
            count = 1;
        }else if(dif == mid - k){
            count++;
        }
        pq.push(mid);
    }
    cout << count << endl;
}

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

using namespace std;
     
const int maxe=2e5+20;
pair <int,int> p[maxe];
bool mark[maxe];

int main(){
    int n,m;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        mark[i]=false;
        }
    for(int i = 0 ; i < m ; i++){
        cin >> p[i].first >> p[i].second;
        if(p[i].second==n){
            mark[p[i].first]=true;
            }
        }
    sort(p,p+m);
    int k=0;
    while(p[k].first==1){
        if(mark[p[k].second]==true){
            cout << "POSSIBLE";
            return 0;
    		}
        k++;
        }
    cout << "IMPOSSIBLE";
   	return 0;
    }

Measured memory_bytes: 2048
#include <iostream>
#include <set>
#include <algorithm>
#include <cstring>
#define N 100005

char str[N]; int len, mid;
std::pair<int, int> ops[N]; int opscnt;

inline void merge_ops()
{
	static std::set<int> rs[N];
	for(int i = 0; i < opscnt; ++i)
		rs[ops[i].first].insert(ops[i].second);

	opscnt = 0;
	for(int l = 1; l <= mid; ++l)
	{
		std::set<int> &cur = rs[l];
		if(cur.empty()) continue;

		int r = *cur.begin();
		ops[opscnt++] = std::make_pair(l, r);
		//printf("f->%d %d\n", l, r);
		cur.erase(cur.begin());

		std::set<int> &dest = rs[r + 1];
		if(cur.size() < dest.size())
			for(int i: cur) dest.insert(i);
		else
		{
			for(int i: dest) cur.insert(i);
			dest.swap(cur);
		}
	}
}

inline bool solve()
{
	static int pre[N];
	pre[0] = 0;
	pre[1] = str[1] - 'a';
	for(int i = 2; i <= mid; ++i)
	{
		pre[i] = str[i] - str[i - 1];
		pre[i] = (pre[i] + 26) % 26;
	}

	int k = 1;
	for(int o = 0; o < opscnt; ++o)
	{
		const std::pair<int, int> &cur = ops[o];
		for(; k <= cur.first; ++k)
		{
			pre[k] += pre[k - 1];
			pre[k] = (pre[k] + 26) % 26;
		}
		int d = int(str[len - cur.first + 1]) - pre[cur.first] - 'a';
		pre[cur.first] += d;
		pre[cur.first] = (pre[cur.first] + 26) % 26;
		pre[cur.second + 1] -= d;
		pre[cur.second + 1] = (pre[cur.second + 1] + 26) % 26;
	}
	for(; k <= mid; ++k)
	{
		pre[k] += pre[k - 1];
		pre[k] = (pre[k] + 26) % 26;
	}

	for(int i = 1; i <= mid; ++i)
	{
		if(pre[i] != str[len - i + 1] - 'a')
			return false;
	}
	return true;
}

int main()
{
	int _;
	scanf("%s%d", str + 1, &_);
	len = strlen(str + 1);
	mid = len >> 1;

	opscnt = 0;
	for(int i = 0; i < _; ++i)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		if(l - 1 > (len - r))
		{
			l = len - l + 1;
			r = len - r + 1;
			std::swap(l, r);
		}
		if(r > mid) r = len - r;

		if(l <= r)
			ops[opscnt++] = std::make_pair(l, r);
	}

	merge_ops();

	if(solve()) printf("YES\n");
	else printf("NO\n");

	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> chi(n);
        for (int i = 1; i <= n-1; i++) {
                int x; cin >> x;
                chi[x-1]++;
        }

        for (int i = 0; i < n; i++) cout << chi[i] << '\n';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3924
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
d=0
for i in range(n):
       a=list(map(int,input().split()))
       e=0
       for j in range(m):
       		e+=a[j]*b[j]
       if e>-c:
       		d+=1
print(d)

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

int main() {
	string s, t; cin >> s >> t;
	int as[26] = {0}, at[26] = {0};
	for (int i = 0; i < s.size(); i++) {
	    as[s[i] - 'a']++;
	    at[t[i] - 'a']++;
	}
	map <int, int> M1, M2;
	for (int i = 0; i < 26; i++) M1[as[i]]++, M2[at[i]]++;
	if (M1.size() != M2.size()) {
	    cout << "No\n";
	    return 0;
	}
	int y = 1;
	for (int i = 0; i < 26; i++) 
	    y &= M1[as[i]] == M2[as[i]];
	
	if (y) cout << "Yes\n";
	else cout << "No\n";
 	return 0;
}

Measured memory_bytes: 776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const ll INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<pii> balls;
ll max_val,min_val;
int main() {
  max_val = 0;
  min_val = INF;
  cin >> N;
  balls.resize(N);
  for (auto &val : balls){
    cin >> val.first >> val.second;
    if(val.first > val.second){
      swap(val.first, val.second);
    }
    max_val = max(max_val, (ll)val.first);
    max_val = max(max_val, (ll)val.second);

    min_val = min(min_val, (ll)val.first);
    min_val = min(min_val, (ll)val.second);
  }
  sort(balls.begin(), balls.end());
  ll result = INF;
  //R_max = max_val, B_min = min_val
  {
    ll R_max,R_min;
    ll B_max,B_min;
    R_max = 0;
    R_min = INF;

    B_max = 0;
    B_min = INF;
    for (const auto &val : balls){
      ll a = val.first;
      ll b = val.second;
      ll big = max(a, b);
      ll small = min(a, b);
      R_max = max(R_max, big);
      R_min = min(R_min, big);
      B_max = max(B_max, small);
      B_min = min(B_min, small);
    }
    result = min(result, (R_max - R_min) * (B_max - B_min));
  }
  //R_max = max_val, R_min = min_val
  {
    ll B_max,B_min;
    B_max = 0;
    B_min = INF;
    ll val1 = (max_val - min_val);
    map<ll, int> R,B;
    for (const auto &val : balls){
      R[val.first]++;
      B[val.second]++;
    }
    for (int i = N - 1; i >= 0; i--){
      pii p = balls[i];
      int a = p.first;//pre R
      int b = p.second;//pre B
      R[a]--;
      B[b]--;
      if (R[a] == 0){
        R.erase(a);
      }
      if (B[b] == 0){
        B.erase(b);
      }
      R[b]++;
      B[a]++;

      B_max = (*B.rbegin()).first;
      B_min = (*B.begin()).first;
      // cout << B_max << " " << B_min << endl;
      result = min(result, val1 * (B_max - B_min));
    }
  }
  cout << result << endl;
  return 0;

}


Measured memory_bytes: 26752
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e7 + 1;
ll arr[N];
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    for(i = 1; i < N; i++){
        for(j = i; j < N; j += i){
            arr[j]++;
        }
    }
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        ll ans = 0;
        for(i =1; i <= n; i++){
            ans += i * arr[i];
        }   
        cout << ans;
    }

    return 0;
}


Measured memory_bytes: 81744
n = int(input())
s = [input() for i in range(n)]
ac = s.count("AC")
wa = s.count("WA")
tle = s.count("TLE")
re = s.count("RE")

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 16164
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]

#累積
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
    
#タプルのアンパック → ans=0,j=M
ans, j = 0, M

#Aの本を0冊読むとき、Bは何冊読めるか → N冊まで繰り返す
for i in range(N+1):
    if K<a[i]: break
    while b[j]>K-a[i]:
        j-=1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47252
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string commands[100];
int ischecked[100];
int n;
int solve(int pos,int delcount)
{;
  if(pos == n)
    return delcount;
  if(ischecked[pos] == 1)
    return 10000;
  if(commands[pos].find("goto") != -1)
  {
    for(int i = 0;i<n;i++)
    {
      if(commands[i] == commands[pos].substr(5))
      {
//        cout<<"jump "<<pos<<" to "<<i<<endl;
        ischecked[pos] = 1;
        int j = solve(i+1,delcount);
        ischecked[pos] = 0;
        commands[pos] = "";
        int k = solve(pos+1,delcount+1);
        commands[pos] = "goto " + commands[i];
        return min(j,k);
      }
    }
  }
  return solve(pos+1,delcount);
}
int main(void)
{
  cin>>n;
  for(int i = 0;i<n;i++)
  {
    ischecked[i] = 0;
    string buf;
    cin>>buf;
    if(buf == "goto")
    {
      cin>>buf;
      commands[i] = "goto " + buf.substr(0,buf.length()-1);
    }else
      commands[i] = buf.substr(0,buf.length()-1);
  }
  cout<<solve(0,0)<<endl;
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N,K;
int w[maxn],min_w = 1e9;
int f[maxn][2];

bool dfs(int k,int p){
    if(k<min_w) return 0;
    if(f[k][p] != -1) return f[k][p];
    int nx = 1;
    for(int i = 1;i<=N;i++) if(k>=w[i]) nx = nx & dfs(k-w[i],p^1);
    return f[k][p] = nx ^ 1;
}

int main(){
    // debug;
    ios;

    cin>>N>>K;
    for(int i = 1;i<=N;i++) cin>>w[i],min_w = min(min_w,w[i]);
    memset(f,-1,sizeof f);
    dfs(K,0);
    if(f[K][0] == 1) cout<<"First\n";
    else cout<<"Second\n";
    
    return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
    ll x;   cin >> x;
    ll l = 0, r = x+1;  //l以上rより小さい
    ll mid, y;
    while (l < r) {
        mid = (l+r)/2;
        y = mid*(mid+1)/2;
        if (y < x && x <= y+(mid+1))
            break;
        else if (x <= y) 
            r = mid;
        else 
            l = mid+1;
    }

    cout << mid + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def prime(x):
    if x == 2:
        return True
    elif x%2 == 0:
        return False
    else:
        i = 3
        while i <= math.sqrt(x):
           if x%i == 0:
                return False
           else:
                i += 2
        return True

        
        

p = 0
n = int(input())

for i in range(n):
    if prime(int(input())) == True:
        p += 1
        

print(p)

Measured memory_bytes: 6616
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];
		for(int i = 0; i < h; i++) {
			a[i] = sc.next();
		}
		for(int i = 0; i < w+2; i++) {
			System.out.print("#");
		}
		System.out.println();
		for(int i = 0; i < h; i++) {
			System.out.println("#" + a[i] + "#");
		}
		for(int i = 0; i < w+2; i++) {
			System.out.print("#");
		}
	}
}


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

int n;
int a, b, c, d;
bool a_can_reach[200010];
bool b_can_reach[200010];

string S;

int main() {
  cin >> n >> a >> b >> c >> d >> S;
  a--;b--;c--;d--;

  // Bが到達可能か
  b_can_reach[b] = true;
  for(int i = b+1; i < n; i++) {
    if( S[i] == '.' && (b_can_reach[i-1] || b_can_reach[i-2]) )
      b_can_reach[i] = true;
    else
      b_can_reach[i] = false;
  }

  // Bを無視してAが到達可能か
  a_can_reach[a] = true;
  for(int i = a+1; i < n; i++) {
    if( S[i] == '.' && (a_can_reach[i-1] || a_can_reach[i-2]) )
      a_can_reach[i] = true;
    else
      a_can_reach[i] = false;
  }

  // C < D なら 個別にゴールを目指す
  if( c < d ) {
    cout << ( (b_can_reach[d] && a_can_reach[c]) ? "Yes" : "No" ) << endl;
  }
  // D < C なら DまででAとBの前後関係を入れ替える必要がある
  else {
    bool can_swap = false;

    int count = 0; // 連続して現れる1の数
    for(int i = b; i <= d+1; i++) {
      if(b_can_reach[i])
        count++;
      else
        count = 0;

      if(count >= 3) {
        can_swap = true;
        break;
      }
    }
    // 例外処理
    if(a_can_reach[b-1] && b_can_reach[b] && b_can_reach[b+1])
      can_swap = true;

    cout << ( (can_swap && b_can_reach[d] && a_can_reach[c]) ? "Yes" : "No" ) << endl;
  }
}

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

def main():
    s = input()
    abc = [chr(i) for i in range(ord('a'), ord('a')+26)]
    
    for i in abc:
        if i not in s:
            print(i)
            exit()
    print('None')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
n, m = map(int, input().split())
import math
if math.fabs(n-m)>=2:
    print(0)
elif math.fabs(n-m)==1:
    x=math.factorial(n)*math.factorial(m)
    y=x%1000000007
    print(y)
else:
    a=math.factorial(m)
    b=a*a
    c=2*b
    d=c%1000000007
    print(d)


Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e18
#define mod pow(10,9)+7
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)

int32_t main()
{
	//c_p_c();
	string s;
  cin>>s;
  int i;
  bool b=false;
  int l=s.length();
  for(i=0;i<l;i++){
    if(s[i]==s[i+1])
       {
         b=true;
         break;
       }
    }
	if(b) cout<<"Bad";
       else cout<<"Good";
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
         public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n=in.nextInt();
            long a[]=new long[n],b[]=new long[n];
            for(int i=0;i<n;i++)a[i]=in.nextLong();
            for(int i=0;i<n;i++)b[i]=in.nextLong();
            long n1=0,n2=0;
            for(int i=0;i<n;i++){
             if(a[i]<b[i]){
              if((b[i]-a[i])%2!=0){
               n1++;n2+=(b[i]-a[i]+1)/2;
              }else n2+=(b[i]-a[i])/2;
             }else if(b[i]<a[i]){
              n1+=a[i]-b[i];
             }
            }//System.out.println(n1+" "+n2);
            if(n2>=n1)out.print("Yes");else out.print("No");
         }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 27828
N, M = map(int, input().split())
sc = [list(map(int, input().split()))for i in range(M)]
ans="-1"
tmp=0
for i in range(0,10**N):
	if N>2:
		s = str('{:0=3}'.format(i))
	elif N>1:
		s = str('{:0=2}'.format(i))
	else:
		s = str(i)
	#print(s)
	for j in range(M):
		if s[sc[j][0]-1]!=str(sc[j][1]):
			break
	else:
		if N>0 and s[0]!="0" or N==1:
			ans=s
			break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k;
    string s;
    cin>>s>>k;
    if(s.length() == 1)
    {
        cout<<k/2<<endl;
        exit(0);
    }
    long long ans1=0,ans2=1;
    int dif = 1;
    for(int i=0;i<s.length();i++)
    {
        if(dif || s[i] != s[i-1])
        {
            dif = 0;
            continue;
        }
        ans1++;
        dif=1;
    }
    int last = dif;
    dif=1;
    for(int i=1;i<s.length();i++)
    {
        if(dif || s[i] != s[i-1])
        {
            dif = 0;
            continue;
        }
        ans2++;
        dif=1;
    }
    int last1 = dif;
    if(last == 1)
    {
        cout<<ans1*k<<endl;
        exit(0);
    }
    if(last == 0 && s[s.length()-1]!=s[0])
    {
        cout<<ans1*k<<endl;
        exit(0);
    }
    if(last1 == 0)
    {
        cout<<ans1+ans2*(k-1)<<endl;
    }
    else
    {
        cout<<ans1*(k-k/2)+ans2*(k/2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int a, b, c;
	ll k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 1) cout << b - a << endl;
	else cout << a - b << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

bool p[55556];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());
  int n;cin>>n;
  vector<int> v;
  // v.push_back(2);
  p[1]=true;
  for(int i=2;i<=sqrt(55556);i++){
    if(!p[i]){
      for(int j=i+i;j<=55556;j+=i){
        p[j]=true;
      }
    }
  }
  for(int i=2;i<=55555;i++){
    if(p[i]==false && i%5==1)v.push_back(i);
  }
  sort(v.begin(),v.end());
  // P((int)v.size());
  // REP(i,(int)v.size()){
  //   P(v[i]);
  // }
  REP(i,n){
    P(v[i]);
  }
  return 0;
}


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

int main(void) {
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;
  string s;
  for(int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AC") ac++;
    else if (s == "WA") wa++;
    else if (s == "TLE") tle++;
    else re++;
  }
  cout << "AC x " << ac << '\n';
  cout << "WA x " << wa << '\n';
  cout << "TLE x " << tle << '\n';
  cout << "RE x " << re << '\n';
}

Measured memory_bytes: 3652
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
M = 200000
UD = [[] for _ in range(2 * M + 10)]
RL = [[] for _ in range(2 * M + 10)]

RU = [[] for _ in range(2 * M + 10)]
RD = [[] for _ in range(2 * M + 10)]
LU = [[] for _ in range(2 * M + 10)]
LD = [[] for _ in range(2 * M + 10)]

for _ in range(N):
    x, y, di = input().split()
    x, y = int(x), int(y)
    if di == "R":
        RL[y].append(x * 2)
        RU[x+y].append(x * 2)
        RD[x-y+M].append(x * 2)
    elif di == "L":
        RL[y].append(x * 2 + 1)
        LU[x-y+M].append(x * 2 + 1)
        LD[x+y].append(x * 2 + 1)
    elif di == "U":
        UD[x].append(y * 2)
        RU[x+y].append(x * 2 + 1)
        LU[x-y+M].append(x * 2)
    elif di == "D":
        UD[x].append(y * 2 + 1)
        RD[x-y+M].append(x * 2 + 1)
        LD[x+y].append(x * 2)

def chk(XX):
    def subchk(X):
        t = - (1 << 100)
        re = 1 << 100
        for x in sorted(X):
            a = x >> 1
            b = x & 1
            if b == 0:
                t = a
            else:
                re = min(re, a - t)
        return re * 10
    
    RE = 1 << 100
    for xx in XX:
        RE = min(RE, subchk(xx))
    return RE

ans = 1 << 100
ans = min(ans, chk(UD) // 2)
ans = min(ans, chk(RL) // 2)
ans = min(ans, chk(RU))
ans = min(ans, chk(RD))
ans = min(ans, chk(LU))
ans = min(ans, chk(LD))

print("SAFE" if ans > 1 << 80 else ans)


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

using namespace std;

int main(){
   int L;
   cin >> L;
   double ans=L*L*L;
   ans /= 27;
   cout << fixed << setprecision(10) << ans << endl;
   return 0;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	 char ch=nc(); int i=0,f=1;
	 while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	 while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	 return i*f;
}

const int N=1e5+50;
int n,rt=1,tag=0;
vector <int> edge[N];
inline int dfs(int x,int f) {
	if(tag) return 1;
	int cnt=0;
	for(auto v:edge[x]) 
		if(v^f) cnt+=dfs(v,x);
	if(!cnt) return 1;
	else if(cnt==1) return 0;
	else return tag=1;
}
int main() {
	n=rd();
	if(n==2) return puts("Second"),0;
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd();
		edge[x].push_back(y);
		edge[y].push_back(x);
	} 
	while(edge[rt].size()<2) ++rt;
	cout<<((dfs(rt,0)||tag)?"First":"Second");
}

Measured memory_bytes: 6144