akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,K,i;
  scanf("%d %d",&N,&K);
  int A[N+1];
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  for(i=0;i<N-K;i++){
    if(A[i]<A[i+K]) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2424
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[110];
int q[110];
pair<int,int>ev[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++)scanf("%d",p+i);
	for(int i=0;i<a-1;i++){
		ev[i]=make_pair(p[i],i);
	}
	std::sort(ev,ev+a-1);
	for(int i=0;i<a;i++)q[i]=-1;
	for(int i=0;i<a-1;i++){
		int at=ev[i].second;
		if(q[at]==-1)q[at]=ev[i].first;
		if(q[at+1]==-1)q[at+1]=ev[i].first;
	}
	int ret=0;
	for(int i=0;i<a;i++)ret+=q[i];printf("%d\n",ret);
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

// 最大公約数
ll gcd(ll a, ll b) {
  ll r;

  // a >= b
  if (a < b) {
    swap(a, b);
  }

  // ユークリッドの互除法
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

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

  ll n, x;
  cin >> n >> x;

  vector<ll> c(n);

  rep(i, n) {
    cin >> c[i];
  }

  ll ans = abs(x - c[0]);
  REP(i, n) {
    ans = gcd(ans, abs(c[i] - c[i - 1]));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
//edpc_h.cpp
//Sun Jan 27 15:32:13 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

char a[1000][1000];
int memo[1000][1000];
int h,w;

ll haba(int x, int y){
	if (memo[x][y] != -1){
		return memo[x][y];
	}
	ll ans1 = 0;
	ll ans2 = 0;
	if (x+1<h && a[x+1][y] == '.'){
		ans1 = haba(x+1,y)%1000000007;
	}
	if (y+1<w && a[x][y+1] == '.'){
		ans2 = haba(x,y+1)%1000000007;
	}
	ll temp = (ans1+ans2)%1000000007;
	memo[x][y] = temp;
	return temp;
}


int main(){
//	int h,w;
	cin >> h >> w;

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cin >> a[i][j];
			memo[i][j] = -1;
		}
	}
	memo[h-1][w-1] = 1;

	cout << haba(0,0)%1000000007<< endl;
}

Measured memory_bytes: 5248
N = int(input())
a = list(map(int,input().split()))
b = [None for _ in range(N)]
for i in range(N):
    j = N-i
    if j > N//2:
        b[j-1] = a[j-1]
    else:
        s = 0
        for k in range(2*j-1, N, j):
            s = (s+b[k])%2
        b[j-1] = (a[j-1]-s) % 2
ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i+1)
if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))

Measured memory_bytes: 20532
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct UnionFind
{
    vector<ll> par;

    UnionFind(ll n) : par(n, -1) {}
    void init(ll n) { par.assign(n, -1); }

    ll root(ll x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(ll x, ll y)
    {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(ll x)
    {
        return -par[root(x)];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    for (ll i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    ll ans = (n - 1) * n / 2;
    vector<ll> res;
    res.push_back(ans);
    for (ll i = m - 1; i >= 1; i--)
    {
        if (!uf.issame(a[i], b[i]))
        {
            ans -= (uf.size(a[i]) * uf.size(b[i]));
        }
        res.push_back(ans);
        uf.merge(a[i], b[i]);
    }
    ll N = res.size();
    for (ll i = N - 1; i >= 0; i--)
    {
        cout << res[i] << endl;
    }
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a==b&&b==c)
		cout<<1<<endl;
	else if(a!=b&&a!=c&&b!=c)
		cout<<3<<endl;
	else
		cout<<2<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  string s;
  cin >> n >> s;

  int m = 0;
  fo(i, 1, n) {
    string a = s.substr(0, i);
    string b = s.substr(i);
    int t = 0;
    re(j, 26) {
      char c = 'a' + j;
      if(a.find(c) < a.size() && b.find(c) < b.size()) {
        t++;
      }
    }
    m = max(m, t);
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>

int ceil_pow2(int n){
	int res = 0;
	while(1U<<res < (unsigned int)n)res++;
	return res;
}

typedef int32_t Int;
inline Int max(Int a, Int b){return a>b?a:b;}
inline Int segtree_op(Int a, Int b){return max(a, b);}
const Int segtree_id = INT32_MIN;

int n, lg;
Int arr[] = {[0 ... 1<<20] segtree_id};

Int* segtree(int n){
	int lg = ceil_pow2(n);
	Int* res = (Int*)malloc(sizeof(Int) * (1<<lg) * 2);
	for(int i=0; i<=(1<<lg)*2; i++)res[i] = segtree_id;
	return res;
}
void update(int k){arr[k] = segtree_op(arr[k*2], arr[2*k+1]);}
void set(int p, Int x){
	//int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = x;
	for(int i=1; i<=lg; i++)update(p>>i);
}
Int get(int p){
	return arr[p + lg];
}
Int prod(int l, int r){
	Int sml = segtree_id, smr = segtree_id;
	//int lg = ceil_pow2(n);
	l += 1<<lg;
	r += 1<<lg;
	while(l < r){
		if(l & 1) sml = segtree_op(sml, arr[l++]);
		if(r & 1) smr = segtree_op(arr[--r], smr);
		l >>= 1;
		r >>= 1;
	}
	return segtree_op(sml, smr);
}
Int all_prod(){return arr[1];}
int max_right(int l, bool (*f)(Int)){
	if(l == n) return n;
	//int lg = ceil_pow2(n);
	int size = 1<<lg;
	l += size;
	Int sm = segtree_id;
	do{
		while(l % 2 == 0) l >>= 1;
		if(!f(segtree_op(sm, arr[l]))){
			while(l < size){
				l = 2*l;
				if(f(segtree_op(sm, arr[l]))){
					sm = segtree_op(sm, arr[l]);
					l++;
				}
			}
			return l - size;
		}
		sm = segtree_op(sm, arr[l]);
		l++;
	}while((l & -l) != l);
	return n;
}
int min_right(int r, bool (*f)(Int)){
	if(r == 0) return 0;
	//int lg = ceil_pow2(n);
	int size = 1<<lg;
	r += size;
	Int sm = segtree_id;
	do{
		r--;
		while(r>1 && r&1) r >>= 1;
		if(!f(segtree_op(arr[r], sm))){
			while(r < size){
				r = 2*r + 1;
				if(f(segtree_op(arr[r], sm))){
					sm = segtree_op(arr[r], sm);
					r--;
				}
			}
			return r + 1 - size;
		}
		sm = segtree_op(arr[r], sm);
	}while((r & -r) != r);
	return 0;
}

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

int Q, T, X, Y;
bool f(Int x){return x < Y;}
int main(){
	n = nextint(); Q = nextint();
	lg = ceil_pow2(n);
	//Int *d = segtree(n);
	for(int i=0; i<n; i++) set(i, nextint());
	while(Q--){
		T = nextint(); X = nextint()-1; Y = nextint();
		if(T == 1)set(X, Y);
		else if(T == 2)printf("%d\n", prod(X, Y));
		else printf("%d\n", 1 + max_right(X, f));
	}
	return 0;
}


Measured memory_bytes: 8380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int odd_counter =0;
		int even_counter =0;
		
		for( int m = 1 ; m <= n; m++) {
			
			if ( m % 2 == 1 ) {
				odd_counter  = odd_counter + 1;
			}
			else {	
				even_counter = even_counter + 1;		
			}	
			
		}	
		float k = (float) odd_counter / (float)(odd_counter + even_counter);
		System.out.println(k);
	 }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main(){
  int N,M;
  scanf("%d%d",&N,&M);

  vector<pair<int,int>> st(N),cp(M);

  int a,b;
  rep(i,N){
    scanf("%d%d",&a,&b);
    st[i] = make_pair(a,b);
  }

  int c,d;
  rep(i,M){
    scanf("%d%d",&c,&d);
    cp[i] = make_pair(c,d);
  }

  int INF = 1000000000;
  //for(auto i:st) printf("%d:%d\n",i.first,i.second);
  rep(i,N){
    int min_root = INF,point;
    rep(j,M){
      if(min_root > abs(st[i].first - cp[j].first) + abs(st[i].second - cp[j].second)){
        min_root = abs(st[i].first - cp[j].first) + abs(st[i].second - cp[j].second); 
        point = j + 1;
      }
    }
    printf("%d\n",point);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  int ret = 0;
  if(n>=2)ret += (n-1)*n/2;
  if(m>=2)ret+=(m-1)*m/2;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char code[4];
    bool flag = false;
    for(int i = 0; i < 4; i++) {
        cin >> code[i];
        if(code[i] == code[i-1]) {
            flag = true;
        }
    }
    flag ? cout << "Bad" << endl : cout << "Good" << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    double pi = 2.0 * asin(1.0);
    double unit_r = 180.0 / pi;

    double hantei = (a * a * b) / 2;
    double c = 2 * (a * a * b - x);
    double tangent = c / (a * a * a);
    if(hantei > x) {
        tangent = (a * b * b) / (2 * x);
    }
    double atangent = atan(tangent) * unit_r;

    cout << fixed << setprecision(10) << atangent << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* 逆元(法mod = 1e9+7) */
ll modinv(ll a){
    ll b = mod, u = 1, v = 0;
    while (b){
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
        }
    return modu(u);
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> A(N);
    vector<int> B(N);
    REP(i,N)A[i] = in();
    REP(i,N)B[i] = A[i];
    vector<int> maxi(1000000);
    REP(i,N){
        int tmp = 0;
        for(int l = 2;;){
            if(A[i]%l == 0){
                A[i]/=l;
                tmp++;
            }else{
                chmax(maxi[l],tmp);
                l++;
                tmp = 0;
            }
            if(l > 1000){
                maxi[A[i]] = 1;
                break;
            }
            if(tmp == 0 && A[i] <= 1)break;
        }
    }
    ll lcma = 1;
    REP(i,1000000){
        lcma = modu(lcma * modpow(i,maxi[i]));
    }
    ll answer = 0;
    REP(i,N){
        answer = modu(answer + lcma * modinv(B[i]));
    }
    cout << answer <<  "\n";
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vbool from_1(n, false);
    vbool to_N(n, false);
    from_1[0] = true;
    to_N[n-1] = true;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == 1) from_1[b-1] = true;
        if (b == n) to_N[a-1] = true;
    }
    rep(i, n) {
        if (from_1[i] & to_N[i]) {
            puts("POSSIBLE");
            return 0;
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String n = scanner.nextLine();
		long   k = scanner.nextLong();
		long ans = 0;
		boolean flg = true;

		ans = Long.parseLong(n.substring(0, 1));

		if(ans == 1){
			for(int i = 1; i < k; i++) {

				long x  =Long.parseLong(n.substring(i, i + 1));


				if(x != 1) {

					ans = Long.parseLong(n.substring(i, i + 1));
					flg = false;
					break;
				}
			}

			if(flg) ans = 1;
		}

		System.out.println(ans);



	}
}


Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
#define D double
#define ll long long int
#define f(i,a,b) for(int i=a;i<b;i++)
#define MEM(a,val) memset(a,val,sizeof(a))

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   
    ll n;   cin>>n;
    ll ans=0;
    ll f500=n/500;
    ans+=(1000*f500);
    n-=(f500*500);
    ll f5=n/5;
    ans+=(5*f5);
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

int main() {
	int n, k; cin >> n >> k;
	vll a(n);
	ll sum = 0, ans = 0;
	Loop(i, n) {
		cin >> a[i];
		if (a[i] > 0) sum += a[i];
	}
	ll pos = 0, neg = 0;
	Loop(i, k - 1) {
		if (a[i] >= 0) pos += a[i];
		else neg += a[i];
	}
	Loop(i, n - k + 1) {
		if (a[i + k - 1] >= 0) pos += a[i + k - 1];
		else neg += a[i + k - 1];
		if (pos + neg > 0) {
			ans = max(ans, sum + neg);
		}
		else {
			ans = max(ans, sum - pos);
		}
		if (a[i] >= 0) pos -= a[i];
		else neg -= a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Iterator;
import java.util.Scanner;
import java.util.HashSet;
public class Main {
	public static void main(String[] args){
//		Scanner sc = new Scanner(System.in);
//
//      int N = sc.nextInt();
//		String S = sc.next();
//
//		int cnt = N - 1;
//
//	    for(int i = 0; i < N; i++){
//	    	int wkcnt = 0;
//		    for(int j = 0; j < N; j++){
//		    	if (i > j){
//		    		if (S.charAt(j) == 'W'){
//		    			wkcnt++;
//		    		}
//		    	}else if (i < j){
//		    		if (S.charAt(j) == 'E'){
//		    			wkcnt++;
//		    		}
//		    	}
//		    }
//		    cnt = Math.min(cnt, wkcnt);
//	    }
//		System.out.println(cnt);
		// ↑↑↑ ＴＬＥでひっかかったソース ↑↑↑

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();

		int cntE = 0;

		// Eの件数をもとめる
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == 'E') cntE++; // Eの件数
		}

		int ans = cntE;
		for(int i = 0; i < N; i++){
			// Eは減算、Wは加算
			if(S.charAt(i) == 'E') cntE--;
			if(i > 0 && S.charAt(i - 1) == 'W') cntE++;
			ans = Math.min(ans, cntE);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28856
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;



int main() {
	int n;
	cin >> n;
	n *= 2;
	string s;
	cin >> s;
	
	vector<int> a, b;
	for(int i = 0; i < n; ++i) {
		if(s[i] == 'a') a.push_back(i);
		else b.push_back(i);
	}
	vector<int> his(n);
	for(int i = 0; i < n / 2; ++i) {
		his[a[i]] = b[i];
		his[b[i]] = a[i];
	}
	
	vector<string> dp(n + 1);
	for(int i = n - 1; i >= 0; --i) {
		dp[i] = dp[i+1];
		if(his[i] > i) {
			if(s[i] == 'a') {
				dp[i] = max(dp[i], "ab" + dp[his[i] + 1]);
				continue;
			}
			vector<bool> taken(n);
			taken[i] = taken[his[i]] = true;
			int rightmost = his[i];
			for(int k = i + 1; k < rightmost; ++k) if(s[k] == 'b') {
				taken[k] = taken[his[k]] = true;
				rightmost = his[k];
			}
			string maybe;
			for(int k = i; k <= rightmost; ++k) if(taken[k]) maybe += s[k];
			maybe += dp[rightmost+1];
			dp[i] = max(dp[i], maybe);
			debug() << imie(i) imie(maybe);
		}
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 14592
#!usr/bin/env python3

def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()
    print(str(a*b) + ' ' + str((a+b) * 2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	int count=1;
	for(int i=0;i<n;i++){
		count=min(count*2,count+k);
	}
	cout << count << endl;
	return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;


int n, m;
vector<int> edg[MAXN], redg[MAXN];
int col[MAXN];
int num[3], ne, nv;

bool dfs(int x, int c)
{
	if(col[x] != -1)
		return col[x] == c;
	col[x] = c;
	num[col[x]]++, ne += edg[x].size(), nv += 1;
	bool ret = true;
	for(int i = 0; i < edg[x].size(); i++)
		if(!dfs(edg[x][i], (c + 1) % 3))
			ret = false;
	for(int i = 0; i < redg[x].size(); i++)
		if(!dfs(redg[x][i], (c + 2) % 3))
			ret = false;
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y);
		redg[y].push_back(x);
	}

	memset(col, -1, sizeof(col));

	long long ans = 0;
	for(int i = 1; i <= n; i++)
		if(col[i] == -1)
		{
			memset(num, 0, sizeof(num));
			nv = ne = 0;
			bool flag = dfs(i, 0);
			if(flag)
			{
				if(num[0] && num[1] && num[2])
					ans += (long long)num[0] * num[1] + (long long)num[1] * num[2] + (long long)num[2] * num[0];
				else
					ans += ne;
			}
			else
			{
				ans += (long long)nv * nv;
			}
		}
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define  endl '\n'
using namespace std;

vector<ll> divisors(ll n) {
    vector<ll> d;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) {
            d.push_back(i);
            if (n / i != i) d.push_back(n / i);
        }
    return d;
}

map<ll, ll> primeFactors(ll n) {
    map<ll, ll> cnt;
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }

    for (ll i = 3; i * i <= n; i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2)
        cnt[n]++;
    return cnt;
}

bool is_good(map<ll, ll> mp) {
    if (mp.size() == 1) return 1;
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    map<ll, ll> fact = primeFactors(n);
    auto hna = fact.begin();
    if (fact.size() == 1 && hna->second == 1) return cout << 1, 0;
    vector<ll> div = divisors(n);
    sort(div.begin(), div.end());
    set<int> taken;
    int cnt = 0;
    //for(auto i:fac) cout<<i.first<<" "<<i.second<<" ";

    for (auto d:div) {
        if (n == 1) break;
        fact = primeFactors(d);
        auto hna = fact.begin();
        if (fact.size() == 1 && n%d==0 ) {
            //cout << n << endl;
            n /= d;
            cnt++;

        }
    }


    cout << cnt;

}

Measured memory_bytes: 3704
#include <stdio.h>

void swap(int* p, int *q){
    int tmp;
    if(*p > *q){
        tmp = *p;
        *p = *q;
        *q = tmp;
    }
}

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    swap(&a,&b);
    swap(&b,&c);
    swap(&a,&b);
    swap(&b,&c);
    printf("%d %d %d\n",a,b,c);
    return 0;
}




Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int a, b, c, d, e, na, nb, nc; 
  while(cin >> a >> b >> c >> d >> e >> na >> nb >> nc){
    if(d <= nc){
      cout << a * na + b * nb + e * nc << endl;
    }else{
      int ans = a * na + b * nb + c * nc;
      int D = d;
      d -= nc;

      int t = min(nb, d);
      nb -= t;
      d -= t;
      t = min(na, d);
      na -= t;
      d -= t;
      ans = min(ans, a * na + b * nb + e * D);
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void) {
	 int a,i,j,f[8] = {0};
	 float t;
	 scanf("%d",&a);
	 for(i=1;i<=a;i++){
	 	scanf("%f",&t);
	 	if(t<165.0f) f[1]++;
	 	if(165.0f<=t&&t<170.0f) f[2]++;
	 	if(170.0f<=t&&t<175.0f) f[3]++;
	 	if(175.0f<=t&&t<180.0f) f[4]++;
	 	if(180.0f<=t&&t<185.0f) f[5]++;
	 	if(185.0f<=t) f[6]++;
	 }
	 for(i=1;i<=6;i++){
	 	printf("%d:",i);
	 	for(j=1;j<=f[i];j++) printf("*");
	 	printf("\n");
	 }
	return 0;
}

Measured memory_bytes: 636
import sys
readline = sys.stdin.buffer.readline

n = int(readline())
t,a = 0,0
for i in range(n):
    rt,ra = map(int,readline().split())
    x = max((t-1)//rt+1,(a-1)//ra+1)
    t = rt*x
    a = ra*x
    if a+t == 0:
        t += rt
        a += ra

print(t+a)



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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
	int d, n; cin >> d >> n;
	if (d == 0) {
		if (n < 100)
			cout << n << endl;
		else cout << 101 << endl;
	}
	else if (d == 1) {
		if (n < 100)
			cout << n << "00" << endl;
		else cout << 10100 << endl;
	}
	else if (d == 2) {
		if (n < 100)
			cout << n << "0000" << endl;
		else cout << 1010000 << endl;
 	}

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main () {
	FIO
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	k--;
	cout<<arr[k];
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<set>
using namespace std;
int main()
{
	int s;
	set<int>se;
	cin >>s;
	se.insert(s) ;
	while(1){
		if(s%2==1) s=s*3+1;
		else s/=2; 
		int len=se.size();
		se.insert(s);
		if(len==se.size()) break;
	} 
	cout <<se.size()+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,m,f[100005];
int main() {
SPEED;
cin>>n>>m;
f[0]=1;
for(ll i=1;i<=100000;i++)
	f[i]=(f[i-1]*i)%MOD;
if(abs(n-m)>1)
{
	cout<<0<<endl;
	return 0;
}
ll ans=(f[n]*f[m])%MOD;
if(n==m)
	ans=(ans*2)%MOD;
cout<<ans<<endl;
	return 0;
           }



Measured memory_bytes: 1024
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var ans = 1000-N%1000;
  if(ans == 1000){
    ans = 0;
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

#define PI 3.14159265358979323846264338327950L

int main() {
    float a, b, h, m;
    cin >> a >> b >> h >> m;

    // if (h == 0) h = 12;
    // if (m == 0) m = 60;

    // float h_ang = (h / 12) * 360;
    // float m_ang = (m / 60) * 360;

    // float c_ang = abs(h_ang - m_ang);

    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    // cout << rad << endl;
    // cout << pow(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)), 0.5) << endl;
    long double rsq = pow(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)), 0.5);
    printf("%20.20Lf\n", rsq);
    return 0;
}

Measured memory_bytes: 4140
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
signed main() {
	while (true) {
		int m, t, p, r;
		cin >> m >> t >> p >> r;
		if (m == 0) { break; }
		vvel time(t, vel(p, -1));
		vvel pena(t, vel(p, 0));
		rep(i, r) {
			int m1, t1, p1, j1;
			cin >> m1 >> t1 >> p1 >> j1;
			t1--; p1--;
			if (j1 != 0) {
				pena[t1][p1]++;
			}
			else {
				time[t1][p1] = m1;
			}
		}
		vel count(t, 0);
		vel sum_time(t, 0);
		V<qin> ret(t);
		rep(i, t) {
			rep(j, p) {
				if (time[i][j] != -1) {
					count[i]++;
					sum_time[i] += time[i][j];
					sum_time[i] += pena[i][j] * 20;
				}
			}
			ret[i] = mkp(mkp(count[i], -sum_time[i]), i);
		}
		sor(ret); rev(ret);
		cout << ret[0].second+1;
		for (int i = 1; i < t; i++) {
			if (ret[i].first == ret[i - 1].first) {
				cout << "=" << ret[i].second+1;
			}
			else {
				cout << "," << ret[i].second+1;
			}
		}
		cout << endl;
	}
}



Measured memory_bytes: 3176
from collections import Counter
 
N = int(input())
A_raw = Counter(list(map(int, input().split())))
A = [x[0] for x in A_raw.items() if x[1] == 1]
A.sort()
B = [x[0] for x in A_raw.items() if x[1] > 1]
B.sort()
seen = [0]*(1000000+1)
for b in B:
    if seen[b] == 0:
        x = b
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = b*j
ans = 0
for a in A:
    if seen[a] == 0:
        ans += 1
        x = a
        j = 1
        while x <= 1000000:
            seen[x] = 1
            j += 1
            x = a*j
print(ans)


Measured memory_bytes: 130052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll C; cin >> C;
    if (C>=30) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        int n;
        long[][] dp;
        boolean[][] set;
        int[] a;

        private void res(int left, int right, boolean max) {
            if (left == right) return;
            if (!set[left+1][right]) res(left+1, right, !max);
            if (!set[left][right-1]) res(left, right-1, !max);
            if (max) dp[left][right] = Math.max(a[left] + dp[left+1][right], a[right] + dp[left][right-1]);
            else dp[left][right] = Math.min(-a[left] + dp[left+1][right], -a[right] + dp[left][right-1]);
            set[left][right] = true;
        }

        private void solve(InputReader inp, PrintWriter out) {
            n = inp.nextInt();
            dp = new long[n][n];
            set = new boolean[n][n];
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = inp.nextInt();
                set[i][i] = true;
                dp[i][i] = a[i];
                if (n % 2 == 0) dp[i][i] *= -1;
            }
            res(0, n-1, true);
            out.print(dp[0][n-1]);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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



Measured memory_bytes: 130028
#include <bits/stdc++.h>
using namespace std;
const int MAXI = 1005;

int N, g[MAXI][MAXI];

int solve(int N) {
	for (int i = 1; i*(i-1)/2 <= N; i++) {
		if (i*(i-1)/2 == N) {
			int cnt = 0;
			for (int j = 1; j <= i; j++) {
				for (int k = j+1; k <= i; k++) {
					g[j][k] = g[k][j] = ++cnt;
				}
			}
			
			cout << "Yes\n";
			cout << i << "\n";
			for (int j = 1; j <= i; j++) {
				cout << i-1;
				for (int k = 1; k <= i; k++) {
					if (k == j) continue;
					cout << " " << g[j][k];
				}
				cout << "\n";
			}
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	solve(N);
	
	return 0;
}


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

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

  vector<int> V(N);
  rep( i, 0, N ) cin >> V.at(i);

  vector<int> C(N);
  rep( i, 0, N ) cin >> C.at(i);

  int Ans = 0;
  rep( i, 0, N ) {
    int temp = V.at(i) - C.at(i);
    if ( temp > 0 ) Ans += temp;
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int n,k,ans,t[105];
int main()
{
    n=read();k=read();
    for(int i=1;i<=k;i++)
    {
        int m=read();
        while(m--)
            t[read()]=1;
    }
    for(int i=1;i<=n;i++)
        if(!t[i])
            ans++;
    printf("%d\n",ans);
}


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

int main() {
	string s;
	cin >> s;
	int dp[2][s.size()+1]; fill((int *)dp, (int *)dp + sizeof(dp)/sizeof(int), 0);
	dp[1][0] = 1;
	for (int i = 1; i <= s.size(); i++) {
		int x = s[i-1] - '0';
		dp[0][i] = min(dp[0][i-1] + x, dp[1][i-1] + (10-x));
		dp[1][i] = min(dp[0][i-1] + x + 1, dp[1][i-1] + 9 - x);
	}
	int ans = dp[0][s.size()];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12120
#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 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; }

int main(){
    ll k;
    cin>>k;
    vector<ll> a(50);
    ll base=k/50,sim=k%50;
    for(int i=0;i<50;i++){
        a[i]=i+base;
    }
    for(ll i=0;i<sim;i++){
        for(ll j=0;j<50;j++){
            if(i==j) a[j]+=50;
            else a[j]--;
        }
    }
    cout<<50<<endl;
    for(int i=0;i<49;i++){
        cout<<a[i]<<' ';
    }
    cout<<a[49]<<endl;
    return 0;
}

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

int N;
long long int A[100005];

long long int dp[100005][2];

int main(void) {
	cin >> N;

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

	for (int i = 1; i <= N; i++) {
		dp[i][0] = -9999999999999999;
		dp[i][1]= -9999999999999999;
	}

	dp[2][0] = A[1] + A[2];
	dp[2][1] = -A[1] - A[2];

	for (int i = 3; i <= N; i++) {
		dp[i][0] = max(dp[i][0], dp[i - 1][0] + A[i]);
		dp[i][1] = max(dp[i][1], dp[i - 1][0] - A[i - 1] * 2 - A[i]);
		dp[i][0] = max(dp[i][0], dp[i - 1][1] + A[i]);
		dp[i][1] = max(dp[i][1], dp[i - 1][1] + A[i - 1] * 2 - A[i]);
	}

	cout << max(dp[N][0], dp[N][1]) << endl;


	//system("pause");
	return 0;
}

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

X = list(map(int, input().split()))


ave = int(sum(X)/n)

sum = 0
sum1 = 0
sum2 = 0
for i in X:
    sum += (ave - i)**2
    sum1 += (ave - 1 - i)**2
    sum2 += (ave + 1 - i)**2
print(min(sum, sum1, sum2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for(ll i = a; i < b; i++)
#define blu(i, a, b) for(ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {
       
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
     t=1;
    while (t--)
    {
        ll n,c=0,sum1,sum2,sum3,sum,k;
        cin>>n;
        vl v(n,0);
        flu(i,0,n)cin>>v[i];
        sort(all(v));
       for(i=0;i<n;i++)
        {
           for(j=0;j<n && i!=j;j++)
            {
                for(k=0;k<n && k!=i && k!=j;k++)
                {   if(v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
                {
                    sum1= v[i]+v[j];
                    sum2=v[j]+v[k];
                    sum3= v[k]+v[i];
                    if(sum1>v[k] && sum2>v[i] && sum3>v[j])c++;
                }
                }
            }
        }
        cout<<c<<e;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0 ; i < (int)(n) ; i++)
typedef long long ll;
////////////////////////////////////////////////
int main(){
    int k;
    cin >> k;
    int seven = 7%k, ans=1;
    vector<int> v(k+1);
    rep(i,k+1){
        if (seven==0){ 
            cout << ans << endl;
            break;
        }
        if (v[seven]==1){ 
            cout << -1 << endl;
            break;
        }
        v[seven]=1;
        seven = (seven*10+7)%k;
        ans += 1;
    }
}

Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, K;
vector<ll> a;
ll solve()
{
    ll res = 0;
    cin >> N >> K;
    a.resize(N);
    for (auto& in : a)
        cin >> in;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll ans = -1;
    for (int i = 0; i < N; i++) {
        ll sum = 0;
        for (ll j = i; j < N; j++) {
            if (sum + a[j] < K) {
                sum += a[j];
                continue;
            }
            ans = max(ans, j);
        }
    }
    return res = N - ans - 1;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}

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

int main() {
    int N;
    cin >>N;
    for(int i=0;i<=N/4+1;i++){
        for(int j=0;j<=N/7+1;j++){
            if(i*4+j*7 ==N){
                cout << "Yes"<<endl;
                return 0;
            }
        }
    }
    cout <<"No"<<endl;
    }

Measured memory_bytes: 256