akhauriyash/Code-Regression huggingface dataset:
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}


std::string str="All Good Till Here";

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

int32_t main()
{
    fastio
	ll tt,k,i,j,x;
	//cin>>tt;
  tt=1;
	while(tt--)
	{
    cin>>k;
    string str;
    cin>>str;
    if(str.length()<=k)cout<<str;
    else
    {
      str=str.substr(0,k)+"...";
      cout<<str<<"\n";
    }
	}
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        string s; cin>>s;
        vi a,z;
        rep(i,0,s.size()){
            if(s[i] == 'A') a.pb(i);
            if(s[i] == 'Z') z.pb(i);
        }
        sort(a.begin(), a.end());
        sort(z.begin(), z.end(),greater<int>());
        cout<<z[0] - a[0] + 1;
        

    }
}

Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,len=0,j,flag=0;
    string s;
    cin>>s;
    len=s.size();
    for(i=0; i+1<len; i++)
    {
        for(j=i+1; j<len; j++)
        {
            if(s[i]==s[j])
            {
                flag=1;
                break;
            }
        }
    }
   // cout<<flag<<endl;
    if(flag==0)
    {
        cout<<"yes"<<endl;
    }
    else
    {
        cout<<"no"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  re0 bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
/*
Ä³¸ö¶¯ÎïxµÄÖÖÀàÎªËüÇ°Á½¸ö¶¯ÎïµÄÖÖÀàºÍËüÇ°Ò»¸ö¶¯ÎïµÄÖÖÀàºÍ»Ø´ðµÄÒì»ò.
ÁîÑòÎª1,ÀÇÎª0,»Ø´ðoÎª1,xÎª0.
Ôòans[x]=ans[x-2]=='S'^ans[x-1]=='S'^c[x-1]=='o'; 
*/
char c[yuzu|10],ans[yuzu|10];
int n=read();

int judge(int x){
ans[x]=(ans[x-2]=='S')^(ans[x-1]=='S')^(c[x-1]=='o')?'S':'W';
if (x==n){
  return ((ans[x-1]=='S')^(ans[x]=='S')^(c[x]=='o')^(ans[1]=='W')) 
         &&((ans[x]=='S')^(ans[1]=='S')^(c[1]=='o')^(ans[2]=='W'));
  }
return judge(x+1); 
}

int main(){
scanf("%s",c+1);
ans[1]=ans[2]='S';
if (judge(3)) return puts(ans+1),0;
ans[2]='W';
if (judge(3)) return puts(ans+1),0;
ans[1]='W',ans[2]='S';
if (judge(3)) return puts(ans+1),0;
ans[2]='W';
if (judge(3)) return puts(ans+1),0;
puts("-1");
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); long sum = 0;
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		long ans = Long.MAX_VALUE, sn_sum = 0;
		for(int i = 0; i < N - 1; i++) {
			sn_sum += A[i];
			ans = Math.min(ans, Math.abs(sn_sum - (sum - sn_sum)));
		}
		System.out.println(ans);
	}
}

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

const int N = 1e5 + 5;

long long dp[N];
int w[105], v[105];


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

    int n, W;
    cin >> n >> W;
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
    for (int i = 0; i < n; i++) {
        for (int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= W; i++) ans = max(ans, dp[i]);
    cout << ans << '\n';
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-3;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int main(void){
  int n;
  cin>>n;
  while(n--){
    vector<P> point(5);
    REP(i,5){
      double x,y;
      cin>>x>>y;
      point[i] = P(x,y);
    }
    double S = abs(cross(point[2]-point[0],point[1]-point[0]));
    double par = 0;
    bool in1,in2;
    REP(i,3){
      par += abs(cross(point[i]-point[3],point[(i+1)%3]-point[3]));
    }
    in1 = (abs(S-par)<EPS);
    par = 0;
    REP(i,3){
      par += abs(cross(point[i]-point[4],point[(i+1)%3]-point[4]));
    }
    in2 = (abs(S-par)<EPS);
    if((in1&&in2)||!(in1||in2)){
      cout<<"NG"<<endl;
    }else{
      cout<<"OK"<<endl;
    }
  }



  return 0;
}

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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N, M;
multiset<int> S;

signed main() {

    in(N, M);
    rep(i, N) {
        int x;
        in(x);
        S.insert(x);
    }

    rep(i, M) {
        int e = *S.rbegin();
        S.erase(S.lower_bound(e));
        e /= 2;
        S.insert(e);
    }

    int ans = 0;
    for_each(all(S), [&ans](int x) { ans += x; });
    out(ans);

    return 0;
}


Measured memory_bytes: 4992
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int n;
  cin>>n;
  int a=n/100;
  int b=(n-a*100);
  int c=b/10;
  int d=(b-c*10);
  cout<<(a==d?"Yes":"No")<<endl;
  


 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  bool a;
  
  for (int i = 0; i <= K; i++) {
    a = true;
    for (int j = i; j <= K; j++) {
      for (int k = j; k <= K; k++) {
        if (i + j + k == S && i == j && j == k) {
          count ++;
          a = false;
        }
        if (i + j + k == S && a == true) {
          if (i == j || j == k || k == i) {
            count += 3;
          }
          else {
            count += 6;
          }
        }
      }
    }
  }
  cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

typedef long long ll;
typedef unsigned long long ull;

//?´???°??????
bool isPrime(int x) {
	if (x < 2)return 0;
	else if (x == 2)return 1;
	if (x % 2 == 0)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++) {
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
	}
}

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

//???????´???? ??°??????????????????
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res*x%MOD;
		x = x*x%MOD;
		n >>= 1;
	}
	return res;
}

static const int MAX_N = 100000;
static const int MAX_P = 100;

int main() {
	bool is_prime[MAX_N * 2];
	eratos(MAX_N * 2, is_prime);
	vector<int> prime;
	for (int i = 0; i <= MAX_N * 2; i++) {
		if (is_prime[i]) {
			prime.push_back(i);
		}
	}

	static vector<int> M[MAX_N + 1];
	for (int N, P; cin >> N >> P&&N != -1;) {
		if (M[N].size() == 0) {
			int mprime = lower_bound(prime.begin(), prime.end(), N) - prime.begin();
			if (is_prime[N])mprime++;
			for (int i = mprime; i < mprime + MAX_P; i++) {
				for (int j = i; j < mprime + MAX_P; j++) {
					M[N].push_back(prime[i] + prime[j]);
					//cout << prime[i] << " " << prime[j] << " " << prime[i] + prime[j] << endl;
				}
			}
			sort(M[N].begin(), M[N].end());
		}
		cout << M[N][P - 1] << endl;
	}
	return 0;
}

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

char in[120];
pair<pair<string,int>,int> p[110];

int main() {
  int a;scanf("%d",&a);
for(int i=0;i<a;i++){
	int t;scanf("%s%d",in,&t);
	string tmp=in;
	p[i]=make_pair(make_pair(in,-t),i);
}
std::sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);

}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = [sys.stdin.readline().rstrip() for _ in range(N)]
M = int(sys.stdin.readline())
T = [sys.stdin.readline().rstrip() for _ in range(M)]

ans = 0
for s in set(S):
    a = S.count(s)
    b = T.count(s)
    ans = max(ans, a - b, 0)

print(ans)


Measured memory_bytes: 15692
#include <iostream>
#include <algorithm>
#define FOR(i,b,e) for(int i = b; i < e; i++)
using namespace std;

long long solve(int* a, int l) {
	long long ans = 0;
	sort(a, a + l);
	for (int i = l / 3; i < l; i+=2)ans += a[i];
	return ans;
}

int main() {
	int n; int a[300001];
	cin >> n;
	FOR(i, 0, n * 3)cin >> a[i];
	cout << solve(a, n * 3) << endl;
}

Measured memory_bytes: 1408
//Name: Twin Prime
//Level: 2
//Category: 数学,素数
//Note: 

/**
 * 10000以下の双子素数を列挙しておけば、あとは線形探索でよい。
 *
 * オーダーは O(M log log M)。
 * ただしMは求める必要がある最大の素数で、M=10000。
 */
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

vector<bool> eratosthenes(int N) {
    vector<bool> is_prime(N+1, true);
    is_prime[0] = is_prime[1] = false;

    const int LIM = static_cast<int>(sqrt(N));
    for(long long i = 2; i <= LIM; ++i) {
        if(is_prime[i]) {
            for(long long j = i*i; j <= N; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return is_prime;
}

bool solve(bool first) {
    const static auto is_prime = eratosthenes(10000);

    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;
    for(int i = N; i >= 0; --i) {
        if(is_prime[i] && is_prime[i-2]) {
            cout << i-2 << ' ' << i << endl;
            break;
        }
    }

    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define fri(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define ol(v) v.begin(),v.end()
#define forc(v) for(auto it:v)
#define se second
#define fi first
#define pb push_back
#define pf push_front
#define MX 1e18
#define MN -MX

using namespace std;
typedef long long ll;
typedef long double ld;

template <typename T> istream&operator>>(istream &inp, vector<T> &vec){
	fri(i,vec.size()) inp>>vec[i];
	return inp;
}

template <typename T> ostream&operator<<(ostream &oup, vector<T> vec){
	forc(vec) oup<<it<<" ";
	oup<<"\n";
	return oup;
}


int main(){
	ios::sync_with_stdio(false);
	#ifdef DBG
		freopen("in", "r", stdin);
	#endif
	vector<ll> arr(3);
	cin>>arr;
	sort(ol(arr));
	cout<<arr[0]+arr[1]<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

#print(n,a)

b=[]
for i in range(0,n):
    if a[i]%2==0:
        b.append(a[i])
#print(b)

c=[]
for i in range(0,len(b)):
    if b[i]%3==0 or b[i]%5==0:
        c.append(b[i])
#print(c)

if len(b)==len(c):
    print('APPROVED')
else:
    print('DENIED')

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

using namespace std;

int main(){
  int x, y;
  cin>>x>>y;

  int t,k;

  if(y % 2 == 0){
    if(((y-2*x)/2)>=0 and ((4*x-y)/2)>=0){
      cout<<"Yes"<<endl;
    } else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }




}


Measured memory_bytes: 3588
num,ave = map(int,input().split())
numx = list(map(int,input().split()))

L = len(numx)
numy = [0] * L
for i in range(L):
    numy[i] = numx[i] - ave

if abs(min(numy)) < abs(max(numy)):
    maxX = max(numy)
else:
    maxX = abs(min(numy))

dp = [[0]*(2*maxX*L+1) for _ in range(L+1)]
dp[0][maxX*L] = 1
for i in range(L):
    for j in range(2*maxX*L+1):
        if (j-numy[i]) < 0 or (j - numy[i]) > 2*maxX*L:
          dp[i+1][j] = dp[i][j]
        else:
          dp[i+1][j] = dp[i][j] + dp[i][j-numy[i]]
print(dp[L][maxX*L]-1)

Measured memory_bytes: 5104
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
		mp[a-1]++;
		mp[a+1]++;
	}
	int ans = 0LL;
	for(auto& p : mp) {
		ans = max(ans, p.se);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
import itertools
n, m, x = map(int, input().split())
caaa = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 7
for i in range(1, n + 1):
    for caa in list(itertools.combinations(caaa, i)):
        c = 0
        aa = [0] * m
        for j in range(i):
            c += caa[j][0]
            for k in range(m):
                aa[k] += caa[j][k + 1]
        if all(aa[l] >= x for l in range(m)):
            ans = min(c, ans)
print(-1 if ans == 10 ** 7 else ans)

Measured memory_bytes: 9388
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;
const int maxn=1e2+10;
const int Mod=1e9+7;

int N,K;
long long DP[maxm][maxn],Add[maxm][maxn],A[maxn];

int main(){
	register int i,j,k;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++) scanf("%lld",A+i);
	for(i=0;i<=N;i++) DP[0][i]=Add[0][i]=1;
	for(i=0;i<=K;i++) Add[i][0]=1;
	for(i=1;i<=K;i++){
		for(j=1;j<=N;j++){
			if(i-A[j]>0) DP[i][j]=(Add[i][j-1]-Add[i-A[j]-1][j-1])%Mod;
			else DP[i][j]=Add[i][j-1];
			Add[i][j]=(Add[i-1][j]+DP[i][j])%Mod;
		}
	}
	DP[K][N]=(DP[K][N]+Mod)%Mod;
	cout<<DP[K][N];
	return 0;
}

Measured memory_bytes: 172160
import math

N = int(input())
gc = [0] * (N + 1)
ans = 1


def solve(n):
    num = 2
    while num <= n:
        while int(n % num) is 0:
            n /= num
            gc[num] += 1
        num += 1
        if n is 1:
            break
    return 0


for i in range(1, N + 1):
    solve(i)
for p in gc:
    if p is not 0:
        ans *= p + 1
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int main(){
	string s;
	string S;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]!='x'){
			S+=s[i];
		}
	}
	string T = S;
	reverse(all(T));
	if(S!=T){
		cout << -1 << endl;
		return 0;
	}
	int l = 0, r = s.size()-1;
	int ans = 0;
	while(l<r){
		if(s[l]==s[r]){
			l++;
			r--;
		}else{
			if(s[l]=='x'){
				ans++;
				l++;
			}else{
				ans++;
				r--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

const int INF = 1145141919;

int main(){
	int n;
	scanf("%d", &n);
	int a[100005];
	for(int i = 0; i < 100005; i++){
		a[i] = INF;
	}
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	int i = 0;
	int vis = a[0];
	int ans = 0;
	while(i < n){
		vis = a[i];
		int cnt = 0;
		while(i+cnt < n && a[i+cnt] == vis){
			cnt++;
		}
		ans += cnt%2;
		i += cnt;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  bool findSet(int x,int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i,n){
        int now = h[i];
        if(g[i].size() == 0 ) ans ++ ;
        else{
            bool ok = 1;
            for(auto next:g[i]){
                if(now <= h[next])ok = 0;
            }
            if(ok)ans ++ ;
        }
    }
    cout << ans << endl;
}

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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	String order, msg;

	void run() {
		int N = sc.nextInt();
		while (N-- > 0) {
			order = sc.next();
			msg = sc.next();
			for (int i = order.length() - 1; i >= 0; i--) {
				operation(order.charAt(i));
			}
			System.out.println(msg);
		}
	}

	void operation(char op) {
		String tmp = "";
		int len = msg.length();
		switch (op) {
		case 'C':
			tmp = msg.substring(1, len);
			tmp += msg.charAt(0);
			break;
		case 'J':
			tmp = msg.charAt(len - 1) + "";
			tmp += msg.substring(0, len - 1);
			break;
		case 'E':
			int h = msg.length() / 2;
			if (len % 2 == 0) {
				tmp = msg.substring(h, len);
				tmp += msg.substring(0, h);
			} else {
				tmp = msg.substring(h + 1, len);
				tmp += msg.charAt(h);
				tmp += msg.substring(0, h);
			}
			break;
		case 'A':
			tmp = new StringBuilder(msg).reverse().toString();
			break;
		case 'M':
			for (int i = 0; i < len; i++) {
				if (Character.isDigit(msg.charAt(i))) {
					tmp += (Integer.valueOf(msg.charAt(i) - '0') + 1) % 10;
				} else {
					tmp += msg.charAt(i);
				}
			}
			break;
		case 'P':
			for (int i = 0; i < len; i++) {
				if (Character.isDigit(msg.charAt(i))) {
					int t = Integer.valueOf(msg.charAt(i) - '0') - 1;
					tmp += t < 0 ? 9 : t;
				} else {
					tmp += msg.charAt(i);
				}
			}
			break;
		default:
			break;
		}
		msg = tmp;
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

const int MAX = 500000;
int A[MAX + 1];
int H;

void maxHeapify(int i) {
  int largest;
  int l = i * 2;
  int r = i * 2 + 1;

  if (l <= H && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

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

  cin >> H;

  for (int i = 1; i <= H; i++) cin >> A[i];

  for (int i = H / 2; i >= 1; i--) maxHeapify(i);

  for (int i = 1; i <= H; i++) cout << " " << A[i];
  cout << endl;

  return 0;
}

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000009
#define mod 1000000007
using namespace std;
typedef long long ll;

int n;
int mat[22][22];
ll dp[22][(1<<21)];

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++){
		cin >> mat[i][j];
	}
	
	// dp[i][mask] = i'den öncekiler mask ile eşlendi
	
	for (int i = n-1; i >= 0; i--){
		for (int mask = 0; mask < (1<<n); mask++){
			if (__builtin_popcount(mask) != i) continue; 
			dp[i][mask] = 0;
			for (int j = 0; j < n; j++){
				if (mat[i][j] && ((mask & (1<<j)) == 0)){
					if (i < n-1) dp[i][mask] += dp[i+1][mask | (1<<j)];
					else dp[i][mask] += 1;
					dp[i][mask] %= mod;
				}
			}
		}
	}
	
	cout << dp[0][0] << endl;
	
}

Measured memory_bytes: 309504
<?php
$in = [];
fscanf(STDIN, "%d", $n);
for($i = 0; $i < $n - 1; $i++){
    $in[] = array_map('intval', explode(' ', fgets(STDIN)));
}
for($i = 0; $i < $n; $i++){
    $sum = 0;
    for($j = $i; $j < $n-1; $j++){
        if($sum < $in[$j][1]) $sum = $in[$j][1];
        elseif($sum % $in[$j][2] == 0) ;
        else $sum = $sum + $in[$j][2] - $sum % $in[$j][2];
        $sum += $in[$j][0];
    }
    echo $sum ."\n";
}

Measured memory_bytes: 4604
#
# Keitai Message
#

class Cellular < Hash
  def initialize
    @buf=[]
    @ptr=['0', -1]
    self.store('1', %w". , ! ?"+[' '])
    self.store('2', %w"a b c")
    self.store('3', %w"d e f")
    self.store('4', %w"g h i")
    self.store('5', %w"j k l")
    self.store('6', %w"m n o")
    self.store('7', %w"p q r s")
    self.store('8', %w"t u v")
    self.store('9', %w"w x y z")
  end

  def push(b)
    if b=='0'
      enter
    else
      @ptr[0]=b
      @ptr[1]=@ptr[1]+1
      @ptr[1]=0 if @ptr[1]==self[@ptr[0]].size
    end
  end

  def enter
    @buf<<self[@ptr[0]][@ptr[1]] if @ptr[0]!='0'
    @ptr=['0', -1]
  end

  def message
    @buf.join('')
  end

end

gets.to_i.times do

  cell = Cellular.new
  gets.chomp.chars { |c| cell.push(c) }
  puts cell.message

end

Measured memory_bytes: 6108
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

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

int main(void)
{
        int n;
        cin >> n;
        int a, b, c, d;
        d = n % 10;
        n /= 10;
        c = n % 10;
        n /= 10;
        b = n % 10;
        n /= 10;
        a = n % 10;

        if(a+b+c+d==7){
                cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
                return 0;
        }else if(a+b+c-d==7){
                cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
                return 0;
        }else if(a+b-c+d==7){
                cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
                return 0;
        }else if(a+b-c-d==7){
                cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
                return 0;
        }else if(a-b+c+d==7){
                cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
                return 0;
        }else if(a-b+c-d==7){
                cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
                return 0;
        }else if(a-b-c+d==7){
                cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
                return 0;
        }else if(a-b-c-d==7){
                cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
                return 0;
        }

        return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

char alf[26];
int N;

void solve(string ans,int maxi,int rem){
    if(rem==0){
        cout << ans << endl;
        return;
    }
    rep(i,maxi+1) solve(ans+alf[i],max(maxi,i+1),rem-1);
}

int main(void){
    cin >> N;
    rep(i,26) alf[i]='a'+i;
    solve("",0,N);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt{
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

using mint=ModInt<MOD>;
mint dp[2010][2010];
mint sum[2010][2010];
int main() {
	int n,m; cin>>n>>m;
	int s[n]; rep(i,n) cin>>s[i];
	int t[m]; rep(i,m) cin>>t[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]!=t[j-1]){
				dp[i][j]=0;
			}else{
				dp[i][j]=sum[i-1][j-1]+1;
			}
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j];
		}
	}
	cout<<sum[n][m]+1<<endl;
	return 0;
}

Measured memory_bytes: 63488
#include <iostream>

using namespace std;

int max(int a, int b) {
    if (a>b) return a;
    else return b;
}

int main(void) {
    int i, N, H[30], m, X;
    cin >> N;
    for (i=0;i<N;i++) cin >> H[i];
    m = H[0];
    X = 1;
    for (i=1;i<N;i++) {
        if (m<=H[i]) X++;
        m = max(m,H[i]);
    }

    cout << X << endl;

    return 0;
}

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

using namespace std;
const int N = 1e6+100;
typedef long long ll;
int main(){
	int n,k;
	double ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		int a;
		if(i<=k-1) 
		{
			for(int j=1;;j++)
			{
				if(i*pow(2,j)>=k) 
				{
					a=j;
					break;
				}
			}
			ans+=1.0/n*pow(0.5,a);
		}
		else ans+=1.0/n;
	}
	printf("%.15lf\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N, K; cin >> N >> K;
    ll ans = 0;
    for(ll b = K + 1; b <= N; b++){
        ans += (N / b) * (b - K);
        ans += max(min(N % b - K + 1, N % b), 0LL);
        // pt(ans);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a+b);
  for (int i=1;i<=1000;i++) {
    if(i*i == x) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i <= n; i++)

int n;
map<int, int> m;
ll ans = 0;

int main(){
    cin >> n;
    Rep(i, n){
        int a;
        cin >> a;
        m[i+a]++;
        ans += m[i-a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20500
#include<stdio.h>

int n;
int k;
int w[100000];

int check(int p){
	int i=0;
	int s;
	for(int j=0;j<k;j++){
		s=0;
		while(s+w[i]<=p){
			s+=w[i];
			i++;
			if(i==n)return n;
		}
	}
	return i;
}

int solve(){
	int left=0;
	int right=1000000000;
	int mid;
	
	while(right-left>1){
		mid=(left+right)/2;
		int v=check(mid);
		if(v>=n)right=mid;
		else left=mid;
	}
	
	return right;
}

int main(void){
	scanf("%d",&n);
	scanf("%d",&k);
	
	for(int i=0;i<n;i++)scanf("%d",&w[i]);
	
	int ans=solve();
	printf("%d\n",ans);
	
	return 0;
}



Measured memory_bytes: 2244
import java.io.*;
import java.text.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int array[]= new int[5];
		String msg  = "Yay!";
		for (int i = 0; i < 5; i++) {
			array[i] =sc.nextInt();
		}
		int tag = sc.nextInt();
		Arrays.sort(array);
		if (array[4] - array[0]  > tag) {
			msg = ":(";
		}
		
		System.out.println(msg);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a[200010]={0},b[200010]={0};
int main()
{
    int t=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
            b[t]=a[n-1-i];
        else
        {
            b[n-t-1]=a[n-1-i];
            t++;
        }
    }
    for(int i=0;i<n;i++)
        printf("%d ",b[i]);
    printf("\n");
    return 0;
}


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

int main() {

	ll d, n; cin >> d >> n;
	
	ll ans;
	if (d == 0) {
		if (n != 100) ans = n;
		else ans = 101;		
	}
	else {
		ll tmp = 1;
		for (ll i = 0; i < d; i++) {
			tmp *= 100;
		}
		if (n != 100) ans = tmp * n;
		else ans = tmp * 101;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5 + 5)


void solve()
{
    string s,t;
    cin>>s>>t;

    int n = s.size() , m = t.size();

    int ans = m;
    for(int i=0;i+m<=n;i++)
    {
        int cur = 0;
        string x = s.substr(i,m);
        for(int j=0;j<m;j++)
        {
            if(t[j] != x[j])
                cur++;
        }

        ans = min(ans,cur);
    }

    cout<<ans;

}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 3668
s = input()
for _ in range(int(input())):
    code=input().split()
    if code[0]=='print'  :
        print(s[int(code[1]):int(code[2])+1])
    elif code[0]=='reverse':
        s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
    elif code[0]=='replace':
        s = s[:int(code[1])] + code[3] + s[int(code[2])+1:]


Measured memory_bytes: 5612
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<int>d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (d[i - 1] < d[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define pb push_back
#define nc getchar
using namespace std;
inline void read(int &x) {
	char b = nc(); x = 0;
	for (; !isdigit(b); b = nc());
	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';
}
struct Node {
	int x, y, id;	
	inline bool operator<(const Node &o) const {
		return x < o.x || (x == o.x && y < o.y);
	}
} a[100005];
int n, s, t, D, f[100005], fa[100005], rk[100005];
int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
long long ans;
bitset < 100005 > vis;
inline int ABS(int x) {return x > 0 ? x : -x;}
inline void ae(int u, int v) {
	if ((u = find(u)) != (v = find(v))) {
		if (rk[u] < rk[v]) swap(u, v);
		rk[u] += rk[u] == rk[v]; fa[v] = u;
	}
}
void build(int k) {
	sort(a + 1, a + 1 + n); int i, j, l, r;
	for (i = j = l = r = 1; i <= n; ++i) {
		while (a[l].x < a[i].x - D || (a[l].x == a[i].x - D && a[i].y - a[l].y > k)) ++l;
		while (a[r].x < a[i].x - D || (a[r].x == a[i].x - D && a[r].y - a[i].y <= k)) ++r;
		f[a[i].id] += r - l; j = max(j, l); if (j < r) ae(a[i].id, a[j].id);
		for (; j + 1 < r; ++j) ae(a[j].id, a[j+1].id);
	}
}
int main() {
	read(n); read(s); read(t);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int x, y, i = 1; i <= n; ++i)
		read(x), read(y), a[i] = (Node){x + y, x - y, i};
	D = max(ABS(a[s].x - a[t].x), ABS(a[s].y - a[t].y));
	build(D);
	for (int i = 1; i <= n; ++i) swap(a[i].x, a[i].y);
	build(D-1);
	for (int i = 1; i <= n; ++i)
		if (find(i) == find(s)) ans += f[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  vector<int> A(3);
  rep(i, 3) cin >> A[i];

  sort(all(A), greater<int>());

  int ans = 0;
  if ((A[0] - A[1] + A[0] - A[2]) & 1) {
    ans++;
    if ((A[0] - A[1]) & 1) {
      A[0]++;
      A[1]++;
    } else {
      A[0]++;
      A[2]++;
    }
  }

  ans += (A[0] * 2 - A[1] - A[2]) / 2;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		cin>>a>>b;
		ans+=b-a+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
na = lambda: input()

text = na()
num = []

for t in text:
    num.append(int(t))

ans = 0
pm = []
for a in [1,-1]:
    for b in [1,-1]:
        for c in [1,-1]:
            pm_tmp = [1]
            pm_tmp.append(a)
            pm_tmp.append(b)
            pm_tmp.append(c)
            pm.append(pm_tmp)

for p in pm:
    ans_num = 0
    for q in range(4):
        ans_num += num[q]*p[q]
        if q == 0:
            ans_txt = str(num[q])
        else:
            if p[q] == -1:
                ans_txt += "-"
            elif p[q] == 1:
                ans_txt += "+"  
            ans_txt += str(num[q]) 
    if ans_num == 7:
        ans_txt += "=7"
        ans = ans_txt
            
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define sz 100002
int a,b,test,i,j;
using namespace std;
int main()
{
    ll int n,k,x,y,res=0;
    cin>>n>>k>>x>>y;
    ll int mn=min(n,k);
    res=mn*x;
    n-=mn;
    res+=y*n;
    cout<<res<<endl;


}


Measured memory_bytes: 256
import math

n=int(input())
a=list(map(int,input().split()))

b=list(reversed(a))

g=[]
g.append(a[0])
for i in range(1,n):
  x=math.gcd(g[-1],a[i])
  g.append(x)

h=[]
h.append(b[0])
for j in range(1,n):
  y=math.gcd(h[-1],b[j])
  h.append(y)
  
ans=[]
for k in range(n):
  if k==0:
    ans.append(h[n-2])
  elif k==n-1:
    ans.append(g[n-2])
  else:
    e=g[k-1]
    f=h[n-1-k-1]
    ans.append(math.gcd(e,f))
    
print(max(ans))

Measured memory_bytes: 103684
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> pii;
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false);

int main(){fast;
	string s; cin>>s;
	if(sz(s) % 2){
		cout<<"No\n";
		return 0;
	}
	int n = sz(s);
	rep(i, n){
		if(i % 2 == 0 && s[i] != 'h'){
			puts("No");
			return 0;
		}
		if(i % 2 && s[i] != 'i'){
			puts("No");
			return 0;
		}
	}
			puts("Yes");
}


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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll a[100100], b[100100], c[100100], arr[100100][5], n, maxi;
string s;

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

	cin >> n;
	for (ll i = 1; i <= n; i++){
		cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
	} 
	a[1] = arr[1][1];
	b[1] = arr[1][2];
	c[1] = arr[1][3];
	for (ll i = 2; i <= n; i++){
		a[i] += max(b[i-1], c[i-1]);
		a[i] += arr[i][1];
		b[i] += max(c[i-1], a[i-1]);
		b[i] += arr[i][2];
		c[i] += max(a[i-1], b[i-1]);
		c[i] += arr[i][3];
	}
	maxi = max(a[n], b[n]);
	maxi = max(maxi, c[n]);
	cout << maxi << '\n';
}
  

Measured memory_bytes: 6528