akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "YES"
#define NO  "NO"

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int a, b; cin >> a >> b;
  cout << (a + b) % 24 << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


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

const long long mod = 1e9 + 7;

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

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

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

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

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

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

int main(){
    int n, c;
    cin >> n >> c;
    vector<vi> d(c, vi(c));
    rep(i, c) rep(j, c) cin >> d[i][j];
    vector<vi> ci(n, vi(n));
    rep(i, n) rep(j, n) {
        cin >> ci[i][j];
        ci[i][j]--;
    }
    vector<vi> cnt(3, vi(c));
    rep(i, n) rep(j, n) {
        cnt[((i+1)+(j+1))%3][ci[i][j]]++;
    }
    int ans = INF;
    rep(i, c) rep(j, c) rep(k, c) {
        if (!(i!=j&&j!=k&&k!=i)) continue;
        int sum = 0;
        rep(i2, c) sum += cnt[0][i2] * d[i2][i];
        rep(i2, c) sum += cnt[1][i2] * d[i2][j];
        rep(i2, c) sum += cnt[2][i2] * d[i2][k];
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4616
s=int(input())
l=[s]
l.append(3*s+1 if s%2 else s//2)
i=1
while l.count(l[i])<2:
  l.append(3*l[i]+1 if l[i]%2 else l[i]//2)
  i+=1
print(i+1)

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

typedef long long ll;

ll W[100001], V[100001];
ll N, maxW;
ll dp[101][100001];

ll f(ll i, ll w)
{
	if (w > maxW) return -V[i-1];

	if (i == N) return 0;

	if (dp[i][w] == -1)
		dp[i][w] = max(V[i] + f(i+1, w + W[i]), f(i+1, w));

	return dp[i][w];
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> N >> maxW;
	memset(dp, -1, sizeof(dp));

	for (int i = 0; i < N; ++i)
		cin >> W[i] >> V[i];

	cout << f(0, 0) << endl;

	return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>
int main(){
  int N,M,P,kazu,sum,tosen,i,haito;
  
  while(1){
    sum=0;
    scanf("%d%d%d",&N,&M,&P);
    if(N==0 && M==0 && P==0)break;
    
    for(i=1;i<=N;i++){
      scanf("%d",&kazu);
      sum+=kazu*100;
      if(i==M)haito=kazu;
    }

    if(haito>0)printf("%d\n",(sum*(100-P)/100)/haito);
    else printf("0\n");
  }


  return 0;
}

Measured memory_bytes: 612
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);

	if ((a * b) % 2 == 0)
	{
		printf("Even");
	}
	else
	{
		printf("Odd");
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X,N;
		X=sc.nextInt();
		N=sc.nextInt();

		int syoki_hairetu[] = new int[301];
		for(int i=0;i<301;i++) {
			syoki_hairetu[i]=-100+i;
		}


		int p[]=new int[N];
		for(int i=0;i<N;i++) {
			p[i]=sc.nextInt();
			syoki_hairetu[100+p[i]]=-101;
		}

		int tmp;
		int min_abs=1000;
		int min_number=1000;

		for(int i=0;i<301;i++) {
			tmp=Math.abs(X-syoki_hairetu[i]);
			if(tmp<min_abs) {
				min_abs=tmp;
				min_number=syoki_hairetu[i];
			}
		}
		System.out.println(min_number);
		/*for(int i=0;i<301;i++) {
			System.out.print(syoki_hairetu[i]+" ");

		}*/
	}
}


Measured memory_bytes: 35924
A,B,K = map(int,input().split(" "))
list = []

if B - A + 1 <= K * 2:
    for i in range(A,B+1):
        print(i)
else:
    count = 0
    for i in range(A,B+1):
        count += 1
        print(i)
        if count >= K:
            break
    count = 0
    for i in range(B-K+1,B+1):
        print(i)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n;
  cin>>a>>b>>n;
  if(n>=b){
    cout<<1LL*a*(b-1)/b<<endl;
  }else{
    cout<<1LL*a*n/b<<endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	ll N;
	int a, b;
	cin >> N >> a >> b;

	ll result = repeat_square(2, N) - 1; // 2^n - 1
	result -= combination(N, a);
	result -= combination(N, b);

	if(result < 0) result += 2 * MOD;
	result %= MOD;

	cout << result << endl;	
  return 0;
}


Measured memory_bytes: 256
def read_input():
    a = int(input())
    b = int(input())

    return a, b

def submit():
    a, b = read_input()

    if a > b:
        print('GREATER')
    elif a < b:
        print('LESS')
    else:
        print('EQUAL')

if __name__ == '__main__':
    submit()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		int ans=0;
		double x1,y1,x2,y2,x3,y3,x4,y4,m1,m2;
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(x1==x2||x3==x4){
			if(x1==x2&&x3==x4) ans=1;
		}else{
			m1=(y2-y1)/(x2-x1);
			m2=(y4-y3)/(x4-x3);
			if(fabs(m1-m2)<(1e-10)) ans=1;
		}
		if(ans)	cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

int main() {
  char b;
  cin>>b;
  if(b=='A') 
    cout<<'T'<<endl;
  else if(b=='T') 
    cout<<'A'<<endl;
  else if(b=='G') 
    cout<<'C'<<endl;
  else 
    cout<<'G'<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
int n, A[MAX_N];

void Out(int k) {
	if (k == 0)
		cout << '[' << A[0] << ']';
	else
		cout << A[0];
	for (int i = 1; i < n; i++) {
		if (k == i)
			cout << ' ' << '[' << A[i] << ']';
		else
			cout << ' ' << A[i];
	}
	cout << endl;
}

int Partition(int p, int r) {
	int x = A[r], i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	Out(Partition(0, n - 1));
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  vector<int> res(n);
  int ans=0;
  for(int i=n-1;i>=0;i--){
    int q=0;
    for(int j=i;j<n;j+=i+1) q+=res[j];
    if(q%2==1&&a[i]==0){
      res[i]=1;
      ans++;
    }else if(q%2==0&&a[i]==1){
      res[i]=1;
      ans++;
    }
  }
  cout<<ans<<endl;
  rep(i,n){
    if(res[i]==1) cout<<i+1<<" ";
  }
}




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

#define rep(i, n) for(int i = 0, i_length = (n); i < i_length; i++)
#define MOD 1000000007
#define ll long long

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

	vector<int> p;
	p.resize(n);

	rep(i, k) {
		int x;
		cin >> x;

		rep(j, x) {
			int y;
			cin >> y;
			p[y-1]++;
		}
	}

	int ans = 0;
	rep(i, n) {
		if (p[i] == 0) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
    int person[2];
    int attack[2];
    cin >> person[0] >> attack[0];
    cin >> person[1] >> attack[1];
    int flag = 0;
    while(person[0] > 0 && person[1] > 0){
        person[abs(flag-1)] -= attack[flag];
        flag = abs(flag-1);
    }
    if(flag == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,res; cin >> n;
    VI x(101,0) , y(101,0) , h(101,0);
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0) res = i;
    }

    rep(i,101){
        rep(j,101){
            bool flag = true;
            int height = h[res] + abs(x[res] - j) + abs(y[res] - i);
            rep(k,n){
                int tmp = 0;
                tmp = max(tmp,(height - abs(x[k] - j)-abs(y[k] - i)));
                if( tmp != h[k] ){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << j << " " << i << " " << height << endl;
                return 0;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
using System.IO;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var H1 = GetInt();
            var M1 = GetInt();
            var H2 = GetInt();
            var M2  = GetInt();
            var K = GetInt();

            var T1 = H1 * 60 + M1;
            var T2 = H2 * 60 + M2;

            var T = T2 - T1;

            Console.WriteLine(T-K);

            

            return;
        }
    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

Measured memory_bytes: 27544
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	const int M = 1000000007;
	vector<vector<int> > dp(n + 1, vector<int>(k + 1));
	fill(dp[n].begin(), dp[n].end(), 1);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - v[i]);
			int r = j;
            int &ret = dp[i][j];
			ret = dp[i + 1][r];
			if (l) {
				ret += M - dp[i + 1][l - 1];
				if (ret >= M)
					ret -= M;
			}
			if (j) {
				ret += dp[i][j - 1];
				if (ret >= M)
					ret -= M;
			}
		}
	}
	printf("%d\n", (dp[0][k] - (k ? dp[0][k - 1] : 0) + M) % M);
	return 0;
}


Measured memory_bytes: 40192
#include <iostream>
#include <string>
#include <cctype>

using namespace std;


string exchange(string s, int h){
    string ans;
    string temp = s.substr(0,h);

    ans = s.substr(h,s.size()-h) + s.substr(0,h);

    return ans;

}

int main(){
    string n,temp;
    int m;
    int h[100];

    while(cin >> n){
        if(n == "-"){break;}
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h[i];
        }

        for(int i=0;i<m;i++){
            n = exchange(n, h[i]);
        }

        cout << n <<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
def lscan; gets.split.map(&:to_i); end

tables = [lscan,lscan,lscan]

gets.to_i.times do
  b = gets.to_i
  tables.map!{|li| li.map{|e| e == b ? nil : e }}
end

bg = false
bg ||= !tables[0][0] && !tables[0][1] && !tables[0][2]
bg ||= !tables[1][0] && !tables[1][1] && !tables[1][2]
bg ||= !tables[2][0] && !tables[2][1] && !tables[2][2]
bg ||= !tables[0][0] && !tables[1][0] && !tables[2][0]
bg ||= !tables[0][1] && !tables[1][1] && !tables[2][1]
bg ||= !tables[0][2] && !tables[1][2] && !tables[2][2]
bg ||= !tables[0][0] && !tables[1][1] && !tables[2][2]
bg ||= !tables[0][2] && !tables[1][1] && !tables[2][0]

puts bg ? 'Yes' : 'No'

Measured memory_bytes: 1788
// ABC169C
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	string s;
	double b;
	int l;

	cin>>s;
	s=s.substr(0,3);
	cout <<s<<endl;
	return 0;
}


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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p*p <= n; p++) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { num++; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long N, P; cin >> N >> P;
  if (P == 1) { cout << 1 << endl; return 0; }
  vector<pair<long long, long long>> pf = prime_factorize(P);
  vector<long long> v;
  for (pair<long long, long long> p : pf) {
    long long cnt = p.second / N;
    for (int i = 0; i < cnt; i++) v.push_back(p.first);
  }
  long long ans = 1;
  for (int i = 0; i < v.size(); i++) ans *= v.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x;
    int i = 0;
    
    while ( 1 ) {
        scanf("%d", &x);
        if ( x == 0 ) {
            break;
        }
        i++;
        printf("Case %d: %d\n", i, x);
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s,t,u;
    ll a,b;
    cin>>s>>t>>a>>b>>u;
    cout<<a-(s==u)<<' '<<b-(t==u)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
     
		int n = sc.nextInt();
        n = n % 1000;
        if(n == 0){
        	System.out.println(0);
        } else {
			System.out.println(1000 - n);
        }
	}
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int func(int n){
  int l = in();
  int r = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  line.push_back(1);
  function<int(int)> func =
    [&](int x)->int{
      rep(i,n+1){
        if(x%line[i]==0){
          return (i&1)^1;
        }
      }
    };
  int res = 0;
  rep(i,l,r+1){
    res += func(i);
  }
  return res;
}

int main(){
  int n;
  while(n=in()){
    cout << func(n) << endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> cs(n);
    for (int i = 0; i < n; i++) {
        cin >> cs[i];
    }
    int acc[202020] = {};
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (i > 0 && cs[i] == cs[i - 1]) {
            dp[i + 1] = dp[i];
        } else {
            dp[i + 1] = ((long long) dp[i] + acc[cs[i]]) % MOD;
            acc[cs[i]] = ((long long) acc[cs[i]] + dp[i]) % MOD;
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 2560
n = int(input())

for _ in range(n):
    train = ''
    seq = input()
    for i in range(0, len(seq), 3):
        if i == 0:
            train += seq[i]
        if seq[i - 2:i] == '->' and train[-1] == seq[i - 3]:
            train = train + seq[i]
        if seq[i - 2:i] == '<-' and train[0] == seq[i - 3]:
            train = seq[i] + train
    print(train)



Measured memory_bytes: 5608
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long dp[1003][1003];
int h,w;
char q[1003][1003];
int main(){std::ios::sync_with_stdio(false);
cin>>h>>w;
for(int i=1;i<=h;i++){
	for(int j=1;j<=w;j++){
		cin>>q[i][j];
	}
}
for(int i=1;i<=h;i++){
	if(q[i][1]=='.'){
		dp[i][1]=1;
	}else break;
}
for(int j=1;j<=w;j++){
	if(q[1][j]=='.'){
		dp[1][j]=1;
	}else break;
}
for(int i=2;i<=h;i++){
	for(int j=2;j<=w;j++){
		if(q[i][j]=='#')continue;
		long long o=0;
		if(q[i-1][j]=='.'){
			o+=dp[i-1][j];
		}
		if(q[i][j-1]=='.'){
			o+=dp[i][j-1];
		}
		dp[i][j]=o;
		dp[i][j]%=1000000007;
	}
}
cout<<dp[h][w]<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





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

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    vector<int>ans(15);
    int k=0;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            if(k)
                k--;
        }
        else{
            ans[k++]=s[i]-'0';

        }

    }

    for(int i=0;i<k;i++)
        cout << ans[i];

    return 0;
}

Measured memory_bytes: 256
N = int(input())
dpA = [0, 1, 4]
dpC = [0, 1, 4]
dpG = [0, 1, 4]
dpT = [0, 1, 4]
dpAG = [0, 0, 1]
dpGA = [0, 0, 1]
dpAC = [0, 0, 1]
dpAT = [0, 0, 1]
dpAGG = [0, 0, 0]
dpATG = [0, 0, 0]
dpAGT = [0, 0, 0]

for i in range(2, N):
	newA = dpA[i] + dpC[i] + dpG[i] + dpT[i]
	newC = dpA[i] + dpC[i] + dpG[i] + dpT[i] - dpAG[i] - dpGA[i] - dpAGG[i] - dpATG[i] - dpAGT[i]
	newG = dpA[i] + dpC[i] + dpG[i] + dpT[i] - dpAC[i]
	newT = dpA[i] + dpC[i] + dpG[i] + dpT[i]
	newAG = dpA[i]
	newGA = dpG[i]
	newAC = dpA[i] - dpGA[i]
	newAT = dpA[i]
	newAGG = dpAG[i]
	newATG = dpAT[i]
	newAGT = dpAG[i]
	dpA.append(newA)
	dpC.append(newC)
	dpG.append(newG)
	dpT.append(newT)
	dpAG.append(newAG)
	dpGA.append(newGA)
	dpAC.append(newAC)
	dpAT.append(newAT)
	dpAGG.append(newAGG)
	dpATG.append(newATG)
	dpAGT.append(newAGT)
print((dpA[N]+dpC[N]+dpG[N]+dpT[N])%1000000007)

Measured memory_bytes: 38384
// 'That's all it is. A leap of faith'

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

template<typename Type>
long long sz(Type x) {
    return ll(x.size());
}

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;

    if(s[sz(s) - 1] == 's') cout << s << "es";
    else cout << s << "s";

    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int A[10];
	int K;
	rep(i, 3) cin >> A[i];
	cin >> K;

	rep(i, K) {
		sort(A, A+3, greater<int>());
		A[0] *= 2;
	}
	int ans = accumulate(A, A+3, 0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int c[30][30],h,w,n;

bool S(){
	int m[30][30];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)m[i][j]=c[i][j];
	for(int i=0;i<h;i++){
		int top=0,g[30];
		for(int j=0;j<w;j++){
			if(m[i][j])g[top]=m[i][j],top++;
			m[i][j]=0;
		}
		for(int j=0;j<top;j++)m[i][j]=g[j];
	}
	bool ok=false;
	while(true){
		bool na=true,t[30][30],mv=false;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				t[i][j]=false;
				if(m[i][j]!=0)na=false,t[i][j]=true;
			}
		}
		if(na){ok=true;break;}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(m[i][j]>0){
					bool r=true;
					for(int k=0;k<n;k++){
						if(k+i>=h)r=false;
						else if(m[k+i][j]!=m[i][j])r=false;
					}
					if(r){for(int k=0;k<n;k++)t[i+k][j]=false;mv=true;}
					r=true;
					for(int k=0;k<n;k++){
						if(k+j>=w)r=false;
						else if(m[i][j+k]!=m[i][j])r=false;
					}
					if(r){for(int k=0;k<n;k++)t[i][j+k]=false;mv=true;}
				}
			}
		}
		if(!mv)break;
		for(int i=0;i<h;i++){
			int top=0,g[30];
			for(int j=0;j<w;j++){
				if(t[i][j])g[top]=m[i][j],top++;
				m[i][j]=0;
			}
			for(int j=0;j<top;j++)m[i][j]=g[j];
		}
	}
	return ok;
}

int main(){
	cin>>w>>h>>n;
	for(int i=w-1;i>=0;i--){
		for(int j=0;j<h;j++){
			char z;cin>>z;
			if(z=='.')c[j][i]=0;
			else c[j][i]=z-'A'+1;
		}
	}
	bool ok=false;
	for(int i=1;i<h;i++){
		for(int j=0;j<w;j++){
			if(i){
				swap(c[i-1][j],c[i][j]);
				if(S())ok=true;
				swap(c[i-1][j],c[i][j]);
			}
		}
	}
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 3112
import queue
import sys

input = sys.stdin.readline
N = int(input())
alist = [[] for _ in range(N+1)]
d = {}
q = queue.Queue()

for _ in range(N-1):
    u, v, w = map(int, input().split())
    alist[u].append(v)
    alist[v].append(u)
    d[(u, v)] = w

q.put(1)
d[(1, 1)] = 0
seen = [False]*(N+1)
seen[1] = True

while not q.empty():
    s = q.get()
    for n in alist[s]:
        if not seen[n]:
            q.put(n)
            seen[n] = True
            d[(1, n)] = d[1, s]+d[tuple(sorted([s, n]))]

for i in range(1, N+1):
    print(d[(1, i)] % 2)


Measured memory_bytes: 101020
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt = 998244353;
int mii[1 << 18], tms[1 << 18];

struct Node {
	int dt, wp;
	int l, r;
	void inline upd(int x) {
		wp = x;
		dt = 1ll * x * mii[r - l] % jt;
	}
} t[1 << 20];

void inline pd(int now) {
	if(!t[now].wp) return;
	t[now << 1].upd(t[now].wp);
	t[now << 1 | 1].upd(t[now].wp);
	t[now].wp = 0;
}

void inline pu(int now) {
	int len = t[now << 1].r - t[now << 1].l + 1;
	t[now].dt = (1ll * t[now << 1 | 1].dt * tms[len] + t[now << 1].dt) % jt;
}

int n, q;

void inline init(int now = 1, int nl = 1, int nr = n) {
	t[now].l = nl; t[now].r = nr;
	if(nl == nr) return void(t[now].upd(1));
	int m = (nl + nr) >> 1;
	init(now << 1, nl, m);
	init(now << 1 | 1, m + 1, nr);
	pu(now);
}

void inline add(int l, int r, int x, int now = 1, int nl = 1, int nr = n) {
	if(nl >= l && nr <= r) {
		t[now].upd(x);
		return;
	}
	if(nl > r || nr < l) return;
	pd(now);
	int m = (nl + nr) >> 1;
	add(l, r, x, now << 1, nl, m);
	add(l, r, x, now << 1 | 1, m + 1, nr);
	pu(now);
}

int main() {
	scanf("%d%d", &n, &q);
	mii[0] = tms[0] = 1;
	cont(i, n) {
		mii[i] = (10ll * mii[i - 1] + 1) % jt;
		tms[i] = 10ll * tms[i - 1] % jt;
	}
	init();
	cont(i, q) {
		int l, r, d; scanf("%d%d%d", &l, &r, &d);
		l = n + 1 - l; r = n + 1 - r; swap(l, r);
		add(l, r, d);
		printf("%d\n", t[1].dt);
	}
	return 0;
}


Measured memory_bytes: 13544
#include <iostream>
#include <vector>

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

  std::vector<int> C(N-1), S(N-1), F(N-1);

  for (int i = 0; i < N-1; i++) {
    std::cin >> C[i] >> S[i] >> F[i];
  }

  for (int i = 0; i < N-1; i++) {
    int t = 0;

    for (int j = i; j < N-1; j++) {
      t = ((std::max(t, S[j]) + F[j] - 1) / F[j]) * F[j] + C[j];
    }

    std::cout << t << std::endl;
  }

  std::cout << 0 << std::endl;
}


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

int main() {
    ll a, b;
    while (cin >> a >> b) {
        cout << __gcd(a, b) << " " << a / __gcd(a, b) * b << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF= 1e18L+5;

int main() {
	int n;
	cin >> n;
	std::vector<double> dp(n+1,0);
	dp[0]=1;
	for(int i=0; i<n; i++){
		double x;
		cin>> x;
		for(int j=i+1;j>=0; j--){
			dp[j] = (j==0 ? 0: dp[j-1]*x)+dp[j]*(1-x);
		}
	}
	double ans = 0;
	for(int h =n/2+1; h<=n;h++)
		ans += dp[h];
	printf("%0.10f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	if (x > y)
	{
		int t;
		t = x;
		x = y;
		y = t;
	}
	if (x > z)
	{
		int t;
		t = x;
		x = z;
		z = t;
	}
	if (y > z)
	{
		int t;
		t = y;
		y = z;
		z = t;
	}

	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,m;
  cin >> a >> b;
  m=(a+b)%2;
  if (m == 0){
    cout << (a+b)/2 << endl;
  }
  else {
    cout << (a+b+1)/2 << endl;
  }
}
  

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vvc c(N,vc(N));//横一行そろえて、やる
    vl cnt(N,0);
    ll ans=INF;
    vector<bool> a(N,true),aa(N,true),b(N,false);
    bool possible=false;
    rep(i,N){
        rep(j,N){
            cin >> c[i][j];
            if(c[i][j]=='#'){
                cnt[i]++;
                possible=true;
                b[j]=true;
            }
            else{
                a[i]=false;
                aa[j]=false;
            }
        }
    }
    if(!possible){
        cout << -1 << endl;
        return 0;
    }
    rep(i,N){
        ll k=2*N-cnt[i];
        if(!b[i]){
            k++;
        }
        ans=min(ans,k);
    }
    rep(i,N){
        if(aa[i]){
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3880
//2019.8.18 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int a;
    char str[20];
    inline void MAIN(){
        a=read(),scanf("%s",str+1);
        if(a>=3200)printf("%s",str+1);
        else puts("red");
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

int main(void){
    // Here your code !
    int a, b;
    scanf("%d %d", &a, &b);
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) printf("Possible");
    else printf("Impossible");
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll n; cin >> n;
   Vi a(n); REP(i, n) cin >> a[i];
   Vi a_odd, a_even;
   REP(i, n){
      (i % 2 == 0) ? a_even.pb(a[i]) : a_odd.pb(a[i]);
   }
   SORT(a_odd); SORT(a_even);
   Vi s_odd(n / 2 + 1, 0), s_even((n + 1) / 2 + 1, 0);
   REP(i, n / 2){
      s_odd[i + 1] = s_odd[i] + a_odd[i];
   }
   REP(i, (n + 1) / 2){
      s_even[i + 1] = s_even[i] + a_even[i];
   }
   VVi x(2, Vi(2, -INF));
   REP(k, (n + 1) / 2 + 1){
      chmax(x[0][k % 2], s_even[(n + 1) / 2] - 2 * s_even[k]);
   }
   REP(k, n / 2 + 1){
      chmax(x[1][k % 2], s_odd[n / 2] - 2 * s_odd[k]);
   }
   /*
   REP(i, 2){
      REP(j, 2){
         printf("x[%lld][%lld] = %lld\t", i, j, x[i][j]);
      }
   }
   */
   cout << max(x[0][0] + x[1][0], x[0][1] + x[1][1]) << endl;
}


Measured memory_bytes: 2804
# import sys
# input = sys.stdin.readline
INF = 10**11
A,B,Q = map(int,input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
def binary_search(lis,x):
    ok = 0
    ng = len(lis)-1
    while ng-ok > 1:
        mid = (ok+ng)//2
        if lis[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok
#print(s,t)
for _ in range(Q):
    x = int(input())
    ps = binary_search(s,x)
    pt = binary_search(t,x)
    ans = INF
    #print(ps,pt)
    for i in range(ps,ps+2):
        for j in range(pt,pt+2):
            ans = min(ans,abs(s[i]-x)+abs(s[i]-t[j]), abs(t[j]-x)+abs(t[j]-s[i]))
    print(ans)  
            


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

bool ok(const string & s, int i){
  return s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C';
}

int main(){
  int n; cin >> n;  
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i+2 < n; ++i){
    if(ok(s,i))cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
    vector<int>V;

    int n;

    for(int i=0;i<2;i++){
        scanf("%d",&n);
        while(n--){
            int a,b;
            scanf("%d%d",&a,&b);
            V.push_back(a*60+b);
        }
    }

    sort(V.begin(),V.end());

    V.erase(unique(V.begin(),V.end()),V.end());

    for(int i=0;i<V.size();i++){
        if(i)printf(" ");
        printf("%d:%02d",V[i]/60,V[i]%60);
    }
    puts("");

    return 0;
}

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

int main() {
	string a, b; cin >> a >> b;
	if(a.size() > b.size()) cout << "GREATER" << endl;
	else if(a.size() < b.size()) cout << "LESS" << endl;
	else {
		int res = 0;
		for (int i = 0; i < a.size(); i++)
		{
			if(a[i] - '0' > b[i] - '0') {
				res = 1;
				break;
			}
			else if(a[i] - '0' < b[i] - '0') {
				res = -1;
				break;
			}
		}
		if(res == 0) cout << "EQUAL" << endl;
		else if(res == 1) cout << "GREATER" << endl;
		else cout << "LESS" << endl;
	}


	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    string S;
    cin>>S;
    //sort(S.begin(),S.end());
    if(S[0]==S[1] or S[1]==S[2] or S[2]==S[3])cout<<"Bad";
    else cout<<"Good";
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

vl a, p;

ll rec(ll n, ll x) {
    if (n == 0) return 1;

    assert(n >= 1);
    if (x == 1) { // B
        return 0;
    } else if (x <= 1 + a[n - 1]) { // B(n-1)
        return rec(n - 1, x - 1); 
    } else if (x == 1 + a[n - 1] + 1) { // B(n-1)P
        return p[n - 1] + 1;
    } else if (x <= 1 + a[n - 1] + 1 + a[n - 1]) { // B(n-1)P(n-1)
        return p[n - 1] + 1 + rec(n - 1, x - (a[n-1]+2));
    } else { // B(n-1)P(n-1)B
        return p[n - 1] * 2 + 1; 
    }
}

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

    ll N, X; cin >> N >> X;

    //vs L(N+1);
    a = vl(N + 1, 0);
    p = vl(N + 1, 0);
    //L[0] = "P";
    a[0] = 1;
    p[0] = 1;
    REP(i, N) {    
        //L[i + 1] = "B" + L[i] + "P" + L[i] + "B";
        //a[i + 1] = L[i + 1].size();
        a[i + 1] = a[i] * 2 + 3;
        p[i + 1] = p[i] * 2 + 1;
    }

    assert(N >= 1);
    assert(X >= 1);
    ll ans = rec(N, X);

    cout <<  ans << endl;
    a.clear();
    p.clear();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
// int ans;
string s;

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

	cin >> s;
    N = s.length();

    rep(i, N / 2) {
        if (s[i] != s[N - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int mid = (N - 1) / 2;
    rep(i, mid / 2) {
        if (s[i] != s[mid - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int from = (N + 3) / 2;
    for (int i = 0; i < N - from; i++) {
        if (s[i + from - 1] != s[N - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" <<  endl;
	return 0;
}

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

using namespace std;

double circle(int r){
    return 2* 3.14159 * r;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int r;
    cin >> r;
    cout << fixed;
    cout << setprecision(2)<<circle(r);

}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

int solve(ll s){
    if (s == 1 || s == 2) {
        cout << 4 << "\n";
        return 0;
    }
    ll ans = 0, current = s;
    while (current != 4) {
        if (current % 2) current += 2 * current + 1;
        else current /= 2;
        ans++;
    }
    cout << ans + 4 << "\n";
    return 0;
}

int main() {
    ll s;
    ignore_ret(scanf("%lld",&s));
    solve(s);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	while(true){
		int n, d;
		cin >> n >> d;
		
		if(n == 0){
			break;
		}
		
		vector<long long int> v[110];
		long long int S[110] = {};
		
		for(int i = 0; i < n; i++){
			int m;
			cin >> m;
			v[i].push_back(INF);
			for(int j = 0; j < m; j++){
				int num;
				cin >> num;
				v[i].push_back(num);
				S[i] += num;
			}
		}
		
		while(true){
			vector<P> vs;
			for(int i = 0; i < n; i++){
				P p;
				p.first = S[i];
				p.second = i;
				vs.push_back(p);
				//cout << S[i] << " ";
			}
			//cout << endl;
			sort(vs.begin(), vs.end());
			bool flag = true;
			for(int i = 0; i < n; i++){
				int index = n - 1;
				if(i == vs[n - 1].second){
					index--;
				}
				if(vs[index].first - d <= S[i] - v[i][v[i].size() - 1]){
					S[i] -= v[i][v[i].size() - 1];
					v[i].pop_back();
					flag = false;
				}
			}
			if(flag){
				break;
			}
		}
		
		int SS = 0;
		for(int i = 0; i < n; i++){
			SS += v[i].size();
			//cout << v[i].size() << endl;
		}
		
		if(SS == n){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3264