akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node {
  char value;

  struct node *child[5];
};

struct node tree;

void insert(char *str);
void find(char *str);
int id(char c);

int main(int argc, char *argv[])
{
  char cmd[6 + 1];
  char str[12 + 1];
  int n, i;

  for (i = 0; i < 5; i++) tree.child[i] = NULL;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", cmd);
    if (!strcmp(cmd, "insert")) {
      scanf("%s", str);
      insert(str);
    } else if (!strcmp(cmd, "find")) {
      scanf("%s", str);
      find(str);
    }
  }

  return 0;
}

void insert(char *str)
{
  int i, j;
  struct node *current = &tree, *prev;

  for (i = 0; i <= strlen(str); i++) {
    prev = current;
    current = current->child[id(str[i])];

    if (current == NULL) {
      current = (struct node *)malloc(sizeof(struct node));
      current->value = str[i];
      for (j = 0; j < 5; j++) current->child[j] = NULL;
      prev->child[id(str[i])] = current;
    }
  }
}

void find(char *str)
{
  int i;
  struct node *p = &tree;

  for (i = 0; i <= strlen(str); i++) {
    if (p->child[id(str[i])] == NULL) {
      printf("no\n");
      return;
    } else p = p->child[id(str[i])];
  }
  printf("yes\n");
  return;
}

int id(char c)
{
  switch (c) {
  case '\0':
    return 0;

  case 'A':
    return 1;

  case 'C':
    return 2;

  case 'G':
    return 3;

  case 'T':
    return 4;

  default:
    return -1;
  }
}

Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int k,s;cin >> k >> s;
      int ans = 0;
      for(int i = 0;i <= k;i++){
            for(int j = 0;j <= k;j++){
                  int r = s - i - j;
                  if(r >= 0 && r <= k)ans++;
            }
      }
      cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	ic(n)
	rep(0,i,n+1){
		if(i*27/25==n){
			c(i)
			return 0;
		}
	}
	c(":(")
}	
		

Measured memory_bytes: 256
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        r: usize,
    }
    println!("{}", r * r);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			
			int[] as = new int[N];
			for(int i = 0; i < N; i++){
				as[i] = -sc.nextInt();
			}
			Arrays.sort(as);
			for(int i = 0; i < N; i++){
				as[i] = -as[i];
			}
			
			int alice = 0, bob = 0;
			for(int i = 0; i < N; i++){
				if(i % 2 == 0){
					alice += as[i];
				}else{
					bob += as[i];
				}
			}
			
			System.out.println(alice - bob);
			
			
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int m, f, r;
	int s;

	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		if (m < 0 || f < 0) puts("F");
		else {
			s = m + f;
			if (s >= 80) puts("A");
			else if (s >= 65) puts("B");
			else if (s >= 50) puts("C");
			else if (s < 30) puts("F");
			else puts(r >= 50 ? "C" : "D");
		}
	}
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(void){

    
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    
    double sum = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a.begin(), a.end(), greater<int>());

    bool isOK = true;
    for(int i=0; i<m; i++) {
        if(sum / (4*m) > a[i]) isOK = false;
    }

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

    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

ll mfrac(ll n){
    if(n==0) return 1;
    else return n*mfrac(n-1)%MOD;
}

ll mperm(ll n,ll r){
    ll res=1;
    for(ll i=0;i<r;i++) res=res*(n-i)%MOD;
    return res;
}

ll mcomb(ll n,ll r){
    if(r>n-r) r=n-r;
    ll res=mperm(n,r);
    return res*mpow(mfrac(r),MOD-2)%MOD;
}

ll N;
ll A[100000];
ll cnt[100000];

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

    rep(i,N) cnt[A[i]]++;
    bool flag=true;
    for(int i=(~N&1);i<N;i+=2){
        if(i==0 && cnt[i]!=1){
            flag=false;
            break;
        }else if(i!=0 && cnt[i]!=2){
            flag=false;
            break;
        }
    }

    ll ans;
    if(flag) ans=mpow(2,N/2);
    else ans=0;

    cout<<ans<<endl;
}

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

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	int mn = INT_MAX;
	for(int i=1; i<=100; i++) {
		int sum = 0;
		for(int t: v) {
			sum += (t-i)*(t-i);
		}
		mn = min(mn, sum);
	}
	cout << mn;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX = 200000;
int N, M;
//頂点数が多すぎるので隣接行列は使えない.代わりに隣接リストを使う
//Gは1と隣接,HはNと隣接
vector<bool> G(MAX,false), H(MAX,false);
int main() {
	cin >> N >> M;
	rep(i, M) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		if (s == 0) G[t] = true;
		if (t == 0) G[s] = true;
		if (s == N-1) H[t] = true;
		if (t == N-1) H[s] = true;
	}
	//1とN以外の点を経由してNに着けるかをチェック
	bool vis = false;
	for (int v = 1;v <= N - 2;v++) {	
		if (G[v]&&H[v]) vis = true;
	}
	if (vis) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 1;i <= N;i++) {
		cin >> A[i - 1];
		A[i - 1] -= i;
	}
	sort(all(A));
	int b = A[N / 2];
	ll ans = 0;
	for (int i = 0;i < N;i++) {
		ans += (ll)abs(A[i] - b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int count_0 = 0;
	int count_1 = 0;
	char c;

	do{
		scanf("%c", &c);
		if (c == '0')
			count_0++;
		if (c == '1')
			count_1++;
	} while (c != '\n');
	if (count_0 < count_1)
		printf("%d\n", count_0 * 2);
	else
		printf("%d\n", count_1 * 2);
}

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

#define MAX 300100

bool isPrime[MAX];

int main() {
	fill(isPrime, isPrime + MAX, true);
	isPrime[0] = false;
	for (int i = 2; i < MAX; i++) {
		if (i % 7 != 1 && i % 7 != 6) continue;
		if (isPrime[i]) {
			for (int j = 2 * i; j < MAX; j += i) {
				isPrime[j] = false;
			}
		}
	}

	int n;
	while (cin >> n , n != 1) {
		cout << n << ":";
		for (int i = 6; i <= n; i++) {
			if (i % 7 != 1 && i % 7 != 6) continue;
			if (n % i == 0 && isPrime[i]) {
				cout << " " << i ;
			}
		}

		cout << endl;
	}

}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N, M;
  CIN(N >> M);
  if (M == N) {
    COUT("Yes");
  } else {
    COUT("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N;
  int count=0;
  cin>>N;
  //a*b+c
  for(int i=1;i*i<N;i++){
    count+=(N-1)/i-i+1;
    if(i*i<=N-1){count--;}
    count+=(N-1)/i-i+1;
    //cout<<i<<" "<<count<<endl;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    set<int> S;
    
    for (int i = 0; i < n ; i++){
        int a;
        cin >> a;
        S.insert(a);
    }
    
    int size2 = S.size();
    
    if (n == size2) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double E;

double calc(int x, int y){
    return abs(sqrt(x*x + y*y) - E);
}

int main(void){
    while(true){
        double res = 1000000.0;
        int D; cin >> D >> E;
        if(D == 0) break;
        for(int i = 0; i < D; i++){
            int j = D-i;
            res = min(res, calc(i, j));
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
#include<stdio.h>
#include<string.h>
#include<ctype.h>

void Trimming(char *str){
	char *p = str;
	
	while(*str != '\0'){
		if(isupper(*str) != 0){
			*p = *str + 0x20;
		}else{
			*p = *str;
		}
		p++;
		str++;
	}
	*p = '\0';
}


int main(){
	
	int i,j;
	int word_cnt,cnt;
	char row[100]={0};
	char text[1001][100]={0};
	char word[21]={0};
	
	i = 0;
	cnt = 0;
	
	scanf("%s",word);
	while( 1 ){
		scanf("%s",row);
		if(strcmp( row,"END_OF_TEXT") == 0){
			break;
		}
		Trimming(row);
		strcpy(&text[i][0],row);
		i++;
	}
	word_cnt = i;
	
	for(i=0; i<word_cnt; i++){
		if(strcmp(&text[i][0],word) == 0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	
	return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>

int main(void)
{
	int a, b, c, tmp;
	int i, j,t;
	int Arry[3];
	
	scanf( "%d %d %d", &a, &b, &c );
	Arry[0] = a;
	Arry[1] = b;
	Arry[2] = c;
	
	for( i = 0; i < 3; i++ )
	{
		for( j = i+1; j < 3; j++ )
		{
			if( Arry[i] > Arry[j] )
			{
				tmp = Arry[i];
				Arry[i] = Arry[j];
				Arry[j] = tmp;
			}
		}
	}
	
	printf( "%d %d %d\n", Arry[0], Arry[1], Arry[2] );
	
	return 0;
}

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

#define endl '\n'
using namespace std;
using ll = long long;
using Linear = pair<ll,ll>;
#define a first
#define b second

const int N = 200005;

int n;
ll c;
ll h[N];
ll dp[N];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> c;
    for(int i = 0; i < n; i++) cin >> h[i];
}

ll getVal(Linear &l, ll x)
{
    return l.a*x+l.b;
}

pair<ll,ll> inter(Linear &g, Linear &h)
{
    ll up = h.b-g.b;
    ll down = g.a-h.a;
    if(down < 0) up *= -1, down *= -1;
    return make_pair(up, down);
}

ll getMin(vector<Linear> &hull, ll x)
{
    static int idx = 0;
    // test: hull.size()-1?
    if(idx >= hull.size()) idx = max(0, (int)hull.size()-2);
    while(idx+1 < hull.size())
    {
        if(getVal(hull[idx+1], x) <= getVal(hull[idx], x)) idx++;
        else break;
    }
    return getVal(hull[idx], x);
}

void validateHull(vector<Linear> &hull, Linear &h)
{
    while(hull.size() >= 2)
    {
        auto &f = hull.end()[-2];
        auto &g = hull.end()[-1];  // back
        // x of inter(h, f) <= x of inter(f, g)
        auto inter_hf = inter(h, f);
        auto inter_fg = inter(f, g);
        // inter_hf.first / inter_hf.second <= inter_fg.first / inter_fg.second
        if((__int128)inter_hf.first*inter_fg.second <= (__int128)inter_fg.first*inter_hf.second)
            hull.pop_back();
        else
            break;
    }
    hull.push_back(h);
}

void process()
{
    vector<Linear> hull;
    dp[0] = 0;
    hull.emplace_back(-2*h[0], dp[0]+h[0]*h[0]);
    for(int i = 1; i < n; i++)
    {
        dp[i] = getMin(hull, h[i]) + h[i]*h[i] + c;
        Linear tmp(-2*h[i], dp[i]+h[i]*h[i]);
        // validate convex hull
        validateHull(hull, tmp);
    }
    cout << dp[n-1] << endl;
}



Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void solve() {
	long long left, right; cin >> left >> right;
	long long ans = 2018;
	for (long long i = left; i < right; i++) {
		for (long long j = i + 1; j < right + 1; j++) {
			ans = min(ans, (i*j) % 2019);
			if (ans == 0) goto res;
		}
	}
	res:
	cout << ans << endl;

}

int main(void) {
	solve();
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) for _ in input().split()]

# my initial trial below ##############################
# from itertools import combinations
# INF = 10 ** 15
# combs = combinations(range(1, n), 3)
# grief = INF
# for comb in combs:
#     p = sum(a[:comb[0]])
#     q = sum(a[comb[0]:comb[1]])
#     r = sum(a[comb[1]:comb[2]])
#     s = sum(a[comb[2]:])

#     tmp = max(p, q, r, s) - min(p, q, r, s)
#     if tmp < grief:
#         grief = tmp

# print(grief)  # running time limit error

# solution below ######################################
INF = 10**15
cumul_sum = [0]
for i, ai in enumerate(a):
    cumul_sum.append(ai + cumul_sum[i])


def cal_sum(left, right):
    return cumul_sum[right] - cumul_sum[left]


def two_pointers(l, r, split, diff):
    left_sum = cal_sum(l, split)
    right_sum = cal_sum(split, r)
    diff = abs(left_sum - right_sum)

    for i in range(split, r):
        tmp_left_sum = cal_sum(l, i)
        tmp_right_sum = cal_sum(i, r)
        tmp_diff = abs(tmp_left_sum - tmp_right_sum)

        if diff >= tmp_diff:
            left_sum = tmp_left_sum
            right_sum = tmp_right_sum
            diff = tmp_diff
        else:
            return i - 1, diff, left_sum, right_sum
    else:
        return r - 1, tmp_diff, tmp_left_sum, tmp_right_sum


l_split = 1
r_split = 3
griefs = []
for i in range(2, n - 1):
    # left
    l_split, l_diff, p, q = two_pointers(0, i, l_split, INF)
    # right
    r_split, r_diff, r, s = two_pointers(i, n, r_split, INF)
    griefs.append(max(p, q, r, s) - min(p, q, r, s))

print(min(griefs))


Measured memory_bytes: 28844
#include <iostream>
#include <iomanip>

void Output(int arr[4][3][10]) {
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 10; ++k) {
				std::cout << " " << arr[i][j][k];
			}
			std::cout << std::endl;
		}
		if(i < 3) std::cout << "####################" << std::endl;
	}
}

int main()
{
	int v_build_floor_room[4][3][10] = {};
	int n;
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		int b, f, r, v;
		std::cin >> b >> f >> r >> v;
		v_build_floor_room[b-1][f-1][r-1] += v;
	}
	Output(v_build_floor_room);
	return 0;
}




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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)

struct query
{
    ll l, r;
};
ll Q;
vector<query> queries;

bool is_prime(ll n)
{
    if (n < 2)
    {
        return false;
    }
    ll i = 2;
    while (i * i <= n)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}

int main()
{
    ll right = INT64_MIN;
    ll left = INT64_MAX;
    cin >> Q;
    queries.resize(Q);
    rep(i, queries.size())
    {
        cin >> queries[i].l >> queries[i].r;
        left = min(left, queries[i].l);
        right = max(right, queries[i].r);
    }
    vector<ll> dp((right - left) / 2 + 1);
    for (ll i = left; i <= right; i += 2)
    {
        ll j = (i - left) / 2;
        if (j != 0)
        {
            dp[j] = dp[j - 1];
        }
        if (is_prime(i) && is_prime((i + 1) / 2))
        {
            dp[j]++;
        }
    }
    for (query query : queries)
    {
        ll ans = 0;
        ans += dp[(query.r - left) / 2];
        if (query.l != left)
        {
            ans -= dp[(query.l - left) / 2 - 1];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2560
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int[] b = Arrays.copyOf(a, n);
		Arrays.sort(b);

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			if (a[i] == b[n - 1]) {
				pw.println(b[n - 2]);
			} else {
				pw.println(b[n - 1]);
			}
		}
		pw.flush();
	}
}


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

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

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

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

signed main(){
	int l, k;
	while(cin >> l >> k){
		vector<int> dp(l + 1, 0);
		dp[1] = 1;
		if(k < dp.size()) dp[k] = 1;
		rep(i, dp.size()){
			if(i + 2 < dp.size()) dp[i + 2] += dp[i];
			if(i + k + 1 < dp.size()) dp[i + k + 1] += dp[i];
		}

		cout << accumulate(all(dp), 0LL) << endl;
	}
}



Measured memory_bytes: 3128
#include <stdio.h>
#include <string.h>

int main(){
	int num,i;
	int flag[30];

	memset(flag,0,sizeof(flag));

	for(i = 0;i < 28;i++){
		scanf("%d",&num);
		flag[num-1] = 1;
	}

	for(i = 0;i < 30;i++){
		if(!flag[i]){
			printf("%d\n",i+1);
		}
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
void solve()
{
  int n;
  cin>>n;
  int p,q,r,a=0,b=0,c=0;
  rep(i,n)
  {
    cin>>p>>q>>r;
    p+=max(b,c);
    q+=max(a,c);
    r+=max(a,b);
    a=p;b=q;c=r;
  }
  cout<<max({a,b,c});
}
int main()
{
  fastio;
 // fopen();
  int t;
  //cin>>t;
  rep(i,1)
  { 
    //cout<<"Case #"<<i+1<<": ";
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 2e5+5;
int n,k,val[N];
double ans,sum;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	for(ri i=1;i<=n;++i)
		read(val[i]),++val[i];
	for(ri i=1;i<=k;++i)
		sum+=val[i]/2.;
	ans=sum;
	for(ri i=k+1;i<=n;++i){
		sum+=val[i]/2.-val[i-k]/2.;
		ans=max(ans,sum);
	}
	printf("%.6f",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

class Main {
    static int[] label = new int[6];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean ans = false;
        int[] label2 = new int[6];

        for (int i = 0; i < 6; i++)
            label[i] = sc.nextInt();
        for (int i = 0; i < 6; i++)
            label2[i] = sc.nextInt();

        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 3; j++) {
                if (Arrays.equals(label2, label)) {
                    ans = true;
                    break;
                }
                dice1('X');
            }
            if (Arrays.equals(label2, label)) {
                ans = true;
                break;
            }
            dice1('N');
            if (i >= 2)
                dice1('N');
            if (i >= 3)
                dice1('N');
        }
        if (ans) {
            System.out.println("Yes");
        }  else {
            System.out.println("No");
        }    
    }

    public static void dice1(char c) {
        int temp;
        switch (c) {
        case 'N':
            temp = label[0];
            label[0] = label[1];
            label[1] = label[5];
            label[5] = label[4];
            label[4] = temp;
            break;
        default :
            temp = label[1];
            label[1] = label[2];
            label[2] = label[4];
            label[4] = label[3];
            label[3] = temp;
            break;
        }
    }
}


Measured memory_bytes: 26432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(){
	int a,b;
	cin>>a>>b;
	int A=a+b;
	int B=a+(a-1);
	int C=b+(b-1);
	int ans=max(A,max(B,C));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

void extgcd(int a,int b, int& x,int& y)
{
	if(b != 0){
		extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
}

int mod_inverse(int a,int m)
{
	int x,y;
	extgcd(a,m,x,y);
	return (m + x % m) % m;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n,s,w,q;
        cin >> n >> s >> w >> q;
        if(n == 0){
            break;
        }
        vi a(n);
        int g = s;
        rep(i,n){
            a[i] = (g/7) % 10;
            if(g%2 == 0){
                g = g/2;
            }else{
                g = (g/2)^w;
            }
        }
        if(q == 2 || q == 5){
            ll ans = 0;
            int zero = 0;
            rep(i,n){
                if(a[i] == 0){
                    zero++;
                }
                if(a[i] % q == 0){
                    ans += i-zero+1;
                }
            }
            cout << ans << "\n";
            continue;
        }
        vi dp(n+1,0),ten(n+1);
        ten[0] = 1;
        map<int,int> mp;
        mp[0] = 0;
        int inv = mod_inverse(10,q);
        rep(i,n){
            ten[i+1] = ((ll)ten[i] * inv) % q;
        }
        ll ans = 0;
        int nw = 0;
        rep(i,n){
            nw = (nw * 10 + a[i]) % q;
            int val = ((ll)nw * ten[i+1]) % q;
            if(mp.find(val) != mp.end()){
                int id = mp[val];
                dp[i+1] = dp[id] + (a[id] != 0);
                ans += dp[i+1];
            }
            mp[val] = i+1;
        }
        cout << ans << "\n";
    }
    return 0;
}



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


//This code is written by Sneh Thakkar on 16-12-2019

/*       AUTHOR NAME:

        _/_/_/_/   _/\        _/     _/_/_/_/_/    _/      _/
       _/         _/ _\      _/     _/            _/      _/
      _/_/_/_/   _/   _\    _/     _/_/_/_/_/    _/_/_/_/_/
           _/   _/     _\  _/     _/            _/      _/
    _/_/_/_/   _/       _\_/     _/_/_/_/_/    _/      _/
       
        
*/

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

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


int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;
    ll a[4]={0};
    cin>>n>>k;
    a[n]=1;
    a[k]=1;
    for(ll i=1;i<=3;i++)
    {
        if(a[i]==0)
        {
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007

using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    long p=1;

    ll cnt=0;
    for(i=0; i<n; i++) {
        if(a[i]==p) {
            p++; continue;
        }
        if(p==1) {
            cnt += (a[i]-1);
            p++;
        }
        else if(a[i]%p==0) {
            cnt += (a[i]/p-1);
        }
        else {
            cnt += (a[i]/p);
        }
    }
    printf("%lld\n", cnt);

    return 0;
}


Measured memory_bytes: 1152
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
            
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }     
signed main()
{   jaldi
    int a,b;
    cin>>a>>b;
    int x=(a*b)/(gcd(a,b));
    cout<<x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 



int main() {  
   string s;
   cin>>s;
   if(s=="AAA" || s=="BBB") 
   cout<<"No";
   else cout<<"Yes";
      
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, m; cin >> n >> m;
  vi K(m), p(m);
  vvi s(m);
  rep(i, m) {
    cin >> K[i];
    rep(j, K[i]) {
      int tmp; cin >> tmp;
      s[i].pb(--tmp);
    }
  }
  rep(i, m) {
    cin >> p[i];
  }

  int ans = 0;
  rep(i, 1<<n) {
    vector<bool> isOn(n);
    int count = 0;
    rep(j, n) isOn[j] = (i>>j) & 1;
    rep(j, m) {
      int cnt = 0;
      rep(k, K[j]) {
        if(isOn[s[j][k]]) cnt++;
      }
      if ((cnt&1) == (p[j]&1)) {
        count++;
      }
    }
    if (count == m) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long X)
{
    string ans;
    if (X >= 30)
        ans = YES;
    else
    {
        ans = NO;
    }
    cout << ans << endl;
}

signed main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    sort(A.begin(), A.end());
    vector<long long> sum(N + 1, 0);
    for(int i = 0; i < N; i++)sum[i + 1] = sum[i] + A[i];
    
    int cnt = 0;
    for(int i = 1; i < N; i++){
        if(sum[i] * 2 < A[i])cnt = i;
    }
    
    int ans = N - cnt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<int> C;
#define X real()
#define Y imag()
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
int n;
cin>>n;
int v[n][3];
for(int i=0;i<n;i++)
{
	int a,b,c;
	cin>>a>>b>>c;
	v[i][0]=a;
	v[i][1]=b;
	v[i][2]=c;
	
}
int dp[n][3];
dp[0][0]=v[0][0];
dp[0][1]=v[0][1];
dp[0][2]=v[0][2];
for(int i=1;i<n;i++)
{
	dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
	dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
	dp[i][2]=v[i][2]+max(dp[i-1][1],dp[i-1][0]);
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}return 0;}







Measured memory_bytes: 2560
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main ()
{
  long long n,k;
  cin >> n >> k;
  vector<int> dice(n);
  for(auto & e:dice){
    cin >>e;
  }
  long maxi=0;
  long Pmax=accumulate(dice.begin(),dice.begin()+k,0);
  long Prev=accumulate(dice.begin(),dice.begin()+k,0);

  //cout << Pmax << endl;
  for(int i=1;i<n-k+1;i++){
    long ThisTime=Prev-dice[i-1]+dice[i+k-1];
    if(ThisTime > Pmax){
      maxi = i;
      Pmax = ThisTime;
    }
    Prev=ThisTime;
  }
  double sumEx=0;
  //cout << "===" << endl;
  for(int i=maxi;i<maxi+k;i++){
    double Ex = (dice[i]+1)/2.0;
    sumEx += Ex;
    //cout << i << " " <<dice[i]<<" "<< Ex <<" "<<sumEx<<endl;
  }
  cout << setprecision(10)<< sumEx <<endl;
 return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int start, end;
  int len;
  int count;
  char buff[100];
  bool flg;
 
  cin >> start;
  cin >> end;
  
  count = 0;
  for (int i = start; i <= end; i++) {
    sprintf(buff, "%d", i);
    len = strlen(buff);
    // cout << len << endl;
    flg = true;
    for (int j = 0; j < strlen(buff) / 2; j++) {
      if (buff[j] == buff[len - j - 1]) {
        // OK
      } else {
        // cout << "j = " << j << endl;
        // cout << "buff[j] = " << buff[j] << endl;
        // cout << "buff[len - j] = " << buff[len - j - 1] << endl;
        flg = false;
        break;
      }
    }
    if (flg == true) {
      count = count + 1;
    }
  }
  cout << count << endl;    
}

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

int n,m,maxv=-1;
char a[25][25];
int GA[25][25][25][25];

int main()
{
	cin>>n>>m;
	memset(a,' ',sizeof(a));
	memset(GA,inf,sizeof(GA));
	
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  
		   cin>>a[i][j];
	}
	
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (a[i][j]==a[i][j-1]&&a[i][j]=='.')  
			   GA[i][j][i][j-1]=GA[i][j-1][i][j]=1;
			if (a[i][j]==a[i][j+1]&&a[i][j]=='.')  
			   GA[i][j][i][j+1]=GA[i][j+1][i][j]=1;
			if (a[i][j]==a[i+1][j]&&a[i][j]=='.')  
			   GA[i][j][i+1][j]=GA[i+1][j][i][j]=1;
			if (a[i][j]==a[i-1][j]&&a[i][j]=='.')  
			   GA[i][j][i-1][j]=GA[i-1][j][i][j]=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  
		   GA[i][j][i][j]=0;
	}
	
	for (int ki=1;ki<=n;ki++)
	{
		for (int kj=1;kj<=m;kj++)
		{
			if (a[ki][kj]=='#')  continue;
			for (int ii=1;ii<=n;ii++)
			{
				for (int ij=1;ij<=m;ij++)
				{
					if (a[ii][ij]=='#')  continue;
					for (int ji=1;ji<=n;ji++)
					{
						for (int jj=1;jj<=m;jj++)
						{
							if (a[ji][jj]=='#')  continue;
							if (GA[ii][ij][ji][jj]>GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj])
							{
								GA[ii][ij][ji][jj]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
								GA[ji][jj][ii][ij]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
							}
						}
					}
				}
			}
		}
	}
	for (int ii=1;ii<=n;ii++)
	{
		for (int ij=1;ij<=m;ij++)
		{
			for (int ji=1;ji<=n;ji++)
			{
				for (int jj=1;jj<=m;jj++)
				{
					if (GA[ii][ij][ji][jj]>n*m)  continue;
					else maxv=max(maxv,GA[ii][ij][ji][jj]);
				}
			}
		}
	}
	cout<<maxv<<endl;
	return 0;
}

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

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

    int x[N];
    int sumLen = 0;
    for (int i=0; i < N; i++) {
        cin >> x[i];
        int lenB = abs(K - x[i]);

        if (x[i] <= lenB) sumLen += 2 * x[i];
        else sumLen += 2 * lenB;
    }

    cout << sumLen << endl;
    return 0;
}

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

int main() {
  int N,M,x;
  cin >> N >> M;
  vector<int> cnt(N);
  for (int i = 0; i < 2*M; i++) {
    cin >> x;
    for (int j = 0; j < N; j++) {
      if (x == j+1) {
        cnt.at(j)++;
        break;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << cnt.at(i) << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m, k, a, b;
    cin >> n >> m >> k;
    vector<long long>  ap(n+1), bp(m+1);
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        ap[i+1] = ap[i] + (long long) a;
    }

    for (int i=0; i<m; i++) {
        scanf("%d", &b);
        bp[i+1] = bp[i] + (long long) b;
    }

    int ans = 0, j = m;
    for (int i=0; i<n+1; i++) {
        if (ap[i] > k) break;
        while (bp[j]+ap[i] > k) --j;
        if (i+j > ans) ans = i+j;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		String ans = "";
		if(A%2==B%2) {
			ans = "Alice";
		}else {
			ans = "Borys";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<int> g[(int)2e5 + 10];
int n, q, ck[(int)2e5+10];
ll ans[(int)2e5 + 10];
void dfs(int x, int a) {
	ck[x] = true;
	ans[x] += a;
	ll k = ans[x];
	for (int v : g[x]) {
		if (ck[v]) continue;
		dfs(v, k);
	}
}
int main(void) {
	scanf("%d %d", &n, &q);
	for (int i = 1; i < n; i++) {
		int a, b; scanf("%d %d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int a, b; scanf("%d %d", &a, &b);
		ans[a] += b;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%lld ", ans[i]);
	}
}

Measured memory_bytes: 21888
#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<sstream>
#include<algorithm>

using namespace std;

string replacedelim(string t){
  string tt=t;
  replace(begin(tt),end(tt),'/',' ');
  return tt;
}  

int main(){
  for(int n,m;cin>>n>>m,n;){
    set<string> s;
    set<vector<string> > dirs;
    while(n--){
      string t;
      cin>>t;
      s.insert(t);
      stringstream ss(replacedelim(t));
      vector<string> v;
      for(string s;ss>>s;){
	v.push_back(s);
      }
      vector<string> w;
      for(int i=0;i+1<v.size();i++){
	w.push_back(v[i]);
	dirs.insert(w);
      }
    }
    while(m--){
      bool f=false;
      set<string>::iterator it[2];
      for(int i=0;i<2;i++){
	string t;
	cin>>t;
	stringstream ss(replacedelim(t));
	vector<string> v;
	vector<vector<string> > vs;
	for(string st;ss>>st;){
	  if(st==".."){
	    if(v.empty()){
	      f=true;
	    }else{
	      v.pop_back();
	    }
	  }else if(st!="."){
	    v.push_back(st);
	    vs.push_back(v);
	  }
	}
	for(int j=0;j+1<vs.size();j++){
	  f|=vs.size()&&!dirs.count(vs[j]);
	}
	string pt;
	for(auto e:v){
	  pt+="/"+e;
	}
	bool es=t.back()=='/'||t.back()=='.';
	f|=es&&!vs.empty()&&!dirs.count(vs.back());
	if(!es){
	  it[i]=s.find(pt);
	}
	if(es||it[i]==end(s)){
	  it[i]=s.find(pt+"/index.html");
	}
      }
      cout<<((f||it[0]==end(s)||it[1]==end(s))?"not found":
	     (it[0]==it[1])?"yes":"no")<<endl;
    }
  }
}

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

int main()
{
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;s[i];i++)
    {
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hishi = 0; int choho = 0;
		while(sc.hasNext()){
			String[] temp = sc.nextLine().split(",");
			int[] a = new int[3];
			for(int i=0; i<3; i++)	a[i] = Integer.parseInt(temp[i]);
			if(a[0]==a[1]) hishi++;
			else if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]) choho++;
		}
		System.out.printf("%d%n%d%n",choho,hishi);
	}

}

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

int main(){
    //入力
    string S;

    cin >> S;

    //計算
    bool flag=true;
    while(flag){
        S.erase(S.size()-2);
        if(S.substr(0,S.size()/2)==S.substr(S.size()/2)){
            cout << S.size() << endl;
            flag = false;
        }
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int n, r, l; cin >> n >> r >> l;
	vector<int> d(r), t(r + 1), x(r);
	for (int i = 0; i < r; ++i) {
		cin >> d[i] >> t[i] >> x[i];
		d[i]--;
	}
	t[r] = l;
	vector<int> po(n), ti(n);
	priority_queue<pair<int, int> > pq;
	for (int i = 1; i <= r; ++i) {
		po[d[i - 1]] += x[i - 1];
		pq.push(make_pair(po[d[i - 1]], -d[i - 1]));
		while (!pq.empty() && pq.top().first != po[-pq.top().second]) pq.pop();
		ti[-pq.top().second] += t[i] - t[i - 1];
	}
	cout << max_element(ti.begin(), ti.end()) - ti.begin() + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 19624
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {

    int A, B;

    std::cin >> A >> B;


    std::cout << std::max(A + B, std::max(A + A - 1, B + B - 1)) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    ll a,b,c;cin>>a>>b>>c;
    cout<<(a*b*c%2 ==0 ? 0 : min(a*b,min(b*c,c*a))) << endl;    
    
    return 0;
    
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val digitNum = Math.log10(n.toDouble()).toInt()
  val d0 = n % 10
  val d1 = n / 10 % 10
  val d2 = n / 100 % 10
  val d3 = n / 1000 % 10
  val d4 = n / 10000 % 10
//  val d5 = n / 100000 % 10
  
  val answer = when (digitNum) {
    0 -> {
      d0
    }
    1 -> {
      9
    }
    2 -> {
      9 + (d2 - 1) * 100 + (d1 * 10 + d0 + 1)
    }
    3 -> {
      909
    }
    4 -> {
      909 + (d4 - 1) * 10000 + (d3 * 1000 + d2 * 100 + d1 * 10 + d0 + 1)
    }
    5 -> {
      90909
    }
    else -> throw Exception("")
  }
  println(answer)
}



Measured memory_bytes: 31780
#include <bits/stdc++.h>
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);
  reverse(a, a + n);
  int p1 = 0, p2 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) p1 += a[i];
    else p2 += a[i];
  }
  cout << abs(p1 - p2) << endl;
}


Measured memory_bytes: 256