akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

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

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int X = sn.nextInt();
        int Y = sn.nextInt();
        
        for(int i=1; i<=X; i++){
            if(4*i + 2*(X-i) == Y || 2*i + 4*(X-i) == Y){
                System.out.println("Yes");
                break;
            }
            if(i == X) System.out.println("No");
        }
    }
}

Measured memory_bytes: 35884
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

string S, T; cin >> S >> T;

cout << T << S << endl;





}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

import sys
input = sys.stdin.readline

def nCr(n, r, mod):
    ret = [1]*(r+1)
    for i in range(1, r+1):
        ret[i] = (ret[i-1] * (n-i+1) * pow(i,mod-2,mod)) % mod
    return ret

def main():
    n, a, b = map(int, input().split())
    mod = 10**9+7
#すべて
    ret = pow(2, n, mod)-1
#a,bの場合
    nCrsq = nCr(n, b, mod)
    ret -= nCrsq[b]
    ret -= nCrsq[a]

    print(ret%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10944
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUIntListFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO ()
main = do
    a <- getIntList
    let b = map (\x -> (x - 1, 1::Int)) a
    let c = VU.accum (+) (VU.replicate 10 0) b
    let ret = if (c VU.! 4 == 2) && (c VU.! 6 == 1) then "YES" else "NO"
    putStrLn ret



Measured memory_bytes: 380
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c[] = s.toCharArray();

    if (c[0] == c[1] && c[1] == c[2]) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


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

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

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

    int ans = 1, maxi = A[0];
    for(int i = 1; i < n; i++){
        if(maxi <= A[i]){
            ans++;
        }
        maxi = max(maxi, A[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
#include <chrono>
using namespace std;
typedef long long LL;


int main(void)
{
	
	chrono::system_clock::time_point start, end;
	start = chrono::system_clock::now();
	
	//printf("time %lf[ms]\n", time);
	

	LL D,dim=1;
	cin >> D;
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> randabc(1, 26);
	vector<vector<LL>> t(dim, vector<LL>(D + 1));

	


	vector<int> c(27);
	
	for (int i = 1; i <= 26; i++) {
		cin >> c[i];
	}
	vector<vector<LL>> s(D + 1, vector<LL>(27, 0));
	
	for (int i = 1; i <= D; i++) {
		for (int j = 1; j <= 26; j++) {
			cin >> s[i][j];
		}
	}

	LL man = 0;
	double timee;
	do {
		for (int i = 0; i < dim; i++) {
			for (int j = 1; j <= D; j++) {
				t[i][j] = randabc(mt);
			}
		}
		for (int k = 0; k < dim; k++) {
			vector<LL> last(27, 0);
			man = 0;
			for (int i = 1; i <= D; i++) {
				LL dis = 0;
				man += s[i][t[k][i]];
				last[t[k][i]] = i;
				for (int j = 1; j <= 26; j++) {
					dis += (c[j] * (i - last[j]));
				}
				man -= dis;
				//cout <<man<<endl;
			}
		}
		end = chrono::system_clock::now();
		timee = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
	}while((1000000+man)<0 && timee<=1950);



	for (int i = 0; i < dim; i++) {
		for (int j = 1; j <= D; j++) {
			cout << t[i][j] << endl;;
		}
	}


	return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,m,i,j,k,f;
    int *a;
    scanf("%d",&n);
    a = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        f=0;
        scanf("%d",&k);
        for(j=0;j<n;j++){
            if(a[k-1]+1==a[j]){
                f=1;
                break;
            }
        }
        if(f==1){continue;}
        a[k-1]++;
        if(a[k-1]>=2020){
            a[k-1]=2019;
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 2092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	d := iScan()
	fmt.Println((n + d*2) / (d*2 + 1))
}


Measured memory_bytes: 1768
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int K=sc.nextInt();
		long Mmin=0,Mmax=0;
		long ans=0;
		for(int a=0;a<K;a++) {
			Mmin+=a;
		}
		for(int a=0;a<K;a++) {
			Mmax+=N-a;
		}
		ans=Mmax-Mmin+1;
		//max-min+1
		int min=K;
		int max=N-K;
		//p(ans);
		for(int a=K+1;a<=N+1;a++) {
			Mmin+=min;
			Mmax+=max;
			ans=(ans+Mmax-Mmin+1)%mod;
			//if(ans<0)break;
			//System.out.println(ans);
			min++;max--;
			
		}
		p(ans);
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35844
#include<stdio.h>
int main()
{
	int a,b,c,d=0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i=a;i<=b;i++)
	{
		if(c%i==0)
		{
			d++;
		}
	}
	printf("%d\n",d);
}


Measured memory_bytes: 2044
program prob3
    implicit none
    integer::N, i, l, ans, a, b, c, j
    character(len=10)::s

    ans = 0
    a = 0
    b = 0
    c = 0
    read(*,*) N
    do j = 1, N
        read(*,*) s
        l = len_trim(s)
        do i = 1, l-1
            if(s(i:i) .eq. "A" .and. s(i+1:i+1) .eq. "B") then
                ans = ans + 1
            end if
        end do
        if(s(1:1) .eq. "B")then
            b = b+1
            if(s(l:l) .eq. "A")then
                c = c+1
            end if
        end if
        if(s(l:l) .eq. "A")then
            a = a+1
        end if
    end do
    ans = ans + min(a,b)
    if(a==c .and. b==c .and. a>0)then
        ans = ans - 1
    end if
    write(*,*) ans

    stop
end program

Measured memory_bytes: 2828
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main(void)
{
	long long int A, B;
	scanf("%lld%lld", &A, &B);
	long long int K = A + B;
	if (K % 2 == 1) {
		printf("IMPOSSIBLE");
		return 0;
	}
	printf("%lld", K/2);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<set>
using namespace std;

int NextNum( int num )
{
	if ( num % 2 == 0 ) {
		return num / 2;
	}
	else {
		return 3 * num + 1;
	}
}

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

	int next = s;
	set<int> nums;
	nums.insert( next );

	int idx = 1;
	while ( true ) {
		next = NextNum( next );
		pair<set<int>::iterator, bool> res =
			nums.insert( next );
		if ( !res.second ) {
			cout << idx + 1 << endl;
			return 0;
		}
		++idx;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

N,D=map(int,input().split(' '))
X = np.zeros(shape=(N,D))
for i in range(N):
  X[i]=np.array(list(map(int,input().split(' '))))

def distance(v1,v2):
  return np.linalg.norm(v1-v2)

res=0
C=itertools.combinations(list(range(N)),2)
for c in C:
  res+=distance(X[c[0]],X[c[1]]).is_integer()
print(res)

Measured memory_bytes: 12500
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0];
	return 0;
} 

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    ulong t = 1, a = 1;
    auto n = readln.chomp.to!int;

    foreach (_i; 0..n) {
        ulong tp, ap;
        readf("%d %d", &tp, &ap); readln;

        auto tpd = t / tp;
        auto tpr = t % tp;
        auto apd = a / ap;
        auto apr = a % ap;

        if (tpd > apd) {
            if (tpr) {
                t = tp * (tpd+1);
                a = ap * (tpd+1);
            } else {
                t = tp * tpd;
                a = ap * tpd;
            }
        } else {
            if (apr) {
                t = tp * (apd+1);
                a = ap * (apd+1);
            } else {
                t = tp * apd;
                a = ap * apd;
            }
        }
    }

    writeln(t + a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
//#define mod 100000000

using namespace std;



int main()
{
    //cout<<26*26*26+702;
    long long unsigned int n;
    cin>>n;
    string ans="";
    while(n)
    {

        n--;
        ans+= char('a'+ n%26 );
        n=n/26;
    }
    reverse(ans.begin(),ans.end());

    cout<<ans<<endl;

}









Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <list>
#include <queue>

using namespace std;

struct edge {int to, dist;
	edge(const int t, const int c): to(t), dist(c){}
};

int x[9] = {1, 1, 1, 1, 1, 2, 2, 2, 3};
int y[9] = {-2, -1, 0, 1, 2, -1, 0, 1, 0};
const int INF = 99999;

typedef pair<int, int> P;

void set_edge(vector<edge> G[], int s, int t, int w)
{
	G[s].push_back(edge(t,w));
}

int Dijkstra(const vector<edge> G[], int n, int s, int t)
{
	int* d = new int[n];
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+n, INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for (int i=0; i< G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v]+e.dist){
				d[e.to] = d[v]+e.dist;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	int dist = d[t];

	delete[] d;

	return dist;
}

int main()
{
	int w, h, ans;
	string str;

	while(true){
		cin >> w >> h;
		if(w==0 && h==0){return 0;}
		int* graph = new int[w*2*h];
		vector<edge> Graph[w*2*h];
		vector<int> s;
		vector<int> t;

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cin >> str;
				if(str == "X"){graph[i*w+j] = INF; graph[(i*w+j)+(h*w)] = INF;}
				else if(str == "S"){graph[i*w+j]=0; graph[(i*w+j)+(h*w)]=0; s.push_back(i*w+j); s.push_back((i*w+j)+(h*w));}
				else if(str == "T"){graph[i*w+j]=0; graph[(i*w+j)+(h*w)]=0; t.push_back(i*w+j); t.push_back((i*w+j)+(h*w));}
				else{ graph[i*w+j] = atoi(str.c_str()); graph[(i*w+j)+(h*w)] = graph[i*w+j];}
			}
		}
		/* 	二部グラフの作成 */
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(graph[i*w+j]!=INF){
					for(int k=0; k<9; k++){
						if((j+x[k]<w)&&(i-y[k]>=0)&&(i-y[k]<h)){
							if(graph[(i-y[k])*w+(j+x[k])]!=INF){ 
								set_edge(Graph, i*w+j, (i-y[k])*w+(j+x[k])+h*w, graph[(i-y[k])*w+(j+x[k])+h*w]);
							}
						}
						if((j-x[k]>=0)&&(i-y[k]>=0)&&(i-y[k]<h)){
							if(graph[(i-y[k])*w+(j-x[k])]!=INF){ 
								set_edge(Graph, i*w+j+h*w, (i-y[k])*w+(j-x[k]), graph[(i-y[k])*w+(j-x[k])+h*w]);
							}
						}

					}
				}
			}
		}

		delete[] graph;

		/* SどうしとTどうしを接続 */
		for(int i=0; i< s.size(); i++){
			for(int j=0; j< s.size(); j++){
				set_edge(Graph, s[i], s[j], 0);
			}
		}
		for(int i=0; i< t.size(); i++){
			for(int j=0; j< t.size(); j++){
				set_edge(Graph, t[i], t[j], 0);
			}
		}

		ans = INF; ans = min(ans,Dijkstra( Graph, w*h*2, s[0], t[0]));
		if(ans!=INF){cout << ans << endl;}
		else{cout << -1 << endl;}

	}
}

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

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

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n, x = 0, y = 0, t = 0;
  bool ok = true;
  cin >> n;
  rep(i, n) {
    ll nowx, nowy, nowt;
    cin >> nowt >> nowx >> nowy;

    if (((abs(nowx - x)) + (abs(nowy - y)) > (nowt - t)))
      ok = false;

    if (((nowt - t) - (abs(nowx - x)) - (abs(nowy - y))) % 2 != 0)
      ok = false;
    t=nowt,x=nowx,y=nowy;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    int sum = 0;
    REP (i, N) cin >> A[i], sum += A[i];
    cout << (sum >= H ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    ans = 0
    if n>=k:
        ans = x * k + y * (n - k)
    else:
        ans = x * n
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 38636
x,y=[int(x) for x in input().split()]
print("#"*y)
for i in range(x-2):
  print("#","."*(y-2),"#",sep="")
print("#"*y)

while True:
  x,y=[int(x) for x in input().split()]
  print()
  if x==0 and y==0:
    break
  else:
    print("#"*y)
    for i in range(x-2):
      print("#","."*(y-2),"#",sep="")
    print("#"*y)



Measured memory_bytes: 5644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		String s = null;
		
		try {
			String[] sp = scanner.nextLine().split(" ");
			s = sp[0];
		} catch (NumberFormatException e) {
		} catch (NullPointerException e) {
		}

		if(s.equals("Sunny")) {
			s = "Cloudy";
		}else if(s.equals("Cloudy")) {
			s = "Rainy";
		}else {
			s = "Sunny";
		}
		
		scanner.close();
		
	 	System.out.println(s);
	}
}


Measured memory_bytes: 20564
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

using Point = complex<ld>;

const ld eps = 1e-10;

bool comp(Point a, Point b) {
  return real(a - b) * 1.347589 + imag(a - b) > 0;
}

ld dot(Point a, Point b) { return real(conj(a) * b); }
ld cross(Point a, Point b) { return imag(conj(a) * b); }

struct Line {
  Point a, b;
  Line (Point p, Point q) : a(p), b(q) {;}
};

Point is_ll(Line s, Line t) {
  Point sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

void solve(ll N, vector<ll> x, vector<ll> y) {
  const Point p1 = Point(3.293485, 9.49480194);
  const Point p2 = Point(4.47101083, 9.1273874);
  const Line line(p1, p2);
  vector<Point> p(N);
  REP(i,N) p[i] = Point(x[i], y[i]);
  vector<pair<ld,int>> vec1;
  vector<ld> vec2;
  REP(i,N) REP(j,i) {
    Line l(p[i], p[j]);
    Point point = is_ll(l, line);
    const ld d = abs(point - p1);
    vec1.emplace_back(d, i);
    vec1.emplace_back(d, j);
    vec2.push_back(d);
  }
  sort(ALL(vec2));
  vector<ld> vec3;
  for (ld x: vec2) {
    if (vec3.empty() || abs(vec3.back() - x) > eps)
      vec3.push_back(x);
  }
  const int m = vec3.size();
  vector<set<int>> sets(m);
  for (auto p: vec1) {
    auto it = lower_bound(ALL(vec3), p.first - eps);
    sets[it - begin(vec3)].insert(p.second);
  }
  vector<int> two(256);
  const int mod = 998244353;
  two[0] = 1;
  REP(i,255) two[i+1] = two[i] * 2 % mod;
  int res = two[N];
  for (auto &s: sets) {
    res = (res - (two[s.size()] - 1 - s.size()) + mod) % mod;
  }
  res -= N + 1;
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
  ll N;
 	scanf("%lld", &N);
	vector<ll> x(N-1+1);
	vector<ll> y(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	}
	solve(N, x, y);
	return 0;
}


Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

void solve(int n,int m){
    vector<int> sum(n,0);
    rep(j,m){
        rep(i,n){
            int p; cin >> p;
            sum[i] += p;
        }
    }
    sort(all(sum));
    reverse(all(sum));
    cout << sum[0] << endl;
}

int main(){
    int n,m;
    while(1){
        cin >> n >> m;
        if(n == 0 and m == 0) break;
        solve(n,m);
    }
}



Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(a);in(b);
	printf("%d\n",(a-1)/b+1);
	return 0;
}

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

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

	vector<long> l(M),r(M);
	for(int i = 0; i < M; ++i) {
		cin >> l[i] >> r[i];
	}
	int max_l = *max_element(l.begin(), l.end());
	int min_r = *min_element(r.begin(), r.end());
	if(max_l > min_r) {
		cout << 0 << endl;
	} else {
		cout << min_r - max_l + 1 << endl;
	}
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a > b){
			a--;
		}
		System.out.println(a);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;
 
int main(){
	string n;
  	cin >> n;
  if(n[0] == n[2]){
    cout << "Yes" << endl;
  }else{
		cout << "No" << endl;
  }
return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int x = 0;
    cin>>s;
    for(int i=0; i<3; i++){
        if(s[i] == 'o'){
            x++;
        }
    }
    cout<< 700 + 100*x <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> >g(n + 3);
    for(int i = 1; i <= m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int k = 0;
    vector<int>vis(n + 3, 0);
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0){
            k++;
            vis[i] = 1;
            queue<int>q;
            q.push(i);
            while(!q.empty()){
                int u = q.front();
                q.pop();
                for(int j = 0; j < g[u].size(); j++){
                    int v = g[u][j];
                    if(vis[v] == 0){
                        vis[v] = 1;
                        q.push(v);
                    }
                }
            }
        }
    }
    cout << k;
    return 0;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
	char c;
	cin>>c;
	cout<<char(c+1)<<endl;	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import bisect

inf = float('inf')

def solve(S: str):
    N = len(S)
    rl = []
    for i in range(N-1):
        if S[i:i+2] == 'RL':
            rl.append(i+1)
    rl.append(inf)
    res = [0] * N
    j = 0
    rl_c = rl[j]
    for i, c in enumerate(S):
        if i >= rl_c:
            j += 1
            rl_c = rl[j]
            rl_p = rl[j-1]
        if c == 'R':
            diff = rl_c - i
            if diff % 2 == 0:
                res[rl_c] += 1
            else:
                res[rl_c-1] += 1
        else:
            diff = i - rl_p
            if diff % 2 == 0:
                res[rl_p] += 1
            else:
                res[rl_p-1] += 1
    print(' '.join(map(str, res)))
            
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52464
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; 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 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  map<char,char> m = {
    {'A','T'},
    {'C','G'},
    {'G','C'},
    {'T','A'},
  };
  char c;
  cin >> c;

  cout << m[c] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14

int main(){
	ll n, m, q, l, r; cin >> n >> m >> q;
	vector<vector<ll>> ansl(n,vector<ll>(n,0));
	REP(i,m){
		cin >> l >> r;l--;r--;
		ansl[l][r]++;
	}
	FOR(i,1,n-1) ansl[i][0]=ansl[i-1][0]+ansl[i][0];
	FOR(i,1,n-1) ansl[0][i]=ansl[0][i-1]+ansl[0][i];
	FOR(i,1,n-1)FOR(j,1,n-1) ansl[i][j]=ansl[i-1][j]+ansl[i][j-1]-ansl[i-1][j-1]+ansl[i][j];
	REP(i,q){
		cin >> l >> r;l--;r--;
		if (l==0) cout << ansl[r][r] << endl;
		else cout << ansl[r][r]-ansl[l-1][r]-ansl[r][l-1]+ansl[l-1][l-1] << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const ll INF = 1000000007;
const int MAX_V = 200002;
vi G[MAX_V];
int d[MAX_V];
void dfs(int v, int x) {
  d[v] = x;
  for (auto u : G[v]) {
    if (d[u] == -1) dfs(u, d[v] + 1);
  }
  return;
}

int main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  fill(d, d + MAX_V, -1);
  dfs(0, 0);
  int df[MAX_V];
  swap(d, df);
  fill(d, d + MAX_V, -1);
  dfs(n - 1, 0);
  int x = 0, y = 0;
  rep(i, n) {
    // cout<<df[i]<<":"<<d[i]<<endl;
    if (df[i] <= d[i])
      x++;
    else
      y++;
  }
  if (x == y) {
    if (n % 2) {
      print("Fennec");
    } else {
      print("Snuke");
    }
    return 0;
  }
  if (x > y) {
    print("Fennec");
  } else {
    print("Snuke");
  }
  return 0;
}

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

#define endl "\n"
#define int long long int

#define MOD 998244353

int32_t main()
{
	int n, k;
	cin >> n >> k;
	vector<pair<int, int> > v(k);
	for(int i=0;i<k;i++)
	{
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());

	vector<int> cnt(n+1, 0), sum(n+1, 0);
	cnt[n-1] = 1;
	sum[n-1] = 1;
	for(int i=n-2;i>=0;i--)
	{
		int indx = -1;
		for(int j=0;j<k;j++)
		{
			if(i+v[j].second < n)	
			{
				indx = j;
				cnt[i] += sum[i+v[j].first] - sum[i+v[j].second+1];
				cnt[i] += MOD;
				cnt[i] %= MOD;
			}
			else break;
		}
		indx++;
		if(indx<k && i+v[indx].first < n)
		{
			cnt[i] += sum[i+v[indx].first];
			cnt[i] %= MOD;
		}
		sum[i] = cnt[i] + sum[i+1];
		sum[i] %= MOD;
	}
	cout << cnt[0] << endl;
	return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){   
    if (b!=0) return gcd(b, a%b);
    else return a;
}

int main(){
    int n,ans=1;
    cin >> n;
    vector<int> a(n),l(n),r(n);
    for(int i=0;i<n;i++) cin>>a.at(i);
    l[0]=a[0];
    r[0]=a[n-1];
    for(int i=1;i<n;i++){
        l[i]=gcd(l[i-1],a[i]);
    }
    for(int i=1;i<n;i++){
        r[i]=gcd(r[i-1],a[n-i-1]);
    }
    for(int i=1;i<n-1;i++){
        ans=max(gcd(l[i-1],r[n-i-2]),ans);
    }
    ans=max(l[n-2],ans);
    ans=max(r[n-2],ans);
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int main() {
  int A,B;

  cin >> A>>B ;

  cout << max(0,A-B*2) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[100005];
int main()
{
  int n, t, a;
  cin >> n >> t >> a;
 
    int k = -1;
    double minDiff = 99999999.0;
    for(int i=0; i<n; ++i){
        int h;
        cin >> h;
        double temp = t - h * 0.006;
        double diff = abs(a - temp);
        if(diff < minDiff){
            minDiff = diff;
            k = i;
        }
    }
    cout << (k + 1) << endl;
 
    return 0; 	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    if(n%2==0)cout<<0.5<<endl;
    else cout<<(double)(n+1)/2/(double)n<<endl;
}

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

#define rep(i, n) for(int i=0; i < (int)n; i++)

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) cin >> a.at(i);
  reverse(a.begin(), a.end());

  for(int i=0; i < n; i++) {
    cout << a[i];
    if(i != n-1) cout << " ";
  }
  cout << endl;
}



Measured memory_bytes: 3072
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
    int A=int.Parse(str[0]);
    int B=int.Parse(str[1]);
    int C=int.Parse(str[2]);
      if((A-B)>=C){
        Console.WriteLine(0);
      }else{
        Console.WriteLine(C-(A-B));
      }
    }
    
  }

}


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

import sys
import os

#input_text_path = __file__.replace('.py', '.txt')
#fd = os.open(input_text_path, os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

w, h, x, y, r = list(map(int, input().split()))
if x - r >= 0 and x + r <= w and y - r >= 0 and y + r <= h:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7672
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int dfs(int N){
  if(N<6) return N;

  int beki9 = 1;
  int beki6 = 1;
  while(beki9<=N) beki9 *= 9;
  while(beki6<=N) beki6 *= 6;
  beki9 /= 9;
  beki6 /= 6;
  int tmp1 = dfs(N-beki9) + 1;
  int tmp2 = dfs(N-beki6) + 1;
  return min(tmp1,tmp2);
}

int main(){
  int N;
  cin >> N;
  cout << dfs(N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m,w,t;
map<string,int> a;
vl v,p,l,x,y;
vvl r,q;

ll f(int i,int j){
	return abs(x[i]-x[j])+abs(y[i]-y[j]);
}

int main(){
	cin>>n>>m>>w>>t;
	v=p=vl(m);
	l=x=y=vl(n);
	r=q=vvl(n);
	vvl dp(1<<n,vl(n,INF));
	vl DP(1<<n,INF),dp2(t+1);
	for(int i=0;i<m;i++){
		string s;
		cin>>s>>v[i]>>p[i];
		a[s]=i;
	}
	for(int i=0;i<n;i++){
		cin>>l[i]>>x[i]>>y[i];
		r[i]=q[i]=vl(l[i]);
		for(int j=0;j<l[i];j++){
			string s;
			cin>>s>>q[i][j];
			r[i][j]=a[s];
		}
	}
	for(int i=0;i<n;i++) dp[1<<i][i]=abs(x[i])+abs(y[i]);
	for(int i=0;i<1<<n;i++) for(int j=0;j<n;j++) if(i&1<<j){
		ll I=i-(1<<j);
		for(int k=0;k<n;k++) if(I&1<<k){
			dp[i][j]=min(dp[i][j],dp[I][k]+f(k,j));
		}
		DP[i]=min(DP[i],dp[i][j]+abs(x[j])+abs(y[j]));
	}
	for(int i=1;i<1<<n;i++){
		vl b(m),dp1(w+1);
		for(int j=0;j<n;j++) if(i&1<<j){
			for(int k=0;k<l[j];k++) b[r[j][k]]=max(b[r[j][k]],p[r[j][k]]-q[j][k]);
		}
		for(int j=0;j<m;j++){
			for(int k=v[j];k<=w;k++) dp1[k]=max(dp1[k],dp1[k-v[j]]+b[j]);
		}
		for(int j=DP[i];j<=t;j++) dp2[j]=max(dp2[j],dp2[j-DP[i]]+dp1[w]);
	}
	cout<<dp2[t]<<endl;
}

Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w, A, B; scanf("%d%d%d%d", &h, &w, &A, &B);
	
	std::vector<std::string> s(h, std::string(w, '0'));

	for(int i = 0; i < h; i++) {
		if(i < B) {
			for(int j = 0; j < A; j++) s[i][j] = '1';
		} else {
			for(int j = A; j < w; j++) s[i][j] = '1';
		}
	}
	
	for(auto v: s) cout << v << endl;
	return 0;
}


Measured memory_bytes: 2304
N = int(input())
A = [int(i) for i in input().split()]
C = [0 for i in range(10**5+1)]
for a in A:
    C[a] += 1
s = False
for i in range(1, len(C)):
    if C[i] >= 2:
        if C[i] % 2 == 0:
            s = not s
if s:
    print(len(set(A))-1)
else:
    print(len(set(A)))


Measured memory_bytes: 15012
#include <algorithm>
#include <iostream>
using namespace std;

int matatabiTable[16][16];
int heiankyoTable[16][16];

int N;
int gx,gy;
int p;
int x_1,y_1,x_2,y_2;

int main() {
  cin >> N;

  for (int i=0;i<N;i++) {
    for (int j=0;j<16;j++) {
      for (int k=0;k<16;k++) {
	matatabiTable[j][k] = 0;
	heiankyoTable[j][k] = 0;
      }
    }
    // 0行0列にはマタタビが置かれていると考える
    for (int j=0;j<16;j++) {
      matatabiTable[j][0] += 2;
    }
    for (int k=0;k<16;k++) {
      matatabiTable[0][k] += 1;
    }
    cin >> gx >> gy;
    cin >> p;
    for (int j=0;j<p;j++) { // matatabiTableの作成
      cin >> x_1 >> y_1 >> x_2 >> y_2;
      if (x_1 == x_2) { // 上にマタタビの場合
	matatabiTable[x_1][max(y_1,y_2)] += 2;
      } else if (y_1 == y_2) { //左にマタタビの場合
	matatabiTable[max(x_1,x_2)][y_1] += 1;
      } else {
      
      }
    }
    /*
    for (int j=0;j<15;j++) {
      for (int k=0;k<15;k++) {
	cout << matatabiTable[k][j] << " ";
      }
      cout << endl;
    }
    cout << endl;
    */
    for (int j=0;j<=gx;j++) {
      for (int k=0;k<=gy;k++) {
	if (j==0 && k==0) {
	  heiankyoTable[j][k] = 1;
	} else if (matatabiTable[j][k] == 3) {
	  heiankyoTable[j][k] = 0;
	} else if (matatabiTable[j][k] == 2) {
	  heiankyoTable[j][k] = heiankyoTable[j-1][k];
	} else if (matatabiTable[j][k] == 1) {
	  heiankyoTable[j][k] = heiankyoTable[j][k-1];
	} else {
	  heiankyoTable[j][k] = heiankyoTable[j][k-1] + heiankyoTable[j-1][k];
	}
      }
    }
    /*
    for (int j=0;j<15;j++) {
      for (int k=0;k<15;k++) {
	cout << heiankyoTable[k][j] << " ";
      }
      cout << endl;
    }
    */
    if (heiankyoTable[gx][gy] > 0) {
      cout << heiankyoTable[gx][gy] << endl;
    } else {
      cout << "Miserable Hokusai!" << endl;
    }
  }
}

Measured memory_bytes: 1160