akhauriyash/Code-Regression huggingface dataset:
a = list(map(int, input().split()))
ds = [abs(e - max(a)) for e in a if e-max(a) != 0]

if len(ds) == 1:
    if ds[0] % 2 == 0:
        res = ds[0] // 2
    else:
        res = (ds[0]-1) // 2 + 2
elif len(ds) > 1:
    base = min(ds) - 1
    rem = max(ds) - base
    if rem == 1:
        res = base + 1
    elif rem % 2 == 0:
        res = base + (rem - 2) // 2 + 3
    elif rem % 2 != 0:
        res = base + (rem - 1) // 2 + 1
else:
    res = 0

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	int sum = 0;
	cin >> str;
	for(int i = 0; i < str.size(); i++){
		sum += (str[i] - '0');
		sum %= 9;
	}

	if (sum)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

}

Measured memory_bytes: 3708
#include<iostream>
#include<climits>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
  int n;cin>>n;
  long s=0,a,ans=LONG_MAX;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  a=accumulate(v.begin(),v.end(),0L);
  for(int i=0;i<n-1;i++)s+=v[i],a-=v[i],ans=min(ans,labs(s-a));
  cout<<ans<<endl;
  return 0;
}

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


int main(){
    int n;
    scanf("%d",&n);
    int p=n%10;
    if(p==2||p==4||p==5||p==7||p==9)printf("hon\n");
    if(p==0||p==1||p==6||p==8)printf("pon\n");
    if(p==3)printf("bon\n");
    return 0;
}


Measured memory_bytes: 3684
def resolve():
    n, k = map(int, input().split())
    H_sort = list(sorted([int(input()) for _ in range(n)],reverse=True))
    ans = 10**9
    for i in range(n-k+1):
        ans = min(ans, H_sort[i]-H_sort[i+k-1])
    print(ans)
resolve()

Measured memory_bytes: 14180
N, M = gets.split.map(&:to_i)
AB_n = N.times.map{|_| gets.split.map(&:to_i)}.sort{|a, b| a[0] <=> b[0]}

m = M
ans = 0
AB_n.each do |a, b|
  if m <= b
    ans += m * a
    m -= m
  else
    ans += b * a
    m -= b
  end

  if m == 0
     break
  end
end
p ans

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		int a = Integer.parseInt(nums[0]);
		int b = Integer.parseInt(nums[1]);
		int c = Integer.parseInt(nums[2]);
		int d = Integer.parseInt(nums[3]);

		if (Math.abs(a - c) <= d) {
			System.out.println("Yes");
		} else if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

using namespace std;

using int64 = long long;

int main() {
  set< int > st;
  int v;
  cin >> v;
  while(!st.count(v)) {
    st.emplace(v);
    if(v % 2 == 1) v = v * 3 + 1;
    else v /= 2;
  }
  cout << st.size() + 1 << endl;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	int n, i;
	string ans = "second";
	long long a;
	cin >> n;
	for(i = 0; i < n; ++i) {

		cin >> a;
		if(a % 2 == 1){
			ans = "first";

		}
	}
	cout << ans;
	return 0;
}

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

int main () {;
	int W, H, x, y, r;
	int tmp;
	cin >> W >> H >> x >> y >> r;
	
	if(x - r <0 || x + r > W || y - r < 0 || y + r>H) {
	cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    double w,h,x,y;  cin >> w >> h >> x >> y;
    bool check = false;
    double Ans = (w * h)/2.0;
    cout << setprecision(15) << fixed << Ans << " " << (x + x == w && y + y == h);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int Alice = 0;
  int Bob = 0;
  for (int i = N - 1; i >= 0; i -= 2) Alice += a.at(i);
  for (int i = N - 2; i >= 0; i -= 2) Bob += a.at(i);
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if(x += mod - m.x >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, const mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint cl = m;
    combination c(200005);
    for(int i=n-1; i>=0; i--)
    {
        mint lans = cl;
        lans *= c(n-1, i);
        if(k >= i) ans += lans;
        cl *= (m-1);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6372
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int field[][] = new int[21][21];
		while(true){
			for(int i=0; i<21; i++){
				for(int j=0; j<21; j++){
					field[i][j] = 0;
				}
			}
			int N = in.nextInt();
			if(N == 0) break;
			for(int i=0; i<N; i++){
				int x = in.nextInt();
				int y = in.nextInt();
				field[x][y] = 1;
			}
			
			int x = 10;
			int y = 10;
			int M = in.nextInt();
			int jewel = 0;
			for(int i=0; i<M; i++){
				String str = in.next();
				int d=9;
				if(str.equals("N")) d=0;
				else if(str.equals("S")) d=1;
				else if(str.equals("E")) d=2;
				else if(str.equals("W")) d=3;
				int l = in.nextInt();
				switch(d){
				case 0:
					for(int j=0; j<=l; j++){
						if(field[x][y+j]==1){
							field[x][y+j]=0;
							jewel++;
						}
					}
					y=y+l;
					break;
				case 1:
					for(int j=0; j<=l; j++){
						if(field[x][y-j]==1){
							field[x][y-j]=0;
							jewel++;
						}
					}
					y=y-l;
					break;
				case 2:
					for(int j=0; j<=l; j++){
						if(field[x+j][y]==1){
							field[x+j][y]=0;
							jewel++;
						}
					}
					x=x+l;
					break;
				case 3:
					for(int j=0; j<=l; j++){
						if(field[x-j][y]==1){
							field[x-j][y]=0;
							jewel++;
						}
					}
					x=x-l;
					break;
				}				
			}
			
			if(jewel == N) System.out.println("Yes");
			else System.out.println("No");
			
		}
	}	
}

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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> l(n+1);
  l.at(0) = 2;
  l.at(1) = 1;
  for (int i = 2; i < n + 1; i++) {
    l.at(i) = l.at(i-1) + l.at(i-2);
  }
  cout << l.at(n) << endl;
}


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

// 入力
int N, M, Q;
vector<long long> a, b, c, d;

// 数列 A のスコアを計算
long long score(const vector<int> &A) {
    long long res = 0;
    for (int i = 0; i < Q; ++i) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

// 数列 A を全列挙
long long rec(vector<int> &A) {
    // 終端条件
    if (A.size() == N) return score(A);
    
    // 数列 A の前回要素
    int prev_last = (A.empty() ? 1 : A.back());
    long long res = 0;
    for (int add = prev_last; add <= M; ++add) {
        A.push_back(add);

        // 再帰呼出しながら、スコア最大値を更新
        res = max(res, rec(A)); 
        A.pop_back();
    }
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int q = 0; q < Q; ++q) {
        cin >> a[q] >> b[q] >> c[q] >> d[q];
        --a[q], --b[q];
    }
    vector<int> A;
    cout << rec(A) << endl;
}


Measured memory_bytes: 3536
n = int(input())
a = []

for i in range(2):
    a.append(list(map(int, input().split())))

#print(a)

def solve(i, j):
    if i >= 2 or j >= n:
        return 0
    cur = a[i][j]
    right = cur + solve(i, j+1)
    down = cur + solve(i+1, j)
    return max(right, down)

print(solve(0, 0))

Measured memory_bytes: 48364
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
               
                while(N>1000){
                    N = N-1000;
                }
                
                System.out.println(1000-N);               
        }               
}

Measured memory_bytes: 35608
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            nums[v] += nums[nv] + 1
            tmp += pow2[nums[nv] + 1] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


Measured memory_bytes: 58132
use std::io::Write;
macro_rules! eprintln (
    ($($arg:tt)*) => { {
        writeln!(&mut ::std::io::stderr(), $($arg)*);
    } }
);

macro_rules! eprint (
    ($($arg:tt)*) => { {
        write!(&mut ::std::io::stderr(), $($arg)*);
    } }
);

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:tt)*) => (if cfg!(debug_assertions) {eprint!("[DEBUG] "); eprintln!($($arg)*)});
}

fn main() {
    let mut rd = reader::Reader::new();

    let n: usize = rd.next();
    let s: String = rd.next();
    let mut s = s.chars().collect::<Vec<char>>();
    let c = s[0];
    s.push(c);
//    debug!("{}", s.iter().collect::<String>());

    for a in vec![true, false] {
        for b in vec![true, false] {
            let mut t: Vec<bool> = vec![a, b];
            for i in 1..n + 1 {
                let x = (s[i] == 'o') ^ t[i] ^ t[i - 1];
                t.push(x);
            }
            if t[0] == t[n] && t[1] == t[n + 1] {
                t.truncate(n);
                let ans = t.into_iter().map(|b| if b { 'S' } else { 'W' }).collect::<String>();
                println!("{}", ans);
                return;
            }
        }
    }
    println!("-1");
}

mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    #[allow(dead_code)]
    pub struct Reader {
        buf: VecDeque<String>,
    }

    #[allow(dead_code)]
    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
//   	int n ;
//   string s;
//   cin >> n >> s;
//   int c = n/2 ;
  
//   if(s.substr(0,c) == s.substr(c,c) ) 
//   {
//     cout << "Yes"<<endl;
//   }else{
//     cout <<"No"<<endl;
//   }
    int a;
    cin >> a;
    cout << a*a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  vi arr(N);
  rep(i,N) cin >> arr[i];

  vi copy = arr;
  sort(all(copy));
  int med1 = copy[N/2-1];
  int med2 = copy[N/2];

  rep(i,N) {
    if (arr[i] <= med1) cout << med2 << endl;
    else cout << med1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
def sum(n, s)
  (s + n) * (n / s) / 2
end
a = gets.to_i
s = sum(a, 1)
s3 = sum(a - (a % 3), 3)
s5 = sum(a - (a % 5), 5)
s15 = sum(a - (a % 15), 15)
puts s - s3 - s5 + s15

Measured memory_bytes: 14236
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,Q;
	scan(N>>Q);
	string S;
	scan(S);
	ll ACsum[100001]={};
	bool ACb[100001]={};
	rep(i,N-1){
		if(S[i]=='A'&&S[i+1]=='C'){
			ACsum[i+1]=ACsum[i]+1;
			ACb[i]=1;
		}
		else ACsum[i+1]=ACsum[i];
	}
	ACsum[N]=ACsum[N-1];
	rep(i,Q){
		int l,r;
		scan(l>>r);
		if(ACb[r-1]) prin(ACsum[r]-ACsum[l-1]-1);
		else prin(ACsum[r]-ACsum[l-1]);
	}
	return 0;
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created by Meepo on 4/1/2017.
 */
public class Main {
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public void solveA() throws IOException {
        int n = nextInt();
        int[] a = new int[3 * n];
        for (int i = 0; i < 3 * n; i++) {
            a[i] = nextInt();
        }
        Arrays.sort(a);
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[3 * n - 2 * i - 2];
        }
        out.println(ans);
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solveA();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

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


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    for(int i = 0; i < 101; i++) {
        for (int j = 0; j < 101; j++) {
            int needH = -1;
            for(int k = 0; k < N; k++) {
                if (h[k] > 0) {
                    int tmp = h[k] + abs(i - y[k]) + abs(j - x[k]);
                    if (needH == -1) {
                        needH = tmp;
                    } else {
                        if (needH != tmp) {
                            needH = -2;
                            break;
                        }
                    }
                }
            }
            if (needH == -2) continue;
            for (int k = 0; k < N; k++) {
                if (h[k] == 0) {
                    int dist = abs(i - y[k]) + abs(j - x[k]);
                    if (needH > dist) {
                        needH = -2;
                        break;
                    }
                }
            }
            if (needH == -2) continue;

            cout << j << ' ' << i << ' ' << needH << endl;
            return 0;
        }
    }
}


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

int a[3] = {3, 5, 7};
int res = 0;

void dfs(long long x, int limit);
bool judge(int n);

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

    dfs(0, N);
    
    cout << res << endl;
}

void dfs(long long x, int limit){
    if(x > limit)      return;
    
    for(int i = 0; i < 3; i++){
        long long m = 10 * x + a[i];
        if(m > limit)   return;
        
        if(judge(m)){
            res++;
            // cout << m << endl;
        }
        
        dfs(m, limit);
    }
}

bool judge(int n){
    string s = to_string(n);
    bool three_flag = false;
    bool five_flag = false;
    bool seven_flag = false;
    
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '3'){
            three_flag = true;
        }
        else if(s[i] == '5'){
            five_flag = true;
        }
        else if(s[i] == '7'){
            seven_flag = true;
        }
        else{
            return false;
        }
    }
    
    if(three_flag && five_flag && seven_flag)   return true;
    return false;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

char ask(ll n) {
    cout << "? " << n << endl;
    char ans;
    cin >> ans;
    return ans;
}

void bye(ll n) {
    cout << "! " << n << endl;
    exit(0);
}

// 10^x (x>=0)
void sub() {
    const ll mi = 9;
    if (ask(mi) == 'Y') { // mi > N(値)
        bye(1);
    }

    // 10<=N<=10^9
    for (int n = 1e9; n >= 10; n /= 10) {
        if (ask(n - 1) == 'N') {
            bye(n);
        }
    }
}

int main(){
    const ll ma = 1e17;
    if (ask(ma) == 'Y') { // 10^17のほうが辞書順でNより大きい
        sub();
    }

    string s = "999999999999999999";
    FOR(i, 1, 10) {
        s[0] = '0' + i;
        ll n = stoll(s);
        if (ask(n) == 'Y')break;
    }
    FOR(i, 1, 10) {
        int ub = 9, lb = -1, mid;
        while (ub - lb > 1) {
            mid = (lb + ub) / 2;
            s[i] = ('0' + mid);
            ll n = stoll(s);
            (ask(n) == 'Y' ? ub : lb) = mid;
        }
        s[i] = '0' + ub;
    }

    // 桁数
    for (int i = 1e9, d = 10; i >= 1; i /= 10, --d) {
        if (ask(i) == 'Y') {
            bye(stoll(s.substr(0, d)));
        }
    }
}


Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(){
  int h, w;
  while (1){
    cin >> h >> w;
    if (h == 0 && w == 0){
      break;
    } else {
      for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
          if ((i+j)%2 == 0){
            putchar('#');
          } else {
            putchar('.');
          }
        }
        puts("");
      }
      puts("");
    }
  }
  return 0;
}



Measured memory_bytes: 3016
' Imports System.Collections.Generic
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N As Integer = Console.ReadLine()
        Dim S As String = Console.ReadLine()
        Console.WriteLine(If(N Mod 2 = 0, _
            If(S.Substring(0, N / 2) = S.Substring(N / 2), "Yes", "No"), "No"))
        Return
    End Sub
End Class


Measured memory_bytes: 28392
#include <stdio.h>

#include <stdlib.h>

long abs_l(long i){
  if(i < 0)
    return -1 * i;

  return i;
}

int main(void){
  int *c;
  int n;
  scanf("%d",&n);

  c = (int*)malloc(sizeof(int) * n);

  long sum = 0;
  int i;
  for(i = 0; i < n;i++){
    scanf("%d",&c[i]);
    sum += c[i];
  }

  long res = abs_l(c[0] - (sum - c[0]));
  long sunuke = 0;
  for(i = 0; i < n - 1;i++){
    sunuke += c[i];
    sum -= c[i];
    if(abs_l(sunuke - sum) < res)
      res = abs_l(sunuke - sum);
  }

  printf("%ld\n",res);

  free(c);
  return 0;
}

Measured memory_bytes: 896
//package oct30;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static Scanner io = new Scanner(System.in);

    public static void main(String[] args) {

        int N = io.nextInt();
        io.nextLine();

        ArrayList<ArrayList<Integer>> day = new ArrayList<>();
        ArrayList<ArrayList<Integer>> max = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            day.add(new ArrayList<Integer>());
            for (int j = 0; j < 3; j++) day.get(i).add(io.nextInt());
            io.nextLine();
            max.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < 3; i++) {
            max.get(0).add(day.get(0).get(i));
        }

        for (int i = 1; i < N; i++) {
            max.get(i).add(Math.max(max.get(i-1).get(1), max.get(i-1).get(2)) + day.get(i).get(0));
            max.get(i).add(Math.max(max.get(i-1).get(0), max.get(i-1).get(2)) + day.get(i).get(1));
            max.get(i).add(Math.max(max.get(i-1).get(0), max.get(i-1).get(1)) + day.get(i).get(2));
        }

        System.out.println(Math.max(Math.max(max.get(N-1).get(0), max.get(N-1).get(1)), max.get(N-1).get(2)));
    }
}


Measured memory_bytes: 178360
def mincof_distance(n:0,vec1:[],vec2:[])
    if n >= 4
        total = []
        vec1.length.times do |num|
            total.push((vec1[num]-vec2[num]).abs)
        end
        return total.max
    else
        total = 0
        vec1.length.times do |num|
            total += ((vec1[num]-vec2[num]).abs)**n
        end
        return total**(1.0/n)
    end
end

_ = gets
v1 = gets.split.map(&:to_f)
v2 = gets.split.map(&:to_f)
puts "#{sprintf("%.5f",mincof_distance(n:1,vec1:v1,vec2:v2))}"
puts "#{sprintf("%.5f",mincof_distance(n:2,vec1:v1,vec2:v2))}"
puts "#{sprintf("%.5f",mincof_distance(n:3,vec1:v1,vec2:v2))}"
puts "#{sprintf("%.5f",mincof_distance(n:4,vec1:v1,vec2:v2))}"


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define p_ll pair<ll, ll>
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  string A; cin >> A;
  int l = A.length();
  int a[26] = {};
  vector<int> pos = {l};
  for (int i=l-1; i>=0; i--) {
    a[A[i]-'a']++;
    bool ok = true; 
    rep(num,26) if (a[num]==0) ok = false;
    if (ok) { pos.push_back(i); fill_n(a,26,0); }
  }
  reverse(pos.begin(), pos.end());

  string result;
  int now = 0;
  rep(i,pos.size()) {
    // for (auto x: a) cout << x << " "; cout << endl;
    char c = 'a'; while (a[c-'a']) c++;
    result += c;
    if (i!=pos.size()-1) {
      while(A[now]!=c) now++;
      now++;
      // cout << now << endl;
      fill_n(a,26,0);
      while (now<pos[i+1]) { a[A[now]-'a']++; now++; }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define MAXH 11
#define MAXW 10000
int H, W;
int field[MAXH][MAXW];
int main(void) {
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                cin >> field[i][j];
        int p = 1, ret = 0;
        for (int i = 0; i < H; i++) p *= 2;
        for (int i = 0; i < p; i++) {
            int table[H][W];
            for (int k = 0; k < H; k++)
                for (int j = 0; j < W; j++)
                    table[k][j] = field[k][j];
            for (int j = 0; j < H; j++) {
                if (((i >> j) % 2) == 1) {
                    for (int k = 0; k < W; k++) {
                        table[j][k] = 1-table[j][k];
                    }
                }
            }
            int ans = 0;
            for (int j = 0; j < W; j++) {
                int num0 = 0;
                for (int k = 0; k < H; k++) {
                    if (table[k][j] == 0) num0++;
                }
                ans += max(H-num0, num0);
            }
            ret = max(ret, ans);
        }
        cout << ret << endl;
    }
    return 0;
}

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

int main() {
    long n;
    cin >> n;
    set<string> items;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        items.insert(s);
    }
    cout << items.size() << endl;
}


Measured memory_bytes: 19256
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int n, l, q, h[100010], dt[20][100010];

int main()
{
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; i++ ) scanf("%d", h+i);
    scanf("%d%d", &l, &q);
    for(int i = 1 ; i <= n ; i++ )
        dt[0][i] = (int)(upper_bound(h+1, h+n+1, h[i]+l) - h) - 1;
    for(int j = 1 ; j < 20 ; j++ ) for(int i = 1 ; i <= n ; i++ )
        dt[j][i] = dt[j-1][dt[j-1][i]];
    while( q-- )
    {
        int a, b, cnt = 0, d;
        scanf("%d%d", &a, &b);
        if( a > b ) swap(a, b);
        for(int i = 19 ; i >= 0 ; i-- )
        {
            if( dt[i][a] < b )
            {
                cnt += (1<<i);
                a = dt[i][a];
                d = 0;
            }
            else d = i;
        }
        printf("%d\n", cnt+1);
    }
    return 0;
}


Measured memory_bytes: 8960
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
//using
using namespace std;
/*using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;*/
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;


signed main(){
   int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    int a = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        a += A[i];
        a %= mod;
    }
 
    int b = 0;
 
    for (int i = 0; i < N; i++)
    {
     
        a -= A[i];
        if (a < 0) a += mod;
 
        b += A[i] * a;
        b %= mod;
    }
 
    cout << b << endl;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  //奇数ならOdd, 偶数ならEven
  if (a % 2 == 0 || b % 2 == 0)
    cout << "Even" << endl;
  else
    cout << "Odd" << endl;
}


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

typedef long long ll;

int main() {
	string n;
	cin >> n;
		
	int x = 0;
	for (int i = 0; i < n.size(); ++i)
		x = (x + (n[i] - '0')) % 9;

	if (!x) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3380
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int main(){
    string A, B;
    cin >> A >> B;
    if(A == B) {
        cout << "EQUAL" << endl;
        return 0;
    }
    ll int ans = (int)(A.length()) - (int)B.length();
    if (ans > 0) cout << "GREATER" << endl;
    else if (ans < 0) cout << "LESS" << endl;
    else {
        int num = 0;
        for (int i = 0; i < A.length(); i++) {
            ll int x = stoi(A.substr(num, i+1));
            ll int y = stoi(B.substr(num, i+1));
            if(x == y) {
                num++;
                continue;
            }
            ans = x - y;
            if (ans > 0) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (ans < 0) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
  int h1, h2, m1, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
   if(h1 == h2){
  cout << (m2 - m1)- k << endl;
   }
    else{
  
  if( m1 > m2 ){
   int i = h2 - 1;
   int x = 60*(i - h1);
    int w = m2 + 60;
    x += w - m1;
    if(x >= k){
    cout << x - k << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
  
 else{
  int y = 60*( h2 - h1 );
    y += m2 - m1;
   if( y >= k){
    cout << y - k << endl;
  }
   else{
      cout << 0 << endl;
    }
 } 
}
   }


Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    sx, sy, tx, ty = LI()
    right = (tx - sx)
    up = (ty - sy)
    p1 = 'R' * right + 'U' * up
    p2 = 'L' * right + 'D' * up
    p3 = 'D' + 'R' * (right + 1) + 'U' * (up + 1) + 'L'
    p4 = 'U' + 'L' * (right + 1) + 'D' * (up + 1) + 'R'
    print(p1+p2+p3+p4)
main()



Measured memory_bytes: 6736
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<x<<endl
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e5+50;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
//::iterator it;
int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}
/*

*/

 
 

Measured memory_bytes: 256
n=int(input())
a=[0]*(n)
b=[0]*(n)
c=[0]*(n)
for _ in range(n):a[_],b[_],c[_]=map(int,input().split())

INF=float("inf")
dpa=[-INF]*n
dpb=[-INF]*n
dpc=[-INF]*n
dpa[0]=a[0]
dpb[0]=b[0]
dpc[0]=c[0]

for i in range(1,n):
    dpa[i]=a[i]+max(dpb[i-1],dpc[i-1])
    dpb[i]=b[i]+max(dpc[i-1],dpa[i-1])
    dpc[i]=c[i]+max(dpa[i-1],dpb[i-1])
    
print(max(dpa[-1],dpb[-1],dpc[-1]))
    




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

constexpr int INF = 998244353;

vector<int> a, b;

int main(){
    int N; cin >> N;
    a.resize(N);
    b.resize(N);

    rep(i, N){
        cin >> a[i];
        b[a[i]]++;
    }
    if(a[0] != 0 || b[0] > 1){
        cout << 0 << endl;
        return 0;
    }

    int maxv = *max_element(begin(a), end(a));
    ll ans = 1;
    for(int i = 1; i < maxv; ++i){
        rep(j, b[i+1]){
            ans *= b[i];
            ans %= INF;
        }
    }

    cout << ans << endl;

}

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

int main()
{
    long long int r, d, x[11];
    cin >> r >> d >> x[0];

    for(int i = 1; i <= 10; i++)
    {
        x[i] = r*x[i-1] - d;
        cout << x[i] << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int N;
scanf("%d",&N);
int k=0;
int i;

for(i=1;i<N;i++){
   int a=1;
   int j=0;
   while(a*a<i){
      if(i%a==0){
          j=j+1;
      }
      a=a+1;
   }
   k=k+2*j;
   if(a*a==i){
       k=k+1;
   }
}

printf("%d",k);

}

Measured memory_bytes: 1704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k, a[110];
int dp[110][100010];
int cum[110][100010];

signed main() {
	cin >> n >> k;
	dp[0][0] = 1;
	for (int i = 0; i <= k; i++)cum[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		for (int j = 0; j <= k; j++) {
			if (j - a[i] <= 0)dp[i][j] = cum[i - 1][j];
			else dp[i][j] = cum[i - 1][j] - cum[i - 1][j - a[i] - 1] + mod;
			dp[i][j] %= mod;
			cum[i][j] = dp[i][j] + cum[i][j - 1];
			cum[i][j] %= mod;
		}
	}
	cout << dp[n][k] << endl;
}

Measured memory_bytes: 162048
x=map(int, input())
a=map(int, input().split())
b=list(a)
c=len(b)

count=0
for i in range(1,c-1):
  tree= [b[i-1], b[i], b[i+1]]
  if (min(tree) != b[i]) and (max(tree) != b[i]):

  	count=count+1
  else:
  	next
    
print(count)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,p;
    cin>>n>>m>>p;
    int d[m];
    for(int i=0;i<m;i++){
        cin>>d[i];
    }
    sort(d,d+m);
    vector<int> v;
    int num=m;
    for(int i=0;i<m;i++){
        if(d[i]>=p){
            if(num==m){
                num=i;
            }
            v.pb(d[i]);
        }
        else{
            d[i]+=n;
        }
    }
    for(int i=0;i<m&&i<num;i++){
        v.pb(d[i]);
    }
    int ans=n-(max(v[0]-p,p+n-v[m-1]));
    for(int i=0;i<m-1;i++){
        ans=min(v[i]-p+v[i]+n-v[i+1],ans);
    }
    for(int i=m-1;i>0;i--){
        ans=min(p+n-v[i]+v[i-1]+n-v[i],ans);
    }
    cout<< ans*100<<endl;

    return 0;
}




Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
	fastio();
	ll a,b;cin>>a>>b;
	if((a+b)%2==0)
		cout<<(a+b)/2;
	else
		cout<<"IMPOSSIBLE"<<endl;
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int result = 0;

int Func(vector<int> v){
    if (v.size()==0) return 0;
    
    int flag = 0;
    for (int i=1;i<v.size();i++) {
        int diff = v[i] - v[i-1];
        if (diff<0) flag = 1;
        else if (flag==1 and diff>0) {
            flag = 2;
            break;
        }
    }
    
    int v_min = *min_element(v.begin(),v.end());
    int v_max = *max_element(v.begin(),v.end());
    
    if (flag==2) {
        result += v_min;
        for (int i=0;i<v.size();i++) v[i] -= v_min;
        
        vector<int> temp_v = {};
        for (int i=0;i<v.size();i++) {
            if (v[i]==0) {
//                for (int j=0;j<temp_v.size();j++) cout << temp_v[j] << " ";
//                cout << endl;
                Func(temp_v);
                temp_v.clear();
            }
            else {
                temp_v.push_back(v[i]);
            }
            if (i==v.size()-1) Func(temp_v);
        }
    }
    else{
        result += v_max;
    }
    
    return 0;
}

int main(){
    int N;
    vector<int> h{};
    
    cin >> N;
    for (int i=0;i<N;i++) {
        int temp;
        cin >> temp;
        h.push_back(temp);
        //cout << temp << endl;
    }
    
    Func(h);
    cout << result << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
def eval_pair(A, B, x):
  return A**5-B**5 == x

def get_pair(x):
  # exit early for x a power of 5.
  # apart from this, A,B don't need to be zero.
  A = int(round(x**(1/5)))
  if A**5 == x: return (A, 0)
  # try A, B:
  # +,+ and +,-
  # don't need -,- (same as +,-)
  # can't do -,+ because x is constrained positive
  # for +,+ A>=120 would give x>10**9
  # so 1<=A<120 and 1<=B<119
  valid = [(A,B) for A in range(1,120) for B in range(1,119) if eval_pair(A,B,x)]
  if valid: return valid.pop()
  # for +,- both are positive so A>=64 would give x=10**9
  # so 1<=A<64 and -64<B<-1
  valid = [(A,B) for A in range(1,64) for B in range(-1,-64, -1) if eval_pair(A,B,x)]
  if valid: return valid.pop()

x = int(input())
valid_pair = get_pair(x)
print(*valid_pair)

Measured memory_bytes: 9280
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] k = new int[n];
			for(int i = 0;i < n;i++){
				k[i] = scan.nextInt();
			}
			char[] st = scan.next().toCharArray();
			char[] al = new char[52];
			for(int i = 0;i < 26;i++){
				al[i] = (char)(97+i);
				al[i+26] = (char)(65+i);
			}
			int h;
			for(int i = 0,j = 0;i < st.length;i++,j++){
				h = ((int)st[i] > 96)?(int)st[i]-97:(int)st[i]-39;
				if(j == n){
					j = 0;
				}
				h -= k[j];
				if(h < 0){
					h += 52;
				}
				System.out.print(al[h]);
			}
			System.out.println();
		}
	}
}

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

 

int main() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    int ans = 0;
    X -= Z;
    ans += X / (Y + Z);
    cout << ans << endl;
}


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

static const int N=100;
int p[N+1];
int main(){
    int n,a,num,cnt,b;
    cnt=0;
    num=-1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a==num){cnt++;num=-1;}
        else num=a;
        
    }

   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int D; ll G;
vector<int> p;
vector<ll> c;
vector<bool> a;
int res = 10 * 100 + 1;

void solve(int problems, ll sum, int num){
  if (problems == D){
    // 解き切る問題を決定した
    if (sum < G){
      // scoreがまだGに達していなければ解き切っていない問題のうち最大の配点の問題に着手する
      for (int i=D-1; i>=0; i--){
        if (a.at(i)) continue;
        ll buf = (G - sum + 100 * (i+1) - 1) / (100 * (i+1));
        num += buf;
        if (buf <= p.at(i)) res = min(res, num);
        break;
      }
    }else{
      res = min(res, num);
    }
    return;
  }
  ll one = 100 * (problems + 1);
  // 問題problemsは解き切らない
  solve(problems+1, sum, num);
  // 問題problemsを解き切る
  ll buf100 = one * p.at(problems) + c.at(problems);
  a.at(problems) = true;
  solve(problems+1, sum + buf100, num + p.at(problems));
  a.at(problems) = false;
}

int main() {
  // 入力
  cin >>D >>G;
  p.assign(D, 0);
  c.assign(D, 0);
  a.assign(D, false);
  rep(i, D) cin >>p.at(i) >>c.at(i);

  // 完全に解き切る100i点の問題を全探索
  solve(0, 0, 0);
  cout <<res <<endl;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
L = []
for i in range(H):
    L.append(list(input()))
def cnt(L):
    n = 0
    for i in range(H):
        n += L[i].count('#')
    return n
A = [0,1]
import itertools
B = list(itertools.product(A, repeat=H))
C = list(itertools.product(A, repeat=W))
ans = 0
import copy
for i in range(len(B)):
    D = copy.deepcopy(L)
    for b in range(len(B[i])):
        if B[i][b] == 1:
            for l in range(W):
                D[b][l] = '.'
    for j in range(len(C)):
        E = copy.deepcopy(D)
        for c in range(len(C[j])):
            if C[j][c] == 1:
                for k in range(H):
                    E[k][c] = '.'
        if cnt(E) == K:
            ans += 1
print(ans)

Measured memory_bytes: 72660
#include<iostream>
using namespace std;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int r,g,b,total;
 
	cin >> r >> g >> b;
	r = r *100;
	g = g*10;
	total= r+g+b;
	
	if (total% 4== 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,l;
int a;
int ans=0;
signed main(){
    cin>>n>>l;
    if(l>=0){
        for(int i=l+1;i<n+l;i++)ans+=i;
        cout<<ans<<endl;
    }
    else if(n>abs(l)){
        for(int i=l;i<n+l;i++)ans+=i;
        cout<<ans<<endl;
    }
    else{
        for(int i=l;i<n+l-1;i++)ans+=i;
        cout<<ans<<endl;
    }
    return 0;
}



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

#define INF 1145141919

int N;
int T[10010];
int dp[2][10010][2];

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

  for (int j=0; j<=N; j++) {
    for (int k=0; k<2; k++) {
      dp[0][j][k] = INF;
    }
  }

  dp[0][0][0] = 0;
  dp[0][0][1] = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=N; j++) {
      for (int k=0; k<2; k++) {
        dp[(i+1)%2][j][k] = INF;
      }
    }
    for (int j=0; j<N; j++) {
      for (int k=0; k<2; k++) {
        int nj = k == 0 ? j + 1 : j;
        if (dp[i%2][j][k] == INF) continue;
        dp[(i+1)%2][nj][k]   = min(dp[(i+1)%2][nj][k],   dp[i%2][j][k]);
        dp[(i+1)%2][nj][1-k] = min(dp[(i+1)%2][nj][1-k], dp[i%2][j][k] + T[i]);
      }
    }
  }
  cout << min(dp[N%2][N/2][0], dp[N%2][N/2][1]) << "\n";
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> AB(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    cin >> AB.at(i).at(0);
    cin >> AB.at(i).at(1);
  }

  sort(AB.begin(), AB.end(),
       [](auto& x, auto& y) { return x.at(1) < y.at(1); });

  string ans = "Yes";
  int t = 0;
  for (int i = 0; i < N; i++) {
    int a = AB.at(i).at(0);
    int b = AB.at(i).at(1);
    t += a;
    if (t <= b) {
      continue;
    }
    ans = "No";
    break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;
public class Main {
    public static void main (String[]args){
        //数直線上に 2000001個の石が置かれています。これらの石の座標は −1000000,−999999,−999998,…,999999,1000000です。
        //これらの石のうち、ある連続する K個の石が黒で塗られており、それ以外の石は白で塗られています。
        //また、座標 Xにある石は黒で塗られていることが分かっています。黒で塗られている石が置かれている可能性のある座標をすべて、小さい順に出力してください。

        // 制約 1≤K≤100 0≤X≤100 入力中の値はすべて整数である。

        // Scannerのインスタンス化
        Scanner scanner = new Scanner(System.in);
        
        int K = scanner.nextInt();
        int X = scanner.nextInt();

        // 黒塗りされた石の最大値
        int max  = X + (K - 1);

        // 黒塗りされた石の最小値
        int min = X - (K - 1);

        // 全出力を行う
        while (min <= max){
            System.out.println(min);
            min++;
        }
        
        
        scanner.close();

    }
} 

Measured memory_bytes: 23764