akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C = MAP()
l = [INT() for i in range(N)]

def dfs(idx, a, b, c):
    if idx == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(idx+1, a, b, c)
    ret1 = dfs(idx+1, a + l[idx], b, c) + 10
    ret2 = dfs(idx+1, a, b + l[idx], c) + 10
    ret3 = dfs(idx+1, a, b, c + l[idx]) + 10
    return min(ret0, ret1, ret2, ret3)
if __name__ == "__main__":
    print(dfs(0, 0, 0 ,0))

Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(N , K , S);
  int M = 1000000000;
  vi ans(N);
  if(K == N){
    rep(i , N) ans[i] = S;
    out(ans);
  } 
  else if(K == 0){
    rep(i , N) ans[i] = (S == M ? M - 1 : M);
    out(ans);
  }
  else if(S == 1){
    rep(i , K) ans[i] = 1;
    for(int i = K ; i < N ; i++) ans[i] = M;
    out(ans);
  }
  else{
    ans[0] = 1;
    rep1(i , K) ans[i] = S - ans[i - 1];
    for(int i = K + 1 ; i < N ; i++){
      ans[i] = (S == M ? M - 2 : M);
    }
    out(ans);
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)


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

  VI C, S, F;
  REP(i, N-1) {
    int c, s, f;
    cin >> c >> s >> f;
    C.PB(c);
    S.PB(s);
    F.PB(f);
  }
  REP(i, N-1) {
    int time = 0;
    FOR(j, i, N-1) {
      if (time < S[j])
        time = S[j];
      else {
        int times = (time - S[j] + F[j] - 1) / F[j];
        time = S[j] + F[j] * times;
      }
      time += C[j];
    }
    cout << time << endl;
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,m;
    cin>>n>>m;
    int ans = n*(n-1);
    ans/=2;
    int ans2 = m*(m-1);
    ans2/=2;
    cout<<ans+ans2;


    printclock;
    return 0;
}


Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod
#define maxm
#define maxn
ll s[200010];
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n, x;
	
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x);
		s[i] = s[i - 1] + x;
	}
	ll ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i < n; i++) {
		ans = min(ans, abs(s[n] - s[i] - s[i]));
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
N = int(input())
P = [None] + list(map(int, input().split()))

p_to_index = [None] * (N + 1)
for index, x in enumerate(P[1:], 1):
    p_to_index[x] = index


def BIT_add(i):
    while i <= N:
        tree[i] += 1
        i += i & (-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i & (-i)
    return s

def BIT_search(x):
    i = 0
    s = 0
    step = 1 << (len(bin(N)[2:]) - 1)
    while step:
        if i + step <= N and s + tree[i + step] < x:
            i += step
            s += tree[i]
        step >>= 1
    return i + 1

tree = [0] * (N + 1)
ans = 0
for x in range(N, 0, -1):
    c = p_to_index[x]
    L = BIT_sum(c-1)
    R = N - x - L
    a = BIT_search(L - 1) if L >= 2 else 0
    b = BIT_search(L) if L >= 1 else 0
    d = BIT_search(L + 1) if R >= 1 else N + 1
    e = BIT_search(L + 2) if R >= 2 else N + 1
    BIT_add(c)
    tmp = 0
    if b != 0:
        tmp += (b - a) * (d - c)
    if d != 0:
        tmp += (e - d) * (c - b)
    ans += tmp * x

print (ans)


Measured memory_bytes: 63944
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn solve(s: Vec<char>) -> u64 {
    let s: Vec<u64> = s
        .into_iter()
        .map(|c| c.to_digit(10).unwrap() as u64)
        .collect();
    let len = s.len();
    let pat = 1 << (len - 1);
    let mut res = 0;

    for i in 0..pat {
        let mut local_res = 0;
        for j in 0..len {
            if (i << j & pat) == pat {
                res += local_res;
                local_res = 0;
            } else {
                local_res *= 10
            }
            local_res += s[j];
        }
        res += local_res;
    }
    res
}

fn main() {
    input! {s: chars};
    println!("{}", solve(s));

}


Measured memory_bytes: 4352
n = int(input())
p = [(int(x), i) for i, x in enumerate(input().split())]
p.sort(reverse=True)

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: return
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

bit = BinaryIndexedTree(n)
ans = 0

for x, i in p:
    i += 1
    bit.add(i, 1)
    idx = bit.sum(i)
    l1, l2 = bit.lower_bound(idx-1), bit.lower_bound(idx-2)
    r1, r2 = bit.lower_bound(idx+1), bit.lower_bound(idx+2)
    ans += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * x

print(ans)


Measured memory_bytes: 60048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.fishingSheetCalculation();
		return;
	}
	
	//1000円を出した場合のお釣りの枚数を計算する
	private void fishingSheetCalculation() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			while (true) {
				
				String inputStr = bufferedReader.readLine();
				int paymentAmountNum = Integer.parseInt(inputStr); //支払金額を計算
				
				//入力された値が0ならば、入力は終了とみなす
				if (paymentAmountNum == 0) {
					break;
				}
				
				int fishingNum = 1000 - paymentAmountNum; //お釣りの金額を計算
				
				int coinSheetsNum = 0; //お釣りとして渡す硬貨の枚数
				while (true) {
					
					if (fishingNum >= 500) {
						fishingNum = fishingNum - 500;
						coinSheetsNum++;
					} else if (fishingNum >= 100) {
						fishingNum = fishingNum - 100;
						coinSheetsNum++;
					} else if (fishingNum >= 50) {
						fishingNum = fishingNum - 50;
						coinSheetsNum++;
					} else if (fishingNum >= 10) {
						fishingNum = fishingNum - 10;
						coinSheetsNum++;
					} else if (fishingNum >= 5) {
						fishingNum = fishingNum - 5;
						coinSheetsNum++;
					} else if (fishingNum >= 1) {
						fishingNum = fishingNum - 1;
						coinSheetsNum++;
					} else if (fishingNum == 0) {
						break;
					}
					
				}
				
				System.out.println(coinSheetsNum);
			}
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 16860
// Problem : F - LCS
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_f?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 2000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
string s, t;
int mem[3011][3011];
int solve(int i = 0, int j = 0) {
	if (i == s.size() || j == t.size())return 0;
	int& ret = mem[i][j];
	if (~ret)return ret;
	ret = 0;
	if (s[i] == t[j])return ret=solve(i + 1, j + 1) + 1;
	ret = solve(i + 1, j);
	ret = max(ret, solve(i, j + 1));
	return ret;
}
void build(int i = 0, int j = 0) {
	if (i == s.size() || j == t.size())return;
	int ret = mem[i][j];
	if (s[i] == t[j]&&ret == solve(i + 1, j + 1) + 1) {
		cout << s[i];
		return build(i + 1, j + 1);
	}
	if (ret == solve(i + 1, j)) {
		return  build(i + 1, j);
	}
	if (ret == solve(i, j + 1)) {
	return 	build(i, j + 1);
	}
}
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	cin >> s >> t;
	clr(mem, -1);
	solve();
	build();
}


Measured memory_bytes: 39344
<?php
	$n = intval(fgets(STDIN)) - 1;
	$val = explode(" ",str_replace("\n","",fgets(STDIN)));

	for($i = $n;$i >= 0;$i -= 2){
		echo $val[$i]." ";
	}
    
	for($j = abs($i + 1);$j <= $n;$j += 2){
		echo $val[$j]." ";
	}
?>

Measured memory_bytes: 40532
type ABC(stream:System.IO.TextReader) =
  member this.Scan2 f1 f2 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1]))

let util = ABC(stdin)

let N, L = util.Scan2 int int
let xs = [1..N] |> List.map (fun i -> L + i - 1)
let tot = List.sum xs
let eat = List.minBy abs xs

printfn "%d" <| tot - eat


Measured memory_bytes: 14172
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;

int main(void)
{
  int n;
  int a,t;
  int h[100010];
  scanf("%d %d %d",&n,&t,&a);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  ll min=100010000;
  int min_n;
  for(int i=0;i<n;i++){
    ll tmp=abs(a*1000-(t*1000-h[i]*6));
    //printf("%lld\n",tmp);
    if(tmp<min){
      min=tmp;
      min_n=i+1;
    }
  }

  printf("%d\n",min_n);
  return 0;
}


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

map<pair<ll,ll>, ll> dp;

ll solve(ll S,ll X){
  if(S<0||X<0) return 0;
  if(dp[make_pair(S,X)]!=0) return dp[make_pair(S,X)];
  if(S==0&&X==0) return 1;
  if(S==1&&X==0) return 1;
  if(S==0&&X==1) return 1;
  if(S==1&&X==1) return 2;
  ll res=solve(S/2,X/2)%MOD;
  if(S>=1&&X>=1) res=(res+solve((S-1)/2,(X-1)/2))%MOD;
  if(S>=2) res=(res+solve((S-2)/2,X/2))%MOD;
  dp[make_pair(S,X)]=res;
  return res;
}

int main(){
  ll N; cin>>N;
  cout<<solve(N,N)<<endl;
  return 0;
}


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

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			long x = cin.nextLong();
			long y = cin.nextLong();

			long a = x;
			int ans = 0;
			while (a<=y)
			{
				a *= 2;
				ans++;
			}
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	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: 13140
#include <iostream>
using namespace std;

int main(){
 int n,i;
 cin >> n ;
 int a[100];
 for(i=0;i<n;i++) cin >> a[i] ;

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

 return 0;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int N; 
vl X, Y; 

int solve1() {
    int res = -1;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int d = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
            res = max(d, res);
        }
    }
    return res;
}

ll solve2() {
    vl z(N), w(N);
    rep(i, N) {
        z[i] = X[i] + Y[i];
        w[i] = X[i] - Y[i];
    }
    ll zmax = -LINF, wmax = -LINF, zmin = LINF, wmin = LINF;
    rep(i, N) {
        zmax = max(zmax, z[i]);
        wmax = max(wmax, w[i]);
        zmin = min(zmin, z[i]);
        wmin = min(wmin, w[i]);
    }

    return max(zmax - zmin, wmax - wmin);
}


int main() {
    cin >> N;
    X.resize(N); Y.resize(N);
    rep(i, N) cin >> X[i] >> Y[i];

    cout << solve2() << endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v.at(i);
    int ans = 0;
    for(int l = 0; l <= k;l++){
        for(int r = 0; r <= k-l;r++){
            if(l+r > n) continue;
            int d = k - l - r;
            int now = 0;
            vector<int> s;
            for(int i = 0; i < l;i++){
                now += v.at(i);
                s.push_back(v.at(i));
            }
            for(int i = n-r; i < n;i++){
                now += v.at(i);
                s.push_back(v.at(i));
            }
            sort(s.begin(),s.end());
            for(int i = 0;i < d;i++){
                if(i >= s.size()) break;
                if(s.at(i) >= 0) break;
                now -= s.at(i);
            }
            ans = max(ans,now);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, k;
	cin >> a >> b;
	k = abs(a - b);
	if (k % 2 == 0) {
		
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
   string s;
   cin>>s;
   long long rcou=0;
   long long lcou=0;
   rep(i,s.size()){
       if(s.at(i)=='R'){
           rcou++;
       }
       else{
           lcou++;
       }
       if(i!=s.size()-1){
        if(s.at(i)=='L'&&s.at(i+1)=='R'){
          rep(j,rcou-1){
              cout<<0<<" ";
          } 
          long long fr,fl;
          fr=rcou/2+rcou%2+lcou/2;
          fl=lcou/2+lcou%2+rcou/2;
          cout<<fr<<" "<<fl<<" ";
          rep(j,lcou-1){
              cout<<0<<" ";
          }
          rcou=0;lcou=0;
        }
       }
        else{
            
                rep(j,rcou-1){
                    cout<<0<<" ";
                } 
                long long fr,fl;
                fr=rcou/2+rcou%2+lcou/2;
                fl=lcou/2+lcou%2+rcou/2;
                cout<<fr<<" "<<fl<<" ";
                rep(j,lcou-1){
                    cout<<0<<" ";
                }
                rcou=0;lcou=0;
                cout<<endl;
        
        }
    }
   
}


Measured memory_bytes: 640
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const int MX = 500005;
const int MM = 1000000007;

char A[MX], B[MX];
int X[MX], Y[MX];
int N, M;

int main()
{
	scanf("%s%s", A+1, B+1);
	N = strlen(A+1), M = strlen(B+1);
	for(int i = 1; i <= N; i++) X[i] = X[i-1] + (A[i] == 'A'? 1:-1);
	for(int i = 1; i <= M; i++) Y[i] = Y[i-1] + (B[i] == 'A'? 1:-1);

	int Q, a, b, c, d;
	scanf("%d", &Q);
	for(int i = 1; i <= Q; i++){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf("%s\n", (X[b] + Y[c-1] - X[a-1] - Y[d]) % 3 == 0? "YES":"NO");
	}
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



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

    int n;
    cin>>n;

    int ans = n%1000;
    
    if(ans!=0)
        ans =abs(ans - 1000);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int[] d = na(n);
    int m = ni();
    int[] t = na(m);
    Arrays.sort(d);
    Arrays.sort(t);

    int ptr = -1;
    for (int x : t) {
      ptr ++;
      while (x > d[ptr]) {
        ptr ++;
      }
      if (d[ptr] != x) {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 66080
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  string s;
  cin >> s;
  if (s.size() == 1) {
    cout << 1 << endl;
    return 0;
  }
  vvl d(2, vl(s.size(), 0));
  d[0][0] = 1;
  d[1][0] = 0;
  d[1][1] = 1;
  REP(i, 1, s.size()) {
    if (s[i] != s[i - 1]) {
      d[0][i] = max(d[0][i], d[0][i - 1] + 1);
    }
    d[0][i] = max(d[0][i], d[1][i - 1] + 1);
    // cout << i << ":" << d[1][i - 1] << endl;
    if (i >= 2) {
      d[1][i] = max(d[0][i - 2] + 1, d[1][i]);
      if (i >= 3) {
        if (s[i - 3] != s[i - 1] && s[i - 2] != s[i]) {
          d[1][i] = max(d[1][i - 2] + 1, d[1][i]);
        }
      }
    }
  }
  // rep(i, 2) {
  //   rep(j, 6) { cout << d[i][j]; }
  //   cout << endl;
  // }
  cout << max(d[0][s.size() - 1], d[1][s.size() - 1]) << endl;
  return 0;
}


Measured memory_bytes: 5244
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int OK1,OK2;
int main(){
	string s;
	cin>>s;
	rb(i,0,s.length()-1-3){
		if(OK1==0){
			if(s[i]=='1'){
			if(s[i+1]<='2'&&s[i+1]>='0'){
				if(s[i+2]>='0'&&s[i+2]<='9'&&s[i+3]<='9'&&s[i+3]>='0'){
					OK1=1;
//					i+=4;
				}
			}
		}
		if(s[i]=='0'){
			if(s[i+1]<='9'&&s[i+1]>='1'){
				if(s[i+2]>='0'&&s[i+2]<='9'&&s[i+3]<='9'&&s[i+3]>='0'){
					OK1=1;
//					i+=4;
				}
			}
		}
		}
		if(OK2==0){
			if(s[i]>='0'&&s[i]<='9'&&s[i+1]<='9'&&s[i+1]>='0'){
			if(s[i+2]=='1'){
				if(s[i+3]<='2'&&s[i+3]>='0'){
					OK2=1;
//					i+=4;
				}
			}
			if(s[i+2]=='0'){
				if(s[i+3]<='9'&&s[i+3]>='1'){
					OK2=1;
//					i+=4;
				}
			}
		}
		}
		
	}
	if(OK1&&OK2){
		printf("AMBIGUOUS\n");
		return 0;
	}
	if(!OK1&&!OK2){
		printf("NA\n");
		return 0;
	}
	if(OK1){
		printf("MMYY");
	}
	else{
		printf("YYMM");
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<utility>
#include<deque>
using namespace std;
#define MOD 1000000007
typedef long long ll;

ll kai[100001];
ll n,ans;
vector<ll> l,r;
char s[200010];
int a[200001];
int main(){
    scanf("%lld",&n);
    scanf("%s",s);
    if(s[0]=='W'||s[2*n-1]=='W'){
        printf("0\n");
        return 0;
    }
    kai[0]=1;
    for(ll i=1;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=MOD;
    }
    for(int i=1;i<2*n;i++){
        if(s[i]==s[i-1]){
            a[i]=a[i-1]^1;
        }
        else{
            a[i]=a[i-1];
        }
    }
    ans=1;
    for(int i=0;i<2*n;i++){
        if(a[i]){
            if(l.size()>r.size()){
                ans*=(ll)(l.size()-r.size());
                ans%=MOD;
            }
            else{
                printf("0\n");
                return 0;
            }
            r.push_back(i);
        }
        else{
            l.push_back(i);
        }
    }
    ans*=kai[n];
    ans%=MOD;
    if(l.size()!=r.size()){
        ans=0LL;
    }
    printf("%lld\n",ans);
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

int main() {

	int n, k;
	cin >> n >> k;

	vi dp(100000+100,1), a(n);

	tik(i,0,n)
		cin >> a[i];

	tik(i,1,100000+100) {
		tik(j,0,n) {
			if(i-a[j] < 0)
				continue;
			dp[i] &= !dp[i-a[j]]; 
		}
	}

	if(dp[k])
		cout << "Second";
	else
		cout << "First";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
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; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 



int main() {
  int X,Y;cin>>X>>Y;
  cout << X+Y/2 << endl;
  return 0;
} 


Measured memory_bytes: 3572
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.length();
	if(l==2){
		cout<<s;
	}
	else{
		for(int i=2;i>=0;i--){
			cout<<s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hh = readLine()!!.split(" ").map { it.toInt() }

    val dp = IntArray(n){ Int.MAX_VALUE }

    for (i in 0 until n) {

        //println("h:$i")

        if (i == 0) {
            dp[i] = 0
            continue
        }

        val start = Math.max(0, i-k)
        var min = Int.MAX_VALUE

        for (j in start until i) {
            min = Math.min(min, dp[j] + Math.abs(hh[j]-hh[i]))
            //println("$j to $i /min: $min")
        }

        dp[i] = min
    }

    println(dp[n-1])
}

Measured memory_bytes: 51700
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	string s;
	cin >> s;
	int n = s.size();
	int r = 1, l = n+1;
	while (r+1< l)
	{
		int now = (r+l)/2;
		bool ch = true;
		for(int i = n-now; i<= now-2; i++){
			if(s[i]!=s[i+1]) ch = false;
		}
		if(ch) r=now;
		else l = now;
	}
	
	cout << r << endl;
}

Measured memory_bytes: 3760
# EduDPD - Knapsack 1
import sys
input = sys.stdin.readline

n, w = list(map(int, input().rstrip().split()))
arr = [tuple(map(int, input().rstrip().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
    for j in range(w, arr[i][0] - 1, -1):
        dp[j] = max(dp[j], dp[j - arr[i][0]] + arr[i][1])
print(max(dp))

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


#include <bits/stdc++.h>

using namespace std;

class DWall {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int h, w;
        cin >> h >> w;
        vector<vector<int>> c(10, vector<int>(10));
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                cin >> c[i][j];
            }
        }
        vector<vector<int>> a_vec(h, vector<int>(w));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> a_vec[i][j];
            }
        }
        for (int l = 0; l < 3; ++l) {
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < 10; ++j) {
                    for (int k = 0; k < 10; ++k) {
                        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
                    }
                }
            }
        }
        int ans = 0;
        for (const auto &row : a_vec) {
            for (const auto &a : row) {
                if (a == -1)continue;
                ans += c[a][1];
            }
        }
        cout << ans << endl;
    }
};


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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main(){
    int n, m ;
    vector<vector<int>> vec (1000005) ;
    cin >> n >> m ;
    rep(i, n){
        int a, b ;
        cin >> a >> b ;
        a-- ;
        vec[a].push_back(b) ;
    }
    int ans = 0 ;
    priority_queue<int, vector<int>> que ;
    rep(i, m){
        int k = vec[i].size() ;
        rep(j, k){
            que.push(vec[i][j]) ;
        }
        if(!que.empty()){
            ans += que.top() ;
            que.pop() ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 29420
#include <iostream>
using namespace std;
char ch[100000000];
int main() {
   string s;
   cin >> s;
   for (int i = 0; i < s.size(); ++ i){
      ch[i] = s[i];
   }
   cout << ch[0];
   for (int i = 1; i < s.size(); ++ i){
      if (i % 2 == 0){
      	cout << ch[i];
      }
   }  	
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";

int main(){
    int n, m;
    cin >> n >> m;
    vector<vi> to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].pb(b);
        to[b].pb(a);
    }
    queue<int> q;
    vi dir(n, -1);
    q.push(0);
    while (!q.empty()) {
        int p = q.front(); q.pop();
        for (int i : to[p]) {
            if (dir[i]!=-1) continue;
            q.push(i);
            dir[i] = p;
        }
    }
    cout << YES << endl;
    rep1(i, n-1) cout << dir[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 10100
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if(a1+a2+a3>=22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  


  return 0;
}



Measured memory_bytes: 256
k = input()
a, b = (int(x) for x in input().split())
K = int(k)
A = int(a)
B = int(b)
C = B - A + 1
p = 1

for p in range(C):
    if A % K == 0:
        i = 1
        break
    else:
        A += 1
        i = 0

if i == 1:
    print('OK')
else:
    print('NG')


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

int main() {
    string s;
    cin >> s;
    bool corner = true;
    for (int i=1; i<s.size(); ++i) {
        if (s[i] != '9') corner = false;
    }
    int ans;
    if (corner) {
        ans = (s[0] - '0') + (s.size()-1)*9;
    } else {
        ans = (s[0] - '0' - 1) + (s.size()-1)*9;
    }
    cout << ans << endl;
}

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

int sumsum(int n){
    int sum = 0;

    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    
    int total_AtoB = 0;

    for(int i=1;i<N+1;i++){
        int tmp = sumsum(i);
        if(A<=tmp && tmp<=B){
            //cout << i << endl;
            total_AtoB += i;
        }
    }

    cout << total_AtoB << endl;


}

Measured memory_bytes: 256
#include <iostream>


int main(){

    std::string s;
    std::cin >> s;

    if(s.length()%2 != 0||s.length() == 0 || s.length() > 10){
        std::cout << "No";
        return 0;
    }

    for(int i = 0; i < s.length(); i+=2){
        if(s[i] != 'h' || s[i+1] != 'i'){
            std::cout << "No";
            return 0;
        }
    }

    std::cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n,m,x;
  scanf("%d %d %d", &n, &m, &x);
  int a[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i]);
  }
  int left = 0;
  for (int i = 0; i < m; i++) {
    if (a[i] < x) {
      left++;
    } else {
      break;
    }
  }
  int right = m-left;
  int answer = left;
  if (right < left) {
    answer = right;
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(c) begin(c), end(c)
using namespace std;

template <class T>
void scrib_impl(char const* title, T v){
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

int main() {
    int n = 0;
    string s{}, t{}, a{};
    cin >> n >> s >> t;
    
    REP(i, n) {
        a += s.at(i);
        a += t.at(i);
    }
    
    cout << a << endl;
    
    return 0;
}


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

int main() {
	vector<int> a(5);
	int k;
	rep(i,5){
		cin >> a[i];
	}
	cin >> k;
	string ans = "Yay!";
	for (int i = 0; i < 4; i++){
		for (int j = 1; j < 5; j++){
			if (a[j] - a[i] > k) ans = ":(";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    unordered_set<int> us;
    rep(i, a.size()) us.emplace(a[i]);
    YORN(a.size() == us.size())

    return 0;
}

Measured memory_bytes: 12232
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

class factorials:
    '''
    args:
      n : max val when exploring factorials
    '''
    def __init__(self, n=1):
        self.n = 1# factorials to be searched
        self.factorials = []
        self.update_factorials(n)

    def update_factorials(self, n):
        if self.n >= n:
            return None
        for i in range(self.n+1, n+1):
            done = False
            limit = int(i ** 0.5)
            for j in self.factorials:
                if j > limit: break
                if not i % j:
                    done = True
                    break
            if not done:
                self.factorials.append(i)
        self.n = n
        return None

    def factorials_list(self):
        return self.factorials

    def check_fact(self, x):
        if x > self.n**2:
            self.update_factorials(int(x ** 0.5)+1)
        for f in self.factorials:
            if not x % f:
                return False
        return True

    def prime_factorization(self, val, divisors=None):
        # divisors : default-dict of divisors. Should be specified only if appended vals are required
        max_n = int(math.sqrt(val))
        if self.n < max_n:
            self.update_factorials(max_n)
        if divisors == None:
            divisors = defaultdict(lambda: 0)
        for f in self.factorials:
            if f > val: break
            while True:
                if not val % f:
                    divisors[f] += 1
                    val //= f
                else:
                    break
        if val > 1:
            divisors[val] += 1
        return divisors

def run():
    N = int(input())
    FACT = factorials()
    max_n = int(math.sqrt(N))
    divisors = defaultdict(lambda: 0)
    for n in range(2, N+1):
        divisors = FACT.prime_factorization(n, divisors)
    #print(divisors)
    mod = 10 ** 9 + 7
    ans = 1
    for key, value in divisors.items():
        ans *= value+1
        ans %= mod
    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 9716