akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <deque>
#

using namespace std;

int main() {
	string s;
	cin >> s;

	int n = s.size();

	deque<char> deq(s.begin(), s.end());

	int ans = 0;
	while(deq.size() > 1) {
		auto c1 = deq.front();
		auto c2 = deq.back();

		if (c1 != 'x' && c2 != 'x') {
			if (c1 != c2) {
				ans = -1;
				break;
			}
			deq.pop_front();
			deq.pop_back();
		} else if (c1 == 'x' && c2 == 'x') {
			deq.pop_front();
			deq.pop_back();
		} else if (c1 == 'x' && c2 != 'x') {
			ans++;
			deq.pop_front();
		} else {
			ans++;
			deq.pop_back();
		}
	}


	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  vector<ll>fib(100010);
  //fib[-1]=0;
  fib[0]=1;fib[1]=1;
  for(int i=2;i<=100005;i++)fib[i]=(fib[i-1]+fib[i-2])%MOD;
  ll n,m;cin>>n>>m;
  vl a(m+2);
  a[m+1]=n+1;
  a[0]=-1;
  rep(i,m)cin>>a[i+1];
  ll ans=1;
  rep(i,m+1){
    if((a[i+1]-1)-(a[i]+1)==-1){
      cout<<0<<endl;
      return 0;
    }
    ans*=fib[(a[i+1]-1)-(a[i]+1)];
    ans%=MOD;
  }
  cout<<ans<<endl;
}
  
  

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

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

  int less_than, lim;
  if (a < b) {
    less_than = a;
    lim = b;
  } else {
    less_than = b;
    lim = a;
  }

  for (int i = 0; i < lim; i++) {
    cout << less_than;
  }
  cout << endl;
  return 0;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //


// --------- library end - //



int main(){

  ll N, Q;
  cin >> N >> Q;

  dsu uf(N);

  rep(i, Q){
    ll t, u, v;
    cin >> t >> u >> v;

    if (!t){
      // union
      uf.merge(u, v);
    }
    else{
      // find
      cout << (uf.same(u, v) ? 1 : 0) << endk;
    }
  }



}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

using P = Point<double>;

template<class P>
int lineIntersection(const P& s1, const P& e1, const P& s2,
		const P& e2, P& r) {
	if ((e1-s1).cross(e2-s2)) { //if not parallell
		r = s2-(e2-s2)*(e1-s1).cross(s2-s1)/(e1-s1).cross(e2-s2);
		return 1;
	} else
		return -((e1-s1).cross(s2-s1)==0 || s2==e2);
}

vector<P> polygonCut(const vector<P>& poly, P s, P e) {
	vector<P> res;
	rep(i,0,sz(poly)) {
		P cur = poly[i], prev = i ? poly[i-1] : poly.back();
		bool side = s.cross(e, cur) < 0;
		if (side != (s.cross(e, prev) < 0)) {
			res.emplace_back();
			lineIntersection(s, e, cur, prev, res.back());
		}
		if (side)
			res.push_back(cur);
	}
	return res;
}


template<class T>
T polygonArea2(vector<Point<T>>& v) {
	if(v.empty()) return 0;
	T a = v.back().cross(v[0]);
	rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
	return a;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<P> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i].x >> a[i].y;
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		P p1, p2;
		cin >> p1.x >> p1.y >> p2.x >> p2.y;
		vector<P> poly = polygonCut(a, p2, p1);
		cout << polygonArea2(poly) / 2.0 << '\n';
	}
}



Measured memory_bytes: 3264
#include<cstdio>
#include<cstring>

char affine(char c, int a, int b){
	return (a * (c - 'a') + b) % 26 + 'a';
}

int main(){
	int n;
	char t = 'a';
	char s[257];
	char that[] = "that";
	char thi[] = "this";
	char athat[5], athis[5], r[26], rt[26];
	scanf("%d\n", &n);
	for(int i = 0; i < n; i++){
		int d = 0;
		int a = 0;
		scanf("%c", &t);
		while(t - 10){
			s[d] = t;
			d++;
			scanf("%c", &t);
		}
		s[d] = 0;
		while(a + 1){
			for(int b = 0; b < 26; b++){
				for(int c = 0; c < 4; c++){
					athat[c] = affine(that[c], a, b);
					athis[c] = affine(thi[c], a, b);
				}
				athat[4] = 0;
				athis[4] = 0;
				if(strstr(s, athat) || strstr(s, athis)){
					for(int j = 0; j < 26; j++){
						rt[j] = affine(j + 'a', a, b) - 'a';
						r[rt[j]] = j;
					}
					d = 0;
					while(s[d]){
						if(s[d] != ' '){
							printf("%c", r[s[d] - 'a'] + 'a');
						}else{
							printf(" ");
						}
						d++;
					}
					printf("\n");
					a = -2;
				}
			}
			a++;
		}

	}	
}

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

int main()
{
    string s,t;
    int i,j,k,ans=INT_MAX;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    //if(s.find(t)!=s::npos)cout<<0;
        for(i=0;i<n-m+1;i++){
            int res=0;
            for(j=0;j<m;j++){
                if(s[i+j]!=t[j])res++;
            }
            ans=min(ans,res);
        }
        cout<<ans;
    
    
}

Measured memory_bytes: 3604
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, T = map(int, input().split())
    ans = 10**10
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T: ans = min(ans, c)
    if ans == 10**10: print("TLE")
    else: print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
using System;

namespace A___Apple_Pie
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var A = read[0];
            var P = read[1];

            int pie = (3*A + P) / 2;
            Console.WriteLine(pie);
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        long A = cin.nextLong();
        long B = cin.nextLong();
        if (Math.Abs(A - B) <= 1) Console.WriteLine("Brown");
        else Console.WriteLine("Alice");

    }
    /*
    int[,] check = new int[30, 30];

    int dfs(int a, int b)
    {
        if (check[a, b] != 0) return check[a, b] - 1;
        check[a, b] = 1;
        for (int A = 2; A <= a; A += 2)
        {
            if(dfs(a - A, b + A / 2) == 0)
            {
                check[a, b] = 2;
                return 1;
            }
        }


        for (int B = 2; B <= b; B += 2)
        {
            if (dfs(a + B / 2, b - B) == 0)
            {
                check[a, b] = 2;
                return 1;
            }
        }
        return 0;
    }
    */
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

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

int main(){
	string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 1. 入力データの処理
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		sc.close();

		int productNum = T / A;
		System.out.println(productNum * B);
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a%2!=b%2)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
}



    



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

using namespace std;

struct Point {
	double x, y;
};

double solve(Point s, Point g, Point f) {
	Point sg = { g.x - s.x, g.y - s.y };
	Point sf = { f.x - s.x, f.y - s.y };
	double tmp = sg.x * sf.x + sg.y * sf.y;
	tmp /= (sg.x * sg.x + sg.y * sg.y);
	if (tmp < 0 || 1 < tmp) return min(sqrt(sf.x * sf.x + sf.y * sf.y),
		sqrt(pow(f.x - g.x, 2) + pow(f.y - g.y, 2)));
	Point fh = { -sf.x + tmp * sg.x,-sf.y + tmp * sg.y };
	return sqrt(fh.x * fh.x + fh.y * fh.y);
}

int main() {
	int n1; cin >> n1;
	vector<Point> a(n1 + 2); a[n1 + 1] = { 1000,0 };
	for (int i = 1; i <= n1; ++i) cin >> a[i].x >> a[i].y;
	int n2; cin >> n2;
	vector<Point> b(n2 + 2); b[0] = { 0,1000 }; b[n2 + 1] = { 1000,1000 };
	for (int i = 1; i <= n2; ++i) cin >> b[i].x >> b[i].y;
	double ans = 1e4;
	for (int i = 0; i < n1 + 1; ++i)
		for (int j = 0; j < n2 + 2; ++j)
			ans = min(ans, solve(a[i], a[i + 1], b[j]));
	for (int i = 0; i < n2 + 1; ++i)
		for (int j = 0; j < n1 + 2; ++j)
			ans = min(ans, solve(b[i], b[i + 1], a[j]));
	printf("%.10f", ans);

	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if( a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 ) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
number = []
for i in range(N):
    number.append(int(input()))
sorted_number = sorted(number,reverse=True)
max_number = sorted_number[0]
second_number = sorted_number[1]

for i in number:
    if i != max_number:
        print(max_number)
    else:
        print(second_number)


Measured memory_bytes: 86536
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define maxi(a,b) (((a) > (b)) ? (a) : (b))
#define mini(a,b) (((a) < (b)) ? (a) : (b))

using namespace std;

vector<string> split(const string &str, char delim);

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

	unsigned long long a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	unsigned long long x, y;

	x = a / c;
	y = b / c;
	if (a % c == 0)
		y += 1;

	cout << y - x;

	/********************************************************/
	return 0;
}


vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n+1];
    bool flag = true;
    REP(i,n){
        cin >> A[i+1];
        if(A[i+1] == 1){
            flag = false;
        }
    }

    if(flag){
        cout << 0 << endl;
        return 0;
    }



    int ans[n+1] = {};
    REPR(i,n){
        if(i == 0) break;
        int tmp = i;
        int kosu = 0;
        while(1){
            if(ans[tmp] == 1){
                kosu ++;
            }
            tmp += i ;
            if(tmp >= n+1) break;
        }

        if(kosu %2 != A[i]){
            ans[i] = 1;
        }
    }

    int hoge = 0;
    FOR(i,1,n+1) if(ans[i] == 1) hoge ++;

    cout << hoge << endl;
    FOR(i,1,n+1){
        if(ans[i] == 1){
            cout << i  << " ";
        }

    }
    cout << endl;

}

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = INT_MAX;
	for (int i = 0; i <= x; ++i) {
		int k = (x - i) * 2;
		int j = 0;
		if ((2 * y - k) > 0) {
			if (2 * c < b) {
				k += (2 * y - k);
			} else {
				j = (2 * y - k + 1) / 2;
			}
		}
		ans = min(ans, i * a + j * b + k * c);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
n = int(input())
minchar = {chr(97+i):2500 for i in range(26)}
ans = ""

for i in range(n):
  S = input()
  for i in range(26):
    minchar[chr(i+97)] = min(minchar[chr(i+97)], S.count(chr(97+i)))

for i in range(26):
  ans += minchar[chr(97+i)] * chr(97+i)
print(ans)

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

int main()
{
  int n,i,j;
  scanf("%d",&n);
  for(i=1;i<=9;i++)for(j=1;j<=9;j++)if(i*j==n){printf("Yes");return 0;}
  printf("No");
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans=0;
    int r,s,t,u;

    for(int i=a; i<=b; i++){
        r=i/10000;
        s=(i%10000)/1000;
        u=i%10;
        t=(i/10)%10;
        
        if(r==u && s==t) ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a+=b;if(a>=M)a%=M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n, a[210000], b[210000];
int dp[210000][3];
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  if(n % 2 == 0){
    int odd = a[1], even = a[0];
    b[0] = a[0];b[1] = a[1];
    repd(i,2,n){
      if(i % 2 == 0){
        even += a[i];
        b[i] += b[i-2] + a[i];
      }else{
        odd += a[i];
        b[i] += b[i-2] + a[i];
      }
    }
    int ans = max(odd, even);
    rep(i,n){
      if(i % 2 == 0)continue;
      chmax(ans, b[i-1] + b[n-1] - b[i]);
    }
    cout << ans << endl;
  }else{
    dp[0][0] = a[0];dp[1][1] = a[1];dp[2][0] = a[0]+a[2];dp[2][2] = a[2];
    repd(i,3,n){
      dp[i][0] = dp[i-2][0] + a[i];
      dp[i][1] = max(dp[i-2][1], dp[i-3][0]) + a[i];
      dp[i][2] = max(dp[i-2][2], dp[i-3][1]) + a[i];
    }
    cout << max({dp[n-1][2], dp[n-2][1]}) << endl;
  }
}


Measured memory_bytes: 9884
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

#define no cout << "No" << endl; exit(0)

int main(){
    int N;
    cin >> N;
    int a[N];
    cins(a, a + N);
    sort(a, a + N);
    if(a[0] + 1 < a[N - 1]){
        no;
    }else{
        int less_count = int(lower_bound(a, a + N, a[N - 1]) - a);
        Yes((less_count + 1 <= a[N - 1] && a[N - 1] <= less_count + (N - less_count) / 2) || (a[0] == a[N - 1] && a[0] == N - 1));
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int X,Y=100;
    cin>>X;
    long int ans=0;
    while (Y<X){
        Y=Y+Y/100;
        ans+=1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;



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

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	int maxx = X, minx = Y;
	int x;
	rep(i, 0, N)
	{
		cin >> x;
		chmax(maxx, x);
	}
	rep(i, 0, M)
	{
		cin >> x;
		chmin(minx, x);
	}

	if (maxx < minx)
	{
		cout << "No War" << endl;
	}
	else
	{
		cout << "War" << endl;
	}

	return 0;
}

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

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

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

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN = 1000001;//変更可
long long fac[MXN], inv[MXN], finv[MXN];

void COMinit(int M){
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i < MXN; i++){
        fac[i] = fac[i-1] * i % M;
        inv[i] = M - M / i * inv[M%i] % M;
        finv[i] = finv[i-1] * inv[i] % M;
    }
}

long long COMBI(int N, int K, int M){
    if(N < K){
        return 0;
    }
    if(N < 0||K < 0){
        return 0;
    }
    return fac[N] * finv[N-K] % M * finv[K] % M;
}

long long PERMU(int N, int K, int M){
    if(N < K){
        return 0;
    }
    if(N < 0||K < 0){
        return 0;
    }
    return fac[N] * finv[N-K] % M;
}

long long mod_pow(long long x, long long y, long long M){
    if(y == 0){
        return 1;
    }
    if(y & 1){
        return mod_pow(x, y - 1, M) * x % M;
    }
    long long t = mod_pow(x, y / 2, M);
    return t * t % M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    COMinit(MOD);
    ll ans=0;
    FOR(i,2,N+1){
        ans+=((mod_pow(2,i,MOD)-2)*COMBI(N,i,MOD)%MOD)*mod_pow(8,N-i,MOD)%MOD;
        ans%=MOD;
    }
    cout << (ans+MOD)%MOD << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

using namespace std;

int main(){

  double a,b,c,d, e,f,g,h;

  while(cin>>a){
    cin >>b>>c>>d>>e>>f>>g>>h;

    if(g<a||c<e||h<b||d<f)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  } 

  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define mpr make_pair
typedef pair < int , int > pii;
typedef long long LL;
int n,a[200005],b[200005];
multiset < pii > st;
LL res;
void dec(int d){
	st.erase(st.find(mpr(b[d],d)));
	int S=b[(d+n-1)%n]+b[(d+1)%n];
	if(S>b[d]){
		printf("-1\n");
		exit(0);
	}
	int e=(b[d]-a[d])/S;
	if(!e){
		printf("-1\n");
		exit(0);
	}
	res+=(LL)e;
	b[d]-=(LL)S*(LL)e;
	if(b[d]<a[d]){
		printf("-1\n");
		exit(0);
	}
	if(b[d]>a[d]) st.insert(mpr(b[d],d));
}
int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;++i) scanf("%d",a+i);
	for(i=0;i<n;++i) scanf("%d",b+i);
	for(i=0;i<n;++i){
		if(b[i]>a[i]){
			st.insert(mpr(b[i],i));
		}
		else if(b[i]<a[i]){
			printf("-1\n");
			return 0;
		}
	}
	while(!st.empty()){
		dec(st.rbegin()->second);
	}
	for(i=0;i<n;++i){
		if(a[i]!=b[i]){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;

int main() {
    double N, K;
    cin >> N >> K;
    double answer = 0;
    for(int i = 1 ; i <= N; i++) {
        if(i > K) {
            answer += 1;
            continue;
        }
        int n;
        n = ceil(log(K / i) / log(2));
        answer += pow(0.5, n);
    }
    answer /= N;
    cout << setprecision(10) << answer << endl;
    return 0;
}




Measured memory_bytes: 512
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>

#define ll long long
using namespace std;
int a,b,c,x,y;
int count_c;
int price;

int main(){
  cin>>a>>b>>c>>x>>y;
  price = a*x+b*y;

  // if(a+b-2*c>0){
  //   price = max(x,y)*2*c;
  // }
  for(int i=0;i<=max(x,y)*2;i+=2){
    // cout<<i<<endl;
    price=min(max((x-i/2),0)*a+max((y-i/2),0)*b+i*c,price);
  }
  cout<<price<<endl;
  return 0;
}


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

using namespace std;

const auto MOD = (long long) 1e9 + 7;

int main() {
    unsigned int n;
    string s;
    cin >> n >> s;

    long long a[26] = {};
    for (auto i : s) {
        a[i - 'a']++;
    }

    long long ans = 1;
    for (auto i : a) {
        ans = ans * (i + 1) % MOD;
    }
    ans--;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;
using ll=long long;
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
 
int main() {
ll X,Y;
string N;
int n=0;
int nmax=0;
int ans=0;
  cin >> X>>Y;
 ll syou = Y/X;



 while(syou!=0){
   syou=syou/2;
   ans++;
 }


 
  cout << ans<< endl;
  return 0;
}

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

using namespace std;

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    
    vector <int> v;
    
    v.push_back(a+b);
    v.push_back(a-b);
    v.push_back(a*b);

    sort(v.begin(),v.end());
    
    printf("%d\n",v[2]);

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    long long n;
  	cin >> n;
  	bool a = 1;
  	long long i = 1;
  	while(a){
  	  	if(i * i > n){
  	    	cout << (i - 1) * (i - 1) << endl;
  	    	a = 0;
  	  	}
  		i++;
  	}
  	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


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

    vector<long> floors(n + 1, 0);
    vector<bool> dropped(n+1, false);
    for(int i=0; i<m; i++) {
        int a;
        cin >> a;
        dropped[a] = true;
    }
    floors[1] = (dropped[1])? 0 : 1;
    if(n >= 2) {
        floors[2] = (dropped[2])? 0 : floors[1] + 1;
        for(int i=3; i<=n; i++) {
            if(dropped[i]) continue;
            else {
                long one_step = floors[i-1];
                long two_step = floors[i-2];
                floors[i] = (one_step + two_step) % DIVIDE;
            }
        }
    }

    //PRINT_ARRAY_INLINE(floors);
    cout << floors[n] % DIVIDE << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
int fib(int);
int array[45];
int main(){
  int value,i;
  for(i=1;i<=44;i++) array[i]=-1; /*-1 means there no input*/
  scanf("%d",&value);
  printf("%d\n",fib(value));
  return 0;
}

int fib(int value){
  if(value==0){
    array[value]=1;
    return array[value];
  }
  if(value==1){
    array[value]=1;
    return array[value];
  }
  if(array[value]!=-1) return array[value];
  array[value]=fib(value-1)+fib(value-2);
  return array[value];
}
  
  



Measured memory_bytes: 2148
#include<cstdio>
long long a[100005];

long long abs(long long u){ return u>0?u:-u; }

long long min(long long a,long long b){ return a>b?b:a; }

long long solve(long long s,int n){
    long long sum = 0, res = 0;
    for(int i = 1; i <= n; i++){
        s *= -1;
        sum += a[i];
        if(sum*s<=0){
            res += abs(s-sum);
            sum = s;
        }
    }
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    printf("%lld\n",min(solve(1,n),solve(-1,n)));
    return 0;
}


Measured memory_bytes: 2484
D = 1_000_000_000
    H, W, N = gets.split.map(&:to_i)
     
    h = Hash.new(0)
    N.times do
      a, b = gets.split.map(&:to_i)
      ((a - 1)..(a + 1)).each do |i|
        next if i <= 1 || i >= H
        ((b - 1)..(b + 1)).each do |j|
          next if j <= 1 || j >= W
          h[D * i + j] += 1 
        end
      end
    end

    c = h.values.inject(Array.new(10, 0)) {|a, v| a[v] += 1; a}
    c[0] = (H - 2) * (W - 2) - c.inject(:+)
    puts c

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

int main()
{
    while (true) {
        int h, w;
        cin >> h >> w;
        
        if (!h && !w) break;
        
        bool b1 = true;
        for (int i = 0; i < h; ++i) {
            bool b2 = b1;
            for (int j = 0; j < w; ++j) {
                if (b2) cout << "#";
                else    cout << ".";
                b2 = not b2;
            }
            cout << "\n";
            b1 = not b1;
        }
            
        cout << "\n";
    }
}

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

using namespace std;

const int mxn = 2e5 + 10;
const int Mod = 1e9 + 7;

int Ans = 1e7;
int arr[mxn];

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

    string str1, str2;
    cin>>str1>>str2;
    int sz1 = str1.size(), sz2 = str2.size();

    for(int i=0 ; i<=sz1-sz2; i++){
        int k = i, ct = 0;
        for(int j=0 ; j<sz2 ; j++){
            if(str1[k] != str2[j]) ct++;
            k++;
        }
        Ans = min(Ans, ct);
    }

    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
 
#define MAX 100000
 
int count[MAX+1];
 
void quicksort(int *,char *,int,int);
int partition(int *,char *,int,int);
int stable(int *,int);
 
int main() {
 
  int i,n,k;
  char B[MAX+1],c,d,e;
  int A[MAX+1];
   
 
  scanf("%d%c",&n,&e);
   
  for(i=1;i<n+1;i++){
   scanf("%c%c%d%c",&B[i],&c,&A[i],&d);
   count[i]=i;
  }
 
  quicksort(A,B,1,n);
 
  if(stable(A,n)==0) printf("Stable\n");
  else printf("Not stable\n");
 
  for(k=1;k<=n;k++){
    printf("%c %d\n",B[k],A[k]);
  }
 
  return 0;
}
 
void quicksort(int *A,char *B,int p,int r){
  int q;
   
  if(p<r){
    q=partition(A,B,p,r);
    quicksort(A,B,p,q-1);
    quicksort(A,B,q+1,r);
  }
}
 
int partition(int *A,char *B,int p,int r){
  int x,i,j,s,swap;
  char exc;
 
   x=A[r];
   i=p-1;
 
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap=A[i];
      A[i]=A[j];
      A[j]=swap;
      exc=B[i];
      B[i]=B[j];
      B[j]=exc;
      s=count[i];
      count[i]=count[j];    
      count[j]=s;
    }
}
      swap=A[i+1];
      A[i+1]=A[r];
      A[r]=swap;
      exc=B[i+1];
      B[i+1]=B[r];
      B[r]=exc;
      s=count[i+1];
      count[i+1]=count[r];    
      count[r]=s;
 
      return i+1;
}
 
int stable(int *A,int n){
  int i;
 
  for(i=1;i<=n;i++){
    if(A[i]==A[i+1]){
      if(count[i]>count[i+1]) return 1;
    }
  }
  return 0;
 
}

Measured memory_bytes: 1484
#include <cstdio>
#include <cstdlib>
using namespace std;
int main() {
    char c;
    int s = 0;
    while (scanf("%c", &c) != EOF) {
        if (c == '\n') {
            printf("%d\n", s);
            s = 0;
        } else if (c == '0' && s == 0) {
            break;
        }
        else {
            s += atoi(&c);
        }
    }
}

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

int main(void){
  int a,b,c,w; // w:weekly total
  int ans,d;
  
  cin >> a >> b >> c;
  w = a*7+b;
  while (c>=w){
    ans += 7;
    c -= w;
  }
//  cout << ans << " " << c << endl;
  d=1;
  while (c>0){
    c -= a;
    if (d++==7) c -= b;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3116
def main():
  import sys
  n = int(input())
  a = tuple(map(int,sys.stdin.readline().split()))
  b = tuple(map(int,sys.stdin.readline().split()))
  
  count=0
  buffer=0
  
  for i in range(n):
    c = a[i]
    h = b[i]
    count += min(buffer,c)
    g = max(0,c-buffer)
    count += min(h,g)
    buffer=max(0,h-g)
  else:
    count+=min(buffer,a[-1])
    
    
  print(count)
  
if __name__=="__main__":
  main()

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n,i;cin>>n>>i;
  int ans=n-i+1;
  cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, a,b;
	cin >> n >> a>>b;
	cout << (n -a) % b << endl;

	return 0;
}



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

typedef long long ll;
typedef long double ld;

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

    int N;
    ll T;
    cin >> N >> T;;
    
    vector<ll> t(N);

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

    ll ans = T;

    for(int i = 1; i < N; i++) {
        ans += min(t[i] - t[i - 1], T);
    }

    cout << ans << endl;
}

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

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b * 100 + 0.5;
    a *= ib;
    a /=100;
    cout << a << "\n";
    return 0;
}


Measured memory_bytes: 3716
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    s = "ABC"

  else:
    ##INPUT 
    s = input()
    #a, b = map(int, input().split())

  ## SUBMITION CODES HERE
  if s == "ABC":
    print("ARC")
  else:
    print("ABC")
 
main()

Measured memory_bytes: 8960
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int s;
    cin >> s;
    string n;
    cin >> n;
    
    bool notOk = false;
    
    if(n.size() % 2 == 0){
        string n1 = n.substr(0, n.size()/2);
        string n2 = n.substr(n.size()/2, n.size()/2);
        if(n1 != n2){
            notOk = true;
        }
    }
    else{
        notOk = true;
    }
    
    if(!notOk){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a = [int(x) for x in input().split()]

left = [0] * (n + 1)
right = [0] * (n + 1)

for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in reversed(range(n)):
    right[i] = gcd(right[i + 1], a[i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))

print(ans)


Measured memory_bytes: 16140
# -*- coding: utf-8 -*-
# abc149/abc149_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    R, S, P = i2nn()
    table = {'r': P, 's': R, 'p': S}
    T = list(i2s())
    score = 0
    for i in range(K):
        score += table[T[i]]
    for i in range(K, len(T)):
        if T[i] == T[i - K]:
            T[i] = 'x'
        else:
            score += table[T[i]]
    print(score)
    return

main()


Measured memory_bytes: 4084
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  ll a[N]; FOR(i,0,N) cin >> a[i];
  ll sum[N+1];
  CLR(sum);
  FOR(i,0,N) sum[i+1] = sum[i] + a[i];
  sort(sum, sum + N + 1);
  FOR(i,0,Q) {
    ll x;
    cin >> x;
    ll ans = 0;
    FOR(l,1,N+1) {
      ans += (upper_bound(sum, sum + N + 1, x + sum[l-1]) - sum) - l;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n;
  string s;
  cin >> s;
  n = s.size();
  LL ans = 0;
  bit_search(bit, n-1)
  {
    string now = "";
    now += s[0];
    REP(i, n-1)
    {
      if (bit_check(bit, i)) now += s[i+1];
      else
      {
        ans += stoll(now);
        now = "";
        now += s[i+1];
      }
    }
    ans += stoll(now);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256