akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        string s = sc.NextString();
        long k = sc.NextLong(); // < 10 ^ 18
        long c = 5000000000000000; // = 5 * 10^15
        // 2^(10^15) vs 10^18
        int i = 0;
        while (i < s.Length - 1 && s[i] == '1') i++;
        Console.WriteLine(i >= k ? s[0] : s[i]);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= t * s ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

int dx[4] = { 0, 0, -1, 1 };
int dy[4] = { 1, -1, 0, 0 };
char dw[4] = { 'U', 'D', 'L', 'R' };
const int MAXX = 2000 + 1;
bool grid[MAXX][MAXX];
bool bann[MAXX][MAXX];

string bfs(int sx, int sy, int tx, int ty) {
	queue<int> nextX;
	queue<int> nextY;
	queue<string> nextW;
	nextX.push(sx);
	nextY.push(sy);
	nextW.push("");
	while (!nextX.empty()) {
		int x = nextX.front();
		int y = nextY.front();
		string way = nextW.front();
		nextX.pop();
		nextY.pop();
		nextW.pop();
		grid[x][y] = true;
		if (x == tx && y == ty) {
			x = sx;
			y = sy;
			for (int i = 0; i < way.size(); ++i) {
				if (way[i] == 'U')
					y++;
				else if (way[i] == 'D')
					y--;
				else if (way[i] == 'L')
					x--;
				else if (way[i] == 'R')
					x++;
				bann[x][y] = true;
			}
			bann[sx][sy] = bann[tx][ty] = false;
			return way;
		}
		for (int k = 0; k < 4; ++k) {
			int nx = x + dx[k];
			int ny = y + dy[k];
			if (0 <= nx && nx < MAXX && 0 <= ny && ny < MAXX
					&& grid[nx][ny] == false && bann[nx][ny] == false) {
				nextX.push(nx);
				nextY.push(ny);
				nextW.push(way + dw[k]);
				grid[sx][sy] = grid[tx][ty] = false;
			}
		}
		grid[x][y] = false;
	}
	return "can't";
}

void solve() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
}

void nogood_solve() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	sx += 1000;
	sy += 1000;
	tx += 1000;
	ty += 1000;
	for (int i = 0; i < MAXX; ++i) {
		for (int k = 0; k < MAXX; ++k) {
			grid[i][k] = false;
			bann[i][k] = false;
		}
	}
	string way = "";
	way += bfs(sx, sy, tx, ty);
	way += bfs(tx, ty, sx, sy);
	way += bfs(sx, sy, tx, ty);
	way += bfs(tx, ty, sx, sy);
	cout << way << endl;
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
program ABC043B
    implicit none
    integer(8)::i
    integer(8)::cursor=1
    character(10)::s
    character(10)::out
    read(5,*)s

    do i=1,len_trim(s)
        if(s(i:i)=="0")then
            out(cursor:cursor)="0"
            cursor=cursor+1
        else if(s(i:i)=="1")then
            out(cursor:cursor)="1"
            cursor=cursor+1
        else
            cursor=max(1,cursor-1)
        end if
    end do

    cursor=max(1,cursor-1)

    print'(A)',out(1:cursor)
end program ABC043B

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;

const int MAX_V=210;
ll dL[MAX_V][MAX_V];
ll dS[MAX_V][MAX_V];
int V;
void warshall_floyd(){

  for(int k=0;k<V;k++)
    for(int i=0;i<V;i++)
      for(int j=0;j<V;j++)
	dL[i][j]=min(dL[i][j],dL[i][k]+dL[k][j]);
  return;
}
void warshall_floyd2(){

  for(int k=0;k<V;k++)
    for(int i=0;i<V;i++)
      for(int j=0;j<V;j++)
	dS[i][j]=min(dS[i][j],dS[i][k]+dS[k][j]);
  return;
}
int main(){
  int n,m;
  while(cin>>n>>m,n){
  for(int i=0;i<MAX_V;i++)
    for(int j=0;j<MAX_V;j++){
      if(i==j)
	dL[i][j]=0;
      else
	dL[i][j]=llINF;
    }
  for(int i=0;i<MAX_V;i++)
    for(int j=0;j<MAX_V;j++){
      if(i==j)
	dS[i][j]=0;
      else
	dS[i][j]=llINF;
    }
    V=n;
    for(int i=0;i<m;i++){
      ll x,y,t;
      char s;
      cin>>x>>y>>t;
      cin>>s;
      x--;y--;
      if(s=='L'){
	dL[x][y]=t;
	dL[y][x]=t;
      }else{
	dS[x][y]=t;
	dS[y][x]=t;
      }
    }
    warshall_floyd();
    warshall_floyd2();
    int r;cin>>r;
    ll dp[r+10][n+10];
    for(int i=0;i<r+10;i++)
      for(int j=0;j<n+10;j++)
	  dp[i][j]=llINF;
    int fffff;cin>>fffff;
    dp[0][fffff-1]=0;
    int v[r+10];
    v[0]=fffff-1;
    for(int i=1;i<r;i++){
      cin>>v[i];
      v[i]--;
    }
    for(int i=1;i<r;i++){
      for(int j=0;j<n;j++){
	if(dp[i-1][j]!=llINF){
	  dp[i][j]=min(dp[i][j],dp[i-1][j]+dL[v[i-1]][v[i]]);
	  for(int k=0;k<n;k++){
	    dp[i][k]=min(dp[i][k],dp[i-1][j]+dL[v[i-1]][j]+dS[j][k]+dL[k][v[i]]);
	  }
	}
      }
    }
    ll ans=llINF;
    for(int j=0;j<n;j++){
      // cout<<dp[i][j]<<" ";
      ans=min(ans,dp[r-1][j]);
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 5368
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int ans;
int N;

char c[] = {'7', '5', '3'};

void dfs(string s, int n, int k) {
    if (n == k) {
        int b = 0;
        REP(i, s.size()) {
            switch (s[i]) {
                case '7':
                    b |= (1 << 0);
                    break;
                case '5':
                    b |= (1 << 1);
                    break;
                case '3':
                    b |= (1 << 2);
                    break;
            }
        }

        if (b != 7) return;
        int a = stol(s);
        if (a <= N) ans++;
        return;
    }
    REP(i, 3) {
        dfs(s + c[i], n, k + 1);
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> N;

    FOR(i, 1, 10) {
        dfs("", i, 0);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].append(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for adj in range(y_num):
        if adj in adj_table[current] and not visited[adj]:
            visited[adj] = True
            if matching[adj] == -1 or graph_dfs(matching[adj], matching, visited):
                matching[adj] = current
                return True
    return False


def mbm():
    matching = [-1] * y_num
    res = 0
    for v in range(x_num):
        visited = [False] * y_num
        if graph_dfs(v, matching, visited):
            res += 1
    # print(matching)
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    # v_num = x_num + y_num
    init_adj_table = [[] for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int lb = 0, lw = 0, rb = 0, rw = 0, m;
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == '#')
            rb++;
        else
            rw++;
    }
    m = lb + rw;
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == '#')
        {
            lb++;
            rb--;
        }
        else
        {
            lw++;
            rw--;
        }
        if (m > lb + rw)
            m = lb + rw;
    }

    cout << m << endl;
}

Measured memory_bytes: 768
#-------------------------------------------------------------------------------
# Name:        module2
# Purpose:
#
# Author:      ysakamot
#
# Created:     15/12/2018
# Copyright:   (c) ysakamot 2018
# Licence:     <your licence>
#-------------------------------------------------------------------------------

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    print 0
    sys.stdout.flush()

    input_raw = read_func().strip().split()
    s = (input_raw[0])
    if s == "Vacant":
        return
    zero = s

    print N - 1
    sys.stdout.flush()
    input_raw = read_func().strip().split()
    s = (input_raw[0])
    if s == "Vacant":
        return
    L = 0
    R = N - 1
    while 1:
        M = (R + L)/2
        if R - L == 2:
            print M
            sys.stdout.flush()
            input_raw = read_func().strip().split()
            s = (input_raw[0])
            if s == "Vacant":
                return

        if M % 2 == 1:
            M += 1

        print M
        sys.stdout.flush()
        input_raw = read_func().strip().split()
        s = (input_raw[0])
        if s == "Vacant":
            return
        if s == zero:
            L = M
        else:
            R = M


if __name__ == '__main__':
    main()


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

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

int main(){
    int N,K,G,M;
    int A;
    cin >> N >> K;
    cin >> A;
    M = G = A;
    for (int i = 1; i < N; i++)
    {
        cin >> A;
        G = gcd(G,A);
        if(M < A) M = A;
    }
    if(K%G==0 and K <= M) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}	

Measured memory_bytes: 3584
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100010;

char str[MAXN], st[MAXN];
int a[MAXN];

int main ()
{
    scanf ("%s", &str);
    int len = strlen (str), k = 0;
    for (int i = 0; i < len; i ++)
    {
        if (str[i] != 'x')
        {
            st[k] = str[i];
            a[k] = i;
            k ++;
        }
    }
    st[k] = '\0';
    int x = 0, y = k - 1;
    bool flag = true;
    while (x <= y)
    {
        if (st[x] != st[y])
        {
            flag = false;
            break;
        }
        else
        {
            x ++, y --;
        }
    }
    if (!flag)
    {
        printf ("-1\n");
    }
    else
    {
        int ans = 0;
        int x = 0, y = len - 1;
        while (x <= y)
        {
            if (str[x] == str[y])
            {
                x ++, y --;
            }
            else if (str[x] == 'x')
            {
                ans ++;
                x ++;
            }
            else
            {
                ans ++;
                y --;
            }
        }
        printf ("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 768
# 二つの正整数 a,b
# a,bの積が偶数か奇数か判定
# 奇数ならOdd 偶数ならEvenと出力

# a bの形で標準入力された値を加工
a,b = map(int , input().split())

#a,bの積が偶数 == 2で割って余り0
if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Measured memory_bytes: 9028
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d", &n);
    int rate[9+5]={0};
    
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        if(a<3200)rate[a/400]=1;
        else rate[8]+=1;
    }
    
    int min=0;
    for(int i=0; i<8; i++)min+=rate[i];
    
    if(min==0){
        min++;
        rate[8]--;
    }
    printf("%d %d\n", min, min+rate[8]);
    
    return 0;
}


Measured memory_bytes: 1688
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)
#define infty 2110001000

signed main(void){
  int i, j;
  for(int testcase = 0;;testcase++){
    int2(n, m);
    int d[n], c[m];
    scn(n, d);  //toshi kyori
    scn(m, c);  //nissuu tenkou

    int dp[n + 1][m + 1];
    rep(i, n + 1)rep(j, m + 1)dp[i][j] = infty;

    rep(j, m + 1)dp[0][j] = 0;
    rep1(j, m + 1)rep1(i, n + 1)
    dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i - 1] * c[j - 1]);

    pri(dp[n][m]);


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 4408
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    loop {
        let n = read::<usize>();
        if n == 0 {
            return;
        }
        let w = read_vec::<i64>();
        let mut dp = vec![vec![0; n + 1]; n + 1];

        for wi in 2..n + 1 {
            for i in 0..n {
                let j = i + wi;
                if j > n {
                    break;
                }

                for k in i..j + 1 {
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
                }
                if wi >= 2 && dp[i + 1][j - 1] == wi - 2 && (w[i] - w[j - 1]).abs() <= 1 {
                    dp[i][j] = wi;
                }
            }
        }
        println!("{}", dp[0][n]);
    }
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}



Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll n; cin >> n;
		if(!n) break;
		vector<P> v;
		v.emplace_back(0,0);
		rep(i,n-1){
			ll m,d; cin >> m >> d;
			v.emplace_back(v[m].first+dx[d], v[m].second+dy[d]);
		}
		ll x=-inf,y=-inf,X=inf,Y=inf;
		rep(i,n){
			chmax(x,v[i].first);
			chmax(y,v[i].second);
			chmin(X,v[i].first);
			chmin(Y,v[i].second);
		}
		print2(x-X+1, y-Y+1);
	}
}


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

int main() {
	int r, D, x2000;

	cin >> r >> D >> x2000;

	int ans = x2000;
	for( int i = 0; i < 10; i++ ) {
		ans = r * ans - D;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
class DoublyLinkedList
  def initialize
    @data = []
  end

  def insert(x)
    @data.unshift x
  end

  def delete(x)
    i = @data.index(x)
    @data.delete_at(i) unless i == nil
  end

  def delete_first
    @data.shift
  end

  def delete_last
    @data.pop
  end

  def description
    @data.join(" ")
  end
end

list = DoublyLinkedList.new
n = gets.to_i
(1..n).each {
  op, x = gets.split(" ")
  case op
    when "insert" then list.insert(x.to_i)
    when "delete" then list.delete(x.to_i)
    when "deleteFirst" then list.delete_first
    when "deleteLast" then list.delete_last
  end
}

puts list.description

Measured memory_bytes: 23064
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int h, w;
vector<int> a, b;

void solve() {
	cin >> h >> w;
    a.resize(h), b.resize(h);
    rep(i, h) {
        cin >> a[i] >> b[i];
        -- a[i];
    }
    set<P> se;
    multiset<int> mse;
    rep(i, w) {
        se.insert(P{i, i});
        mse.insert(0);
    }
    rep(i, h) {
        auto ite = se.lower_bound(P{a[i], -inf});
        int res = -1;
        for(; ite != se.end() and (*ite).fr <= b[i];) {
            chmax(res, (*ite).sc);
            mse.erase(mse.lower_bound((*ite).fr - (*ite).sc));
            ite = se.erase(ite);
        }
        if(res != -1 and b[i] < w) {
            se.insert(P{b[i], res});
            mse.insert(b[i] - res);
        }
        if(mse.empty()) {
            cout << -1 << endl;
        } else {
            cout << i + 1 + *mse.begin() << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 28272
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length) sort(array, array + length, greater<>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // ***  問題のpathを記載 ***
    // https://atcoder.jp/contests/abc155/tasks/abc155_b

    // 標準入力から値を取得
    int n;
    cin >> n;

    // 入力数がN個の場合
    int array[n];
    for (int i = 0; i < n; i++)
    {
        cin >> array[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (array[i] % 2 == 0)
        {
            if (array[i] % 3 != 0 && array[i] % 5 != 0)
            {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
    // 成功時は必ず0を返す
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<vector<P>> vertex(n);
  rep(i, n-1){
  	int a, b, c;cin>>a>>b>>c;
    a--;b--;
    vertex[a].push_back(P(b, c));
    vertex[b].push_back(P(a, c));
  }
  vector<bool> visited(n, false);
  int q, k;cin>>q>>k;k--;
  queue<P> que;que.push(P(k, 0));
  vector<ll> dis(n);
  while(!que.empty()){
  	P p=que.front();que.pop();
    dis[p.first]=p.second;
    visited[p.first]=true;
    for(auto& e: vertex[p.first]){
      if(visited[e.first])continue;
      que.push(P(e.first, e.second+p.second));
    }
  }
  rep(i, q){
  	int x, y;cin>>x>>y;x--;y--;
    cout<<dis[x]+dis[y]<<endl;
  }
  return 0;
}



Measured memory_bytes: 10736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
int map[21][21];

#define NUM 21

int move();

int main(){
	int n;
	int x,y;

	while(cin>>n,n){
		for(int i=0;i<NUM;i++)
			for(int j=0;j<NUM;j++)
				map[i][j]=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			map[x][y]=1;
		}
		if(move()) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


int move(){

	char dir;
	int c,num,d;
	int dx[4]={1,-1,0,0};
	int dy[4]={0,0,1,-1};
	int sx=10;
	int sy=10;

	cin >> c;
	for(int i=0;i<c;i++){
		cin>>dir>>num;
		if(dir=='N') d=2;
		else if(dir=='W') d=1;
		else if(dir=='S') d=3;
		else if(dir=='E') d=0;
		for(int j=0;j<num;j++){
			sx+=dx[d];
			sy+=dy[d];
			map[sx][sy]=0;
		}
	}
	for(int i=0;i<NUM;i++)
		for(int j=0;j<NUM;j++)
			if(map[i][j]==1)
				return 0;
	return 1;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll n,ans;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	forn(i,1,n+1){
		ll now=n/i;
		ans+=now*(now+1)*i/2;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3568
N = int(input())
x = list(map(int, input().split()))

min_dis = 1e10
for p in range(min(x),max(x)+1):
    dis = 0
    for y in x:
        dis += (p-y)*(p-y)
    min_dis = min(dis, min_dis)
print(min_dis)


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

int main() {
  int N;
  cin >> N;
  int kekka = -1;
  vector<int>a(N);
  for(int j = 0; j < N; j++){
    cin >> a.at(j);
  }

  int i = 0;
  int num = 1;
    while(i <100000){
  
    num = a.at(num - 1);
    i++;
    if(num == 2){
      kekka = i;
        break;
    }
    }
   cout << kekka << endl;
  
      
}

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

using namespace std;
int n , m , d , k , t , q , qq ;
int main()
{
	cin >> m >> d ;
	for ( int i = 22 ; i <= d ; i ++ )
	{
		for ( int j = 1 ; j <= m ; j ++ )
		{
			t = i % 10 ;
			q = i / 10 ;
			if ( t >= 2 )
			if ( t * q == j )
			{
				qq ++ ;
			}
		}
	}
	cout << qq ;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 1000005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k,at,mn=inf;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&m);
	m--;
	FOR{
		scanf("%lld",&a[i]);
		if(a[i]<mn) at=i;
		mn=min(mn,a[i]);
	}
	cev+=(mn-1)/m;
	cev+=((mn-1)%m==0?0:1);
	mn+=(mn-1)%m;
	if(mn<n){
		cev+=(n-mn)/m;
		cev+=((n-mn)%m==0?0:1);
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
const int INF = 1e18L;
int n;
double A[3001];
double dp[3001][3001];

double solve(int index,int head){
	if(index==n){
		if(index-head+1<head){
			return 1;
		}
		else 
			return 1;
	}
	if(dp[index][head]!=-1) return dp[index][head];
	//if(index-head+1>(n-1)/2) return 0;
	double a,b=0;

	a =  A[index]*solve(index+1,head+1);
	if(index-head+1<=(n-1)/2) b = (1-A[index])*solve(index+1, head);
	//cout<<a<<" "<<b<<endl;

	return dp[index][head]=a+b;
}

int32_t main()
{
    
   
    crap;
    for(int i=0;i<=3000;i++){
    	for(int j=0;j<=3000;j++)
    		dp[i][j]=-1;
    }
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];

    double ans = solve(0,0);//index and count of head
    cout<<fixed<<setprecision(9)<<ans<<endl;
   
}

Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(string N){
    for(int i = 0; i < N.size(); i++) {
        if(N[i] == '7') {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
    return ;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    string N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3040
#include <stdio.h>
#define N 12
char b[N+1][128];
int dx[]={ 1, -1, 0, 0 };
int dy[]={ 0, 0, -1, 1 };
void dfs(int y, int x)
{
    int r, c, k;
    b[y][x]='0';
    for (k=0; k<4; ++k) {
        r=y+dy[k];
        c=x+dx[k];
        if (r<0 || r>=N || c<0 || c>=N || b[r][c]=='0') continue;
        dfs(r, c);
    }
}
int main(void)
{
    while (1) {
        int i, j, res=0;
        for (i=0; i<N; ++i) if (!fgets(b[i], 128, stdin)) return 0;

        for (i=0; i<N; ++i) for (j=0; j<N; ++j)
            if (b[i][j]=='1') { res++; dfs(i, j); }
        printf("%d\n", res);

        if (!fgets(b[N], 128, stdin)) break;
    }
    return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String s = scanner.nextLine();
			if (s.equals("END OF INPUT"))
				break;
			String[] ss = s.split(" ");
			for (int i = 0; i < ss.length; i++)
				System.out.print(ss[i].length());
			System.out.println();
		}
	}
}

Measured memory_bytes: 15344
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define INF 1000000000.0;
typedef pair<double, double> P;


bool compare_y(P a, P b){
    return a.second < b.second;
}

double closest_pair(vector<P> &a, int pos, int n){
    if(n==1) return INF;
    int m = n/2;
    double x = a[m+pos].first;
    double d = min(closest_pair(a,pos,m), closest_pair(a,pos+m,n-m));
    inplace_merge(a.begin()+pos,a.begin()+pos+m,a.begin()+pos+n, compare_y);

    vector<P> b;
    for(int i=0;i<n;i++){
        if(fabs(a[i+pos].first - x) >= d) continue;

        for(int j=0;j < b.size(); j++){
            double dx = a[i+pos].first - b[b.size()-1-j].first;
            double dy = a[i+pos].second - b[b.size()-j-1].second;
            if(dy >= d) break;
            d = min(d, sqrt(dx *dx + dy * dy));
        }
        b.push_back(a[i+pos]);
    }
    /*
    for(int i=0;i<n;i++){
        cout << "(" << a[i+pos].first <<","<< a[i+pos].second<<")";
    }
    cout << endl;
    cout << d << endl;
    */
    return d;
}

int main(){
    int n; cin >> n;
    vector<P> points(n);
    for(int i=0;i<n;i++){
        cin >> points[i].first >> points[i].second;
    }
    sort(points.begin(), points.end());
    printf("%.16lf\n", closest_pair(points, 0, n));
}


Measured memory_bytes: 7688
import sys
 
sys.setrecursionlimit(10**5)

n = int(input())
p = [list() for _ in range(n)]
for i in range(n-1):
    u, v, w = [int(s) for s in input().split()]
    u -= 1
    v -= 1
    w %= 2
    p[u].append((v, w))
    p[v].append((u, w))

costs = [-1 for _ in range(n)]

def dfs(cur, dist):
    if costs[cur] != -1:
        return
    costs[cur] = dist
    for v, d in p[cur]:
        dfs(v, dist^d)
dfs(0, 0)

for i in range(n):
    print(costs[i])



Measured memory_bytes: 76592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

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

  int min = X - K + 1; 
  int max = X + K -1;
  for(int i = min; i <=max; i++) {
    cout << i << " ";
  }
  cout << endl;
}

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

int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if (S.at(0) == S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
int n, t, wt[100+9];
ll ps[100+9];
ll dp[100+9][100000+9];

int main(){
    scanf("%d%d",&n,&t);
    for(int i=0;i<n;i++) scanf("%d%lld",&wt[i],&ps[i]);
    for(int i=wt[n-1];i<=t;i++) dp[n-1][i]=ps[n-1];

   for(int i=n-2;i>=0;i--){
        for(int j=t;j>=0;j--){
            dp[i][j]=dp[i+1][j];
            if(j>wt[i]) dp[i][j]=max(dp[i][j], dp[i+1][j-wt[i]]+ps[i]);
        }
   }

   cout << dp[0][t] << endl;

    return 0;
}


Measured memory_bytes: 81720
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define debug(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int n;
int arr[maxn];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
   // File();
    int k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    vector<int>dp(n+1,oo);
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=1; i<n; i++)
        for(int j=1; j<=i and j<=k; j++)
            dp[i] = min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));

    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 3984
program main
  implicit none
  character(len=10) :: S


  read(*,*) S

  if (S == "Sunny") then
     write(*,'(a)') "Cloudy"
  else if (S == "Cloudy") then
     write(*,'(a)') 'Rainy'
  else if (S == "Rainy") then
     write(*,'(a)') "Sunny"
  end if

  stop

end program main


Measured memory_bytes: 256
unittest
{
	assert( [ "1",
	          "1 1 0 1 0 0 0 1 0 1",
	          " 3  4  5  6  7  8  9 -2 -3  4 -2" ].parse.expand.solve == 8 );
	assert( [ "2",
	          "1 1 1 1 1 0 0 0 0 0",
	          "0 0 0 0 0 1 1 1 1 1",
	          " 0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1",
	          " 0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1" ].parse.expand.solve == -2 );
	assert( [ "3",
	          "1 1 1 1 1 1 0 0 1 1",
	          "0 1 0 1 1 1 1 0 1 0",
	          "1 0 1 1 0 1 0 1 0 1",
	          "-8  6 -2 -8 -8  4  8  7 -6  2  2",
	          "-9  2  0  1  7 -5  0 -2 -6  5  5",
	          " 6 -6  7 -9  6 -5  8  0 -9 -7 -7" ].parse.expand.solve == 23 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto fss = new long[][ n ];
	foreach( ref fs; fss )
	{
		input.popFront;
		fs = input.front.split.to!( long[] );
	}
	auto pss = new long[][ n ];
	foreach( ref ps; pss )
	{
		input.popFront;
		ps = input.front.split.to!( long[] );
	}
	return tuple( fss, pss );
}

auto solve( long[][] fss, long[][] pss )
{
	// 営業時間帯のパターンを生成
	auto oss = genFlags( 10 );
	
	// パターンごとの利益を集計
	auto tt = long.min;
	foreach( os; oss )
	{
		auto t = 0;
		foreach( i, fs; fss )
		{
			auto c = 0;
			foreach( k, f; fs )
			{
				if( os[ k ] && f ) c++;
			}
			t += pss[ i ][ c ];
		}
	
		tt = max( tt, t );
	}
	
	return tt;
}

auto genFlags( long n )
{
	long[][] oss;
	
	oss ~= [ 0 ];
	oss ~= [ 1 ];
	
	foreach( i; 0 .. n - 1 )
	{
		foreach( k; 0 .. oss.length )
		{
			oss ~= oss[ k ].dup;
			oss[ k ] ~= 0;
			oss[ $ - 1 ] ~= 1;
		}
	}
	
	return oss[ 1 .. $ ];		// 全部0のパターンは削る
}


Measured memory_bytes: 2556
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    map<char, string> cards;

    cin >> cards['A'] >> cards['B'] >> cards['C'];

    char turn = 'A';
    char next;

    while(1) {
        if (cards[turn].size() == 0) {
            break;
        }
        next = toupper(cards[turn].front());
        cards[turn].erase(0, 1);
        turn = next;
    }

    cout << turn << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int i=0, num[10], N, K, temp, flag = 1;
  scanf("%d %d", &N, &K);
  int d[K+1];
  for(i=0; i<N; i++){
    scanf("%d", &d[i]);
  }
  i = 0; 
  while(flag == 1){
    flag = 0;
    temp = N+i;
    while(temp != 0 && flag == 0){
      for(int k=0; k<K; k++){
        if(d[k] == temp % 10){flag = 1;break;}
      }
      if(flag == 1) break;
      temp = temp / 10;
    }
	i++;
  }
  printf("%d", N+i-1);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
const int N = 1e5 + 5;
int n;
int odd, even;
int main(){
	scanf("%d", &n);
	for(int i = 0, t; i < n; i ++){
		scanf("%d", &t);
		if(t & 1) odd ++;
		else even ++;
	}
	if(odd & 1) puts("NO");
	else puts("YES");
} 

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

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int McxiToInt(string s){
	int ret=0;
	int p=1;
	
	for(int i=0; i<s.size(); ++i){	
		if('2'<=s[i] && s[i]<='9') p=s[i]-'0';
		else{ //数字じゃなければ絶対mcxiがくる
			int by;
			if(s[i]=='m') by=1000;
			else if(s[i]=='c') by=100;
			else if(s[i]=='x') by=10;
			else if(s[i]=='i') by=1;
			
			ret+=p*by;
			p=1;
		}
	}
		
	return ret;
}

string IntToMcxi(int n){
	int a[4];
	char mcxi[5]="mcxi";
	string ret="";
	
	for(int i=0; i<4; ++i){
		a[3-i] = n%10; 
		n/=10;
	}	
	for(int i=0; i<4; ++i){
		//printf("a[%d]=%d\n", i, a[i]);
		if(a[i]==0) continue;	
		else if(a[i]==1) ret+=mcxi[i];
		else{
			char c='0'+a[i];
			ret+=c;
			ret+=mcxi[i];
		}
		
	}
	
	return ret;
}

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		string a, b;
		cin >> a >> b;	
		//cout << McxiToInt(a) + McxiToInt(b) << endl;
		cout << IntToMcxi( McxiToInt(a) + McxiToInt(b) ) <<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m.at(i);
    X-=m.at(i);
  }
  
  sort(m.begin(),m.end());
  
  if(X < m.at(0)){
    cout << N << endl;
  }else{
    cout << X/m.at(0)+N << endl;
  }
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w, m, maxr = 0, maxc = 0; cin >> h >> w >> m;
	vector<int> r(h);
	vector<int> c(w);
	set<pii> hw;
	vector<int> maxri;
	vector<int> maxci;
	for(int i = 0; i < m; i++)
	{
		int x, y; cin >> x >> y;
		x--; y--;
		hw.insert(make_pair(x, y));
		r[x]++;
		c[y]++;
		maxr = max(maxr, r[x]);
		maxc = max(maxc, c[y]);
	}
	for(int i = 0; i < h; i++) if(r[i] == maxr) maxri.push_back(i);
	for(int i = 0; i < w; i++) if(c[i] == maxc) maxci.push_back(i);
	if((ll) maxri.size() * (ll) maxci.size() > 3e5)
	{
		cout << maxr + maxc;
		return 0;
	}
	bool ok = 1;
	for(int i = 0; i < maxri.size(); i++) for(int j = 0; j < maxci.size(); j++)
		if(!hw.count(make_pair(maxri[i], maxci[j])))
		{
			ok = 0;
			break;
		}
	cout << maxr + maxc - ok;

	return 0;
}

Measured memory_bytes: 23816
import sys
import os

MOD = 10 ** 9 + 7


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

    A, B, C, D = list(map(int, sys.stdin.buffer.readline().split()))
    print('Left' if A + B > C + D else 'Balanced' if A + B == C + D else 'Right')


if __name__ == '__main__':
    main()


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

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve() {
    ll x;
    cin >> x;
    for (int i = -1000; i <= 1000; ++i) {
        ll yy = x + powl(i, 5);
        double zz = 0.2;
        ll tt = powl(yy, zz);
        ll kk = powl(tt, 5);
        if (kk == yy) {
            cout << tt << " " << i;
            break;
        }
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

Measured memory_bytes: 3720
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    ll a,b;
    cin>>a>>b;
    
    if(a>0){
    a--;
    }
    ll aa,bb;
    
    if(a%2==0){
        aa=a/2;
        if(aa%2==1){
            a=a^1;
        }else{
            a=a^0;
        }
    }else{
        aa=(a+1)/2;
        if(aa%2==1){
            a=1;
        }else{
            a=0;
        }
    }
    if(b%2==0){
        bb=b/2;
        if(bb%2==1){
            b=b^1;
        }else{
            b=b^0;
        }
    }else{
        bb=(b+1)/2;
        if(bb%2==1){
            b=1;
        }else{
            b=0;
        }
    }
    
    
    cout<<(a^b)<<endl;
    
    
return 0;
}


Measured memory_bytes: 256
class Main{
    public static void main(String[] a){

        for (int i = 1; i <=9; ++i) {
            for (int j = 1; j <= 9; ++j) {
                StringBuilder sb = new StringBuilder();
                System.out.println(sb.append(i).append('x').append(j).append('=').append(i*j).toString());
            }
        }

    }
}

Measured memory_bytes: 16860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;



int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    rep(i,n){
        bool J=1;
        rep(j,G[i].size()){
            if(h[i] <= h[G[i][j]]) J=0;
        }
        if(J) ans++;
    }
    cout << ans << endl;


}

Measured memory_bytes: 8800
# INPUT
num = list(map(int, input().split()))

# # PROCESS
answer = 0
first_max = max(num)
num.remove(first_max)
second_max = max(num)
num.remove(second_max)
third_max = max(num)

answer = int(str(first_max) + str(second_max)) + third_max


# OUTPUT
print(answer)

Measured memory_bytes: 3060