akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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! {
        a: u64, b: u64
    }

    let ret = if a > b {a-1} else {a};
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 998244353LL
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
 
#define int ll
 
ll min1() {return inf;}
ll max1() {return -inf;}
 
template<typename... Args>
int min1(int a, Args... args) {return min(a,min1(args...));}
template<typename... Args>
int max1(int a, Args... args) {return max(a,max1(args...));}
 
struct node {
	std::vector<ll> v,w;
};

string ans;
char mn;
int len;
string mmn;
int ff=0;

void dfs(string s, int c, int k,int mul){
	if(ff) return;
	if(c==k) {
		if(ans>s) ans=s;
		return;
	}
	int n=s.size();
	string t = s;
	reverse(t.begin(),t.end());
	string u=s+t;

	int st=0;
	int end=n;

	if(c!=k-1&&c!=0) {
		for(int i=n-1;i>-1;i--){
			if(s[i]==mn) {
				int num = (n-i)*2;
				st = i+num-n;
				if(st<0) st=0;
				end = st;
			}
			else break;
		}
	}

	for(int i=st;i<=end;i++) {
		string temp = u.substr(i,n);
		if(c==k-1){
			int cnt = 0;
			for(int i=0;i<n;i++) {
				if(mn==temp[i]) cnt++;
				else break;
			}
			if(cnt>=mul) dfs(temp,c+1,k,mul*2);
			continue;
		}
		int cnt = 0;
		for(int i=n-1;i>-1;i--) {
			if(mn==temp[i]) cnt++;
			else break;
		}
		int pp = cnt;
		for(int i=0;i<k-2-c;i++){
			pp*=2;
		}
		if(pp>=n) {
			string temp = "";
			for(int i=0;i<n;i++) temp += mn;
			ans = mn;
			ff=1;
			return;
		}
		if(cnt>=mul) dfs(temp,c+1,k,mul*2);
	}
}


signed main() {
	fast;

	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;

	mn = s[0];
	len = 1;

	int cur = 1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			cur++;
		}
		else {
			if(s[i-1]<mn) {
				mn=s[i-1];
				len = cur;
			}
			else if(s[i-1]==mn){
				len = max(len,cur);
			}
			cur = 1;
		}
	}
	int f=0;
	if(s[n-1]<mn) {
		mn=s[n-1];
		len = cur;
	}
	else if(s[n-1]==mn){
		if(cur>len) {
			len = cur;
			f=1;
		}
	}

	if(k+f>14||len==n) {
		for(int i=0;i<n;i++) cout<<mn;
		return 0;
	}
	else {
		int pp = len;
		for(int i=0;i<k-1+f;i++) {
			pp*=2;
			if(pp>=n){
				for(int i=0;i<n;i++) cout<<mn;
				return 0;
			}
		}
	}

	mmn = s;

	ans = s;

	dfs(s,0,k,len*(1+f));
	cout<<ans;
} 

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

using namespace std;

int q_sort(int d[],int left,int right){
	if(left >= right) return 0;
	int pipot = d[(left+right)/2], l = left, r = right, tmp;
	while(l<r){
		while(d[l] < pipot) l++;
		while(d[r] > pipot) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}

int main(void)
{
	int n,m;
	cin>>n>>m;
	int a[n];
	int all = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		all += a[i];
	}
	q_sort(a,0,n-1);
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(all <= a[i]*4*m) ans++;
	}
	if(ans >= m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m;
    cin >> n >> m;
    string ans;
    if (n == 1) n += 13;
    if (m == 1) m += 13;
    if (n > m) ans = "Alice";
    else if (n < m) ans = "Bob";
    else ans = "Draw";
    cout << ans << endl;

    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    bool is_res = false;
    ll gcd = L_INF;
    rep(i,n){
        cin >> a[i];
        if(i == 0)gcd = a[0];
        else gcd = __gcd(gcd,a[i]);
    }

    rep(i,n){
        ll dif = a[i] - k;
        if(dif >= 0){
            if(dif % gcd == 0)is_res = true;
        }
    }
    cout << (is_res?"POSSIBLE":"IMPOSSIBLE") << endl;
}


Measured memory_bytes: 1024
def snuke_festival(N: int, A: list, B: list, C: list) -> int:
    '''
    '''
    A.sort(), B.sort(), C.sort()
    sa, sb = [0] * (N + 1), [0] * (N + 1)

    a_idx = 0
    for i, b in enumerate(B):
        sa[i + 1] += sa[i]
        while a_idx < N and A[a_idx] < b:
            sa[i + 1] += 1
            a_idx += 1

    b_idx = 0
    for i, c in enumerate(C):
        sb[i + 1] += sb[i]
        while b_idx < N and B[b_idx] < c:
            sb[i + 1] += sa[b_idx+1]
            b_idx += 1

    return sum(sb)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    B = [int(s) for s in input().split()]
    C = [int(s) for s in input().split()]
    ans = snuke_festival(N, A, B, C)
    print(ans)


Measured memory_bytes: 24640
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]){
    int a, b;
    long long int s, a1, b1;
    long long int min;
    
    while(scanf("%d %d", &a, &b) != EOF){
        //?????§??¬?´???°????±???????
        a1 = a;
        b1 = b;
        
        if(a1 < b1){s = a1; a1 = b1; b1 = s;}
        while(1){
            s = a1 % b1;
            if(s == 0) break;
            a1 = b1;
            b1 = s;
        }

        //????°???¬?????°????±???????
        min = a * (b / b1);
        
        printf("%lld %lld\n", b1, min);
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

class Main {
	static Node node;
	static Node root;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ins;
		for (int i = 0; i < n; i++) {
			ins = sc.next();
			if (ins.equals("print")) {
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			} else if (ins.equals("insert")) {
				Node z = new Node();
				z.key = sc.nextInt();
				insert(z);
			} else if (ins.equals("find")) {
				int k = sc.nextInt();
				find(k);
				System.out.println();
			} else if (ins.equals("delete")) {

				Node z = new Node();
				z.key = sc.nextInt();
				delete(z);
			}

		}
	}
	static void inorder(Node node) {
		if (node == null) return;
		inorder(node.l);
		System.out.print(" " + node.key);
		inorder(node.r);
	}

	static void preorder(Node node) {
		if (node == null) return;
		System.out.print(" " + node.key);
		preorder(node.l);
		preorder(node.r);
	}

	static void insert(Node z) {
		if (root == null) {
			root = z;
			return;
		}
		Node y = null;
		Node x = root;
		while (x != null) {
			y = x;
			if (z.key < x.key) x = x.l;
			else x = x.r;
		}

		if (z.key < y.key) y.l = z;
		else y.r = z;
	}

	static void find(int k) {
		node = root;
		while (true) {
			if (node.key > k) {
				if (node.l == null) {
					System.out.print("no");
					return;
				} else {
					node = node.l;
				}
			} else if (node.key < k) {
				if (node.r == null) {
					System.out.print("no");
					return;
				} else {
					node = node.r;
				}
			} else if (node.key == k) {
				System.out.print("yes");
				return;
			}
		}
	}

	static void delete(Node z) {
		Node p = null;
		node = root;
		while (z.key != node.key) {
			p = node;
			if (node.key > z.key) node = node.l;
			else if (node.key < z.key) node = node.r;
		}
		if (node.l == null && node.r == null) {
			if (p.key < node.key) p.r = null;
			else p.l = null;
		} else if (node.l == null) {
			if (p.key < node.key) p.r = node.r;
			else p.l = node.r;
		} else if (node.r == null) {
			if (p.key < node.key) p.r = node.l;
			else p.l = node.l;
		} else {
			Node node2 = node;
			p = node;
			node = node.r;
			while(node.l!=null){
				p = node;
				node = node.l;
			}
			//System.out.println(node.key + " " + node2.key+" "+p.key);
			node2.key = node.key;
			
			if (node.l == null && node.r == null) {
				//System.out.println(node.key + " " + node2.key+" "+p.key);
				if (p.key <= node.key) p.r = null;
				else p.l = null;
			} else if (node.l == null) {
				if (p.key < node.key) p.r = node.r;
				else p.l = node.r;
			} else if (node.r == null) {
				if (p.key < node.key) p.r = node.l;
				else p.l = node.l;
			}
		}
	}
}

class Node {
	int key;
	Node l;
	Node r;
	Node() {
		key = -1;
		l = null;
		r = null;
	}
}

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

int main(){
	int a=0,b=0,c=0;
	cin >> a >> b >> c;
	//cout <<"入力した数:" << a << " " << b << " " << c << endl;
	void diff(int a,int b,int c);
	diff(a,b,c);
	return 0;
}

void diff(int a,int b,int c){
	int s = b-a+1;
	int sum =0;
	int alldiff[s] = {};
		for(int i=0;i<s;i++){
		alldiff[i] = a+i;
		}
		//cout <<"数の差:" <<s <<endl;
		//cout <<"間の数:";

		for(int j=0;j<s;j++){
		//cout << alldiff[j] << " ";
		}

	for(int k=0;k<s;k++){
		if(c % alldiff[k] == 0){
		sum = sum+1;
		}
		else{sum = sum;}
		}
		cout << sum << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<int> Eratosthenes(const int N) {
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ ) {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ ) {
        if( is_prime[ i ] ) {
            for( int j = 2 * i; j <= N; j += i ) {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;

    vector<int> pr = Eratosthenes(2000);
    int num_prime = 0;
    int ni = 0;
    while (pr[ni] < 10) {
        ni += 1;
    }

    while (num_prime < N) {
        while (pr[ni] % 10 != 1) {
            ni += 1;
        }
        cout << pr[ni] << " ";
        ni += 1;
        num_prime += 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  int sum =0;
  int i;
  for ( i=0 ; i<N ; i++ ){
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;

}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 110
const int MOD = 1000000007;

int pref[maxn];

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    s = " " + s;
    int a = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '(')a++;
        else a--;
        if (a < 0)
            pref[0]++, a = 0;
    }
    a = 0;
    for (int i = 0; i <= n; i++) {
        if (i == 0) {
            if (pref[i])
                for (int j = 0; j < pref[i]; j++)cout << "(" , a++;
            continue;
        }
        cout << s[i];
        if (s[i] == '(')a++;
        else a--;
    }
    for (int i = 0; i < a; i++)
        cout << ")";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts...
        ll n;
        cin>>n;
        vector<ll > v(n);
        for (int i=0;i<n;i++)
            cin>>v[i];
        vector<ll > dp(n+1,inf); // it stores the min cost incurred so far...
        dp[0] = 0; // cost at stone 1 is 0...
  		dp[1] = abs(v[1] - v[0]); // cost for stone 1...
        // Now what matters so far i.e. at ith stone 
  		// 1. from where i had jumped from...
  		// 2. cost so far stored in dp[i]...that is of course minimum...
  		for (int i=2;i<n;i++)
            dp[i] = min(dp[i-1] + abs(v[i]-v[i-1]) , dp[i-2] + abs(v[i]-v[i-2]));
        cout<<dp[n-1];
        // Code Ends...
        return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<math.h>
#include <stdlib.h>
#define M 100000
using namespace std;
  
int main(){
    int n, m,l = 0;
    int p = 0;
    int result = 0;
    int x[100010];
    scanf("%d %d",&n,&m);
    x[0] = 0;
    for (int i = 1; i < n; i++){
        scanf("%d", &x[i]);
        x[i] += x[i - 1];
    }
    while (m--){
        scanf("%d", &l);
        result += abs(x[p + l] - x[p]);
        result %= M;
        p += l;
    }
    printf("%d\n", result);
}

Measured memory_bytes: 1580
N, W = map(int, input().split())
wlist = [0] * N
vlist = [0] * N
for i in range(N):
	wlist[i], vlist[i] = map(int, input().split())
minw = min(wlist)
w = list()
for i in range(4):
	w.append(list())
for i in range(N):
	w[wlist[i] - minw].append(vlist[i])
for i in range(4):
	w[i].sort(reverse = True)
ans = 0
sumw0 = 0
sumv0 = 0
for i in range(len(w[0]) + 1):
	sumw1 = 0
	sumv1 = 0
	for j in range(len(w[1]) + 1):
		sumw2 = 0
		sumv2 = 0
		for k in range(len(w[2]) + 1):
			sumw3 = 0
			sumv3 = 0
			for l in range(len(w[3]) + 1):
				sumw = sumw0 + sumw1 + sumw2 + sumw3
				sumv = sumv0 + sumv1 + sumv2 + sumv3
				if sumw <= W:
					ans = max(ans, sumv)
				if l != len(w[3]):
					sumw3 += minw + 3
					sumv3 += w[3][l]
			if k != len(w[2]):
				sumw2 += minw + 2
				sumv2 += w[2][k]
		if j != len(w[1]):
			sumw1 += minw + 1
			sumv1 += w[1][j]
	if i != len(w[0]):
		sumw0 += minw
		sumv0 += w[0][i]
print(ans)

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

const long long int MOD = 1000000007;

long long int gcd2( long long int a, long long int b ) {

    if ( ( a % b ) == 0 ) return b;
    return gcd2( b, a % b );

}
long long int gcd( long long int a, long long int b ) {
    if ( a < 0 ) a = -a;
    if ( b < 0 ) b = -b;
    if ( a == 0 ) {
        if ( b == 0 ) return 1;
        return b;
    }
    if ( b == 0 ) return a;
    return gcd2( a, b );
}


int main() {

    long long int n;
    cin >> n;

    map< pair< long long int, long long int >, long long int > m;

    long long int zero = 0;

    for ( long long int i = 0; i < n; i++ ) {
        long long int a, b;
        cin >> a >> b;
        if ( a == 0 && b == 0 ) {
            zero++;
            continue;
        }
        if ( a < 0 ) {
            a *= -1;
            b *= -1;
        }
        if ( a == 0 && b < 0 ) b *= -1;
        long long int g = gcd( a, b );
        a /= g;
        b /= g;
        m[ make_pair( a, b ) ]++;
    }

    long long int cnt = n - zero;
    long long int ans = 1;
    for ( auto it = m.begin(); it != m.end(); ++it ) {
        long long int dx = (*it).first.first;
        long long int dy = (*it).first.second;
        long long int p = (*it).second;
        if ( p == 0 ) continue;

        long long int ddx = dy;
        long long int ddy = -dx;
        if ( ddx < 0 ) {
            ddx *= -1;
            ddy *= -1;
        }
        if ( ddx == 0 && ddy < 0 ) ddy *= -1;
        long long int q = m[ make_pair( ddx, ddy ) ];
        if ( q == 0 ) continue;

        long long int cp = 1;
        for ( long long int i = 0; i < p; i++ ) {
            cp *= 2;
            cp %= MOD;
        }
        long long int cq = 1;
        for ( long long int i = 0; i < q; i++ ) {
            cq *= 2;
            cq %= MOD;
        }
//        cout << " " << p << " " << cp << " " << q << " " << cq << endl;
        ans *= ( cp + cq - 1 );
        ans %= MOD;
        cnt -= p + q;

        (*it).second = 0;
        m[ make_pair( ddx, ddy ) ] = 0;

    }

    for ( long long int i = 0; i < cnt; i++ ) {
        ans *= 2;
        ans %= MOD;
    }

    ans += zero;
    ans %= MOD;
    if ( ans == 0 ) ans += MOD;

    cout << ans - 1 << endl;

    return 0;

}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string n;
  cin >> n;
  string res = "";
  for (char c : n) {
    if (c == '1') {
      res.push_back('9');
    } else {
      res.push_back('1');
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

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

  cout << (x-z)/(y+z) << endl;
  return 0;
}


Measured memory_bytes: 256
### constant

MAX_INT = 1 << 30

SCOSTS = [
  [[0, 1, 3, 3],  #0->0
   [1, 1, 2, 2],  #0->1
   [2, 2, 2, 2]], #0->2
  [[1, 1, 2, 2],  #1->0
   [0, 1, 1, 2],  #1->1
   [1, 2, 1, 2]], #1->2
  [[2, 2, 2, 2],  #2->0
   [1, 2, 1, 2],  #2->1
   [0, 3, 1, 3]]  #2->2
]

### main

tn = gets.strip.to_i

tn.times do
  n = gets.strip.to_i
  books = gets.strip.split('').map{|s| s == 'Y'}
  #p [n, books]

  n2 = n * 2
  n4 = n * 4

  costs = [0, MAX_INT, MAX_INT]

  for i in (0..n)
    pcosts = costs
    costs = []

    i2 = i * 2
    i2n2 = i2 + n2
    shelf = 0
    shelf |= 1 if i < n && books[i2]   || i > 0 && books[i2 - 1]
    shelf |= 2 if i < n && books[i2n2] || i > 0 && books[i2n2 - 1]
    #p shelf

    for to in (0..2)
      min_cost = MAX_INT
      for from in (0..2)
        cost = pcosts[from] + SCOSTS[from][to][shelf]
        min_cost = cost if min_cost > cost
      end
      costs[to] = min_cost
      costs[to] += 1 if i < n
    end
  end

  puts costs[0]
end

Measured memory_bytes: 10912
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r;
    lli m,a,b;
    string s;
    // vi a;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>k>>a>>b;
    if(a+2>b||k<=a-1)
    {
        cout<<k+1<<endl;
        return 0;
    }
    k-=a-1;
    cnt=a;
    cnt+=(k/2)*(b-a);
    if(k%2)
        cnt++;
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vi vector<int>
#define vli vector<lli>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
#define pdd pair<lli,lli>
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}

template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}
lli binomialCoeff(lli n, lli k)  
{  
    lli res = 1;  
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (lli i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
        res=res%mod;
    }  
  
    return res;  
}
int get_degree(long long n, long long p) { // returns the degree with which p is in n!
  int degree_num = 0;
  long long u = p;
  long long temp = n;

  while (u <= temp) {
    degree_num += temp / u;
    u *= p;
  }
  return degree_num;
}
long long degree(long long a, long long k, long long p) {
  long long res = 1;
  long long cur = a;

  while (k) {
    if (k % 2) {
      res = (res * cur) % p;
    }
    k /= 2;
    cur = (cur * cur) % p;
  }
  return res;
}
long long combinations(int n, int k, long long p) {
  int num_degree = get_degree(n, p) - get_degree(n - k, p);
  int den_degree = get_degree(k, p);

  if (num_degree > den_degree) {
    return 0;
  }
  long long res = 1;
  for (long long i = n; i > n - k; --i) {
    long long ti = i;
    while(ti % p == 0) {
      ti /= p;
    }
    res = (res * ti) % p;
  }
  for (long long i = 1; i <= k; ++i) {
    long long ti = i;
    while(ti % p == 0) {
      ti /= p;
    }
    res = (res * degree(ti, p-2, p)) % p;
  }
  return res;
}

int main(){
	lli n,a,b;
	lli p=mod;
	cin>>n>>a>>b;
	lli ans=0;
	ans=((llipower(2,n)+(mod-combinations(n,a,p))%mod)%mod+(mod-combinations(n,b,p))%mod)%mod;
	if(a!=0 && b!=0) ans-=1;
	cout<<ans<<endl;

}
 
 

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(long i=k;i<n;++i)
typedef long long ll;
using namespace std;
ll MOD=1e9+7;
const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    // Your code here!
    int X,Y;
    cin>>X>>Y;
    if(!(((2*Y-X)%3==0 && 2*Y>=X )&&((2*X-Y)%3==0 && 2*X>=Y))){
        cout<<0<<endl;
        return 0;
    }
    int n1=(2*Y-X)/3,n2=(2*X-Y)/3;
    COMinit();
    cout<<COM(n1+n2,n1)<<endl;
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,k;
  cin >> n >> k;
  vi dp(n,0);
  vi h(n);
  REP(i,n){
    cin >> h[i];
  }
  FOR(i,1,min(n,k)){
    int mn = INT_MAX;
    REP(j,i){
      mn = min(mn,dp[j]+abs(h[j]-h[i]));
    }
    dp[i] = mn;
  }
  FOR(i,k,n){
    int mn = INT_MAX;
    REP(j,k){
      mn = min(mn,dp[i-j-1]+abs(h[i-j-1]-h[i]));
    }
    dp[i] = mn;
  }
  cout << dp[n-1] << endl;
  // for(auto i:dp) cout << i << endl;
}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,M=map(int,input().split())
edge=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int1,input().split())
    edge[a].append(b)

used=[False]*N
for i in range(N):
    if used[i]==True:
        continue
    stack=[i]
    path=[]
    while stack:
        v=stack.pop()
        if v>=0:
            used[v]=True
            path.append(v)
            for nv in edge[v]:
                if not used[nv]:
                    stack.append(~v)
                    stack.append(nv)
                else:
                    if nv in path:
                        path.append(nv)
                        break
            else:
                continue
            break
        else:
            path.pop()
    else:
        continue
    break
else:
    print(-1)
    exit()
cycle=path[path.index(path[-1]):]
while True:
    s=set(cycle)
    next_cycle=[]
    for i,v in enumerate(cycle[:-1]):
        next_cycle.append(v)
        for nv in edge[v]:
            if nv==cycle[i+1]:
                continue
            if nv in s:
                next_cycle.extend(cycle[cycle.index(nv):])
                break
        else:
            continue
        break
    else:
        break
    cycle=[]
    ss=set()
    for v in next_cycle:
        if v in ss:
            vv=v
            break
        ss.add(v)
    f=False
    for v in next_cycle:
        if v==vv:
            cycle.append(v)
            if not f:
                f=True
            else:
                break
        elif f:
            cycle.append(v)
    
print(len(cycle)-1)
for v in cycle[:-1]:
    print(v+1)

Measured memory_bytes: 74784
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S1[200];

void initialize(){
top = 0;
}

/*int isEmpty(){
if(top == 0)
  return 1;
  }*/

/*void push(int y, int *S){
top++;
S[top] = y;
}*/

void push(int x){
S1[++top] = x;
}

/*int pop(int *S){
if(isEmpty)
  fprintf(stderr,"underflow\n");

top--;
return S[top+1];
}*/

int pop(){
top--;
return S1[top+1];
}


int main(){
int a,b;
char S[200];
int i /*,S1[200]*/;

initialize();

/*for(i = 0; i < 200; i++){
  S[i] = '0';
  S1[i] = 0;
  }*/

  
while(scanf("%s",S) != EOF){
if(S[0] == '+'){
a = pop();
b = pop();
push(a+b);
}

 else if(S[0] == '-'){
b = pop();
a = pop();
push(a-b);
}

 else if(S[0] == '*'){
a = pop();
b = pop();
push(a*b);
}
 else push(atoi(S));

}
   

/*  printf("check1 %s\n",S);

    if(S[0] != '+' || S[0] != '-' || S[0] != '*' ){

    printf("checkA %s\n",S);
    printf("atoi %d\n",atoi(S));
    S1[n] = atoi(S);
    }*/


 
/* for(i = 0; i < n; i++){
   if(S[i] == '+'){
   x = pop(S);
   x += pop(S);
   push(x,S);
   }

   else if(S[i] == '-'){
   x = pop(S);
   x -= pop(S);
   push(x,S);
   }

   else if(S[i] == '*'){
   x = pop(S);
   x *= pop(S);
   push(x,S);
   }

   else push(S[i],S); 

   }*/

printf("%d\n",pop());

return 0;
}

Measured memory_bytes: 548
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

main :-
    get_number(N),
    X is N div 500 * 1000 + N mod 500 div 5 * 5,
    writeln(X).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8180
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>
#define INF 9999999999
using namespace std;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	ll A = 0, B = 0;
	vector<ll> a(N), b(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		A += a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		B += b[i];
	}

	ll af = B-A, bf = B-A;
	for (int i = 0; i < N; i++) {
		if (b[i] - a[i] > 0) {
			int tmp = b[i] - a[i];
			a[i] += 2 * (tmp / 2);
			af -= tmp / 2;
			if (b[i] - a[i] > 0) {
				a[i] += 2;
				af--;
			}
		}
		if (a[i] - b[i] > 0) {
			int tmp = a[i] - b[i];
			b[i] += 2 * tmp;
			bf -= tmp;
			if (a[i] - b[i] > 0) {
				b[i]++;
				bf--;
			}
		}
	}

	if (af >= 0 && bf >= 0 && 2 * af == bf) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int input_num; cin >> input_num;
	vector<int> digit_num(4);
	digit_num[0] = input_num / 1000;
	digit_num[1] = input_num / 100 % 10;
	digit_num[2] = input_num / 10 % 10;
	digit_num[3] = input_num % 10;
	vector<int> opr_flg(3);
	bool end_flg = false;
	int loop1 = 0;
	while (loop1 < 2 && end_flg == false) {
		int loop2 = 0;
		opr_flg[0] = loop1;
		while (loop2 < 2 && end_flg == false) {
			int loop3 = 0;
			opr_flg[1] = loop2;
			while (loop3 < 2 && end_flg == false) {
				opr_flg[2] = loop3;
				int calc_num = digit_num[0];
				for (unsigned int i = 1; i < digit_num.size(); ++i) {
					if (opr_flg[i - 1] == 0) {
						calc_num += digit_num[i];
					} else {
						calc_num -= digit_num[i];
					}
				}
				if (calc_num == 7) {
					end_flg = true;
				}
				loop3++;
			}
			loop2++;
		}
		loop1++;
	}
	string ans = to_string(digit_num[0]);
	for (unsigned int i = 1; i < digit_num.size(); ++i) {
		if (opr_flg[i - 1] == 0) {
			ans += "+";
		} else {
			ans += "-";
		}
		ans += to_string(digit_num[i]);
	}
	ans += "=7";
	cout << ans << endl;
    return;
}

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



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

int main(){
  string s;
  cin>>s;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='C'){
      for(int j=i+1; j<s.size(); j++){
        if(s[j]=='F'){
          cout<<"Yes"<<endl;
          goto end;
        }
      }
    }
  }
  cout<<"No"<<endl;
  end:;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10001

int main(void){

    int N,M,i,j,T[MAX],P[101],X[MAX],ans,tmp;

    scanf("%d",&N);
    for(i = 1;i <= N;i++){
        scanf("%d",&T[i]);
    }
    scanf("%d",&M);
    for(i = 1;i <= M;i++){
        scanf("%d %d",&P[i],&X[i]);
    }

    for(i = 1;i <= M;i++){
        ans = 0;
        for(j = 1;j <= N;j++){
            if(P[i] == j){
                ans += X[i];
            }else{
                ans += T[j];
            }
        }
        printf("%d\n",ans);
    }

    return 0;
}


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

int gcd(int a, int b){
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    else return gcd(b, a%b);
}

int main(){
    int N;  cin >> N;
    vector<int> A(N+1,0);
    for(int i=1; i<=N; i++) cin >> A[i];
    vector<int> G1(N+1,0), G2(N+1,0);

    G1[1] = A[1];  G2[N] = A[N];
    for(int i=2; i<=N; i++){
        G1[i] = gcd(G1[i-1], A[i]);
    }
    for(int i=N-1; i>=1; i--){
        G2[i] = gcd(G2[i+1], A[i]);
    }

    int ans = max(G1[N-1], G2[2]);
    for(int i=2; i<=N-1; i++){
        ans = max(ans, gcd(G1[i-1], G2[i+1]));
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n - 1);
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        c--;
        A[i] = c;
    }
    for (int i = 0; i < n; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < n - 1; i++) {

        cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += B[A[i]];
        if (A[i + 1] == A[i] + 1) {
            ans += C[A[i]];
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[200000];
int b[200000];
int main(void)
{
	int n,i;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",&a[i]);
	int begin=0,end=n-1;
	FOR(i,0,n){
		if(i%2==0) b[begin++]=a[n-i-1];
		else b[end--]=a[n-i-1]; 
	}
	FOR(i,0,n) printf("%d%c",b[i],i==n-1?'\n':' ');
	return 0;
}
    
    


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int n,c;cin >> n >> c;
    vector<vector<int> > imos(31,vector<int>(100010,0));

    rep(i,n){
        int s,t,c;
        cin >> s >> t >> c;s--;c--;
        imos[c][s]++;
        imos[c][t]--;  
    }

    rep(i,c)FOR(j,1,100010)imos[i][j]+=imos[i][j-1];
    rep(i,c)FOR(j,1,100010)if(imos[i][j])imos[i][j]=1;
    int res = 0;
    rep(i,100010){
        int tmp=0;
        rep(j,c)tmp+=imos[j][i];
        res = max(res,tmp);
    }
    
    cout << res <<endl;
    return 0;
}

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

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

  int sum;
  int b = a;
  for (int i = 0; i < 8; i++) {
    sum += b % 10;
    b /= 10;
  }


  if ( a % sum == 0 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
n,m=map(int,input().split())
L,R=map(int,input().split())

for i in range(m-1):
    l,r=map(int,input().split())
    if r<L:
        L,R=0,-1
        break
    if R<l:
        L,R=0,-1
        break
    L=max(L,l)
    R=min(R,r)
print(R-L+1)

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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

int n;
vi a, b, c;
int dp[100001][3] = {};  // dp[i][j] i番目にjをするときの最大値

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

  cin >> n;
  a.pb(0);
  b.pb(0);
  c.pb(0);
  rep(i, 0, n) {
    int A, B, C;
    cin >> A >> B >> C;
    a.pb(A);
    b.pb(B);
    c.pb(C);
  }

  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];
  rep(i, 2, n + 1) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][0] += a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][1] += b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]);
    dp[i][2] += c[i];
  }
  int ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , ll> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;


const int mod = 998244353;
//const db eps = 1e-13;
const ll oo = 1e18;
const int MAX = 1e6+6;
// basic operations
int mul( int a , int b ) {
    return (1ll*a*b)%mod;
}
int add( int a , int b ) {
    return (a+b)%mod;
}
int sub( int a , int b ) {
    return (a-b+mod)%mod;
}
void addSelf( int& a, int b, int m ) {
    a += b;
    b %= m;
}

int exp( int a, int b ) {

    int res = 1;
    while( b ) {

        if ( b % 2 ) {
            res = mul( res, a );
        }
        a = mul(a, a);
        b >>= 1;

    }
    return res;
}

//ll gcd[500005][20], A[500005], N, Q, a, b, r;
//void process2() {
//        int i, j;
//        for (i = 0; i < N; i++)
//                gcd[i][0] = i;
//        for (j = 1; 1 << j <= N; j++)
//                for (i = 0; i + (1 << j) - 1 < N; i++)
//                        gcd[i][j] = __gcd(gcd[i][j - 1], gcd[i + (1 << (j - 1))][j - 1]);
//}
//int RMQ(int a, int b) {
//        int k = (int) log2(b - a + 1);
//        return __gcd(gcd[a][k], gcd[b - (1 << k) + 1][k]);
//}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin>>s;
    deque <char> dq;
    for( auto c: s )
        dq.push_back(c);

    bool rev = false;

    int q;
    cin>>q;
    while(q--) {
        int t;
        cin>>t;
        if(t==1) {
            rev = !rev;
        }
        else{

            int f;
            cin>>f;
            char c;cin>>c;

            if(f==1) {
                if(!rev) {
                    dq.push_front(c);
                } else {
                    dq.push_back(c);
                }
            } else {
                if(rev) {
                    dq.push_front(c);
                } else {
                    dq.push_back(c);
                }
            }

        }

    }
    if(rev) {
        while(!dq.empty()) {
            cout<<dq.back();
            dq.pop_back();
        }
    } else {
        while(!dq.empty()) {
            cout<<dq.front();
            dq.pop_front();
        }
    }
    cout<<"\n";
}

Measured memory_bytes: 976
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        long a = in.nextLong();
        long b = in.nextLong();
        long x= in.nextLong();
        long s=0;
        long first = (a+x-1)/x;
        if (first<=b)
            s++;
        long scope = b-(first*x);
        if (scope>=0)
            System.out.println(s+scope/x);
        else
            System.out.println(0);
    }
}

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

int main () {
    int num;
    cin >> num;
    vector<int> list(num);
    for(int i = 0; i < num; i++) {
        cin >> list[i];
    }
    int dp[num];
    dp[0] = 0;
    dp[1] = abs(list[1] - list[0]);

    for(int i = 2; i<num;i++) {
        int step1 = dp[i-1] + abs(list[i] - list[i - 1]);
        int step2 = dp[i-2] + abs(list[i] - list[i - 2]);
        dp[i] = min(step1, step2);
    }
    cout << dp[num - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
n, m, q = map(int, input().split())
Arr = []
for i in range(n+1):
  Arr.append([0] * (n+1))
for i in range(m):
  l, r = map(int, input().split())
  Arr[l][r] += 1
#print(Arr)

B = []
for i in range(n+1):
  B_line = [0]
  for j in range(1, n+1):
    B_line.append(B_line[-1] + Arr[i][j])
  B.append(B_line)
#print(B)
  
for x in range(q):
  left, right = map(int, input().split())
  train_num = 0
  for i in range(left, right+1):
    train_num += B[i][right] - B[i][left-1]
  print(train_num)

Measured memory_bytes: 55648
import sys
input = sys.stdin.readline
k,n = map(int,input().split())
l = list(map(int,input().split()))
maxi = -1
for i in range(n-1):
  maxi = max(maxi,l[i+1]-l[i])
maxi = max(maxi,k-l[n-1]+l[0])
print(k-maxi)

Measured memory_bytes: 72012
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& base) {
    for (T const& i : base) {
        out << i << ' ';
    }
    return out;
}
int solve(int N, int W, vector<int>& values, vector<int>& weights) {
    const int MAXSUMVAL = 100000;
    int64_t DP[MAXSUMVAL + 1];
    fill(DP, DP + MAXSUMVAL + 1, INT_MAX);
    DP[0] = 0;
    DP[values[0]] = weights[0];
    for (int i = 1; i < N; ++i) {
        for (int v = MAXSUMVAL; v >= values[i]; --v) {
            DP[v] = min(DP[v], DP[v - values[i]] + weights[i]);
        }
    }
    int maxval;
    for (int i = 0; i <= MAXSUMVAL; ++i) {
        if(DP[i] <= W) maxval = i;
    }
    return maxval;
}
int main() {
    int N, W;
    cin >> N >> W;
    vector<int> values(N), weights(N);
    for (int i = 0; i < N; ++i) {
        cin >> weights[i] >> values[i];
    }
    cout << solve(N, W, values, weights) << endl;
}

Measured memory_bytes: 4392
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int n, check = 1e6;
    vector<int> w;
    cin >> n;
    for(int i = 0, k; i<n; i++){
        cin >> k;
        w.push_back(k);
    }
    
    for(int i = 0, sum1, sum2, diff; i<n-1; i++){
        sum1 = accumulate(w.begin(), w.begin()+i+1, 0);
        sum2 = accumulate(w.begin()+i+1, w.end(), 0);
        diff = abs(sum1 - sum2);
        if(diff < check){
            check = diff;
        }
        if(diff == 0){
            break;
        }
    }
    
    cout << check << endl;
}


Measured memory_bytes: 256