akhauriyash/Code-Regression huggingface dataset:
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 205
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
void solve(int64 N) {
	for (int a = 1; a <= 3500; a++) for (int b = a; b <= 3500; b++) {
		int64 lhs = 4LL * a * b;
		int64 rhs = N * (a + b);
		if (rhs > lhs)
			break;
		int lb = 1, rb = 3500;
		int res = lb;
		while (lb < rb) {
			int c = (lb + rb) >> 1;
	//		printf(">> %d %d %d\n", lb, rb, c);
			res = c;
			int64 ls = 4LL * a * b * c;
			int64 rs = N * (a*b + b*c + a*c);
			if (ls == rs) {
				printf("%d %d %d\n", a, b, c);
				return;
			}
			if (rs > ls) {
				lb = c + 1;
			}
			else
				rb = c;
		}
	}
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");
	
	int N, K;
	scanf("%d %d", &N, &K);
	vector <PII> v;
	for (int i = 0; i < N; i++) {
		int A, B;
		scanf("%d %d", &A, &B);
		v.emplace_back(A, B);
	}
	sort(ALL(v));
	vector <int> pow;
	for (int k = K, mask = 1; k > 0; k >>= 1, mask <<= 1) {
		if (k & 1) pow.emplace_back(mask);
	}
	reverse(ALL(pow));
	int64 res = 0LL;
	for (int i = 0; i < N; i++) if ((v[i].X | K) == K) {
		res += v[i].Y;
	}
	int sum = 0;
	for (int x : pow) {
		sum += x;
		int mask = sum - 1;
		int64 acc = 0LL;
		for (int i = 0; i < N; i++) if ((v[i].X | mask) == mask) {
			acc += v[i].Y;
		}
		res = max(res, acc);
	}
	printf("%lld\n", res);

}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;

void preorder(int node, int child[][2])
{
    cout << " " << node;
    if (child[node][0] != -1) preorder(child[node][0], child);
    if (child[node][1] != -1) preorder(child[node][1], child);
}

void inorder(int node, int child[][2])
{
    if (child[node][0] != -1) inorder(child[node][0], child);
    cout << " " << node;
    if (child[node][1] != -1) inorder(child[node][1], child);
}

void postorder(int node, int child[][2])
{
    if (child[node][0] != -1) postorder(child[node][0], child);
    if (child[node][1] != -1) postorder(child[node][1], child);
    cout << " " << node;
}

int main(void)
{
    int n;
    cin >> n;
    int used[n];
    memset(used, -1, sizeof(used));
    int child[n][2];
    for (int i = 0; i < n; i++)
    {
        int id, left, right;
        cin >> id >> left >> right;
        child[id][0] = left;
        child[id][1] = right;
        if (left != -1) used[left] = 0;
        if (right != -1) used[right] = 0;
    }
    int root = 0;
    for (int i = 0; i < n; i++)
    {
        if (used[i] == -1)
        {
            root = i;
            break;
        }
    }
    cout << "Preorder\n";
    preorder(root, child);
    cout << "\n";
    cout << "Inorder\n";
    inorder(root, child);
    cout << "\n";
    cout << "Postorder\n";
    postorder(root, child);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  string s;cin>>s;string sss = s;
  int ss = s.size();
  rep(i,ss){
    repd(j,i,ss){
      sss.erase(i,j-i);
      if(sss == "keyence"){
        cout << "YES" << endl;
        return 0;
      }
      sss = s;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int k,a,b;
const int N= 1e6;





int32_t main()
{
	IOS;
	cin>>k;
	cin>>a>>b;
	if(a%k==0 || ((a/k+1)*k)<=b)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3608
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, K = map(int, readline().split())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]

C = 1 * (C == b'#')

def f(C, x, y):
    D = C.copy()
    for i in range(H):
        if x & (1 << i):
            D[i] = 0
    for i in range(W):
        if y & (1 << i):
            D[:, i] = 0
    return D.sum() == K

ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)


Measured memory_bytes: 27104
N, Y = map(int, input().split())

check = 0
for x in range(0,N+1):
    for y in range(0,N+1-x):
        z = Y - 10000*x - 5000*y
        if z == (N - x - y)*1000:
            z = int(z/1000)
            print(x,y,z)
            check = 1
            break
        # for z in range(0,N+1-x-y):
        #     if 10000*x + 5000*y + 1000*z == Y:
        #         print(x,y,z)
        #         check = 1
        #         break
        # if check == 1:
        #     break
    if check == 1:
        break
if check == 0:
    print("-1 -1 -1")


Measured memory_bytes: 65392
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

	int t;
	cin >> t;
	while (t--)
	{
		int h, w;
		cin >> h >> w;
		vector<int> l(30, INF), r(30, 0), u(30, INF), d(30, 0);
		set<int> st;
		vector<string> s(h);
		for (int i = 0; i < h; i++)
		{
			cin >> s[i];
			for (int j = 0; j < w; j++)
			{
				if (s[i][j] == '.')
					continue;
				int idx = s[i][j] - 'A';
				st.insert(idx);
				l[idx] = min(l[idx], j);
				r[idx] = max(r[idx], j);
				u[idx] = min(u[idx], i);
				d[idx] = max(d[idx], i);
			}
		}
		vector<int> v;
		for (auto val : st)
		{
			v.push_back(val);
		}
		int sz = v.size();
		bool f = false;
		do
		{
			vector<int> pri(30, INF);
			for (int i = 0; i < sz; i++)
			{
				pri[v[i]] = i;
			}
			bool ftmp = true;
			for (int i = 0; i < 26; i++)
			{
				if (l[i] == INF)
					continue;
				for (int x = u[i]; x <= d[i]; x++)
				{
					for (int y = l[i]; y <= r[i]; y++)
					{
						if (s[x][y] == '.')
							ftmp = false;
						else
						{
							int gt = s[x][y] - 'A';
							if (pri[gt] >= pri[i])
								continue;
							else
								ftmp = false;
						}
					}
				}
			}
			if (ftmp)
				f = true;
		} while (next_permutation(v.begin(), v.end()));
		if (!f)
		{
			cout << "SUSPICIOUS" << endl;
		}
		else
		{
			cout << "SAFE" << endl;
		}
	}
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n;cin>>n;
    while(n!=0){
        if(n%10==7){
            cout<<"Yes"<<"\n";
            return;
        }
        n/=10;
    }
    cout<<"No"<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int a[maxn],b[maxn],c[maxn];
int i,j,k,l,t,n,m;
ll ans;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n) scanf("%d",&b[i]);
	fo(i,1,n) scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	i=0;k=1;
	fo(j,1,n){
		while (i<n&&a[i+1]<b[j]) i++;
		while (k<=n&&c[k]<=b[j]) k++;
		ans+=(ll)i*(n-k+1);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var c = cin.next();
            var vowel = new string[] { "a", "i", "u", "e", "o" };
            Console.WriteLine(vowel.Contains(c)? "vowel" : "consonant");
        }
    }

    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 int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            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 long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            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;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll A,B;
	cin>>A>>B;
    ll min_x = 10*B;
    ll ans = -1;
    rep(i,10){
        if(((min_x+i)*8)/100 == A){
            ans = min_x+i;
            break;
        }
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int a;
  cin >> a;
  cout << 800*a - 200*(a/15) << endl;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;
    vector<pii> a(m);
    for(int i = 0; i < m; ++i){
        cin >> a[i].first >> a[i].second;
        --a[i].first;
        --a[i].second;
    }
    vector<ll> ans(m+1, (ll)n * (n-1) / 2);
    UnionFind uf(n);
    for(int i = m - 1; i >= 0; --i){
        if(i != m-1) ans[i] = ans[i+1];
        if(!uf.findSet(a[i].first, a[i].second)) ans[i] -= (ll)uf.size(a[i].first) * uf.size(a[i].second);
        uf.unionSet(a[i].first, a[i].second);
    }
    for(int i = 1; i <= m; ++i){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3328
N = int(input())
if N<2:
    print(1)
elif N>=2 and  N<4:
    print(2)
elif N >=4 and N<8:
    print(4)
elif N>=8 and N<16:
    print(8)
elif N>=16 and N<32:
    print(16)
elif N>=32 and N<64:
    print(32)
elif N>= 64:
    print(64)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] a){
    	Scanner scanner = new Scanner(System.in);
    	
    	int length = Integer.parseInt(scanner.nextLine());
    	String numbers = scanner.nextLine();
    	String[] numberArray = numbers.split(" ",0); 
    	String sortValue;
		System.out.println(Arrays.toString(numberArray).replace(",","").replace("[","").replace("]",""));
		
    	for (int i = 1;i < length; i++) {
    		sortValue = numberArray[i];
    		for (int j = 0; j <= i - 1; j++) {
    			if (Integer.parseInt(sortValue) < Integer.parseInt(numberArray[j])) {
    				for (int k = 0; k <= i-j-1; k++) {
        				numberArray[i-k] = numberArray[i-k-1];
    				}
    				numberArray[j] = sortValue;
    		    break;
    			}
    		}
			System.out.println(Arrays.toString(numberArray).replace(",","").replace("[","").replace("]",""));
    		
    	}
    }
}

Measured memory_bytes: 31804
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<LL> a(X);

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

	vector<LL> b(Y);

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

	vector<LL> c(Z);

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

	vector<LL> tb;

	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			tb.push_back(a[i] + b[j]);
		}
	}

	sort(tb.rbegin(), tb.rend());

	vector<LL> ans;

	LL L = min((LL)tb.size(), K);

	for (int i = 0; i < L; i++) {
			for (int j = 0; j < Z; j++) {
				ans.push_back(tb[i] + c[j]);
			}
	}

	sort(ans.rbegin(), ans.rend());

	for (int i = 0; i < K; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 43368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll A,B;
  cin>>A>>B;
  if(A!=1 && B!=1){cout<<A*B/2+A*B%2<<endl;}
  else{cout<<1<<endl;}
}

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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

/*
*	verified : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4713284#1
*	last revised : 29.July.2020 
 */
template<class T> class BIT {
private:
	int n;
	vector<T> dat;//[1,n]
public:
	BIT(int maxn, int _n) {
		dat.assign(maxn + 1, 0);
		n = _n;
	}
	T sum(int i) {
		T res = 0;
		while (i > 0) {
			res += dat[i];
			i -= i & -i;
		}
		return res;
	}
	void add(int i, T x) {
		while (i <= n) {
			dat[i] += x;
			i += i & -i;
		}
	}
};
#define maxn 500050
#define F first
#define S second
struct range{
  int l,r,id;
  range(){}
  range(int l,int r,int id):l(l),r(r),id(id){}
};
bool comp(range& a,range& b){
  return a.r < b.r;
}
int main(){
  cin.tie(0);ios::sync_with_stdio(false);  
  int N,Q;cin >> N >> Q;
  vector<int> c(N+1);
  for(int i=1;i<=N;i++)cin>>c[i];
  vector<range> a(Q);
  for(int i=0;i<Q;i++){
    int l,r;cin >> l >> r;
    a[i] = range(l,r,i);
  }
  sort(a.begin(),a.end(),comp);
  BIT<int> bit(maxn,maxn);
  vector<int> good(maxn,0);
  vector<int> ans(Q,0);
  int i = 0,j = 1;
  for(;i < Q;i++){
    for(;j <= a[i].r;j++){
      if(good[c[j]] == 0){
        bit.add(j,1);
      }else{
        bit.add(good[c[j]],-1);
        bit.add(j,1);
      }
      good[c[j]] = j;
    }
    if(a[i].l == 1) ans[a[i].id] = bit.sum(a[i].r);
    else ans[a[i].id] = bit.sum(a[i].r) - bit.sum(a[i].l-1);
  }
  for(int i=0;i<Q;i++)cout << ans[i] << '\n';
}


Measured memory_bytes: 17480
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    string a[200000];
    for(int i = 0; i < N; i++) cin >> a[i];
    set<string> b;
    for(int i = 0; i < N; i++) b.insert(a[i]);
    cout << b.size() << endl;
    return 0;
}

Measured memory_bytes: 25412
n = int(input())
a = tuple(map(int, input().split()))

memo = tuple([None] * n for _ in range(n))
for i, aa in enumerate(a):
    memo[i][i] = aa

for l in range(n - 1, -1, -1):
    for r in range(l, n):
        if memo[l][r] is None:
            memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r])

print(memo[0][n - 1])


Measured memory_bytes: 164616
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int arr[60];
int n, p;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].second >> v[i].first;
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += v[i].second;
		if (sum > v[i].first)
			return cout << "No\n", 0;
	}
	cout << "Yes\n";
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
int main(){
	int K=38;
	printf("%d %d\n",K*(K-1)+1,K);
	for(int i=1;i<=K;++i)printf("%d%c",i," \n"[i==K]);
	for(int j=0;j<K-1;++j){
		printf("1");
		for(int k=0;k<K-1;++k)
			printf(" %d",K+1+j*(K-1)+k);
		puts("");
	}
	for(int i=0;i<K-1;++i)
		for(int j=0;j<K-1;++j){
			printf("%d",2+i);
			for(int k=0;k<K-1;++k)
				printf(" %d",K+1+k*(K-1)+(k*i+j)%(K-1));
			puts("");
		}
}


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

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
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll a[100005],b[100005];
int q[100005];

int main() {
  int n,s;
  scanf("%d%d",&n,&s);
  int id=0;
  for(int i=1;i<=n;i++) {
  	scanf("%lld%lld",&a[i],&b[i]);
  	if (a[i]<s) id=i;
  }
  int cnt=0,l=1,r=n;
  while ((l<=id)^(r<=id))
    if (b[l]>=b[r]) {
    	q[++cnt]=a[r];
    	b[l]+=b[r];
    	r--;
	}
	else {
		q[++cnt]=a[l];
		b[r]+=b[l];
		l++;
	}
  if (r<=id) {
  	for(int i=l;i<=r;i++) q[++cnt]=a[i];
  }
  else {
  	for(int i=r;i>=l;i--) q[++cnt]=a[i];
  }
  q[cnt+1]=s;
  ll ans=0;
  for(int i=1;i<=cnt;i++) ans+=abs(q[i]-q[i+1]);
  printf("%lld\n",ans);
  return 0;
}

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

#define endl '\n'
#define ll long long

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	set<string> st;
	int n;
	string s;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> s;
		st.insert(s);
	}

	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 19204
#!ruby -na00F\n
x=$F.find_index{|r|$y=r.index ?1}
n=[[[1,0],[1,1],[0,1]],[[1,0],[2,0],[3,0]],[[0,1],[0,2],[0,3]],[[1,0],[1,-1],[2,-1]],[[1,1],[1,2],[0,1]],[[1,0],[1,1],[2,1]],[[1,0],[0,1],[1,-1]]].find_index{|c|c.all?{|i,j|($F[x+i]&&$F[x+i][$y+j])==?1}}
puts [*?A..?G][n]

Measured memory_bytes: 6116
n,m = gets.split(" ").map!{|i| i.to_i}
x = gets.split(" ").map!{|j| j.to_i}
  x.sort!
  y= []
(m-1).times do |k|
  a = (x[k] - x[k+1]).abs
  y.push(a)
end
y.sort!
min = 0
(m-n).times do |l|
  min += y[l]
end
if n >= m 
  puts 0 
else
puts min
end

  

Measured memory_bytes: 9328
n,m=map(int,input().split())
A = [list(input()) for i in range(n)]
B = [list(input()) for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = True
    for k in range(m):
      if A[k+j][i:i+m] != B[k][:]:
        flag = False
        break
    if flag:
      print("Yes")
      quit()
else:
  print("No")

Measured memory_bytes: 9008
#選択ソート
def selectionSort(A,N):
    #入れ替え回数カウンター
    count = 0
    for i in range(N):
        #iを基準値とする
        minj = i
        
        for j in range(i,N,1):
            #数列の中からもっとも小さい数値のindexをminjとする
            if A[j] < A[minj]:
                minj = j
                
        #入れ替え(minjとiが異なる場合)
        if minj != i:
            count = count + 1
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
    print(' '.join(map(str,A)))
    print(count)
    
N = int(input())
A = list(map(int,input().split()))   
selectionSort(A,N)


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

using namespace std;
const int maxn = 1e5+10;

int n;
int niz[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", niz+i);

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += 1 - (niz[i] % 2);
    }

    if (cnt == n) printf("First\n");
    else if (cnt % 2 == 1) printf("First\n");
    else {
        if (n - cnt > 1) printf("Second\n");
        else {
            bool turn = true;
            int maxi = *max_element(niz, niz+n);
            while (maxi > 1) {
                int ind = -1;
                for (int i = 0; i < n; i++)
                    if (niz[i] % 2 == 1 && niz[i] > 1) ind = i;

                if (ind == -1) break;
                niz[ind]--;

                int gc = niz[0];
                for (int i = 1; i < n; i++)
                    gc = __gcd(gc, niz[i]);

                maxi = -1;
                int cnt = 0;
                for (int i = 0; i < n; i++) {
                    niz[i] /= gc, maxi = max(maxi, niz[i]);
                    cnt += 1 - (niz[i] % 2);
                }
                if (cnt % 2 == 1) break;
                else if (n - cnt > 1) {
                    turn = !turn;
                    break;
                }
                turn = !turn;
            }

            if (turn) printf("Second\n");
            else printf("First\n");
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    double pi = 3.1415926535;
    double R;
    cin >> R;
    cout << 2 * R * pi << endl;
    return 0;
}


Measured memory_bytes: 3788
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            if (X >= 1800) return 1;
            if (X >= 1600) return 2;
            if (X >= 1400) return 3;
            if (X >= 1200) return 4;
            if (X >= 1000) return 5;
            if (X >= 800) return 6;
            if (X >= 600) return 7;

            return 8;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27544
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

int x[55],y[55];
//int num[ten6];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<long l ong int> pq;
    vector<pair<ll,ll>> vint;
    map<pair<ll,ll>,ll> mp;
    //list<int> li;
    //map<string,int>::iterator iter;
    //set<int> sint;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a1>>a2;
        x[i]=a1;y[i]=a2;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j) continue;
            a1=x[i]-x[j];a2=y[i]-y[j];
            mp[make_pair(a1,a2)]++;
        }
    }
    for(auto au:mp)
    {
        sum=max(sum,au.second);
    }
    cout<<n-sum;
    return 0;
}



Measured memory_bytes: 384
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

// gp_hash_table<int, int> table;

const int N = 2e5 + 5;

bool arr[N];

int LIS(const vector<int>& v) {
  multiset<int> s; // multiset if there are duplicates
  for (int x : v) {
    auto it = s.upper_bound(x); // lower_bound for strictly increasing
    if (it != s.end()) s.erase(it);
    s.insert(x);
  }
  return s.size();
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;

  vector <int> vec(n);

  for (int& x : vec) {
    cin >> x;
    x *= -1;
  }

  cout << LIS(vec) << endl;


}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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 << ' ';
  }
  return s;
}

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];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  vector<int> div = divisor(N);
  int ans = 0;
  for (int temp : div) {
    int q = N / temp;
    int m = temp - 1;
    if (m <= q)
      continue;
    ans += m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int div2(int x) {
  if (x % 2 == 1) return 0;
  else return div2(x / 2) + 1;
}

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = INF;
  rep(i,n) ans = min(ans, div2(v[i]));
  cout << ans << endl;
}

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

Measured memory_bytes: 3600
K, N = map(int, input().split())
liked_num = [0,1,2,3,4,5,6,7,8,9]
disliked_num = list(map(int, input().split()))
for s in disliked_num:
    liked_num.remove(s)
cnt = K
flag = 1
while flag:
    not_n = 1
    for i in str(cnt):
        if not int(i) in liked_num:
            not_n = 0
            break
    if not_n:
        break
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int n[1006]={0},m[1006]={0};
	int k=0,i,N,M;
	for(;;k=0){
		scanf("%d%d",&N,&M);
		if(M==0&&M==0)break;
		for(i=0;i<N;i++){
			scanf("%d",&n[i]);
		}
		for(i=0;i<M;i++){
			scanf("%d",&m[i]);
		}
		for(i=0;;i++){
			k+=m[i];
			k+=n[k];
			if(k>=N-1)break;
		}
			
		printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

int main()
{
    rep(i,9)rep(j,9) cout << i+1 << "x" << j + 1 << "=" << (i+1)*(j+1) << endl;
    return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{ int n ;
	cin>>n;
	vector <vector<int>> arr;
	REP(i,n)
	{
		int a,b,c;
		cin>>a>>b>>c;
		// vector <int> temp;
		arr.push_back({a,b,c});

	}
	vector <vector <int>> dp(n,(vector<int>(3,0)));
	dp[0] = arr[0];
	FOR(i,1,n-1)
	{
		dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = arr[i][2] + max(dp[i-1][1],dp[i-1][0]);

	}
	int m = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	cout<<m;
	return 0;
	
}

Measured memory_bytes: 11440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }

        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        }

        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

    }

    public static void main(String[] args) {
        
        FastReader fs = new FastReader();
        int n = fs.nextInt();

        int[][] activities = new int[3][n];

        int[][] dp = new int[3][n];

        
        for (int j = 0; j < n; j++) {
            for (int i = 0; i < 3; i++) {
                activities[i][j] = fs.nextInt();
            }
        }

        dp[0][n-1] = activities[0][n-1];
        dp[1][n-1] = activities[1][n-1];
        dp[2][n-1] = activities[2][n-1];

        for (int j = n-2; j >= 0; j--) {
            // Choose the ith activity on this day...
            for (int i = 0; i < 3; ++i) {
                int currHappiness = activities[i][j];
                int maxHappinessTillTomorrow = Integer.MIN_VALUE;
                for (int k = 0; k < 3; k++) {
                    if (i != k) {
                        maxHappinessTillTomorrow = Math.max(maxHappinessTillTomorrow, dp[k][j+1]);
                    }
                }
                dp[i][j] = currHappiness + maxHappinessTillTomorrow;
            }
        }

        System.out.println(Math.max(dp[0][0], Math.max(dp[1][0], dp[2][0])));

    }


}

Measured memory_bytes: 56676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> ary;
    rep(i,m)
    {
        int tmp;
        cin >> tmp;
        ary.push_back(tmp);
    }
    auto iter = lower_bound(ary.begin(), ary.end(), x);
    cout << min(iter - ary.begin(),  m-(iter - ary.begin()))  << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int x;
  cin >> x;
  cout << 10-(x/200) << endl;
}

Measured memory_bytes: 3632
q,h,s,d=map(int,input().split())
n=int(input())
cospa=[[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
cospa.sort()
money=0
for i in range(4):
  if(n>=cospa[i][1]):
    x=int(n//cospa[i][1])
    money+=int(x*cospa[i][2])
    n%=cospa[i][1]
print(int(money))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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


int main() {

  long  N,i,j,tmp,tmp2;
  cin >> N;
  vector<int> V(N);
  for(i=0;i<N;i++){
    cin >>V[i];
  }
  sort(V.begin(),V.end());
  tmp=V[0];
  while(1){
  for(i=0;i<N;i++){
    if(V[i]%V[0]==0){
      V[i]=V[0];
    }else{
      V[i]=V[i]%V[0];
    }
  }
  sort(V.begin(),V.end());
  if(V[0]==tmp){
    break;
  }else{
    tmp=V[0];
  }
  }
  cout <<V[0] <<endl;
  return 0;
   
}


Measured memory_bytes: 640
a, op, b = input().split()
a = int(a)
b = int(b)

while op != "?":
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)

    a, op, b = input().split()
    a = int(a)
    b = int(b)



Measured memory_bytes: 5596
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

std::vector<int> v;
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d", &x);
        x -= i;
        v.push_back(x);
    }
    std::sort(v.begin(), v.end());
    int m = v[(n-1)/2];
    long long int ans = 0;
    for(int i=0;i<n;i++) ans += abs(v[i]-m);

    printf("%lld", ans);
}

Measured memory_bytes: 1400
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int A[100000];
int main(){
  int KL2GvlyY, i, j, k;
  long long res=4611686016279904256LL, s, tmp;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(KL2GvlyY=0;KL2GvlyY<(2);KL2GvlyY++){
    s = tmp = 0;
    for(i=0;i<(N);i++){
      s += A[i];
      if(i%2==0 && s <= 0){
        tmp += 1 - s;
        s = 1;
      }
      if(i%2==1 && s >= 0){
        tmp += 1 + s;
        s = -1;
      }
    }
    chmin(res, tmp);
    for(i=0;i<(N);i++){
      A[i] = -A[i];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190829-1

// --- original code ---
// int N, A[1d5];
// {
//   int i, j, k;
//   ll res = ll_inf, tmp, s;
// 
//   rd(N,A(N));
//   rep(2){
//     s = tmp = 0;
//     rep(i,N){
//       s += A[i];
//       if(i%2==0 && s <= 0) tmp += 1 - s, s = 1;
//       if(i%2==1 && s >= 0) tmp += 1 + s, s = -1;
//     }
//     res <?= tmp;
//     rep(i,N) A[i] = -A[i];
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 640
n, m = map(int, input().split())
values = []

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values


for i in pfac(m):
    if m % i == 0 and m / i >= n:
        values.append(i)
print(max(values))


Measured memory_bytes: 3060
function main(){
  var debt = 100000;
 
  for(var i = 0; i < input.trim()-0; i++){
    debt = Math.ceil((debt * 1.05)/1000) * 1000;
  }

  console.log(debt);
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  //input = input.split('\n');
  main();
});

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)



void solve() {

    int k, count = 1, val = 7;
    cin >> k;

    val %= k;

    unordered_set<int> uset;
    uset.insert(val);

    while (val > 0) {
        count++;
        val = (val * 10 + 7 ) % k;
        if (uset.find(val) != uset.end()) {
            cout << "-1\n";
            return;
        }
        uset.insert(val);
    }

    cout << count << "\n";
    
 }

int main()
{
    fastio;
    // T
    solve();
    //code
    return 0;
}


Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin>>n;
  long long t; cin>>t;
  int tmp,b_0,b_1,e_0,e_1;
  long long ans = t;
  b_0 = 0;
  e_0 = t;
  for (int i=0;i<n;i++) {
    cin >> tmp;
    b_1 = tmp;
    e_1 = tmp + t;
    if (b_1 < e_0) ans -= e_0 - b_1;
    ans += t;
    b_0 = b_1;
    e_0 = e_1;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

H, W, N = map(int, input().split())
dic = defaultdict(int)
dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dy = [1, 1, 1, 0, 0, 0, -1, -1, -1]
for i in range(N):
    y, x = map(int, input().split())
    for j in range(9):
        ny, nx = y+dy[j], x+dx[j]
        if not 1 < ny < H: continue
        if not 1 < nx < W: continue
        dic[str(ny)+":"+str(nx)] += 1
count = [0]*10
tot = (H-3+1)*(W-3+1)
count[0] = tot-len(dic.keys())
for k,v in dic.items():
    count[v] += 1
for c in count:
    print(c)


Measured memory_bytes: 127136
# input here
_INPUT = """\
123456789
"""

def main():
    n = [int(i) for i in input()]

    if (sum(n)%9 == 0):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 75640
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> key(m);
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		int s = 0;
		rep(j, b)
		{
			int c;
			cin >> c;
			c--;
			s |= (1 << c);
		}
		key[i] = pair<int, int>(a, s);
	}
	vector<ll> dp(1 << n, Inf);
	dp[0] = 0;
	rep(i,(1<<n)){
		rep(j,m){
			dp[i | key[j].second] = min(dp[i | key[j].second], dp[i] + key[j].first);
		}
	}
	if (dp[(1 << n) - 1] == Inf)
		cout << -1 << endl;
	else
		cout << dp[(1 << n) - 1] << endl;


	return 0;
}

Measured memory_bytes: 384
using System;

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[] panel1 = new int[n];
			string[] line = Console.ReadLine().Split(' ');
			int prev = 0;
			for (int j = 0; j < n; j++)
			{
				int v = int.Parse(line[j]) + prev;
				panel1[j] = v;
				prev = v;
			}

			int[] panel2 = new int[n];
			line = Console.ReadLine().Split(' ');
			prev = 0;
			for (int j = n - 1; j >= 0; j--)
			{
				int v = int.Parse(line[j]) + prev;
				panel2[j] = v;
				prev = v;
			}


			int ans = 0;

			for (int i = 0; i < n; i++)
			{
				ans = Math.Max(ans, panel1[i] + panel2[i]);
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 27492