akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

noded = {}
edad = {}

class Node:
    def __init__(self, index):
        self.index = index
        self.color = -1
        self.eda_list = []

class Eda:
    def __init__(self, index, w, left, right):
        self.index = index
        self.w = w
        self.left = left
        self.right = right

def color_oppo_of(node):
    c = node.color
    for eda in [edad[edai] for edai in node.eda_list]:
        if eda.right == node.index:
            oppo = eda.left
        else:
            oppo = eda.right

        if noded[oppo].color == -1:
            if eda.w % 2 == 0:
                noded[oppo].color = node.color
            else:
                noded[oppo].color = (node.color + 1) % 2
            color_oppo_of(noded[oppo])

def solve():
    n = int(input())
    if n == 1:
        print("0")
    else:
        do(n)


def do(n):
    for i in range(n-1):
        U, V, W = map(int, input().split())
        u = U
        v = V
        w = W

        eda = Eda(i, w, u, v)
        edad[i] = eda

        if u not in noded.keys():
            noded[u] = Node(u)
        noded[u].eda_list.append(i)

        if v not in noded.keys():
            noded[v] = Node(v)
        noded[v].eda_list.append(i)

    noded[1].color = 0
    color_oppo_of(noded[1])

    for i in range(1, n+1):
        print(noded[i].color)
        #print(vars(noded[i]))



solve()

Measured memory_bytes: 126328
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

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

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

const int mod = 1e9 + 7;
const int N = 110;
const int K = 1e5 + 10;
int dp[N][K];
int sum[N][K];

int32_t SALI()
{
    int n; cin >> n; int k; cin >> k;
    int a[n+1]; for(int i = 1; i <= n; i++) cin >> a[i];

    dp[0][0] = 1; for(int i = 1; i < K; i++) sum[0][i] = 1;

    int tot = 0;
    for(int i = 1; i <= n; i++){
        tot += a[i];
        for(int j = 0; j <= k; j++){
            // 0 ta min(a[j],j) ke mishe sum[i-1][j+1] - sum[i-1][j-min(a[i],j)];
            if(j <= tot){
            dp[i][j] += sum[i-1][j+1] - sum[i-1][j-min(a[i],j)];
            dp[i][j] %= mod;
            dp[i][j] += mod;
            dp[i][j] %= mod;
            }
            sum[i][j+1] = sum[i][j] + dp[i][j];
            sum[i][j+1] %= mod;
            sum[i][j+1] += mod;
            sum[i][j+1] %= mod;
        }
    }


    cout << ((dp[n][k]%mod) + mod)%mod;
    return 0;
}




/**< WRITEN BY ALI ADELKHAH */



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll unsigned long long int
ll m=1000000007;
int main()
{
	fast;
	string s;cin>>s;
	int c=0,mx=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='R')
			c++;
		if(s[i]=='S')
		{
			if(mx<c)
				mx=c;
			c=0;
		}
	}
	if(mx<c)
		mx=c;
	cout<<mx<<nl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

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

    auto vec = std::vector<std::string>(n);

    for (auto& str : vec) {
        std::cin >> str;
    }

    std::sort(vec.begin(), vec.end());
    auto result = std::accumulate(vec.begin(), vec.end(), std::string(""));
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 3050;

long long binpow(long long x, long long p, int mod) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

int mod = (int) 1e9 + 7;

long long inv(long long x) {
  return binpow(x, mod - 2, mod) % mod;
}

long long f[MAXN], invF[MAXN];

long long cnk(long long n, long long k) {
  long long res = 1ll * f[n] * invF[k] % mod;
  res = res * invF[n - k] % mod;
  return res;
}

int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

int n;
long long dp[MAXN];
long long dp2[MAXN][MAXN];

long long p[MAXN * MAXN];
long long t[MAXN];

int main() { 

  scanf("%d %d", &n, &mod);

  f[0] = 1; invF[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = 1ll * i * f[i - 1] % mod;
    invF[i] = inv(f[i]);
  }

  t[0] = 2;
  for (int i = 1; i <= n; i++) {
    t[i] = 1ll * t[i - 1] * t[i - 1] % mod;
  }

  dp2[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0) {
        dp2[i][j] = 1;
        continue;
      }
      dp2[i][j] = (dp2[i - 1][j] + dp2[i - 1][j - 1]) % mod;
      dp2[i][j] = (dp2[i][j] + 1ll * dp2[i - 1][j] * j % mod) % mod;
    }
  }

  p[0] = 1;
  for (int i = 1; i <= n * n; i++) {
    p[i] = p[i - 1] * 2ll % mod;
  }

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      long long cur = dp2[i][j];
      cur = cur * p[j * (n - i)] % mod;
      cur = cur * t[n - i] % mod;
      // long long p = binpow(2, n - i, mod - 1);
      // cur = cur * binpow(2, p, mod) % mod;
      dp[i] = (dp[i] + cur) % mod;
    }
  }

  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long cur = cnk(n, i) * dp[i] % mod;
    if (i % 2 == 0) {
      ans = (ans + cur) % mod;
    } else {
      ans = subMod(ans, cur) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 145664
use proconio::input;
use proconio::marker::{Chars};

fn main() {
    input!(h: usize, w: usize, k: i32, c: [Chars; h]);

    let mut node = Node {
        h: h,
        w: w,
        k: k,
        c: c,
        ans: 0
    };

    node.dfs(vec![]);

    println!("{}", node.ans);
}

struct Node {
    h: usize,
    w: usize,
    k: i32,
    c: Vec<Vec<char>>,
    ans: i32
}

impl Node {
    fn dfs(
        &mut self,
        bit: Vec<i32>
    ) {
        let mut cnt = 0;

        for i in 0..self.h {
            for j in 0..self.w { 
                let mask_h = bit.get(i).unwrap_or(&0) == &1;
                let mask_w = bit.get(self.h + j).unwrap_or(&0) == &1;
                if mask_h || mask_w {
                    continue
                }
                if self.c[i][j] == '#' {
                    cnt = cnt + 1;
                }
            }
        }

        if bit.len() == (self.h + self.w) {
            if cnt == self.k {
                self.ans = self.ans + 1;
            }
            return;
        }

        // Not Selected
        self.dfs(bit.iter().cloned().chain(vec![0]).collect());
        // Selected
        self.dfs(bit.iter().cloned().chain(vec![1]).collect());
    }
}


Measured memory_bytes: 2200
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn solve(mut n:i32) {
    if n == 0 {
        println!("0");
        return;
    }
    let mut st = Vec::<i8>::new();
    while n != 0 {
        if n % 2 != 0 {
            st.push(1);
            n -= 1;
        } else {
            st.push(0);
        }
        n /= -2;
    }
    while let Some(top) = st.pop() {
        print!("{}", top);
    }
    println!("");
}
fn main() {
    let n = read::<i32>();
    solve(n);
}


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

int main(){
  string N;
  cin >> N;
  
  if (N.at(N.size() - 1) == '3'){
    cout << "bon" << endl;
  }
  else if (N.at(N.size() - 1) == '0' || N.at(N.size() - 1) == '1' || N.at(N.size() - 1) == '6' || N.at(N.size() - 1) == '8'){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3596
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key= lambda x:(-x[1],-x[0]))#報酬が高く、かつ、振り込みの日数が長いものからやるためのソート
memo = [0]*(10**5+1)#請け負うと決めた仕事の日のメモ。1がついている日は仕事がすでにある
work = [float('inf')]*(10**5+1)#振り込みまでに必要な日数のうち、前回請け負いを決めた日
noMore = float('inf') #これ以上の日数が振り込みにかかる仕事は受けれない
ans = 0
for a,b in AB:
    if a< noMore:#期日までに報酬が受け取れる仕事であること
        flag = 1
        for idx in range(min(M-a,work[a]),-1,-1):#この検索範囲の絞り込みがTLE解消の決め手。前回検索時に請け負った日またはM-a日以前の日
            if memo[idx] == 0:#仕事が請けられる
                ans += b#報酬を足す
                memo[idx]=1#仕事を受けたことの記録。この日はもう受けられない
                flag = 0#noMoreの更新分岐のため
                work[a] = idx#次回検索時のメモ
                break
        if flag ==1:#請けれる日が見つからなければ、今後この日数以上の日は受けれないので調べない
            noMore = a
    
print(ans)
    


Measured memory_bytes: 97544
b=[]
W=gets.split[1].to_i
gets
gets.split.each_with_index{|i,j|b<<Array.new(i.to_i,j+1)}
b.flatten.each_slice(W).to_a.each_with_index{|i,j|puts (j.even?? i:i.reverse).join(" ")}


Measured memory_bytes: 3196
-- 3-or-2.hs --- *3 or /2

-- author: Seong Yong-ju

f :: Int -> Int
f x = if x `mod` 2 == 0 then 1 + f (x `quot` 2) else 0

solve :: [Int] -> Int
solve as = sum $ map f as

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map (read :: String -> Int) . take n . words <$> getLine
  print $ solve as


Measured memory_bytes: 7548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<String> list = new ArrayList<String>();

		while(true){
			try{

				String strScan = insBR.readLine();


				if("END_OF_TEXT".equals(strScan)){
					break;
				}else{
					list.add(strScan);
				}


			}catch(IOException e){
				System.out.println(e);
			}

		}


		//????´¢?????????????????????????????°
		String strFindLine = null;
		//????????\???????????????????????°
		String strLine = null;

		//????´¢?????????????????????????????????????????°
		int intCount = 0;
		for(int i = 0; i < list.size(); i++){
			//????´¢??????????????????
			if(i == 0){
				//list???0??????
				strFindLine = list.get(i);
				strFindLine = strFindLine.toLowerCase();
			}else{
				//list1????????\???
				strLine = list.get(i);
				strLine = strLine.toLowerCase();
				//1??????????????§??????????????????????´?
				String[] ary = strLine.split(" ");
				//1????????????????????¨????????´????????????????????????
				for(int j = 0; j < ary.length; j++){
					//ary[]???????????¨findLine???????????°???????????????????´¢
					if(ary[j].length() == strFindLine.length()){

						int intJudge = ary[j].indexOf(strFindLine);

						if(-1 < intJudge){
							intCount++;
						}
					}
				}

			}
		}
		System.out.println( intCount);
	}
}

Measured memory_bytes: 16916
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int prime[1000];
int num[1001];
int p;
void prime_s() {
  prime[0] = 2;
  p = 1;
  for(int i = 3; i <= 1000;i += 2) {
    int j;
    for(j = 0; j < p; j++) {
      if(i % prime[j] == 0) break;
    }
    if(j == p) {
      prime[p++] = i;
    }
  }
}

//素因数分解する
void d(int n) {
  for(int i = 0; i < p; i++) {
    while(n % prime[i] == 0) {
      n /= prime[i];
      num[prime[i]]++;
    }
  }
}

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

  long long  ans1 = 1;
  long long  ans2 = 0;
  prime_s();
  for(int i = 1; i <= n; i++) {
    d(i);
  }

  long long ans_n = 0;
  for(int i = 1; i < 1001; i++) {
      ans1 *= num[i] + 1;
      if(ans1 >= 1000000007){
        ans1 = ans1 % 1000000007;
      }
  }
  cout << ans1 % 1000000007<< endl;

  return 0;
}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

n = INT()
k = INT()

@lru_cache(None)
def F(n, k):
    # n以下で0でないものがちょうどk個ある数字の個数
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    q, r = divmod(n, 10)
    ret = 0
    if k >= 1:
        # 1の位が0
        ret += F(q, k-1) * r
        ret += F(q-1, k-1) * (9-r)
    ret += F(q, k)
    return ret

print(F(n, k))

Measured memory_bytes: 10444
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = sub(readLine().split(" ").map(_.toInt))
    def digit(a: Int, b: Int): Int = if(b == 0) a else digit(b, a % b)

    @tailrec
    def sub(n: Seq[Int]): Unit = {
        val gcd: Int = digit(n(0), n(1))
        val lcm: Int = (n.map(_.toLong).product / gcd.toLong).toInt
        println(s"$gcd $lcm")
        val next: String = readLine()
        if(next == null) Unit else sub(next.split(" ").map(_.toInt))
    }
}

Measured memory_bytes: 43988
N, Q = map(int, input().split())

S = input()
items = []
for i in range(Q):
    items.append(input().split())

left_ok = -1
left_ng = N


def check_left(mid):
    flag = False
    tmp = mid
    for t, d in items:
        if t == S[tmp]:
            if d == "L":
                if tmp - 1 == -1:
                    flag = True
                    break
                tmp -= 1
            else:
                if tmp + 1 >= N:
                    break
                tmp += 1
    return flag


def check_right(mid):
    flag = False
    tmp = mid
    for t, d in items:
        if t == S[tmp]:
            if d == "R":
                if tmp + 1 == N:
                    flag = True
                    break
                tmp += 1
            else:
                if tmp - 1 == -1:
                    break
                tmp -= 1

    return flag


while abs(left_ng - left_ok) > 1:
    mid = (left_ok + left_ng) // 2
    if check_left(mid):
        left_ok = mid
    else:
        left_ng = mid

right_ok = N
right_ng = -1

while abs(right_ok - right_ng) > 1:
    mid = (right_ok + right_ng) // 2

    if check_right(mid):
        right_ok = mid
    else:
        right_ng = mid

ans = N
if left_ok != -1:
    ans -= left_ok + 1

if right_ok != N:
    ans -= N - right_ok

if left_ok >= right_ok:
    ans = 0

print(ans)


Measured memory_bytes: 39356
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int d;
    string s;
    cin >> d;
    if(d==25){
        s="Christmas";
    }else if(d==24){
        s="Christmas Eve";
    }else if(d==23){
        s="Christmas Eve Eve";        
    }else{
        s="Christmas Eve Eve Eve";
    }

    cout << s << endl;

    return 0;
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int w, h, n;
    cin >> w >> h >> n;
    
    int l = 0, r = w, u = h, d = 0;
    while(n--){
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                l = max(l, x);
                break;
            case 2:
                r = min(r, x);
                break;
            case 3:
                d = max(d, y);
                break;
            case 4:
                u = min(u, y);
                break;
            default:
                break;
        }
    }
    
    if((r-l) > 0 && (u-d) > 0){
        cout << (r-l)*(u-d) << endl;
    }else{
        cout << 0 << endl;
    }   
}

Measured memory_bytes: 256
import sys

N = int(input())
a = list(map(int, input().split()))

l = a[0]
m = -1
n = -1
o = -1

for i in range(1,N):
    if a[i] != l and m == -1:
        m = a[i]
    elif a[i] != l and a[i] != m and n == -1 :
        n = a[i]
    elif a[i] != l and a[i] != m and a[i] != n and o == -1:
        print("No")
        sys.exit()

if (m == -1 and n == -1) and l^l == l and a.count(l) == N:
    print("Yes")
elif n == -1 and a.count(l)+a.count(m) == N and ( (a.count(l)*2==a.count(m) and l^m==m) or (a.count(l)==a.count(m)*2 and l^m == l)):
    print("Yes")
elif a.count(l)+a.count(m)+a.count(n) == N and a.count(l) == a.count(m) and a.count(m) == a.count(n) and l^m==n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 60784
#include<iostream>
#include<stdio.h>
#include<numeric>
#include<ios>
#include<cmath>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<assert.h>
#include<bitset>
#include<tuple>
#include<climits>
#include<deque>
#include<utility>
#include<unordered_map>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<iomanip>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int>
#define vpii           vector<pair<int,int>>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x:a) cin>>x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
   nitro
   string s;cin>>s;
   cout<<s.rfind('Z')-s.find('A')+1;
   return 0;
}



Measured memory_bytes: 720
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int K; string S; cin>>K>>S;
	if(S.size()<=K) cout<<S<<"\n";
	else cout<<S.substr(0,K)<<"...\n";
	return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
  void Print() {
    for (int i = 1; i < data.size(); ++i) std::cout << data[i] << " " << std::endl;
  }
};

int main() {
  int N, M, K; cin >> N >> M >> K;
  UnionFindTree tree(N+1);
  vector<int> count(N+1, N-1);
  map<int, set<int>>  ng;

  for (int m = 0; m < M; ++m) {
    int a, b; cin >> a >> b;
    tree.Unite(a, b);

    ng[a].insert(b);
    ng[b].insert(a);
  }
  for (int k = 0; k < K; ++k) {
    int c, d; cin >> c >> d;

    ng[c].insert(d);
    ng[d].insert(c);
  }

  for (int i = 1; i <= N; ++i) {
    int count = tree.Size(i) - 1;
    for (int j : ng[i]) {
      if(tree.IsSameRoot(i, j)) --count;
    }
    cout << count << " ";
  }
  cout << endl;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
using namespace std;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long long n,m,i,j,a,b,c,d,ans=0;
	string s,s1;
	cin>>n;
	long arr[n+1];
	for(i=0;i<n;i++)
	   cin>>arr[i];
	sort(arr,arr+n);
	long sum=accumulate(arr,arr+n,ans);
	if(sum%10==0)
	{
	    j=0;
	    for(i=0;i<n;i++)
	    {
	        if(arr[i]%10!=0)
	        {
	            sum-=arr[i];
	            cout<<sum;
	            return 0;
	        }
	    }
	    cout<<0;
	}
	else cout<<sum;
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			char[] s = in.next().toCharArray();
			HashMap<Integer, Integer> hm = new HashMap<>();
			int currentCount = 0;
			for (int i = 0; i < s.length; i++) {
				char c = s[i];
				c -= 'a';
				currentCount ^= (1 << c);
				int count1 = 0;
				for (int k = 0; k < 26; k++) {
					if (((1 << k) & currentCount) != 0) {
						count1++;
					}
				}
				if (count1 <= 1) {
					hm.put(currentCount, 1);
					if (i == s.length - 1) {
						out.println(1);
					}
				} else {
					int min = s.length;
					Integer m = hm.get(currentCount);
					if (m != null) {
						min = Math.min(m + 1, min);
					}
					for (int k = 0; k < 26; k++) {
						m = hm.get(currentCount ^ (1 << k));
						if (m != null) {
							min = Math.min(m + 1, min);
						}
					}
					hm.put(currentCount, min);
					if (i == s.length - 1) {
						out.println(min);
					}
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}

Measured memory_bytes: 78012
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
ans = 0
cnt = 1
ikimono = A[0]
for i in range(1,N):
    if ikimono*2 < A[i]:
        ans += cnt
        cnt = 1
        ikimono += A[i]
    else:
        cnt += 1
        ikimono += A[i]
print(N-ans)

Measured memory_bytes: 14636
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int N; cin >> N;
	vector<int> X(N);
	for (int i = 0; i < N; ++i)
		cin >> X[i];
	int total = 0;
	for (auto xi : X)
		total += xi;
	int P = (int)(total / (double)N + 0.5);
	int res = 0;
	for (auto xi : X)
		res += (xi - P) * (xi - P);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
  s=input()
  start=0
  end=len(s)
  for i in range(0,len(s)):
    if s[i]=='A':
      start=i
      break
  for i in range(1,len(s)):
    if s[-i]=='Z':
      end=len(s)-i
      break
  print(end-start+1)
main()


Measured memory_bytes: 3512
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    while(cin >> a >> b)
    {
        int cnt = a + b, digit = 0;
        do
        {
            digit++;
            cnt /= 10;
        }while(cnt);
        cout << digit << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
a,b = map(int,input().split())

if a%2 == 1:
    xa = int(a*12.5)+1
else:
    xa = int(a*12.5)
xb = int(b*10)

flag = True
maxi = max(xa,xb)
mini = min(xa,xb)
for i in range(mini,maxi+1):
    if (int(0.08*i) == a) and (int(0.1*i) == b):
        print(i)
        flag = False
        break
        
if flag == True:
    print('-1')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N,Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> sum(100050,0);
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == 'A' && S.at(i + 1) == 'C') sum.at(i + 1)++;
        sum.at(i + 1) += sum.at(i);
    }
    rep (i,Q) {
        int l,r;
        cin >> l >> r;
        cout << sum.at(r - 1) - sum.at(l - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3792
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 heapq import heapify, heappop, heappush

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

L = [INT() for i in range(5)]
A = []
for l in L:
    A.append(ceil(l * 0.1) * 10)
# print(A)

ans = INF
for i in range(5):
    tmp = 0
    for j in range(5):
        if i == j:
            tmp += L[j]
        else:
            tmp += A[j]
    ans = min(tmp, ans)
print(ans)    

Measured memory_bytes: 3920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 62;
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m, A, B;
LL p[maxN], sum[maxN];
struct rec {
	LL x, y; int i;
	inline bool operator < (const rec &v) const {
		return x < v.x;
	}
};
namespace Set {
	set<rec> S;
	typedef set<rec>::iterator Sit;
	int T;

	LL eval(const rec &d, LL p) {
		return d.y + abs(p - d.x) + sum[T] - sum[d.i];
	}

	LL get(LL p) {
		Sit it = S.lower_bound((rec){p});
		LL res = it == S.end() ? INF : eval(*it, p);
		if (it != S.begin()) res = min(res, eval(*(--it), p));
		return res;
	}

	void ins(const rec &d) {
		if (get(d.x) <= d.y) return;
		for (Sit it = S.lower_bound(d); it != S.end() && eval(d, it->x) <= eval(*it, it->x); it = S.lower_bound(d)) S.erase(it);
		while (1) {
			Sit it = S.lower_bound(d);
			if (it == S.begin()) break;
			-- it;
			if (eval(d, it->x) <= eval(*it, it->x)) S.erase(it);
			else break;
		}
		S.insert(d);
	}
}

int main() {

	n = ri(), m = ri(), A = ri(), B = ri();
	p[0] = A, sum[0] = 0, Set::T = 0;
	Set::ins((rec){B, 0, 0});
	
	rep (i, 1, m) {
		p[i] = ri();
		sum[i] = sum[i-1] + abs(p[i] - p[i-1]);
		LL tp = Set::get(p[i]);
		++ Set::T;
		Set::ins((rec){p[i-1] ,tp, i});

//		rep (i, 1, n) printf("%lld%c", Set::get(i), " \n"[i == n]);
	}
	
	LL res = INF;
	rep (i, 1, n) res = min(res, Set::get(i));
	printf("%lld\n", res);
	
	return 0;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n;
	string s;
	cin >> n >> s;
	int k = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') k++;
	}
	if (k > n - k) {
		cout << "Yes\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 256
S = input()
count = 0
max = 0
atcg = ('A', 'T', 'C', 'G')

for i in range(len(S)):
  if S[i] in atcg:
    count += 1
    if max < count:
        max = count
  else:
    count = 0
    
print(max)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define inf 1000000007

int main () {
	//Your code goes here//
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(abs(a-b)>d&&abs(b-c)>d&&abs(a-c)>d) printf("No\n");
	else if(abs(a-b)<=d&&abs(b-c)>d&&abs(a-c)>d) printf("No\n");
	else if(abs(a-b)>d&&abs(b-c)<=d&&abs(a-c)>d) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,sum,a,b;
  cin >> N >> K;
sum = 1;
for (int i = 0; i<N; i++){
  a = sum * 2;
  b = sum + K;
  if(a<b)
    sum = a;
  else
    sum = b;
}
  cout << sum << endl;
}

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

int main(){
        int N;
        cin >> N;
        int a[N];
        for(int i=0; i<N; i++) {
                cin >> a[i];
        }
        sort(a, a+N);
        cout << a[N-1]-a[0] << endl;
        return 0;
}


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

int main()
{
	int a, b;
	cin >> a;
	cin >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a*b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
		return 0;
	}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
import math
 
N, K = mi()
A = li()
 
if K == 0:
    print(max(A))
    exit()
 
left = 0
right = max(A)
 
def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt
 
while True:
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break
    tmp = count(mid)
    if right - left <= 1:
        print(right)
        exit()
    elif tmp > K:
        left = mid
    else:
        right = mid


Measured memory_bytes: 31096
///
// File:  2330.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 19 17:49:51 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  long long n;
  cin >> n;

  for (uint32_t i = 0;; i++) {
    if (n == 1) {
      cout << i << endl;
      break;
    } else if (n == 2) {
      cout << i + 1 << endl;
      break;
    }
    long long third = (n + 2) / 3;
    n = max(third, n - 2 * third);
  }

  return 0;
}

Measured memory_bytes: 3100
import sys
D = input()

if ('N' in D and 'S' not in D) or ('N' not in D and 'S' in D):
  print('No')
  sys.exit()

if ('W' in D and 'E' not in D) or ('W' not in D and 'E' in D):
  print('No')
  sys.exit()

print('Yes')

Measured memory_bytes: 9048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		assert solve(8, "))))((((").equals("(((())))(((())))");
		assert solve(3, "())").equals("(())");
		assert solve(6, ")))())").equals("(((()))())");
		int n = cin.nextInt();
		String s = cin.next();
		String ans = solve(n, s);
		cout.println(ans);
	}

	private static String solve(int n, String s) {
		int[] dep = new int[s.length() + 1];
		int d = 0;
		dep[0] = d;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == '(') {
				d += 1;
			} else if (c == ')') {
				d -= 1;
			} else {
				throw new IllegalArgumentException();
			}
			dep[i + 1] = d;
		}
		int mind = Arrays.stream(dep).min().getAsInt();
		List<Integer> modDep = Arrays.stream(dep).map(x -> x - mind).boxed().collect(Collectors.toList());
		modDep.add(0, 0);
		modDep.add(0);

		StringBuilder ans = new StringBuilder();
		for (int i = 1; i < modDep.size(); i++) {
			int prev = modDep.get(i - 1);
			int cur = modDep.get(i);
			for (int j = 0; j < cur - prev; j++)
				ans.append('(');
			for (int j = 0; j < prev - cur; j++)
				ans.append(')');
		}
		return ans.toString();
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL f(int a,int b)
{
    if(a > b)
        swap(a,b);
    if(a == 1)
    {
        if(b == 1)
            return 1;
        else
            return b - 2;
    }
    return (LL)a*b-(a-2)*2-(b-2)*2-4;
}
int main(void)
{
    int a,b;
    cin>>a>>b;

    cout<<f(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int64_t c;
  cin>>n>>c;
  vector<int64_t> x(n+2,0);
  vector<int> v(n+2,0);
  for(int i=1;i<=n;i++)
    cin>>x.at(i)>>v.at(i);
  x.at(n+1)=c;
  vector<int64_t> sc(n+2,0);
  vector<int64_t> mc(n+2,0);
  vector<int64_t> dc(n+2,0);
  for(int i=1;i<=n;i++){
    sc.at(i)=sc.at(i-1)+v.at(i);
    if(sc.at(i)-x.at(i)>mc.at(i-1)){
      mc.at(i)=sc.at(i)-x.at(i);
      dc.at(i)=x.at(i);
    }else{
      mc.at(i)=mc.at(i-1);
      dc.at(i)=dc.at(i-1);
    }
  }
  vector<int64_t> sa(n+2,0);
  vector<int64_t> ma(n+2,0);
  vector<int64_t> da(n+2,0);
  for(int i=n;i>0;i--){
    sa.at(i)=sa.at(i+1)+v.at(i);
    if(sa.at(i)-(c-x.at(i))>ma.at(i+1)){
      ma.at(i)=sa.at(i)-(c-x.at(i));
      da.at(i)=c-x.at(i);
    }else{
      ma.at(i)=ma.at(i+1);
      da.at(i)=da.at(i+1);
    }
  }
  int64_t m=0;
  for(int i=0;i<=n;i++)
    m=max(m,mc.at(i)+ma.at(i+1)-min(dc.at(i),da.at(i+1)));
  cout<<m<<endl;
}

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

int main(){
	int N, T, c[105], t[105], ans = 2000;
	cin >> N >> T;
	for (int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
		if (t[i] <= T && c[i] < ans)
			ans = c[i];
	}
	if (ans == 2000)
		cout << "TLE" << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, K;
	cin >> A >> B >> K;
	//K -= A;
	int a = A;
	A -= min(a, K);
	K -= a;
	K = max(0LL, K);
	B -= K;
	B = max(B, 0LL);

	cout << A << " " << B << endl;
	

	return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        X: i64,
        A: i64,
        B: i64,
    }
    println!("{}", (X-A)%B);
}


Measured memory_bytes: 4352
K = int(input())

S = list(map(int, "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")))

print(S[K-1])


Measured memory_bytes: 38256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

alice = 0
bob = 0
a.sort{|x, y| y <=> x}.each_with_index do |val, idx|
  if idx % 2 == 0 then
    alice += val
  else
    bob   += val
  end
end

puts (alice - bob).to_s

Measured memory_bytes: 1916
public class Main {
	
		
		public static void main(String[] args) {
			java.util.Scanner scan = new java.util.Scanner(System.in);
		int x = scan.nextInt();
			
		
		if(1<=x && x<=100){;
		System.out.println(x*x*x);// TODO ?????????????????????????????????????????????
		}
			
			
		}
	
	}
	

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

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

int a[20];
int x[20][20];
int y[20][20];

int counter(int x){
  if(x==0) return 0;
  return counter(x>>1)+(x&1);
}

signed main()
{
  int n;
  cin>>n;
  
  for(int i=1; i<=n; i++){
    cin>>a[i];
    for(int j=1; j<=a[i]; j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int ans=0;
  // bits ビットが立っているところが人iが正しい証言をしていることを意味する
  for(int bits=1; bits<(1<<n); bits++){
    bool ok=true;
    // 最大15人の人iについてのループ
    for(int i=1; i<=n; i++){
      // ビットiが立っている時だけ処理する
      // 正しい証言をしていると仮定しているもの(=ビットが立っている)だけ確認すればよい
      // iが立っていないものは「不確か」であって、「不正確であること」では無い事に注意
      if(!(bits & (1<<(i-1)))) continue;
      // 各人iの証言についてのループ
      for(int j=1; j<=a[i]; j++){
        // 矛盾しないかを判定する
        // 0^1 (bits上は不親切と仮定したのに正直者であると証言してしまっている)
        // 1^0 (正直者と仮定したのに不親切と証言してしまっている)
        if(((bits>>x[i][j]-1)&1) ^ y[i][j]) {
          // bits上正しいと仮定した人iの証言が全て矛盾しなければここを通らず、
          // bitsの立っているビットの数が、正直者の数と同値になる
          ok = false;
          break;
        }
      }
    }
    if(ok) chmax(ans, counter(bits));
  }
  cout<<ans<<endl;
}

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

int main() {
  vector<int64_t> vec(3);
  cin>>vec.at(0);
  cin>>vec.at(1);
  cin>>vec.at(2);
  int64_t K;
  cin>>K;
  sort(vec.begin(),vec.end());
  cout<<vec.at(0)+vec.at(1)+vec.at(2)*pow(2,K)<<endl;
  
    
  
}

Measured memory_bytes: 4148