akhauriyash/Code-Regression huggingface dataset:
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  200005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll fac[N];
ll expo(ll base, ll exponent, ll mod=hell) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
ll add(ll x,ll y,ll mod=hell) { x += y; if(x >= mod) x -= mod; return x;}
ll sub(ll x,ll y,ll mod=hell) { x -= y; if(x < 0) x += mod; return x;}
ll mul(ll x,ll y,ll mod=hell) { return (x * 1ll * y) % mod;}
void solve()
{
	ll 	n,m,k;
	cin>>n>>m>>k;
	fac[0]=1;
	rep(i,1,N) fac[i]=mul(fac[i-1],i);
	ll ans=0;
	rep(i,0,k+1)
	{
		ans=add(ans,mul(m,mul(expo(m-1,n-1-i),mul(fac[n-1],mul(expo(fac[i],hell-2),expo(fac[n-i-1],hell-2))))));
	}
	cout<<ans;
}
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
		
	}
	TIME
	return 0;
}

Measured memory_bytes: 5368
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	string s,t;
	cin>>s>>t;
	int i;
	for(i=0;i<t.size()-s.size();i++){
		if(s==t.substr(i,s.size())){
			cout<<"Yes"<<endl;return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3592
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int MOD=998244353;
int used[210][210];
int main(){

	int n;
	cin>>n;
	vi x(n),y(n);
	rep(i,n)cin>>x[i]>>y[i];
	vi po(300,1);
	rep(i,299)po[i+1]=po[i]*2%MOD;
	int out=(po[n]+MOD-n-1)%MOD;
	rep(i,n)loop(j,i+1,n)if(used[i][j]==0){
		vi t{i,j};
		loop(k,j+1,n)if(i!=k&&j!=k&&(x[k]-x[i])*(y[k]-y[j])==(x[k]-x[j])*(y[k]-y[i]))t.pb(k);
		rep(k,t.size())rep(l,t.size())used[t[k]][t[l]]=1;
		out=(out+MOD-po[t.size()]+t.size()+1)%MOD;
	}
	cout<<out<<endl;

}









Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, a[100010];
pii s[100010];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	for (int i = 0; i < n; i++)
		s[i] = pii(a[i], i);
	sort(s, s + n);
	printf("%d", s[0].second + 1);
	for (int i = 1; i < n; i++)
		printf(" %d", s[i].second + 1);
	printf("\n");
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=100;

int n;
vii a(N,vi(N));

int prim();

int main(){
	int i,j;
	cin>>n;
	loop(i,0,n){
		loop(j,0,n){
			int k;
			cin>>k;
			a[i][j]=(k==-1)? inf:k;
		}
	}
	int m=prim();
	cout<<m<<endl;
}

int prim(){
	int u,minv,i;
	vi d(n,inf);
	vi p(n,-1);
	vi color(n,WHITE);
	d[0]=0;
	while(1){
		minv=inf;
		u=-1;
		loop(i,0,n){
			if(minv > d[i] && color[i]!=BLACK){
				u=i;
				minv=d[i];
			}
		}
		if(u==-1){
			break;
		}
		color[u]=BLACK;
		int v;
		loop(v,0,n){
			if(color[v]!=BLACK && a[u][v]!=inf){
				if(d[v]>a[u][v]){
					d[v]=a[u][v];
					p[v]=u;
					color[v]=GRAY;
				}
			}
		}
	}
	int sum=0;
	loop(i,0,n){
		if(p[i]!=-1){
			sum+=a[i][p[i]];
		}
	}
	return sum;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int x,k,d,ans;
 cin>>x>>k>>d;
 if(abs(x)/d > k)
 	ans=abs(x)-k*d;
 else
 {
 	long long int p=k-abs(x)/d;
 	x=abs(x)-(k-p)*d;
 	if(p%2==0)
 		ans=x;
 	else
 		ans=abs(x-d);
 }
 cout<<ans;
 return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
const int N=1000005;
int f[N];
char a[N],b[N];
bool check(int n){
	for (int i=1;i<=n;i++)
		if (a[i]!=b[i]) return 0;
	return 1;
}
int main(){
	int n;scanf("%d\n%s%s",&n,a+1,b+1);
	if (check(n)){
		printf("0\n");
		return 0;
	}
	int ans=1;
	for (int i=n,j=n,x=0;i;i--)
	if (b[i]!=b[i-1]){
		for (j=std::min(j,i);j && a[j]!=b[i];j--) f[j+x]=-x;
		if (!j){
			printf("-1\n");
			return 0;
		}
		x++;
		if (j--<i) ans=std::max(ans,f[i-1+x]+x+1);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------


const int MAX_N = 1e+2;
const int MAX_W = 1e+5;
VVL dp(MAX_N + 1, VL(MAX_W + 1, 0));

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, W; cin >> N >> W;
    VVL wv(N, VL(2)); REP(i,N) cin >> wv[i][0] >> wv[i][1];

    REP(i, N) {
        ll w = wv[i][0];
        ll v = wv[i][1];
        REP(j, W + 1) {
            if (j - w >= 0) {
                dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    ll ans = *max_element(dp[N].begin(), dp[N].end());
    cout << ans << '\n';

    return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int s = 0; s < S.size(); ++s) {
        for (int e = s; e < S.size(); ++e) {
            bool f = true;
            for (int t = s; t <= e; ++t) {
                if (S[t] != 'G' and S[t] != 'C' and S[t] != 'A' and S[t] != 'T') {
                    f = false;
                    break;
                }
            }
            if (f) {
                ans = max(ans, e - s + 1);
            }
        }
    }
    cout << ans << endl;
}


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

bool is_prime(int n)
{
  if(n <= 1)
    return false;
  for (int i = 2; i <= n / i; i++)
  {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  int ans = n;
  while(!is_prime(ans))
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string a,b,c; cin >> a >> b >> c;
  
  if(a.at(a.size() - 1) == b.at(0) and b.at(b.size() - 1) == c.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 3576
n = int(input())
l = [[0,[0,0]]]
for i in range(n):
  [t,x,y] = map(int,list(input().split()))
  l.append([t,[x,y]])

def HammingDist(p1,p2):
  xd = abs(p1[0]-p2[0])
  yd = abs(p1[1]-p2[1])
  return xd+yd
def check(time,dist):
  if (dist > time):
    return False
  elif ((time - dist) % 2 == 0):
    return True
  else:
    return False

flag = 0
length = len(l)

for i in range(length-1):
  if not check(l[i+1][0] - l[i][0], HammingDist(l[i][1],l[i+1][1])):
    flag = 1

if flag:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 29072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using namespace std;

typedef long long ll;

int main() {
	/*string s;
	cin >> s;
	rep(i, 4) {
		int a = 0;
		rep(j, 4) { 
			if (s[i] == s[j])a++;
		}
		if (a != 2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";*/

	/*int n;
	cin >> n;
	vector<int>p(n + 1);
	int i;
	for (i = 1; i < n + 1; i++)cin >> p[i];
	int ans = 0;
	for (i = 2; i < n; i++) {
		if (p[i] != min({ p[i - 1],p[i],p[i + 1] }) && p[i] != max({ p[i - 1],p[i],p[i + 1] }))ans++;
	}
	cout << ans;*/


	/*int N;
	cin >> N;
	vector<int>d(N);
	int i;
	rep(i, N)cin >> d[i];
	sort(all(d));
	cout << d[N / 2] - d[N / 2 - 1];*/

	int N, K;
	cin >> N >> K;
	vector<vector<int>>c(N + 1, vector<int>(N + 1));
	c[0][0] = 1;
	int i, j;
	for (i = 1; i <= N; i++)for (j = 0; j <= i; j++) {
		if (j == 0 || j == i)c[i][j] = 1;
		else {
			c[i][j] += c[i - 1][j - 1] + c[i - 1][j];
			c[i][j] %= mod;
		}
	}
	ll a, b;
	for (i = 1; i <= K; i++) {
		ll ans = 0;
		if (i <= N - K + 1) {
			a = c[N - K + 1][i];
			b = c[K - 1][i - 1];
			ans = a * b % mod;
		}
		cout << ans << "\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 16000
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


suits = ["S","H","C","D"]
check = [[False]*14 for _ in range(4)]


def get_row(arg_ch):
    for i in range(len(suits)):
        if arg_ch == suits[i]:
            return i


N = int(input())

for _ in range(N):
    tmp = input().split()
    check[get_row(tmp[0])][int(tmp[1])] = True


for row in range(4):
    for col in range(1,14):
        if check[row][col] == False:
            print("%s %d"%(suits[row],col))



Measured memory_bytes: 6368
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long maxn = 610;
const long long mod = 1000000007;
long long n;
long long a[maxn];
long long dp[2][maxn][maxn];
long long ex[maxn] , ignoree[maxn];
long long cnt;
long long fac ( long long x ) {
	long long i , s;
	s = 1;
	for ( i = 1 ; i <= x ; i++ ) s = (s * i) % mod;
	return s % mod;
}
void work () {
	long long i , j , k;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n * 2 ; i++ ) {
		scanf ( "%lld" , &a[i] );
		if ( a[i] != -1 ) ex[a[i]] = 1;
	}
	for ( i = 1 ; i <= n ; i++ ) {
		if ( a[i*2] == -1 && a[i*2-1] == -1 ) cnt++;
		if ( a[i*2] != -1 && a[i*2-1] != -1 ) {
			ignoree[a[i*2]] = ignoree[a[i*2-1]] = 1;
		}
	}
	dp[(n*2)%2][0][0] = 1;
	for ( i = n * 2 ; i >= 1 ; i-- ) {
		for ( j = 0 ; j <= n * 2 ; j++ ) {
			for ( k = 0 ; k <= n * 2 ; k++ ) {
				if ( j + k > 2 * n - i ) break;
				dp[(i-1)%2][j][k] = 0;
			}
		}
		if ( ignoree[i] ) {
			for ( j = 0 ; j <= n * 2 ; j++ ) {
				for ( k = 0 ; k <= n * 2 ; k++ ) {
					if ( j + k > 2 * n - i ) break;
					dp[(i-1)%2][j][k] = dp[i%2][j][k];
				}
			}
			continue;
		}
		for ( j = 0 ; j <= n * 2 ; j++ ) {
			for ( k = 0 ; k <= n * 2 ; k++ ) {
				if ( j + k > 2 * n - i ) break;
				if ( ex[i] ) {
					dp[(i-1)%2][j][k+1] = (dp[(i-1)%2][j][k+1] + dp[i%2][j][k]) % mod;
					if ( j ) dp[(i-1)%2][j-1][k] = (dp[(i-1)%2][j-1][k] + dp[i%2][j][k]) % mod;
				}
				else {
					dp[(i-1)%2][j+1][k] = (dp[(i-1)%2][j+1][k] + dp[i%2][j][k]) % mod;
					if ( j ) dp[(i-1)%2][j-1][k] = (dp[(i-1)%2][j-1][k] + dp[i%2][j][k]) % mod;
					if ( k ) dp[(i-1)%2][j][k-1] = (dp[(i-1)%2][j][k-1] + dp[i%2][j][k] * k) % mod;
				}
			}
		}
	}
	printf ( "%lld\n" , ((long long)dp[0][0][0] * fac ( cnt )) % mod );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <math.h>

double s(double a, double b, double c)
{
    double z = (a + b + c) / 2;
    return sqrt(z * (z - a) * (z - b) * (z - c));
}

double d(double x1, double y1, double x2, double y2)
{
    double dx = x1 - x2;
    double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}

int main(void)
{
    double x[32], y[32];
    double *px, *py;
    int i;
    double surface;

    for (i = 0; ~scanf("%lf,%lf", x + i, y + i); i++);

    surface = 0;
    for (; i > 2; i--){
        double d1 = d(x[i - 2], y[i - 2], x[i - 1], y[i - 1]);
        double d2 = d(x[i - 1], y[i - 1], x[0], y[0]);
        double d3 = d(x[0], y[0], x[i - 2], y[i - 2]);
        surface += s(d1, d2, d3);
    }

    printf("%.10f\n", surface);

    return 0;
}

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


int main(void){
	int L;string str;
	cin >> L >> str;
	if( str.substr( 0,L/2 ) == str.substr( L/2 ) )cout << "Yes" << endl;
	else cout << "No" << endl;
//	cout << str.substr( 0,L/2 ) << " " <<  str.substr( L/2 );
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b=0;
    cin>>a;
    for(int i=0;i<25;i++){
        for(int j=0;j<15;j++){
            if(i*4+j*7==a){
                    b++;
                    break;
            }
        }
    }
    if(b>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, x, y = map(int, input().split())
    r = a * x + b * y
    for i1 in range(1, min(x, y) + 1):
        r1 = r - a - b + c * 2
        r = min(r, r1)
    if x > y:
        for j1 in range(y + 1, x + 1):
            r1 = r - a + c * 2
            r = min(r, r1)
    else:
        for j1 in range(x + 1, y + 1):
            r1 = r - b + c * 2
            r = min(r, r1)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
long long gcd(long long a,long long b){
	if(b==0LL){
		return a;
	}else{
		return gcd(b,a%b);
	}
}
long long lcm(long long a,long b){
	if(a==0||b==0){
		return 0;
	}else{
		return a*b/gcd(a,b);
	}
}
int main(){
	long long N,M;
	string S,T;
	cin>>N>>M;
	cin>>S>>T;
	if(S[0]!=T[0]){
		cout<<-1<<endl;
		return 0;
	}
	long long num=lcm(N,M);
	long long mum=gcd(N,M);
	long long sa=num/mum;
	long long now=sa;
	while(now<num){
		if(S[now*N/num]!=T[now*M/num]){
			cout<<-1<<endl;
			return 0;
		}
		now+=sa;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    vector<ll> yaku;
    for(ll i = 1;i * i <= M;i++){
        if(M % i == 0 && i * i != M){
            yaku.push_back(i);
            yaku.push_back(M / i);
        }
        else if(i * i == M)yaku.push_back(i);
    }
    sort(all(yaku));
    auto itr = lower_bound(all(yaku),N);
    cout << M / *itr << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string X; cin >> X;
  int N = X.size();
  int st = 0, cnt = 0;
  rep(i,N){
    if (X[i]=='S') st++;
    else {
      if (st>0) st--;
      else cnt++;
    }

  }  
  cout << cnt+st << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(){

    int n,m;
    cin >> n >> m;

    vector<int> k(m);
    vector<vector<int>> s(m);

    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int t;
            cin >> t;
            t--;
            s[i].push_back(t);
        }
    }
    vector<int> p(m);
    rep(i,m){
        cin >> p[i];
    }
    int ans=0;
    for(int i=0;i<=pow(2,n)-1;i++){
        vector<int> cnt(m,0);
        rep(j,n){
            if((i>>j)&1){
                rep(ii,m){
                    rep(l,s[ii].size()){
                        if(s[ii][l]==j){
                            cnt[ii]++;
                            break;
                        }
                    }
                }
            }
        }
        /*rep(j,m){
            cout << cnt[j] << " ";
        }cout << endl;*/

        rep(j,m){
            if(cnt[j]%2!=p[j]){
                break;
            }
            if(j==m-1){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    ll a, b, c;
    cin >> a >> b >> c;

    if (b >= c) cout << b + c << '\n';
    else {
        c -= b, b <<= 1;
        cout << b + min(a, c) + (a < c) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
N,D,A = map(int,input().split(" "))
line = []
line_append = line.append
for i in range(N):
    x,h = map(int,input().split(" "))
    line_append((x,-(-h//A)))
line.sort()
X = list(map(lambda x: x[0],line))
dmg = [0 for _ in range(N+1)]
ans = 0
for i in range(N):
    x,h = line[i]
    h = max(0,h - dmg[i])
    dmg[i] += h
    dmg[bisect_right(X,x+2*D)] -= h
    dmg[i+1] += dmg[i]
    ans += h

print(ans)

Measured memory_bytes: 81444
#include <bits/stdc++.h>
using namespace std;
const int MAXN=5010,P=131,M=10000000,M2=10000019;
int n,l,r,qp[MAXN],qp2[MAXN],hs[MAXN],hs2[MAXN],vis[M+10],vis2[M2+10];
char c[MAXN];
int hhs (int l,int r) {return (hs[r]-(1ll*hs[l-1]*qp[r-l+1])%M+M)%M;}
int hhs2 (int l,int r) {return (hs2[r]-(1ll*hs2[l-1]*qp2[r-l+1])%M2+M2)%M2;}
bool chk (int x) {
	memset(vis,0,sizeof(vis));
	memset(vis2,0,sizeof(vis2));
	for (int i=1;i<=n-x+1;i++) {
		if (i>x) {vis[hhs(i-x,i-1)]=vis2[hhs2(i-x,i-1)]=1;}
		if (vis[hhs(i,i+x-1)]&&vis2[hhs2(i,i+x-1)]) {return 1;}
	}
	return 0;
}
int main () {
	scanf("%d%s",&n,c+1);
	qp[0]=qp2[0]=1;
	for (int i=1;i<=n;i++) {
		hs[i]=((hs[i-1]*P)%M+c[i]-'a'+1)%M;
		qp[i]=(qp[i-1]*P)%M;
		hs2[i]=((hs2[i-1]*P)%M2+c[i]-'a'+1)%M2;
		qp2[i]=(qp2[i-1]*P)%M2;
	}
	int l=1,r=n;
	if (!chk(1)) {printf("0\n");return 0;}
	while (l<r) {
		int mid=(l+r+1)>>1;
		if (chk(mid)) {l=mid;}
		else {r=mid-1;}
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 78464
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	while(1) {
		int n, q;
		cin >> n >> q;
		if (!n && !q) break;
		getchar();

		Vi v[51];
		Vi ele;
		string s;
		rep(i,0,n) {
			getline(cin, s);
			stringstream ss(s);
			int m;
			ss >> m;
			rep(j,0,m) {
				int t; 
				ss >> t;
				v[i].pb(t);
				ele.pb(t);
			}
		}
		sort(all(ele));
		ele.erase(unique(all(ele)), ele.end());

		int ans = 0;
		q--;
		for (auto it: ele) {
			int cnt = 0;
			rep(i,0,n) {
				auto f = find(all(v[i]), it);
				if (f != v[i].end()) cnt++;
			}
			//printf("it=%d cnt=%d\n",it, cnt);
			if (cnt > q) {
				ans = it;
				q = cnt;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(5):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    for j in range(5):
        for k in range(j,5):
            DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))



print(min(DP[L]))

Measured memory_bytes: 132312
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,a=0;
    cin >> n;
    vector<int> d(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    for(int i=0;i<n;i++){
        for(int j=a;j<n;j++){
            if(i != j){
                sum += d[i] * d[j];
            }
        }
        a++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int lcm(int a, int b){
	if(a%b==0){
		return b;
	}else{
		return lcm(b,a%b);
	}
}
int main(void){
	int n,a[100100],k,i,l;
	bool flag=false;
	cin >> n >> k;
	for(i=0; i<n; i++){
		cin >> a[i];
		if(a[i]==k){
			flag==true;
		}
	}
	sort(a,a+n);
	if(flag){
		cout << "POSSIBLE" << endl;
	}else if(n==1){
		cout << ((a[0]==k)?"POSSIBLE":"IMPOSSIBLE") << endl;
	}else if(a[n-1]<k){
		cout << "IMPOSSIBLE" << endl;
	}else{
		l = lcm(a[1],a[0]);
		for(i=2; i<n; i++){
			if(a[i]%l!=0){
				l = lcm(a[i],l);
			}
		}
		cout << ((k%l==0)?"POSSIBLE":"IMPOSSIBLE") << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code
	int n;
	cin >> n;
	vi a;
	in(a,n);
	sort(all(a), greater<int>());
	ll res = 0;
	if(a.size()>1) res = a[0];
	int k = 1;
	for(int i=1;i<n-1;i++){
		res += a[k];
		if(i%2==0) k+=1;
	}
	cout << res;
}


Measured memory_bytes: 4216
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve((readInt())));
        pw.close();
    }

    static long exponentiation(long base, int exp) {
        long power = 1;
        while (exp > 0) {
            if (exp % 2 == 1) power = power * base % MOD;
            base = base * base % MOD;
            exp /= 2;
        }
        return power;
    }

    static final int MOD = 1_000_000_007;

    private static long solve(int N) {
        long res = exponentiation(10, N)
                - exponentiation(9, N) * 2
                + exponentiation(8, N);

        res = (res + 3L * MOD) % MOD;
        return res;
    }
}

Measured memory_bytes: 32680
#include <iostream>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n; cin>>n; string s; cin>>s;
  int a[n], b[n];
  a[0]=s[0]=='W'; b[n-1]=s[n-1]=='E';
  for(int i=0;i<n-1;i++) a[i+1]=a[i]+(s[i+1]=='W');
  for(int i=n-2;i>=0;i--) b[i]=b[i+1]+(s[i]=='E');
  int an=1e9;
  an=min(an, a[n-2]);
  an=min(an, b[1]);
  for(int i=1;i<n-1;i++) {
    an=min(an, a[i-1]+b[i+1]);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstring>

#define min(a, b) ((a < b) ? a : b)

using namespace std;

const int SIZE = 181 + 1;
const int MAX = 1000000;

int T[SIZE];
int cost1[MAX], cost2[MAX];

int main( void )
{	
	for(int i=0; i < SIZE; ++i) T[i] = i * (i + 1) * (i + 2) / 6;

	memset(cost1, 9, sizeof(cost1));
	for(int i=0; i < MAX; ++i) cost2[i] = MAX;
	cost1[0] = cost2[0] = 0;
	for(int i=0; i < MAX; ++i) {
		if(cost1[i] < 6) {
			for(int j=0; j < SIZE; ++j) {
				if(i + T[j] < MAX)
					cost1[i + T[j]] = min(cost1[i + T[j]], cost1[i] + 1);
			}
		}
		if(cost2[i] < MAX) {
			for(int j=0; j < SIZE; ++j) {
				if(T[j] & 1) {
					if(i + T[j] < MAX)
						cost2[i + T[j]] = min(cost2[i + T[j]], cost2[i] + 1);
				}
			}
		}
	}
	int n;
	while(cin >> n, n) {
		cout << cost1[n] << ' ' << cost2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

char s[maxN];
int main() {
	int n;
	string t;
	scanf("%d",&n);
	cin>>t;
	for(int i=0;i<26;i++)
	{
		s[i] = 'A'+i;
	}
	int m = t.size();
	for(int i=0;i<m;i++)
	{
		int x = t[i]-'A';
		t[i] = 'A'+(x+n)%26; 
	}
	cout<<t<<endl;
	return 0;
}

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

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

  replace(S.begin(),S.end(), ',', ' ');
  cout << S << endl;
}

Measured memory_bytes: 3632
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
a = {}
for i = 1, 4 do
  a[i] = io.read("*n")
end
table.sort(a)
b = {1, 4, 7, 9}
f = true
for i = 1, 4 do
  f = f and a[i] == b[i]
end
print(f and "YES" or "NO")

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i) ;}
  
   int p=1 ;
  for(int i=0;i<N;i++){
   p=vec.at(p-1);
    
     if(p==2){
       cout << i+1 << endl;
     break;}
    
     if(i==N-1){
       cout << -1 << endl; }
    
     }
  
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;


int main(void)
{
	li a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c - 1) {
		cout << b + c << endl;
		return 0;
	}
	cout << b + (a + b + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
_set = set()
ac = 0
wa = 0
ls = []
for i in range(m):
    p, s = [i for i in sys.stdin.readline().split()]
    if s == "AC":
        _set.add(p)
    ls.append([p, s])

new_set = set()
for p, s in ls:
    if s == "AC":
        new_set.add(p)
    if s == "WA" and p in _set and p not in new_set:
        wa += 1
print(len(_set), wa)


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

int main() {
  int a,b;
  cin >> a >> b;
  
  //「#」一行目
 
  for(int i = 0; i < b+2; i++){
      if(i == b+1){
          cout << "#" << endl;
      }else{
          cout << "#" ;
      }
  }
  
  //文字列
  
  for(int i = 0; i < a; i++){
      vector<string> mozi(1);
      
      cin >> mozi.at(0);
      
      cout << "#" << mozi.at(0) << "#" << endl;
  }
  
  //「#」最後の行
  
  for(int i = 0; i < b+2; i++){
      if(i == b+1){
          cout << "#" << endl;
      }else{
          cout << "#" ;
      }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	string w; cin >> w;
	map<char, int> counter;
	rep(i, 0, w.length())counter[w[i]]++;
	bool flag = true;
	map<char, int>::iterator it;
	for (it = counter.begin(); it != counter.end(); it++) {
		if (it->second % 2 != 0) {
			flag = false;
			break;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dfs(VVI& G, int u, int p = -1){
  int res = 0;
  for(int to: G[u])
	if(to != p)
	  res ^= dfs(G, to, u) + 1;
  return res;
}

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

  int N;
  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].EB(v);
	G[v].EB(u);
  }
  cout << (dfs(G, 0)==0?"Bob": "Alice") << endl;

  return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  str s; ll w; cin >> s >> w;
  rep(i, s.size())
  {
    if(i % w == 0) cout << s[i];
  }
  cout << endl;
}
//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func rev(a []int) []int {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([][]int, 2)
	a[0] = make([]int, 0, n)
	a[1] = make([]int, 0, n)
	for i, j := 0, 0; i < n; i, j = i+1, 1-j {
		a[j] = append(a[j], readInt())
	}
	ans := append(rev(a[1]), a[0]...)
	if n%2 != 0 {
		rev(ans)
	}
	sp := ""
	for _, v := range ans {
		printf("%s%d", sp, v)
		sp = " "
	}
	println()
}


Measured memory_bytes: 8192
#include <stdio.h>

int main()
{
	int a,b,c,x,d;
	int T=0;
	scanf("%d %d %d",&a,&b,&c);
	for (x = a;x <= b;x++) {
		if (c%x == 0) {
			T++;
		}
	}
	printf("%d\n",T);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 int n,d,x[105][105],ans=0;
bool chec (int total){
  int x=sqrt(total);
  if (x*x==total) return 1;
  return 0;
}
int sumsquare (int x1,int x2){
  return (x1-x2)*(x1-x2);
}
 main (){
   std::cin>>n>>d;
   for (int i=1;i<=n;i++){
     for(int j=1;j<=d;j++){
       std::cin>>x[i][j];
     }
   }
   for (int i=1;i<=n;i++){
     for (int j=i+1;j<=n;j++){
            int sum=0;
       for (int k=1;k<=d;k++){
           sum+=sumsquare(x[i][k],x[j][k]);
       }
     if (chec(sum)==1) ans++;
     }
   }
   cout<<ans;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    R,S,P=MI()
    T=ST()
    te = [""]*N
    ans = 0
    win = {"r":"p","s":"r","p":"s"}
    for i,t in enumerate(T):
        if i>=K and win[t]==te[i-K]:
            continue
        else:
            if t=="r":
                ans += P
                te[i]="p"
            elif t=="s":
                ans += R
                te[i]="r"
            else:
                ans += S
                te[i]="s"
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 4596
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define ll long long
#define db double
ll len[2005];
vector <ll> L;
int main()
{
    ll n;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&len[i]);
        L.push_back(len[i]);
    }
    sort(L.begin(),L.end());
    ll ans=0;
    for(ll i=0;i<n-2;i++)
    {
        for(ll j=i+1;j<n-1;j++)
        {
            auto it=lower_bound(L.begin(),L.end(),L[i]+L[j]);
            ll cnt=distance(it,L.end());
            ans=ans+n-1-j-cnt;
        }
    }
    printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	int l,s=0;
	cin >> l;
	vector<int>v;
	for (int i = 0; i < l; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++) {
		s += v[i] * (pow(-1, i));
	}
	if (l % 2 == 0) {
		cout << s * (-1);
	}
	else {
		cout << s;
	}
}
	

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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private char[] S, T;
        private void Scan()
        {
            var sc = new Scanner();
            S = sc.Next().ToArray();
            T = sc.Next().ToArray();
        }

        public void Solve()
        {
            Scan();
            Array.Sort(S);
            Array.Sort(T, (a, b) => -a.CompareTo(b));
            Console.WriteLine(new string(S).CompareTo(new string(T)) >= 0 ? "No" : "Yes");
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

const int MOD = 1e9 + 7;

void add(int& a, int b){
  a = (a + b) % MOD;
}

int mult(int a, int b){
  return ((ll)a * (ll)b) % (ll)MOD;
}

int test(int x, int pos){
  return (x >> pos) & 1;
}

void solve(){
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  
  int N = x + y + z + 1;
  int dp[n+1][(1 << N)][2];
  memset(dp, 0, sizeof dp);

  dp[0][1][0] = 1;

  for (int i = 1; i <= n; i++){
    for (int mask = 0; mask < (1 << N); mask++){
      for (int d = 1; d <= 10; d++){
        int new_mask = (mask << d) | 1;// | (1 << (d-1));
        new_mask &= (1 << N) - 1;
        if (test(new_mask, x) && test(new_mask, x + y) && test(new_mask, x + y + z)){
          add(dp[i][new_mask][1], dp[i-1][mask][0]);
        } else {
          add(dp[i][new_mask][0], dp[i-1][mask][0]);
        }
        
        add(dp[i][new_mask][1], dp[i-1][mask][1]);
      }
    }
  }

  int ans = 0;
  for (int mask = 0; mask < (1 << N); mask++){
    add(ans, dp[n][mask][1]);
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


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

const ll INF=(1LL<<60);

int main(void){
    int n; cin >> n;
    ll h[100100];
    ll dp[100100];
    for(int i=1; i<=n; i++) cin >> h[i];

    for(int i=0; i<=n; i++) dp[i]=INF;
    dp[1]=0;

    for(int i=1; i<=n; i++){
        if(i>2) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        if(i>1) chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout << dp[n] << endl;


}

Measured memory_bytes: 1792
n, m = list(map(int, input().split()))
#a = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for i in range(n-m+1):
    for j in range(len(a[0])-len(b[0])+1):
        count = 0
        if b[0] == a[i][j:j+len(b[0])]:
            # print("aaaa")
            for k in range(m):
                if b[k] == a[i+k][j:j+len(b[0])]:
                    count += 1
            if count == m:
                print("Yes")
                exit()
# print(count)
print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if((b-a)&1) puts("IMPOSSIBLE");
	else printf("%d\n",(a+b)/2); 
	return 0;
}

Measured memory_bytes: 764