akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>
 
using namespace std;
 
typedef long long LL;
 
const int N = 1<<13;
const int M = 200 + 5;
const int INF = 1000000000 + 5;
 
int n, m;
int x[N];
int a[M];
LL tag[N << 1];
LL maxv[N << 1];
vector<pair<int, int> > st[M];
 
void push(int x) {
    if (tag[x]) {
        tag[2*x] += tag[x];
        maxv[2*x] += tag[x];
        tag[2*x+1] += tag[x];
        maxv[2*x+1] += tag[x];
        tag[x] = 0;
    }
}
 
void modify(int t, int l, int r, int a, int b, LL v)
{
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
        tag[t] += v;
        maxv[t] += v;
        return;
    }
    push(t);
    int mid = (l + r) >> 1;
    modify(t << 1, l, mid, a, b, v);
    modify(t << 1 | 1, mid + 1, r, a, b, v);
    maxv[t] = max(maxv[t << 1], maxv[t << 1 | 1]);
}
 
LL query(int t, int l, int r, int a, int b)
{
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) {
        return maxv[t];
    }
    push(t);
    int mid = (l + r) >> 1;
    return max(query(t << 1, l, mid, a, b), query(t << 1 | 1, mid + 1, r, a, b));
}
 
void solve()
{
    cin >> n >> m;
    for(int i = 0; i < n - 1; ++ i) {
        scanf("%d", x + i);
    }
 
    long long ans = 0;
    for(int j = 0; j < m; ++ j) {
        st[j].push_back(make_pair(INF, -1));
    }
 
    for(int i = 0; i < n; ++ i) {
        long long tmp = 0;
        for(int j = 0; j < m; ++ j) {
            scanf("%d", a + j);
        }
 
        for(int j = 0; j < m; ++ j) {
            while (a[j] >= st[j].back().first) {
                int r = st[j].back().second;
                int v = st[j].back().first;
                st[j].pop_back();
                int l = st[j].back().second + 1;
                modify(1, 0, n - 1, l, r, -v);
            }
            modify(1, 0, n - 1, st[j].back().second + 1, i, a[j]);
            st[j].push_back(make_pair(a[j], i));
        }
 
        if (i > 0) {
            modify(1, 0, n - 1, 0, i - 1, -x[i - 1]);
        }
        ans = max(ans, query(1, 0, n - 1, 0, i));
    }
    cout << ans << endl;
}
 
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>

using namespace std;





int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);


    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> c = v;
    sort(c.begin(), c.end());
    int count = 0;
    for (int j = 0; j < n; ++j) {
        if (v[j] != c[j]){
            count++;
        }
    }
    cout << (count <= 2 ? "YES" : "NO");

    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> l, vector<ll> r) {
  ll res = 0;
  REP(i,N) res += r[i] - l[i] + 1;
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> r(N-1+1);
	vector<ll> l(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &l[i]);
	  scanf("%lld", &r[i]);
	}
	solve(N, l, r);
	return 0;
}


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


int main(void){
  int n,i,l[15],s=0;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> l[i];
  
  sort(l,l+n);
  
  for (i=0;i<n-1;i++) s+=l[i];
  
  if (s>l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int a, b;
	
	std::cin >> a >> b;
	
	if(a==b) {
		std::cout << "a == b" << std::endl;
	} else if(a>b) {
		std::cout << "a > b" << std::endl;
	} else {
		std::cout << "a < b" << std::endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

int n, T;
P a[3300];
int dp[3300][3300];

void solve()
{
	cin >> n >> T;
	REP(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);

	for (int i = 0; i < n; i++) {
		for (int t = 0; t < T; t++) {
			dp[i + 1][t] = max(dp[i + 1][t], dp[i][t]);
			if (t - a[i].first >= 0) dp[i + 1][t] = max(dp[i + 1][t], dp[i][t - a[i].first] + a[i].second);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[i][T - 1] + a[i].second);
	}

	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


Measured memory_bytes: 42356
//E
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
const int mod = 1e9+7;
ll Pow(ll x,ll d){
	ll tmp = 1;
	if(!d)return 1;
	ll a = Pow(x,d/2);
	tmp = a*a%mod;
	if(d%2)tmp = tmp*x%mod;
	return tmp;
}
ll f[maxn];
int main(){
	ll ans = 0;
	int n,k;
	cin >> n >> k;
	for(int i = k;i >= 1;i--){
		ll x = k/i;
		f[i] = Pow(x,n);	
		for(int j = i+i;j <= k;j+=i)f[i] = (f[i] - f[j] + mod)%mod;
		ans = (ans + f[i]*i)%mod;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll inf = 1ll<<50;
const int maxN = 110;
const int maxM = 10010;
const int INF = 1000000009;
const int M = 10000;
const int MaxN=1000010;
int tot=0;
int n,m,S,T;
ll a[4];
int main()
{
	ll sum = 0;
	ll ma = -INF;
	for(int i=1;i<=3;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
		if(a[i] > ma)
			ma = a[i];
	}
	a[0] = ma;
	ll k;
	scanf("%lld",&k);
	ma = ma * (1<<k);
	sum = sum - a[0] + ma;
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

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<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    string a,b;
    cin>>a;
    while(b.size() < a.size()){
    	b += "hi";
	}
	if(a == b)cout << "Yes" << endl;
	else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, h[30];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];
    
    int x = h[0], ans = 1;
    for (int i = 1; i < n; i++) {
        if (x <= h[i]) {
            ans++;  x = h[i];
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		x: [usize; n],
	}

	// N個のうち、真ん中の2個をa,bとする(a<b)
	let mut mx = x.clone();
	mx.sort();
	let a = mx[n/2-1];
	let b = mx[n/2];

	for i in 0..n {
		if x[i] <= a {
			println!("{}", b);
		}
		else {
			println!("{}", a);
		}
	}
}



Measured memory_bytes: 7792
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using int64 = long long;

void solve(long long A, long long B, long long N) {
  auto x = min<int64>(B - 1, N);
  int64 y = (A * x) / B - A * (x / B);
  cout << y << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  solve(A, B, N);
}


Measured memory_bytes: 3648
n=int(input())
if n==1:
    print('Yes')
    print(2)
    print(1,1)
    print(1,1)
    exit()
if n==2:
    print('No')
    exit() 
a=[[1]]
i=1
for j in range(1,n):
    a.append(list(range(i,i+j)))
    if n==i+j-1:
        break
    elif i+j>n:
        print('No')
        exit()
    i+=j
print('Yes')
m=len(a)
for i in range(m-1):
    for j in range(i+1+(i<1),m):
        a[i].append(a[j][i])
print(m)
for b in a:
    print(len(b),*b)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll st[8*100005];
ll h[8*100005],w[8*100005];
ll query(ll in,ll l,ll r,ll ql,ll qr){
	if(l>r || ql>qr || ql>r || qr<l)
	  return 0;
	  if(ql<=l && qr>=r)
	   return st[in];
	  ll mid=(l+r)/2;
	  return max(query(2*in,l,mid,ql,qr),
	              query(2*in+1,mid+1,r,ql,qr));
}

void update(ll in,ll l,ll r,ll idx,ll val){
	if(l==r){
		st[in]=val;
		return;
	}
	ll mid=(l+r)/2;
	if(l<=idx && idx<=mid){
		update(2*in,l,mid,idx,val);
	}
	else{
		update(2*in+1,mid+1,r,idx,val);
	}
	st[in]=max(st[2*in],st[2*in+1]);
}

int main() {
	ll n,i;
	ll f[8*100005];
	cin>>n;
	for(i=1;i<=n;i++)cin>>h[i];
	for(i=1;i<=n;i++)cin>>w[i];
	ll maxi=0;
	for(i=1;i<=n;i++){
		f[i]=query(1,1,n,1,h[i]-1)+w[i];
		maxi=max(maxi,f[i]);
		update(1,1,n,h[i],f[i]);
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 9984
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int n,x;ll ans,mx1=0,mx2=0;map<ll,int>mp;
void solve(ll x){
	if(mx1<x)swap(mx1,x);
	if(mx2<x)swap(mx2,x);
}
int main(){
	for(scanf("%d",&n);n--;)scanf("%d",&x),mp[x]++;
	for(auto&x:mp){
		if(x.second>=4){
			ans=max(ans,x.first*x.first);
		}
		if(x.second>=2)solve(x.first);
	}
	ans=max(ans,mx1*mx2);
	printf("%lld\n",ans);
} 

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;

void MAIN() {
    scanf("%d", &N);

    int Z;
    if (N % 2) {
	Z = N;
    } else {
	Z = N+1;
    }

    vector<pair<int, int> > ans;
    REP (i, N) REP (j, i) {
	if (i+j+2 != Z) ans.emplace_back(i+1, j+1);
    }
    printf("%d\n", (int)ans.size());
    EACH (e, ans) printf("%d %d\n", e->first, e->second);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
s = input()
n = int(input())
a = "*"
spin = 1

for i in range(n):
    q = input()
    if q[0] == "1":
        spin *= -1
        a = a[::-1]
    else:
        if q[2] == "1":
            a = q[4] + a
        else:
            a = a + q[4]
            
    if len(a) == 100:
        s = a[:a.index("*")] + s[::spin] + a[a.index("*")+1:]
        a = "*"
        spin = 1
            
print(a[:a.index("*")] + s[::spin] + a[a.index("*")+1:])

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  double l;
  cin >> l;
  l /= 3;
  cout << std::fixed << std::setprecision(10) << l * l * l << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ccc = list(map(int, input().split()))
acc = 0
for j in range(N - 1):
    i = aaa[j] - 1
    acc += bbb[i]
    if aaa[j] + 1 == aaa[j + 1]:
        acc += ccc[i]
else:
    acc += bbb[aaa[-1] - 1]
print(acc)


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

int check(string S, int N) {
  int b3 = 0, b5 = 0, b7 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '3') b3 = 1;
    if (S[i] == '5') b5 = 1;
    if (S[i] == '7') b7 = 1;
    if (b3 && b5 && b7) return 1;
  }
  return 0;
}

int f(string S, int N, int acc) {
  if (S.size() < 3 || stol(S) <= N) {
    acc += check(S, N);
    acc += f("3" + S, N, 0);
    acc += f("5" + S, N, 0);
    acc += f("7" + S, N, 0);
  }
  return acc;
}

int main() {
  int N;
  cin >> N;
  cout << f("", N, 0) << endl;
}

Measured memory_bytes: 256
n=int(input())
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
rem=(a%n)
left=n-rem
if b>=(left+a) :
    print("OK")
elif a%n ==0 or b%n==0:
    print("OK")
else :
    print("NG")

Measured memory_bytes: 9180
N=int(input())
s=[list(map(int,input().split())) for i in range(N)]
ans=N
for i in range(N):
    for j in range(i):
        cnt=N
        p=s[i][0]-s[j][0]
        q=s[i][1]-s[j][1]
        for k in range(N):
            if [s[k][0]+p,s[k][1]+q] in s:
                cnt-=1
        ans=min(ans,cnt)

print(ans)


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

int main() {
  long n,m,a,b,ans=0;
  cin >> n >> m;
  vector<vector<int>> vec(m,vector<int>());
  priority_queue<int> q;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a<=m)vec.at(a-1).push_back(b);
  };
  for(int i=0;i<m;i++) {
    for(int j=0;j<vec.at(i).size();j++) {
      q.push(vec.at(i).at(j));
    };
    if(!(q.empty())) {
      ans+=q.top();
      q.pop();
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 5504
ope = list(input().split())
stack = list()

for i in ope:
    if i == '+':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(b + a)
    elif i == '-':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(b - a)
    elif i == '*':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(b * a)
    else:
        stack.append(int(i))

print(stack[0])



Measured memory_bytes: 5596
import random
import time
import numpy as np

def search(day, c, s):
    schedule = []
    satisfy = []
    score = 0
    date = [0] * 26
    
    for d in range(day):
        tmp = 0
        contest = 0
        nmax = -float('inf')
        for i in range(26):
            tmp += c[i] * (d + 1 - date[i])
        for i in range(26):
            tmp2 = s[d][i] - tmp + c[i] * (d + 1 - date[i])
            if nmax < tmp2:
                nmax = tmp2
                contest = i
        
        satisfy.append(tmp - c[contest] * (d + 1 - date[contest]))
        date[contest] = d + 1
        schedule.append(contest)
        score += s[d][contest] - satisfy[d]

    return score, schedule, satisfy

def change(day, contest,D, c, s, schedule, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(D):
        if d == day:
            now = contest + 1
            date[now - 1] = d + 1
        else:
            now = schedule[d] + 1
            date[now - 1] = d + 1
        if d < day:
            ret += satisfy[d]
            continue

        tmp = 0
        for i in range(26):
            tmp += c[i] * (d+1 - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    ans, schedule, dissatisfy = search(D, c, s)
    
    for i in range(D):
        score += s[i][schedule[i]]

    while time.time() - start < 1.85:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        if schedule[day] == contest:
            continue

        save = dissatisfy.copy()
        dec2 = change(day,contest,D,c, s, schedule, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec2:
            ans = score2 - dec2
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save

    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()

Measured memory_bytes: 27292
import sys

N = int(input())
As = [int(sys.stdin.readline()) for _ in range(2**N)]

for _ in range(N):
    winners = []
    for A1, A2 in zip(As[::2], As[1::2]):
        if A1 != A2:
            winners.append(abs(A1-A2))
        else:
            winners.append(A1)
    As = winners

print(As[0])


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

int main() {
	int N;
	cin >> N;
	vector<long> H(N);
	for (long& i : H) cin >> i;
	int right = 0;
	int ans = 0;
	for (int left = 0; left < N - 1; ++left) {
		while (right < N - 1 && H[right] >= H[1 + right]) {
			++right;
		}
		ans = max(ans, right - left);
		if (right == left) ++right;
	}
	cout << ans;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();

			if (n == 1) {
				Console.WriteLine(1);
				return;
			}

			var map = new Dictionary<long, long>();
			int m = n;
			for (int i = 2; i <= n; i++) {
				var factors = GetPrimeFactors(i);
				foreach (var key in factors.Keys) {
					if (map.ContainsKey(key) == false) {
						map[key] = factors[key];
					} else {
						map[key] += factors[key]; ;
					}
				}
			}

			long ans = 1;
			foreach (var key in map.Keys) {
				ans = (ans * (map[key] + 1)) % MOD;
			}

			Console.WriteLine(ans);
		}

		public static Dictionary<long, long> GetPrimeFactors(long value)
		{
			var factors = new Dictionary<long, long>();
			for (int i = 2; i <= value; ++i) {
				while (value % i == 0) {
					if (factors.ContainsKey(i) == false) {
						factors[i] = 1;
					} else {
						factors[i] += 1;
					}

					value /= i;
				}
			}

			return factors;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			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] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			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] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			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] = Double() + 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)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[]) {
	char b; cin >> b;
	if ('A' == b) cout << 'T' << endl;
	if ('T' == b) cout << 'A' << endl;
	if ('C' == b) cout << 'G' << endl;
	if ('G' == b) cout << 'C' << endl;
	return 0;
}

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

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

    int i;
    long long sum = 0;
    for(i = 1; i <= N; i++) {
        if(i%3 != 0 && i%5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int main() {
    int D, G, P[11], C[11];
    cin >> D >> G;
    for(int i=0; i<D; i++) {
        cin >> P[i] >> C[i];
    } 
 
    int ans = 1e9;
    for(int i=0; i<(1<<D); i++) {
        int s = 0, num = 0, max = -1;
        for(int j=0; j<D; j++) {
            if( (i>>j) &1) {
                s += P[j] * 100 * (j+1) + C[j];
                num += P[j];
            } else {
                max = j;
            }
        }
 
        if(s<G) {
            int s1 = (max + 1) * 100;
            int shortage = (G - s + s1 -1) / s1;
            if(shortage >= P[max]) {
                continue;
            }
            num += shortage;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

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

using namespace std;

int h,w;
int used[21][21];
int mn=0;

void dfs(int cur,int num){
	if(cur==h*w){
		mn++;
		return;
	}
	int curh=cur/w;
	int curw=cur%w;
	if(used[curh][curw]!=-1){
		dfs(cur+1,num);
		return;
	}
	// ツ可。ツづ可静敖置
	if(curw+1<w&&used[curh][curw+1]==-1){
		if(!(curw+2<w&&curh>=1&&used[curh-1][curw+1]!=used[curh-1][curw+2]&&used[curh][curw+2]==-1)){
			used[curh][curw]=num;
			used[curh][curw+1]=num;
			dfs(cur+1,num+1);
			used[curh][curw]=-1;
			used[curh][curw+1]=-1;
		}
	}
	// ツ縦ツづ可静敖置
	if(curh+1<h&&used[curh+1][curw]==-1){
		if(!(curw+1<w&&curh>=1&&used[curh-1][curw+1]!=used[curh-1][curw]&&used[curh][curw+1]==-1)){
			used[curh][curw]=num;
			used[curh+1][curw]=num;
			dfs(cur+1,num+1);
			used[curh][curw]=-1;
			used[curh+1][curw]=-1;
		}
	}
}

int main(){

	while(cin>>h>>w&&(h|w)){
		mn=0;
		memset(used,-1,sizeof(used));
		dfs(0,0);
		cout<<mn<<endl;
	}

	return 0;
}

Measured memory_bytes: 876
#include<cstdio>
char s[1005];

int main(){
    long long n;
    scanf("%lld",&n);
    long long base = 1;
    long long cycle = 26;
    int size = 0;
    while(n>=base){
        long long pos = n-base;
        long long len = cycle/26;
        s[++size] = (pos/len)%26+'a';
        base = base + cycle;
        cycle *= 26;
    }
    for(int i = size; i >= 1; i--) printf("%c",s[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 1648
#include<stdio.h>
int A[2000001];
void CouSort(int n){
  int k=10000,i,j,B[2000001],C[10001];
  for(i=0;i<k;i++)
    C[i]=0;
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
  /* C[i]にはiの出現数が記録されている*/
  for(i=1;i<k;i++)
    C[i] = C[i] + C[i-1];
  /* C[i]にはi以下の数の出現数が記録されている*/
  for(j=n-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++)
    printf("%d ",B[i]);
  printf("%d\n",B[n]);
}

main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  CouSort(n);
  return 0;
}

Measured memory_bytes: 16264
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
int i,j,k,l;
int c=-1;
int main(void){
		int n,m;
			cin >> n >> m;
		int now=0;
		rep(i,0,n){
			int a;cin >> a;
			if(c!=-1)
				continue;
			now+=a;
			if(now>m)
				c=i+1;
		}
		if(c==-1)
			c=n+1;
		puts(c);
		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C && A == C) {
		cout << "No" << endl;
	}
	else if (A != B && B != C && A != C) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int lli;
    #define MAX 1001000
    #define MOD 1000000007
    #define endl "\n"
    lli arr[MAX];
    lli ans[MAX];
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        lli t;
        t = 1;
        while(t--){
            lli X;
            cin>>X;
            double t= 100;
            for(lli i = 1; i<=3760; i++){
                t = t*(1.01);
                t = floor(t);
                if(t>= X){
                    cout<<i<<endl;
                    break;
                }
            }
        }
    }

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi A(N), B(N);
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];
	vi plus;
	ll minus = 0;
	int ans = 0;
	REP(i, N) {
		if (A[i] - B[i] > 0) {
			plus.push_back(A[i] - B[i]);
		}
		else if (A[i] - B[i] < 0) {
			minus += (ll)(B[i] - A[i]);
			ans++;
		}
	}
	so(plus); rev(plus);

	int ind = 0;
	while (minus > 0) {
		if (ind >= SZ(plus))break;
		minus -= plus[ind];
		ans++;
		ind++;
	}
	if (minus <= 0)cout << ans << endl;
	else cout << -1 << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1652
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    Nd=set()
    for n in range(1,int(N**0.5)+1):
        if N%n==0:
            Nd.add(n)
            Nd.add(N//n)
    N1d=set()
    for n in range(1,int((N-1)**0.5)+1):
        if (N-1)%n==0:
            N1d.add(n)
            N1d.add((N-1)//n)
    for d in Nd:
        if d==1: continue
        n=N
        while n%d==0: n//=d
        if n%d==1: N1d.add(d)
    print(len(N1d)-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
string s;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0;
	cin >> n;
	vector<string> a;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		a.push_back(s);
	}
	for(int i = 1; i < n; ++i){
		string k = a[i];
		string j = a[i-1];
		if(k[0] != j[j.length()-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	set<string> a1;
	for(int i = 0; i < n; ++i){
		a1.insert(a[i]);
	}
	if(a1.size() != n){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;



    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
        
	public static void main (String[] args) throws java.lang.Exception { 
             Scanner sc = new Scanner(System.in);
                          
             int A = sc.nextInt();
             
             int B = sc.nextInt();
             
            if(A+B < 10){             
               System.out.println(A+B);
            }else{
               System.out.println("error");
            }
               
            
                
        }        
}
               

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int tot = 0;
    rep(i,n) tot += a[i];
    V<P> v(n);
    rep(i,n) {
        v[i] = make_pair(abs(tot-a[i]*n), i);
    }
    sort(all(v));
    cout << v[0].se << endl;
}


Measured memory_bytes: 3632
N,M = map(int,input().split())
sc_s = list(list(map(int,input().split())) for _ in range(M)) 
sc_s.sort()
answer = ['0']*N
def solve():
    for i in range(1,len(sc_s)):
        if sc_s[i][0] == sc_s[i-1][0] and sc_s[i][1] != sc_s[i-1][1]:
            return ['-1']
    for i in range(len(sc_s)):
        if sc_s[i] == [1,0] and N != 1:
            return ['-1']
        answer[sc_s[i][0]-1] = str(sc_s[i][1])
    if answer[0] == '0' and N != 1:
        answer[0] = '1'
    return answer

print(''.join(solve()))
    
        


Measured memory_bytes: 38384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w, k = map(int, readline().split())
a = [readline().rstrip().decode() for _ in range(h)]
cnt = 0
memo = 0
for aa in a:
    memo += 1
    low, high = -1, aa.find('#')
    if high == -1:
        continue
    ans = []
    while high != -1:
        cnt += 1
        ans += [cnt] * (high - low)
        low, high = high, aa.find('#', high + 1)
    ans += [cnt] * (w - low - 1)
    for i in range(memo):
        print(*ans)
    memo = 0
for i in range(memo):
    print(*ans)


Measured memory_bytes: 4176
#include <iostream>
using namespace std;
int main(void){
    
    int h1,h2;
    int k1,k2;
    int a,b,c,d;
    int hiroshi=0;
    int kenjiro=0;
    cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
    hiroshi=h1*a+h2*b+h1/10*c+h2/20*d;
    kenjiro=k1*a+k2*b+k1/10*c+k2/20*d;
    if(hiroshi>kenjiro){
        cout<<"hiroshi"<<endl;
    }
    else if(hiroshi==kenjiro){
        cout<<"even"<<endl;
    }
    else{
        cout<<"kenjiro"<<endl;
    }
}



Measured memory_bytes: 3088
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d",&a,&b);
    for(c=1;c<=3;c++){
        if((a*b*c)%2==1){
            printf("Yes\n");
            break;
        }
    }
    if(c==4){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys

t = 0
h = 0
for line in sys.stdin :
    line = list(map(int, line.split(',')))
    if line[2]**2 == line[0] ** 2 + line[1] ** 2 :
        t += 1
    elif line[0] == line[1] :
        h += 1
print(t)
print(h)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, m;

int bit[maxn];

void upd(int i, int x) {
    while (i<=m) {
	bit[i]+=x;
	i+=i&-i;
    }
}

int qry(int i) {
    int res=0;
    while (i>0) {
	res+=bit[i];
	i-=i&-i;
    }
    return res;
}

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

    cin>>n>>m;
    
    vector<pair<int,int>> v;

    for (int i=0; i<n; i++) {
	int l,r; cin>>l>>r;
	v.emplace_back(l,r);
    }


    sort(v.begin(), v.end(), [](pair<int,int> a, pair<int,int> b) {
	    return a.second-a.first < b.second-b.first;
	});


    for (int i=1,j=0; i<=m; i++) {
	
	while (j<n && v[j].second-v[j].first+1 < i) {
	    upd(v[j].first, 1);
	    upd(v[j].second+1, -1);
	    j++;
	}

	int res = n-j;//we will hit the larger intervals for sure
	for (int a=i; a<=m; a+=i) {
	    res += qry(a);
	}
	cout<<res<<"\n";
    }

 

    return 0;
}


Measured memory_bytes: 6384
#include<stdio.h>
#include<stdlib.h>
int main(void){
int n,l;
  scanf("%d%d",&n,&l);
  int a[n];
  for(int i=0;i<n;i++){
	a[i]=l+i;
  }
  int min=2000,sum=0,idx;
  for(int i=0;i<n;i++){
	if(abs(a[i])<abs(min)){
      min=a[i];
      idx=i;
    }
  	sum+=a[i];
       }
  //printf("%d %d\n",sum,a[idx]);
printf("%d",sum-a[idx]);
       return 0;
       }

Measured memory_bytes: 128
num = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0

for i in range(num):
        sum1 += abs(x[i] - y[i])
        sum2 += abs(x[i] - y[i]) ** 2
        sum3 += abs(x[i] - y[i]) ** 3
        if sum4 < abs(x[i] - y[i]):
                sum4 = abs(x[i] - y[i])

print("{:.5f}".format(sum1))
print("{:.5f}".format(pow(sum2, 1 / 2)))
print("{:.5f}".format(pow(sum3, 1 / 3)))
print("{:.5f}".format(sum4))


Measured memory_bytes: 5660
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll ans[N+1]={0};
    FORI(x,1,101)
    {
        FORI(y,1,101)
        {
            FORI(z,1,101)
            {
                ll n=x*x+y*y+z*z+x*y+y*z+z*x;
                if(n<=N)
                {
                    ans[n]++;
                }
            }
        }
    }
    FORI(i,1,N+1)
    {
        cout<<ans[i]<<endl;
    }

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3796
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
char s[105];
long long k;
int main() {
	scanf("%s",s+1);
	int len=strlen(s+1);
	scanf("%lld",&k);
	int i=1;
	for(;i<=len;i++)
		if(s[i]=='1'&&k>1) k--;
		else break;
	 putchar(s[i]);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int a[100000];

int main() {
    int n;
    cin >> n;
    rep(i, n)cin >> a[i];
    sort(a, a + n);
    int cur = a[0];
    int mn = cur;
    int pre = cur;
    while(1) {
        rep(i, n) {
            if (mn > a[i] % pre && a[i] % pre) {
                pre = a[i] % pre;
            }
        }
        if(cur == pre ) {
            cout << pre << endl;
            return 0;
        }else{
            cur = pre;
        }
    }
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);
int a[MX], b[MX], c[MX];
signed main(){
    int n,ch;
    cin >> n >>ch;
    rep(i,n) {
        cin >> a[i] >> b[i] >> c[i];
    }
    int total = 200002;
    int tt[total];
    int sum[total];
    rep(i,ch) {
        rep(j,total) tt[j]=0;
        rep(j,n) {
            if(c[j]==i+1) {
                tt[a[j]*2-1]++;
                tt[b[j]*2+1]--;
                //cout << j+1<<" "<<a[j]<<" "<<b[j] << endl;
            }
        } 
        rep(j,total) tt[j+1]+=tt[j];
        rep(j,total) if(tt[j]>0) sum[j]++;
    }
    int ma=0;
    rep(i,total) ma = max(sum[i],ma);
    cout << ma << endl;
    return 0;
}



Measured memory_bytes: 9048
n,a,b=map(int,input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  temp=min(min(a-1,b-1),min(n-a,n-b))+1  
  print(min(temp+(abs(a-b)-1)//2,min(max(a-1,b-1),max(n-a,n-b))))

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import numpy as np
def fnSolv():
  iNum = int(input())
  naABC = np.zeros((iNum, 3), dtype = int)
  naDP  = [0]*3
  #naDP  = [10**9, 10**9, 10**9]
  for iI in range(iNum):
    naABC[iI] = list(map(int, input().split()))
  for iA, iB, iC in naABC:
    naDPa = max([naDP[1] + iA, naDP[2] + iA])
    naDPb = max([naDP[2] + iB, naDP[0] + iB])
    naDPc = max([naDP[0] + iC, naDP[1] + iC])
    naDP = [naDPa, naDPb, naDPc]
    #print(naDP)
  print(max(naDP))

if __name__ == '__main__':
  fnSolv()


Measured memory_bytes: 16456
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  ll cnt = 0;
  bool ok = false;
  for (ll i = 0; i < N; ++i) {
    ll d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      cnt += 1;
    }
    else {
      cnt = 0;
    }
    if (cnt >= 3) {
      ok = true;
    }
  }
  if (ok) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


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

int main(){
    int N,X,T;
    cin>>N>>X>>T;

    if (N%X==0){
        cout<<(N/X)*T<<endl;
    }else{
        cout<<(N/X)*T+T<<endl;
    }
    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  double ans=0;  
  for(int i=0; i<N; i++) ans+= 1/A.at(i);
  ans=1/ans;
  std::cout << std::setprecision(18) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	vector<int> arr(5);
	for(int &w : arr) cin >> w;
	for(int i = 0; i < 5; i++)
		if(arr[i] == 0)
			
			return cout << i + 1 << '\n', 0;



	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
	int N,M;
	cin >> N >> M;
	
	int L[100010],R[100010];
	int Lmax=0,Rmin=N;
	for(int i=1;i<=M;i++){
		cin >> L[i] >> R[i];
		if(Lmax < L[i]){
			Lmax=L[i];
		}
		if(Rmin > R[i]){
			Rmin=R[i];
		}
	}
	
	int buf= Rmin-Lmax+1;
	
	if(buf<0){
		cout << 0;
	}else{
		cout <<  buf;
	}
	
	return 0;
		
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//assertの練習
int main(){
    vector<int> can(100010,-1);
    int k=1;
    while(k*(k+1)/2<100010){
        can[k*(k+1)/2]=k;
        k++;
    }
    int n;cin>>n;
    int s=can[n];
    if(s<0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    cout<<s+1<<endl;
    int ans[s+1][s]={};
    int num=1;
    for(int i=0;i<s;i++){
        for(int j=i;j<s;j++){
            ans[i][j]=num;
            num++;
        }
    }

    num=1;
    for(int j=0;j<s;j++){
        for(int i=j+1;i<=s;i++){
            ans[i][j]=num;
            num++;
        }
    }
    rep(i,s+1){
        cout<<s<<' ';
        rep(j,s-1){
            cout<<ans[i][j]<<' ';
        }
        cout<<ans[i][s-1]<<endl;
    }
    return 0;
}


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

int main() {

    int n;
    cin >> n;

    const int MOD = 1e9+7;

    vector<int> cnt(n+1, 0);

    vector<int> num_table(n+1);

    for(int i = 0; i <= n; ++i) {
        num_table[i] = i;
    }

    for(int i = 2; i <= n; ++i) {
        for(int j = 2; j * j <= n; ++j) {
            while(num_table[i] % j == 0) {
                num_table[i] /= j;
                ++cnt[j];
            }
        }
        if(num_table[i] != 1) ++cnt[num_table[i]];
    }

    ll ans = 1;
    for(int i = 2; i <= n; ++i) {
        if(cnt[i] == 0) continue;
        ans = ans * (cnt[i]+1) % MOD;
    }

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

Measured memory_bytes: 3640