akhauriyash/Code-Regression huggingface dataset:
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N

dp[0] = 0
dp[1] = abs(H[1]-H[0])

for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;

int n,par[100010],rnk[100010];

void init(){
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}
int find(int x){
    if(par[x]!=x)return par[x]=find(par[x]);
    return x;
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rnk[x]==rnk[y])rnk[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}

int main(){
    cin>>n;
    pii x[n],y[n];
    for(int i=0;i<n;i++){
        int tx,ty;
        cin>>tx>>ty;
        x[i]=make_pair(tx,i);
        y[i]=make_pair(ty,i);
    }
    sort(x,x+n);
    sort(y,y+n);
    pip dx[n-1],dy[n-1];
    for(int i=0;i<n-1;i++){
        dx[i]=make_pair(x[i+1].first-x[i].first,make_pair(x[i].second,x[i+1].second));
        dy[i]=make_pair(y[i+1].first-y[i].first,make_pair(y[i].second,y[i+1].second));
    }
    sort(dx,dx+n-1);
    sort(dy,dy+n-1);
    init();
    int itx=0,ity=0;
    ll ans=0LL;
    for(int i=0;i<n-1;i++){
        if(dx[itx]<=dy[ity]){
            int u=dx[itx].second.first;
            int v=dx[itx].second.second;
            if(!same(u,v)){
                unite(u,v);
                ans+=dx[itx].first;
            }else{
                i--;
            }
            itx++;
        }else{
            int u=dy[ity].second.first;
            int v=dy[ity].second.second;
            if(!same(u,v)){
                unite(u,v);
                ans+=dy[ity].first;
            }else{
                i--;
            }
            ity++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<cmath>
#include<cstdio>
#define ld long double
using namespace std;
ld getans(int n,ld a1,ld x,ld a2n){
	ld b1,b2n,y;
	if (n==0)return 0;
	if (n==1)return (a1+x/2);
	b1=a1/n*(n-1)+(a1+2*x)/(2*n)+(a1+x)*3/(2*n);
	b2n=a2n/n*(n-1)+(a2n-2*x)/(2*n)+(a2n-x)*3/(2*n);
	y=(b2n-b1)/(2*n-3);
	return (a1+n*x-x/2)+getans(n-1,b1,y,b2n);
}



int main(){
	int n;
	ld a1,x,a2n;
	scanf("%d%LF%LF",&n,&a1,&x);
	a2n=a1+x*(2*n-1);
	printf("%.10LF",getans(n,a1,x,a2n));
	
}

Measured memory_bytes: 18944
//kuso code

#include <iostream>
#include <math.h>

int main()
{
    int X;
    int b, p;
    std::cin >> X;
    
    int max = -1;
    
    for (b = 1; b < 1000; b++) {
        for (p = 2; p < 1000; p++) {
            if (max < (int)pow(b, p) && (int)pow(b, p) <= X) max = (int)pow(b, p);
        /*
            int temp = (int)pow(b, p);
            if (ans < temp && ans <= X) ans = temp;
        */
        }
    }    
      
    std::cout << max << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
using namespace std;
 
typedef long long ll;
 
ll make_rand(){
  static ll x=123456789;
  static ll y=362436069;
  static ll z=521288629;
  static ll w=88675123;
  ll t;
  t=x^(x<<11);
  x=y;y=z;z=w;
  return w=(w^(w>>19))^(t^(t>>8));
}
 
char a[1001][1001];
void solve(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			cin>>a[i][j];
	int maxExp=-1;
	int pos=-1;
	int allone=-1;
	vector<int> poss;
	for(int i=0;i<N;i++){
		int exp=0;
		int one=0;
		for(int j=0;j<N;j++){
			if(a[i][j]=='o')exp+=3;
			else if(a[i][j]=='-'){
				one++;
				exp+=1;
			}
		}
		if(maxExp<exp){
			maxExp=exp;
			pos=i;
			poss.clear();
			poss.push_back(i+1);
		}
		else if(maxExp==exp)
			poss.push_back(i+1);
	   if(N==one)allone=i+1;
	}
	pos++;
	int judge_ai_hand;
	int sum=0;
	// もっとも期待値が高いものに対してもっとも勝てそうなものを選ぶ
	vector<int> ophands;
	int maxexp=-1;
	for(int i=0;i<N;i++){
		int exp=0;
		for(int j=0;j<poss.size();j++){
			if(a[i][poss[j]-1]=='o')exp+=3;
			else if(a[i][poss[j]-1]=='-')exp+=1;
		}
		if(maxexp<exp){
			maxexp=exp;
			ophands.clear();
			ophands.push_back(i+1);
		}
		else if(maxexp==exp)
			ophands.push_back(i+1);
	}
	for(int i=0;i<1000;i++){
		//int hand=pos;
		//int hand=poss[make_rand()%(int)poss.size()];
		int hand=ophands[make_rand()%(int)ophands.size()];
		if(make_rand()%2)
			hand=poss[make_rand()%(int)poss.size()];
		//if(allone!=-1&&(1000-i)+sum>=350)
		//	hand=allone;
		printf("%d\n",hand); fflush(stdout);
		scanf("%d", &judge_ai_hand);
		if(a[pos-1][judge_ai_hand-1]=='o')sum+=3;
		else if(a[pos-1][judge_ai_hand-1]=='-')sum+=1;
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

const long long MAXD = 62;
const long long INF = 1LL<<MAXD;

long long upperBound(long long v) {
    if (v <= 0) {
        return 1;
    }

    if (v >= MAXD) {
        return INF;
    }

    return 1LL << v;
}

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

    vector <long long> A(N+1);
    vector <long long> NL(N+1);
    vector <long long> NLU(N+1, INF);

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

    NLU[0] = 1 - A[0];

    for (int i = 1; i <= N; ++i) {
        NLU[i] = min(INF, NLU[i-1]*2 - A[i]);
    }

    // 2*NL[i] >= A[i+1] + NL[i+1] // two to one
    // NL[i] <= A[i+1] + NL[i+1] // one to one
    long long ans = A[N];
    for (int i = N-1; i >= 0; --i) {
        long long up = min(A[i+1] + NL[i+1], NLU[i]);
        long long low = (A[i+1] + NL[i+1] + 1) / 2;
        up = min(up, upperBound(i)-A[i]);

        // NL[i] + A[i] <= 2^i
        if ( up < low ||
            (i <= MAXD && low > (1LL << i)) ) {
            ans = -1;
            break;
        }

        // otherwise, it's feasible
        if (i <= MAXD) {
            NL[i] = min((1LL<<i), up);
        } else {
            NL[i] = up;
        }

        ans += (NL[i] + A[i]);
    }

    if (A[N] > upperBound(N)) {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] N=cin.ArrayInt(3);
        int count=0;
        for(int i=N[0];i<=N[1];i++)if(N[2]%i==0)count++;
        Console.WriteLine(count);
    }


}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 17952
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MAX = 1000000;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll dp[305][305];

int main(){
  int n,k; cin >> n >> k;
  int m = n-k;//残す数
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  h.insert(h.begin(),0);
  rep(i,n+1)rep(j,m+1) dp[i][j] = INF;
  dp[0][0] = 0;
  
  for(int i = 1; i <= n ;i++)rep(j,m){
    ll now = INF;
    rep(k,i){
      chmin(now, dp[k][j]+max(0,h[i]-h[k]));
    }
    dp[i][j+1] = now;
  }
  
  ll ans = INF;
  rep(i,n+1) chmin(ans, dp[i][m]);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
A, B, C, D = list(input())
for n in range(8):
    formula = "{}{}{}{}{}{}{}".format(A, ["+", "-"][n & 1], B, ["+", "-"][(n >> 1) & 1], C, ["+", "-"][(n >> 2) & 1], D)
    if eval(formula) == 7:
        print(formula + "=7")
        quit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

double dist(double x, double y, double xx, double yy) {
  return sqrt(pow(x - xx, 2) + pow(y - yy, 2));
}

int main() {
  int N;
  cin >> N;
  vector<double> x(N), y(N);
  rep(i, N) {
    cin >> x[i] >> y[i];
  }

  vector<int> p(N);
  rep(i, N) {
    p[i] = i;
  }

  double ans = 0.0;
  int cnt = 0;
  do {
    cnt++;
    double temp = 0.0;
    rep(i, N - 1) {
      temp += dist(x[p[i]], y[p[i]], x[p[i + 1]], y[p[i + 1]]);
    }
    ans += temp;
  } while (next_permutation(all(p)));
  ans /= cnt;
  printf("%.14f\n", ans);  // Lf?
}

Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

# V_i > C_iなら選ぶ

ans = 0 # 価値の合計

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

print(ans)

Measured memory_bytes: 3060
n,m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
b = []
for i in range(n):
    if a[i]*4*m >= s:
        b.append(a[i])
if len(b) < m:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;



	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int surplus[] = new int[1000005]; //余り
		int table[] = new int[85]; //商

		int p,q;
		int tmp,tmp_surplus,cycle_start = 0,tail = 0;

		boolean is_cycle;

		StringBuilder ans = new StringBuilder();

		while(scanner.hasNext()){
			p = scanner.nextInt();
			q = scanner.nextInt();

			for(int i = 0; i < q; i++){

				surplus[i] = -1;
			}

			surplus[p] = 0; //pが再登場しても循環

			tmp = p*10;
			is_cycle = false;

			for(int digit = 1; digit <= 80; digit++){

				tmp_surplus = tmp%q;
				table[digit] = tmp/q;

				if(tmp_surplus == 0){ //割り切れた
					tail = digit;
					break;
				}
				if(surplus[tmp_surplus] != -1){ //循環
					//System.out.printf("循環 桁%d 商%d 余り%d\n", digit,table[digit],tmp_surplus);
					is_cycle = true;
					cycle_start = surplus[tmp_surplus]+1;
					tail = digit;
					break;
				}
				surplus[tmp_surplus] = digit;
				tmp = 10*tmp_surplus;
			}

			if(is_cycle){

				for(int i = 1; i <= tail ; i++){

					ans.append(Integer.toString(table[i]));
				}
				ans.append("\n");
				for(int i = 1; i <= cycle_start-1; i++){

					ans.append(" ");
				}
				for(int i = cycle_start; i <= tail; i++){

					ans.append("^");
				}
				ans.append("\n");

			}else{

				for(int i = 1; i <= tail; i++){

					ans.append(Integer.toString(table[i]));
				}
				ans.append("\n");
			}
		}
		System.out.print(ans.toString());
	}
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 34872
#include <cstdio>
using namespace std;

const int MAXN = 505;

int N, M;
char mat[MAXN][MAXN];

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 0; i < N; i++)
        scanf("%s", mat[i]);
        
    for (int i = 0; i < N; i++, puts(""))
        for (int j = 0; j < M; j++) 
            printf("%c", ".#"[(j < M - 1 && (!j || i % 2)) || mat[i][j] == '#']);
    puts("");
    for (int i = 0; i < N; i++, puts(""))
        for (int j = 0; j < M; j++)
            printf("%c", ".#"[(j && (j == M - 1 || !(i % 2))) || mat[i][j] == '#']);
            
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    long n;
    cin >> n;
    int f = 20;

    for(int i=1;i<=sqrt(n);++i){
        if(n%i==0){
            int x = i;
            int y = n/i;

            string xs = to_string(x);
            string ys = to_string(y);
            int xlen = xs.size();
            int ylen = ys.size();
            int len = (xlen > ylen)?xlen:ylen;

            if(f>len){
                f = len;
            }
        }
    }
    cout << f << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			int n=sc.nextInt();
			int p=n-1;
			int q=n+1;
			while(!isPrime(p))
				p--;
			while(!isPrime(q))
				q++;
			println(p+" "+q);
		}
		sc.close();
	}

	boolean isPrime(int n){
		for(int i=2; i<n; i++)
			if(n%i==0)
				return false;
		return true;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#import sys
#input = lambda: sys.stdin.readline().rstrip()

#MOD
P = 10**9 + 7
N = 200001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2, N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b): return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P

#全方位木dp
#-------------------------------------------------------------------
#扱うクラス
class T:
    num = 1
    child = 0

    def __init__(self, a, b):
        self.num = a
        self.child = b

#零元
zero = T(1, 0)
#一個上に遷移した時の変化
def step(x):
    return T(x.num, x.child+1)
#マージ
def merge(x, y):
    return T((x.num*y.num*comb(x.child+y.child, x.child))%P, x.child+y.child)

G = [[] for _ in range(N)]
down_data = [zero for _ in range(N)]
dat = [zero for _ in range(N)]
rev_data = [zero for _ in range(N)]

class p:
    num = -1
    parent = -1

    def __init__(self, x, y):
        self.num = x
        self.parent = y
node_list = []
def makeNodeList(root):
    #dfsでの探索順の作成
    stack = []
    stack.append(p(root, -1))
    while len(stack) != 0:
        now = stack.pop()
        node_list.append(now)
        for to in G[now.num]:
            if to == now.parent: continue
            stack.append(p(to, now.num))
    node_list.reverse()

def dfs(root):
    for now in node_list:
        for to in G[now.num]:
            if to == now.parent: continue
            down_data[now.num] = merge(down_data[now.num], step(down_data[to]))

def dfs_rev(root):
    for now in node_list:
        #累積
        rev = rev_data[now.num]
        left = []
        right = []
        cnt = 0
        for to in G[now.num]:
            if to==now.parent: continue
            if len(left)==0: left.append(step(down_data[to]))
            else: left.append(merge(left[cnt-1], step(down_data[to])))
            cnt += 1
        cnt = 0
        for to in reversed(G[now.num]):
            if to==now.parent: continue
            if len(right)==0: right.append(step(down_data[to]))
            else: right.append(merge(right[cnt-1], step(down_data[to])))
            cnt += 1
        dat[now.num] = merge(rev, down_data[now.num])
        cnt = 0
        for to in G[now.num]:
            if to==now.parent: continue
            x = zero if cnt==0 else left[cnt-1]
            y = zero if cnt==len(right)-1 else right[len(right)-2-cnt]
            rev_data[to] = step(merge(rev, merge(x, y)))
            cnt += 1

def calc(data_num):
    root = -1
    for i in range(1, data_num+1):
        if len(G[i]) == 1:
            root = i
            break
    makeNodeList(root)
    dfs(root)
    node_list.reverse()
    dfs_rev(root)
#-------------------------------------------------------------------
def main():
    n = int(input())
    for i in range(n-1):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)
    calc(n)

    for i in range(1, n+1): print(dat[i].num)

if __name__ == "__main__": main()


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

int dp(vector<vector<int>>& memo, const vector<string>& s, int h, int w, int H,
       int W) {
  if (memo[h][w] != -1) return memo[h][w];
  if (h == H - 1 && w == W - 1) {
    return 0;
  }
  if (h == H - 1) {
    return memo[h][w] = dp(memo, s, h, w + 1, H, W) +
                        (s[h][w] == '.' && s[h][w + 1] == '#' ? 1 : 0);
  }
  if (w == W - 1) {
    return memo[h][w] = dp(memo, s, h + 1, w, H, W) +
                        (s[h][w] == '.' && s[h + 1][w] == '#' ? 1 : 0);
  }

  return memo[h][w] = min(dp(memo, s, h + 1, w, H, W) +
                              (s[h][w] == '.' && s[h + 1][w] == '#' ? 1 : 0),
                          dp(memo, s, h, w + 1, H, W) +
                              (s[h][w] == '.' && s[h][w + 1] == '#' ? 1 : 0));
}

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }
  vector<vector<int>> memo(H, vector<int>(W, -1));
  dp(memo, s, 0, 0, H, W);
  cout << memo[0][0] + (s[0][0] == '#' ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
 
#pragma GCC optimize ("-O3")
#define rep(i, initial_value, max_value) for (int i{initial_value}; i < max_value; ++i)
#define fore(i, a) for(auto &i:a)
#define each(i, c) \
  for( \
      __typeof((c).begin()) i{(c).begin()}, __typeof((c).end()) end{(c).end()}; \
      i != end; \
      ++i \
  )
#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
 
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T>bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
 
// ===
 
void _main() {
  ll n;
  cin >> n;
 
  ll ans;
  if (n % 2 == 0) {
    ans = n / 2 - 1;
  } else {
    ans = (1 + n) / 2 - 1;
  }
 
  cout << ans << endl;
}

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

int main(){
	string S;
	cin>>S;
	
	if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]||(S[0]==S[1]&&S[1]==S[2])||(S[1]==S[2]&&S[2]==S[3])||(S[0]==S[1]&&S[1]==S[2]&&S[2]==S[3]))
		cout<<"Bad"<<endl;
	else
		cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int x, y;
	cin >> x >> y;

	int a[300] = {};
	a[1] = 300000;
	a[2] = 200000;
	a[3] = 100000;
	if (x == y and x == 1)
		cout << a[x] + a[y] + 400000 << endl;
	else
		cout << a[x] + a[y] << endl;
}


Measured memory_bytes: 768
n = int(input())
nn = n
N = []

print(n, ":", sep = "", end = " ") 

if n % 2 == 0 :
    while n % 2 == 0 :
        N.append(2)
        n //= 2
        
for i in range(3, int(nn ** (1 / 2)) + 1, 2) :
    while n % i == 0 :
        N.append(i)
        n //= i
        
if n != 1 :
    N.append(n)
    
if len(N) == 0 :
    print(n)
else :
    for i in range(len(N)) :
        if i == len(N) - 1 :
            print(N[i])
        else :
            print(N[i], sep = "", end = " ")


Measured memory_bytes: 5628
using System;
using System.Linq;
using System.Text;

namespace CGL_7_E_CrossPointsofCircles
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] inputNum1 = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int[] inputNum2 = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

			Circle circle1 = new Circle (inputNum1[0], inputNum1[1], inputNum1[2]);
			Circle circle2 = new Circle (inputNum2[0], inputNum2[1], inputNum2[2]);

			Vector2[] result = Circle.CrossPoint (circle1, circle2).OrderBy (item => item.X).ThenBy (item => item.Y).ToArray ();

			Console.WriteLine (result[0].X + " " + result[0].Y + " " + result[1].X + " " + result[1].Y);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator + ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X + ob2.X, ob1.Y + ob2.Y);
		}
		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}
		public static Vector2 operator * ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X * scalar, ob.Y * scalar);
		}

		private static decimal Sqrt ( decimal number )
		{
			return new decimal (Math.Sqrt (decimal.ToDouble (number)));
		}
		public decimal Length ()
		{
			return X * X + Y * Y;
		}
		public decimal Normalize ()
		{
			Vector2 tmp = new Vector2 (X, Y);
			return Sqrt (tmp.Length ());
		}
	}

	class Circle
	{
		public Circle ( decimal x, decimal y, decimal radius )
		{
			this.Point = new Vector2 (x, y);
			this.Radius = radius;
		}

		public Vector2 Point { private set; get; }
		public decimal Radius { private set; get; }

		public static Vector2[] CrossPoint ( Circle circle1, Circle circle2 )
		{
			decimal distance = (circle2.Point - circle1.Point).Normalize ();

			decimal tmp = (circle1.Radius * circle1.Radius + distance * distance - circle2.Radius * circle2.Radius) /
				(2 * circle1.Radius * distance);

			decimal radian = new decimal (Math.Acos (decimal.ToDouble (tmp)));

			Vector2 difference = circle2.Point - circle1.Point;
			decimal radian2 = new decimal (Math.Atan2 (decimal.ToDouble (difference.Y), decimal.ToDouble (difference.X)));

			return new Vector2[] { 
				circle1.Point + Polar (circle1.Radius, radian2 + radian),
				circle1.Point + Polar (circle1.Radius, radian2 - radian) 
			};
		}

		public static Vector2 Polar ( decimal radian, decimal radian2 )
		{
			double l = decimal.ToDouble (radian);
			double r = decimal.ToDouble (radian2);

			return new Vector2 (new decimal (Math.Cos (r) * l), new decimal (Math.Sin (r) * l));
		}
	}
}



Measured memory_bytes: 10556
// A. 

#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;
typedef map<LL, LL> LLMap;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	LL ans = 0, sum = 0;
	LLMap m;
	m[0] = 1;
	for (int i = 0; i < n; ++i) {
		LL a;
		cin >> a;
		sum += a;
		ans += m[sum];
		m[sum] += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i,n) cin >> s[i] >> t[i];
    string x; cin >> x;
    int ans = 0;
    bool flag = false;
    rep(i,n){
        if(flag) ans += t[i];
        if(s[i] == x) flag = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
ABC = [tuple(map(int, input().split())) for _ in range(N)]
dp_a = [0] * (N+1)
dp_b = [0] * (N+1)
dp_c = [0] * (N+1)

for i, (a, b, c) in enumerate(ABC):
  dp_a[i+1] = a + max(dp_b[i], dp_c[i])
  dp_b[i+1] = b + max(dp_a[i], dp_c[i])
  dp_c[i+1] = c + max(dp_a[i], dp_b[i])
print(max(dp_a[N], dp_b[N], dp_c[N]))

Measured memory_bytes: 32424
import java.util.Scanner;

//Is it a Right Triangle?
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n--!=0){
			int a[] = new int[3];
			for(int i=0;i<3;i++){
				a[i]=(int)Math.pow(sc.nextInt(), 2);
			}
			System.out.println((a[0]+a[1]==a[2]||a[0]+a[2]==a[1]||a[2]+a[1]==a[0])?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int N,K,Q;
  cin>>N>>K>>Q;
  
  vector<int> A(Q);
  for(int i=0;i<Q;i++){
    cin>>A[i];
  }
  
  vector<int> point(N,K-Q);
  
  
  for(int i=0;i<Q;i++){
    point[A[i]-1]++;
  }
 
  
  for(int i=0;i<N;i++){
    if(point[i]>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

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

int main() {
	int p, q;
	string a, b;
	scanf("%d", &p);
	a = to_string(p);
	for (int i = 0; i < 3; i++)
		b += a[i] == '1' ? '9' : '1';
	q = stoi(b);
	printf("%d", q);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,m;
  cin >> s >> m;
  sort(s.begin(),s.end());
  sort(m.begin(),m.end());
  reverse(m.begin(),m.end());
  if(s<m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#!/bin/sh
read
cnt=0
for i in `echo $REPLY | awk '{for(i=1;i<=NF;i++)print $i}' | sort -n`
do
	cnt=$(( cnt + 1 ))
	eval n$cnt=$i
done
n=$(( n3 % 2 ))
if [ $n -eq 1 ]
then
	echo $(( n1 * n2 ))
else
	echo 0
fi


Measured memory_bytes: 1112
N=int(input())
A=list(map(int,input().split()))
B=[0]*100003
for i in range(N):
    B[A[i]]+=1

max=0
for i in range(100002):
    if max<B[i-1]+B[i]+B[i+1]:
        max=B[i-1]+B[i]+B[i+1]
print(max)

Measured memory_bytes: 13964
#include <array>
#include <cstring>
#include <iostream>
#include <limits>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

vector<vector<P>> v(101);

long long d[101][101];

void dijkstra(int i, const int n, const int m) {
  unsigned char x[n];

  for (int j = 1; j <= n; j++) {
    x[j] = 0;
    d[i][j] = numeric_limits<long long>::max();
  }
  x[i] = 1;
  d[i][i] = 0;

  priority_queue<P, vector<P>, greater<P>> pq;
  for (auto edge : v[i]) {
    pq.push(P(edge.second, edge.first));
  }

  while (!pq.empty()) {
    P minvert = pq.top();
    pq.pop();
    // cout << "pop : " << minvert.second << " " << minvert.first << endl;
    if (x[minvert.second] == 0) {
      x[minvert.second] = 1;
      d[i][minvert.second] = minvert.first;
      // cout << "decide : " << minvert.second << "= " << minvert.first << endl;
      for (auto edge : v[minvert.second]) {
        if (x[edge.first] == 0 &&
            d[i][edge.first] > minvert.first + edge.second) {
          d[i][edge.first] = minvert.first + edge.second;
          pq.push(P(d[i][edge.first], edge.first));
          //    cout << "push : " << edge.first << " " << d[i][edge.first] <<
          //    endl;
        }
      }
    }
  }
  // cout << "----" << endl;
}

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

  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;

    v[a].push_back(P(b, c));
    v[b].push_back(P(a, c));
  }

  for (int i = 1; i <= n; i++)
    dijkstra(i, n, m);

  /*
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      cout << d[i][j] << " ";
    cout << endl;
  }
  */

  unsigned char e[101][101];
  memset(e, 0, sizeof(e));

  int count = 0;

  for (int i = 1; i <= n; i++) {
    for (auto edge : v[i]) {
      int j = edge.first;
      int eij = edge.second;
      for (int s = 1; s <= n; s++) {
        if (d[s][j] == d[s][i] + eij && e[i][j] == 0 && e[j][i] == 0) {
          e[i][j] = 1;
          count++;
          //cout << i << " " << j << endl;
        }
      }
    }
  }

  cout << m - count << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m; lnt s[MAX_N+5], f[MAX_N+5];
vector <int> G[MAX_N+5]; bool mrk[MAX_N+5];
int a[MAX_N+5], b[MAX_N+5], p[MAX_N+5], fa[MAX_N+5];
bool cmp(const int &x, const int &y) {return a[x] < a[y];}
int getf(int x) {return fa[x] == x ? x : fa[x] = getf(fa[x]);}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		read(a[i]), read(b[i]), a[i] = max(a[i]-b[i], 0);
	for (int i = 1, u, v; i <= m; i++)
		read(u), read(v), G[u].push_back(v), G[v].push_back(u);
	for (int i = 1; i <= n; i++)
		p[i] = fa[i] = i, f[i] = a[i], s[i] = b[i];
	sort(p+1, p+n+1, cmp);
	for (int i = 1; i <= n; i++) {
		int u, fu, fv; mrk[u = p[i]] = true;
		for (int v : G[u]) if (mrk[v] && ((fu = getf(u)) ^ (fv = getf(v))))
			fa[fv] = fu, s[fu] += s[fv], f[fu] = min(f[fu], max(f[fv], a[fu]-s[fv]));
	}
	return printf("%lld\n", f[getf(1)]+s[getf(1)]), 0;
}


Measured memory_bytes: 9212
#include <iostream>
typedef long long ll;
using namespace std;

ll x[200010], sum[200010];

int main() {
	int N;
	ll X;
	cin >> N >> X;
	sum[0]=0;
	for(int i=0; i<N; ++i){
		cin >> x[i];
		sum[i+1]=sum[i]+x[i];
	}
	int mxt=(N+1)/2;
	ll ans=X*(N+mxt)+sum[N]*5;
	for(int i=mxt-1; i>0; --i){
		ll now=X*(N+i)+(sum[N]-sum[N-i])*5;
		int mult=5;
		for(int j=N-i; j>0; j -= i){
			now += (sum[j]-sum[max(j-i, 0)])*mult;
			mult += 2;
		}
		if(now<ans) ans=now;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int row, col;
	while (cin >> row >> col) {
		if (row == 0 && col == 0)
			break;
		rep(r, row) {
			rep(c, col) {
				if ((r % 2 == 0 && c % 2 == 0) || (r % 2 && c % 2))
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
long long a[300005],mod=1e9+7,r[65];
int main(){
	long long n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=60;j>=0;j--){
			if((a[i]>>j)&1) r[j]++;
		}
	}
	for(int i=60;i>=0;i--){
		long long num=r[i]*(n-r[i])%mod;
		ans=(ans+num)%mod;
		if(i) ans=ans<<1;
		ans%=mod;
	}
	cout<<ans<<endl;
}

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

int main(){
    string str;
    getline(cin, str);
    for(int i = 0; i < str.size(); i++){
        if(str[i] >= 'a' && str[i] <= 'z')
            str[i] -= 'a' - 'A';
    }
    cout << str << endl;
    return 0;
}

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

int main(){
  int N, Q; cin >> N >> Q;
  fenwick_tree<long long> fw(N);
  rep(i, N) {
    int a; cin >> a;
    fw.add(i, a);
  }
  rep(query, Q) {
    int a, b, c; cin >> a >> b >> c;
    if (a == 0) fw.add(b, c);
    else cout << fw.sum(b, c) << endl;
  }
}

Measured memory_bytes: 8216
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class AABCSwap {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int x, y, z;
	    in >> x >> y >> z;

	    out << z sp x sp y << endl;
	}
};


int main() {
	AABCSwap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
  int x[5],y[5];
  scanf("%d %d %d %d",&x[1],&y[1],&x[2],&y[2]);
  x[3] = x[2]-(y[2]-y[1]);  y[3] = y[2]+(x[2]-x[1]);
  x[4] = x[1]-(y[2]-y[1]);  y[4] = y[1]+(x[2]-x[1]);
  printf("%d %d %d %d",x[3],y[3],x[4],y[4]);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int imax = 0;
  int x = 0;
  for(auto s : S) {
    if(s == 'I') {
      x++;
    } else if(s == 'D') {
      x--;
    }
    imax = max(imax, x);
  }

  cout << imax << endl;
}


Measured memory_bytes: 256
type itemp = ^item;
     item = record
        cont : char;
        next : itemp;
     end;
var s : itemp;
    n : integer;

procedure readitem(var p:itemp);{頭から追加}
var q : itemp;
begin
  q := p;
  new(p);
  read(p^.cont);
  p^.next := q
end;

procedure delitem(var p : itemp);{頭から消す}
begin
  p := p^.next
end;

begin
  n:= 0;
  s:=nil;
  while not eoln do begin
    readitem(s);
    if s^.next <> nil then
      if Ord(s^.cont)+Ord(s^.next^.cont) = 97 then begin
        n := n + 2;
        delitem(s); delitem(s)
      end
  end;
  writeln(n)
end.

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, Q;
int S[1000005];
int T[1000005];
int X[1000005];

int D[1000005];

vector <int> post[1000005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> Q;

    for(int i = 1; i <= N; i++)
        cin >> S[i] >> T[i] >> X[i];

    for(int i = 1; i <= Q; i++)
        cin >> D[i];

    for(int i = 1; i <= N; i++) {
        int l = distance(D, lower_bound(D + 1, D + Q + 1, S[i] - X[i]));
        int r = distance(D, upper_bound(D + 1, D + Q + 1, T[i] - X[i] - 1));
        post[l].push_back(X[i]);
        post[r].push_back(-X[i]);
    }

    multiset<int> s;
    for(int i = 1; i <= Q; i++) {
        for(auto v: post[i]) {
            if(v < 0) s.erase(s.find(-v));
            else s.insert(v);
        }
        cout << (s.empty() ? -1 : *s.begin()) << "\n";
    }
}

Measured memory_bytes: 48372
N = int(input())
l = [[] for _ in range(N)]
for i in range(N):
    l[i] = list(map(int,(input().split())))
l.append([0,0,0])
for i in range(N):
    dt = l[i][0] - l[i-1][0] 
    dx = abs(l[i][1] - l[i-1][1])
    dy = abs(l[i][2] - l[i-1][2])
    d = dx + dy
    if d > dt:
        print("No")
        break
    else:
        if (d-dt)%2 == 1:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 58016
s = input()
n = len(s)+1
ans = 0
ls = [0 for _ in range(n)]
rs = [0 for _ in range(n)]
for i in range(n-1):
    if s[i] == '<':
        ls[i+1] = ls[i]+1
for i in range(n-1):
    if s[-1-i] == '>':
        rs[-2-i] = rs[-1-i]+1
for i,j in zip(ls,rs):
    ans += max(i,j)
print(ans)

Measured memory_bytes: 33804
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;
#define int ll
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }

    return false;
}


//深さ優先
vector<int> seen;
vector<ll> h;

//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み

    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }

    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


signed main() {
    int K; cin >> K;
    int rec[60], ans[60];
    int div = K / 50, md = K % 50;
    int n=50;
    for(int i=0;i<n;i++){
        rec[i]=div+(i<md);
    }
 
    for(int i=0;i<n;i++){
        int S = 0;
        for(int j=0;j<n;j++) {
            if(i != j) S += rec[j];
        }
        ans[i] = 50 * (rec[i] + 1) - S - 1;
    }
    
    cout << 50 << endl;
    rep(i,0,50) cout << (i ? " " : "") << ans[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
if n >= 400 && n <= 599
    puts "8"
elsif  n >= 600 && n <= 799
    puts "7"
elsif  n >= 800 && n <= 999
    puts "6"
elsif  n >= 1000 && n <= 1199
    puts "5"
elsif  n >= 1200 && n <= 1399
    puts "4"
elsif  n >= 1400 && n <= 1599
    puts "3"
elsif  n >= 1600 && n <= 1799
    puts "2"
elsif  n >= 1800 && n <= 1999
    puts "1"
end

Measured memory_bytes: 14304
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

char table[101][101];
int main() {
	int A,B;
	cin >> A >> B;
	for(int j=0;j<100;j++){
		for(int i=0;i<50;i++){
			table[i][j]='#';
		}
		for(int i=50;i<100;i++){
			table[i][j]='.';
		}
	}
	int x=0,y=0;
	for(int i=1;i<A;i++){
		table[x][y]='.';
		y+=2;
		if(y>=100){
			y=0;
			x+=2;
		}
	}
	x=51;
	y=0;
	for(int i=1;i<B;i++){
		table[x][y]='#';
		y+=2;
		if(y>=100){
			y=0;
			x+=2;
		}
	}
	cout << 100 << " " << 100 << endl;
	for(int i=0;i<100;i++){
		cout << table[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 256
let rec solve ass y x h w trace =
  if y >= h || x >= w || ass.(y).[x] = '.' then false
  else begin
    let c = trace.(y).[x] in
    trace.(y).[x] <- '#';
    let return r = trace.(y).[x] <- c; r in
    if y = h - 1 && x = w - 1 then return (ass = trace)
    else return (solve ass (y + 1) x h w trace || solve ass y (x + 1) h w trace)
  end

let () =
  let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
  let ass = Array.init h (fun _ -> Scanf.scanf "%s\n" (fun as_ -> as_)) in
  if solve ass 0 0 h w (Array.init h (fun _ -> String.make w '.')) then print_endline "Possible"
  else print_endline "Impossible"


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n; long long m; cin >> m;
    vector<long long> a(n), b(n+1, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) b[i+1] = b[i] + a[i];
    long long lf = 0; long long rg = 1e6;
    while (rg - lf > 1) {
        long long mid = (rg + lf) / 2;
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            auto c = lower_bound(a.begin(), a.end(), mid - a[i]) - a.begin();
            cnt += n - c;
        }
        if (cnt >= m) lf = mid;
        else rg = mid;
    }
    long long cnt = 0; long long sum = 0;
    for (int i = 0; i < n; i++) {
        auto c = lower_bound(a.begin(), a.end(), lf-a[i]) - a.begin();
        cnt += n - c;
        sum += a[i] * (n-c) + b[n] - b[c];
    }
    sum -= (cnt - m) * lf;
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ll co=0;
    bool b=0; 
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x==y)
            co++;
        else
            co=0;
        if(co>=3)
            b=1;
    }    
    if(b)
        cout<<"Yes";
    else
        cout<<"No";
    subt;
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000000;
double a[55];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        scanf("%lf",&a[i]);
    sort(a,a+n);
    for(int i=1; i<n; i++)
        a[i]=(a[i-1]+a[i])/2.0;
    printf("%.6f",a[n-1]);
    return 0;
}


Measured memory_bytes: 256