akhauriyash/Code-Regression huggingface dataset:
import sys
import math
input = sys.stdin.readline


class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, vec):
        return Vector(self.x+vec.x, self.y+vec.y)

    def __sub__(self, vec):
        return Vector(self.x-vec.x, self.y-vec.y)

    def __mul__(self, sc):
        return Vector(self.x*sc, self.y*sc)

    def __truediv__(self, sc):
        return Vector(self.x/sc, self.y/sc)

    def __iadd__(self, vec):
        self.x += vec.x
        self.y += vec.y
        return self

    def __isub__(self, vec):
        self.x -= vec.x
        self.y -= vec.y
        return self

    def __imul__(self, sc):
        self.x *= sc
        self.y *= sc
        return self

    def __itruediv__(self, sc):
        self.x /= sc
        self.y /= sc
        return self

    def __str__(self):
        return '{:.9f} {:.9f}'.format(self.x, self.y)

    def __eq__(self, vec):
        return self.x == vec.x and self.y == vec.y

    def dot(self, vec):
        return self.x * vec.x + self.y * vec.y

    def cross(self, vec):
        return self.x * vec.y - self.y * vec.x

    def abs(self):
        return (self.x*self.x + self.y*self.y)**0.5

    def ortho(self):
        return Vector(-self.y, self.x)

x0, y0, x1, y1 = map(int, input().split())
p0 = Vector(x0, y0)
p1 = Vector(x1, y1)
v1 = p1-p0

for _ in [0]*int(input()):
    x, y = map(int, input().split())
    p2 = Vector(x, y)
    v2 = p2-p0

    det = v2.cross(v1)
    if det > 0:
        print('CLOCKWISE')
    elif det < 0:
        print('COUNTER_CLOCKWISE')
    elif v2.dot(v1) < 0:
        print('ONLINE_BACK')
    elif v2.dot(v2) > v1.dot(v1):
        print('ONLINE_FRONT')
    else:
        print('ON_SEGMENT')



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  int ans = 0;
  bool odd = false;
  while (!odd) {
    for (int i=0; i<N; i++){
      if (A.at(i) % 2 != 0){
        odd = true;
        break;
      }else{
        A.at(i) /= 2;
      }
    }
    if (odd) break;
    ans += 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 300010
#define Mod 998244353
#define LL long long
LL s1[N],s2[N];
LL find(LL x,LL y)
{
    LL ans=1;
    x=x%Mod;
    while(y)
    {
        if(y%2)
            ans=ans*x%Mod;
        x=x*x%Mod;
        y=y/2;
    }
    return ans;
}
int main()
{
    LL n,m,x,y;
    LL i,j,k;
    LL ans;
    scanf("%lld%lld%lld%lld",&n,&x,&y,&m);
    s1[0]=1;
    for(i=1;i<=n;i++)
        s1[i]=s1[i-1]*i%Mod;
    s2[n]=find(s1[n],Mod-2);
    for(i=n;i>=1;i--)
        s2[i-1]=s2[i]*i%Mod;
    ans=0;
    for(i=0;i<=n;i++)
    {
        if((m-i*x)%y!=0||(m-i*x<0)||(m-i*x)/y>n)
            continue;
        ans=(ans+s1[n]*s2[i]%Mod*s2[n-i]%Mod*s1[n]%Mod*s2[(m-i*x)/y]%Mod*s2[n-(m-i*x)/y]%Mod)%Mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4864
MOD = 10 ** 9 + 7  # prime number

def cmb(n, r, mod=MOD):
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    numerator, denominator = 1, 1
    for i in range(1, r + 1):
        numerator = (numerator * (n + 1 - i)) % mod
        denominator = (denominator * i) % mod
    return numerator * pow(denominator, mod - 2, mod) % mod

X, Y = map(int, input().split())
if (X + Y) % 3 != 0:
    print(0)
else:
    n = int((X + Y) / 3)
    a = Y - n
    b = X - n
    if not (a >= 0 and b >= 0):
        print(0)
    else:
        ans = cmb(a + b, a)
        print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
	char s[101];
	scanf("%s",s);
	int cont=0;
	for(int i=0;i<strlen(s)/2;i++){
		if(s[i]!=s[strlen(s)-i-1])
			cont+=1;
	}
	printf("%d\n",cont);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define F(x,y) cnt[(x)&(y)]
using namespace std;
int n,m,cnt[1025];
int main(){
	For(i,0,1023) cnt[i]=cnt[i/2]^(i&1);
	scanf("%d%d",&n,&m);
	For(i,1,(1<<n)-1){
		For(j,1,(1<<m)-1) putchar('0'^F(i,j)^F(i-1,j)^F(i,j-1)^F(i-1,j-1));
		puts("");
	}
}

Measured memory_bytes: 1280
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int a[maxn];
int Xiaobo()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	ll ans=mod,mid=1;
	int flag=1;
	while(flag) {
		ll sum=0;
		flag=0;
		for(int i=1;i<=n;i++) {
			sum+=(a[i]-mid)*(a[i]-mid); 
		}
		if(sum<=ans) {
			ans=sum;
			flag=1;
		}
		mid++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split())
logs = list(map(int, input().split()))

ng_len = 1
ok_len = 1000000000


def possible_len(length: int, log: list, k: int):
    count = 0
    for i in range(N):
        count += math.ceil(log[i] / length) - 1
    if count <= k:
        return True
    else:
        return False


while ok_len - ng_len > 1:
    mid = (ng_len + ok_len) // 2
    if possible_len(mid, logs, K):
        ok_len = mid
    else:
        ng_len = mid

if possible_len(ng_len, logs, K):
    print(ng_len)
else:
    print(ok_len)


Measured memory_bytes: 30864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int H,W,M,X[301010],Y[301010];
pii d[301010],d2[301010];
int st[301010],top;

int base=1<<19,tree[1<<20];
void build(){
	for(int i=0;i<301010;i++) tree[i+base]=Y[i];
	for(int i=base-1;i>=0;i--) tree[i]=max(tree[i<<1],tree[i<<1|1]);
}
void update(int p,int v){
	p+=base;
	tree[p]+=v;
	for(p>>=1;p;p>>=1) tree[p]=max(tree[p<<1],tree[p<<1|1]);
}
int query(int l,int r){
	l+=base; r+=base;
	int ret=-inf;
	while(l<=r){
		if(l&1) ret=max(ret,tree[l]);
		if(~r&1) ret=max(ret,tree[r]);
		l=(l+1)>>1; r=(r-1)>>1;
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>H>>W>>M;
	for(int i=0;i<M;i++){
		cin>>d[i].fi>>d[i].se;
		X[d[i].fi]++;
		Y[d[i].se]++;
	}
	build();
	sort(d,d+M);
	int ans=0;
	for(int i=0;i<M;i++){
		update(d[i].se,-1);
		st[top++]=d[i].se;
		if(d[i].fi==d[i+1].fi) continue;
		ans=max(ans,X[d[i].fi]+tree[1]);
		while(top--) update(st[top],1);
		top=0;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//


int H,W;
char s[51][51];
int table[51][51];
int gx = H-1, gy = W-1;
int black = 0;

int main(){
        cin >> H >> W;
        for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                        cin >> s[i][j];
                        if(s[i][j] == '#') black++;
                        table[i][j] = 1e9;
                }
        }

        queue<P> q;
        q.push(make_pair(0,0));
        table[0][0] = 0;

        while(!q.empty()){
                P p = q.front();
                q.pop();

                if(p.first == gx && p.second == gy) break;

                for(int i = 0; i < 4; i++){
                        int nx = p.first + dx[i];
                        int ny = p.second + dy[i];

                        if(nx >= 0 && nx < H && ny >= 0 && ny < W && s[nx][ny] != '#' && table[nx][ny] == 1e9){
                                table[nx][ny] = table[p.first][p.second] + 1;
                                q.push(make_pair(nx,ny));
                        }
                }
        }




        //このテーブルのインデックスをgx,gyにしても動くはずなのにうまく動作しないのはなぜ？
        if(table[H-1][W-1] == 1e9) cout << -1 << endl;
        else{
                cout << H*W - (table[H-1][W-1]+1) - black << endl;
        }

        return 0;


}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, n;
    char s[1000];
    for (i = 0;  i < 5; i++)
    {
        scanf("%d", &n);
        if (n == 0)
        {
            printf("%d", i + 1);
            return (0);
        }
    }
    return (0);
}


Measured memory_bytes: 1728
n = int(input())
dat_a = list(map(int, input().split()))
dat = []
for i in range(n):
    dat.append((i+1, dat_a[i]))

#print(dat)
dat.sort(key=lambda x: x[1])
#print(dat)
res = []
for i in range(n):
    res.append(str(dat[i][0]))
print(" ".join(res))


Measured memory_bytes: 67820
#include<cstdio>
int main()
{
	int d,n;
	scanf("%d%d",&d,&n);
	if (n==100)
	{
		printf("101");
		for (int i=1;i<=d;++i) printf("00");
		return 0;
	}
	printf("%d",n);
	for (int i=1;i<=d;++i) printf("00");
	return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A==1){
    if(B==2)cout << 3;
    if(B==3)cout << 2;
  }if(A==2){
    if(B==1)cout << 3;
    if(B==3)cout << 1;
  }if(A==3){
    if(B==1)cout << 2;
    if(B==2)cout << 1;
  }
}

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

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

  int X;
  cin >> X;

  int k = 1;

  while (k * X % 360 != 0)
  {
    k++;
  }
  cout << k << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int H, W;
	cin >> H >> W;
	vector<vector<char>>dat(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> dat[i][j];
		}
	}


	ll ans = 0;
	for (int i = 0; i < W - 1; i++) {
		vector<vector<ll>>dp(H+1,vector<ll>(H+1,0)),cost(H+1,vector<ll>(H+1,0));
		for (int j = 1; j <= H; j++) {
			for (int k = 1; k <= H; k++) {
				cost[j][k] = cost[j - 1][k - 1] + (dat[j-1][i] == dat[k-1][i+1]);
			}
		}
		for (int j = H; j >= 0; j--) {
			for (int k = H; k >= 0; k--) {
				if (j == H && k == H)continue;
				ll c1 = (j != H) ? dp[j + 1][k] + cost[j + 1][k] : inf;
				ll c2 = (k != H) ? dp[j][k + 1] + cost[j][k + 1] : inf;
				dp[j][k] = min(c1, c2);
			}
		}
		ans += dp[0][0];
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 1864
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  string s; cin >> s;
  cout << s[0] << s[1] << s[2] << "\n";
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#define N_MAX 999999


int prime[( N_MAX + 1 ) / 2 ];
int memo[ N_MAX + 1 ];

int mkprime( void );

int main( void )
{
	int n;

	prime[0] = 2;
	memo[1] = 0;
	memo[2] = 1;

	mkprime();

	while( std::cin >> n ){
		std::cout << memo[n] << std::endl;
	}
	
	return 0;
}

int mkprime( void ){
	int i, j, endindex = 1;

	for( i = 3; i < N_MAX + 1; i++ ){
		for( j = 0; prime[j] * prime[j] <= i; j++ ){
		if( i % prime[j] == 0 ){
				goto tag;
			}
		}

		prime[ endindex ] = i;
		endindex++;

tag:
		memo[i] = endindex;
	}
}

Measured memory_bytes: 5376
for k in range (300):
    H, W = map(int, input().split())
    if H==0:
        break
    
    for j in range(W):
        print('#',end='')
    print('')
    
    for i in range(H-2):
        print('#',end='')
        for j in range(W-2): 
            print('.',end='')
        print('#')
        
    for j in range(W):
        print('#',end='')
    
    print('')
    print('')


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}

int main2() {
  int N = nextLong();
  ll A = nextLong();
  ll B = nextLong();
  vector<ll> S(N+1);
  const ll INF = (1e18) + 10;
  S[0] = -INF;
  REP(i, N) S[i+1] = nextLong();

  if (A > B) swap(A, B);

  for (int i = 1; i + 2 <= N; i++) {
    if (S[i+2] - S[i] < A) {
      cout << 0 << endl;
      return 0;
    }
  }
  // pv(ALL(S));
  vector<mint> dp(N+2);
  dp[0] = 1;
  int left = 0; // 最初に非ゼロとなる位置。 i < left なる i は全て 0
  mint val = 0;
  int k = 0;
  for (int i = 1; i <= N; i++) {

    // cout << "i=" << i << " : "; pv(ALL(dp));
    for (; k < i && S[k] <= S[i] - B; k++) val += dp[k];
    dp[i] = val;

    if (S[i] - S[i-1] < A) {
      while (left < i-1) {
        val -= dp[left];
        dp[left] = 0;
        left++;
      }
      if (left >= k) {
        val = 0;
        k = left;
      }
    }
  }

  // cout << "i=" << N+1 << " : "; pv(ALL(dp));

  mint ans = 0;
  for (int k = left; k <= N; k++) ans += dp[k];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4876
#include "bits/stdc++.h"
using namespace std; 
#define LIM 3002

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";


ll n, a[LIM];
ll dp[LIM][LIM][2];
ll solve(int l, int r, int chance) {
	if (l > r)
		return 0;
	ll &cache = dp[l][r][chance];
	if (cache != -1)	return cache;
	if (chance == 1) {
		return cache = max(a[l]+solve(l+1, r, chance^1), a[r]+solve(l, r-1, chance^1));
	} else {
		return cache = min(solve(l+1, r, chance^1), solve(l, r-1, chance^1));
	}
}

int main() {
	int i, j, t;
	memset(dp, -1, sizeof dp );
	scl(n);	
	ll sum = 0;
	for(i=1; i<=n; i++) {
		scl(a[i]);
		sum += a[i];
	}
	//debug2(solve(1, n, 0), sum);
	cout << 2LL*solve(1, n, 1) - sum << endl;
	return 0;
}




Measured memory_bytes: 141312
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	int n, x;
	
	scanf("%d", &n);
	int s = 0;
	while (n--){
		scanf("%d", &x);
		if (x & 1){
			s++;
		}
	}
	puts( (s & 1) ? "NO" : "YES");
 } 

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
out=10**18
for i in range(n):
    ans=ans*a[i]
    if out<ans:
        ans=-1
        break
for i in range(n):
    if a[i]==0:
        ans=0
        break
print(ans)

Measured memory_bytes: 84552
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev = -2
ans = 0
for i in range(len(A)):
    if A[i] == prev+1:
        ans += C[prev-1]
    ans += B[A[i]-1]
    prev = A[i]

print(ans)

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

using namespace std;

long long mp[1000];
long long res;
int n;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		char ch[1000];
		scanf("%s", ch);
		mp[ch[0]]++;
	}
	int P[6] = {0, 'M', 'A', 'R', 'C', 'H'};
	for(int i = 1; i <= 3; i++)
		for(int j = i + 1; j <= 4; j++)
			for(int k = j + 1; k <= 5; k++)
				res += mp[P[i]] * mp[P[j]] * mp[P[k]];
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
template<class T> inline void read(T &n){
	char ch=GC;T w=1,x=0;
	while(!isdigit(ch)){if(ch=='-') w=-1;ch=GC;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=GC;}
	n=x*w;
}
const int maxn=100005;
const int inf=0x3f3f3f3f;
int n,P[maxn],Q[maxn];
int last[maxn<<1],Next[maxn<<2],to[maxn<<2],w[maxn<<2],cnt=1;
inline void addedge(int x,int y,int z){
	Next[++cnt]=last[x],last[x]=cnt;
	to[cnt]=y,w[cnt]=z;
}
inline void add(int x,int y,int z){
	addedge(x,y,z),addedge(y,x,0);
}
int dep[maxn<<1],cur[maxn<<1],st,ed;
queue <int> q;
bool bfs(){
    memset(dep,0,sizeof(dep));
    dep[st]=1;q.push(st);
    while(!q.empty()){
        int u=q.front();q.pop();
        for(int i=last[u];i;i=Next[i]){
            int v=to[i];
            if(w[i]&&!dep[v]){
                dep[v]=dep[u]+1;
                q.push(v);
            }
        }
    }
    return dep[ed];
}
int dfs(int u,int low){
    if(u==ed) return low;
    int add=0;
    for(int i=cur[u];i&&add<low;i=Next[i]){
        int v=to[i];cur[u]=i;
        if(dep[v]==dep[u]+1&&w[i]){
            int tmp=dfs(v,min(low-add,w[i]));
            w[i]-=tmp,w[i^1]+=tmp;
            add+=tmp;
        }
    }
    return add;
}
int dinic(){
    int res=0;
    while(bfs()){
        memcpy(cur,last,sizeof(last));
        res+=dfs(st,inf);
    }
    return res;
}
int bela[maxn],belb[maxn],tot;
int main(){
	read(n),ed=n*2+1;
	for(int i=1;i<=n;i++) read(P[i]),P[i]++;
	for(int i=1;i<=n;i++) read(Q[i]),Q[i]++;
	for(int i=1;i<=n;i++)
	if(!bela[i]){
		bela[i]=++tot;
		for(int j=P[i];j!=i;j=P[j]) bela[j]=tot;
	}
	for(int i=1;i<=n;i++)
	if(!belb[i]){
		belb[i]=++tot;
		for(int j=Q[i];j!=i;j=Q[j]) belb[j]=tot;
	}
	int ans=n;
	for(int i=1;i<=n;i++){
		if(P[i]==i&&Q[i]==i) ans--;
		if(P[i]==i&&Q[i]!=i) add(st,belb[i],1);
		if(P[i]!=i&&Q[i]==i) add(bela[i],ed,1);
		if(P[i]!=Q[i]&&P[i]!=i&&Q[i]!=i) add(bela[i],belb[i],1); 
		if(P[i]==Q[i]&&P[i]!=i&&Q[i]!=i) add(bela[i],belb[i],1),add(belb[i],bela[i],1);
	}
	cout<<ans-dinic();
	return 0;
}

Measured memory_bytes: 12928
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1 
 
int main() {
    // input
    int H, W;
    cin >> H >> W;
    char vec[55][55];
	for(int i = 0;i < H; i++)
	  scanf("%s",vec[i]);
    
    
    // calculation
    int cnt;
    REP(i, H) {
        REP(j, W) {
            if (vec[i][j] == '.') {
                cnt = 0;
                for (int k = i-1; k <= i+1; ++k) {
                    for (int l = j-1; l <= j+1; ++l) {
                        if (k < 0 || l <0) {
                            continue;
                        } else if (vec[k][l] == '#') {
                            cnt++;
                        }
                    }
                }
                cout << cnt;
            }
            else {
                cout << '#';
            }
        }
        cout << "\n";
    }
    
    return 0;
}

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a < b) cout << 0 << endl;
  else cout << a-b << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef vector<int> vi;

int main(void) {
    int N, L;
    cin >> N >> L;

    vi a(N);
    int i;
    for (i=0; i<N; i++) {
        scanf("%d", &a[i]);
    }

    int j=0;
    for (i=0; i<N-1; i++) {
        if (a[i]+a[i+1] >= L) {
            j = i+1;
            break;
        }
    }

    if (!j) {
        cout << "Impossible\n";
    } else {
        cout << "Possible\n";

        for (i=N-1; i>j; i--)
            printf("%d\n", i);

        for (i=1; i<=j; i++)
            printf("%d\n", i);
    }

    return 0;
}


Measured memory_bytes: 1152
N = input()
rN = N[::-1]

res = 0
add = False

for i, n in enumerate(rN):
    p = int(n)
    if add:
        p += 1
    if p == 10:
        continue
    elif p == 5:
        if len(N) > i+1 and int(rN[i+1]) >= 5:
            add = True
            res += p
        else:
            add = False
            res += p
    elif p < 5:
        add = False
        res += p
    else:
        add = True
        res += 10-p

if add:
    res += 1

print(res)


Measured memory_bytes: 58352
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    string s;
    long long k,c=0,ans=0;
    cin>>s>>k;
    f(i,0,s.size()){
        if(s[i]=='1'){
            c++;
        }
        else{
            ans=i;
            break;
        }
    }
    if(c>=k){
        cout<<'1'<<endl;
    }
    else{
        cout<<s[ans]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
def get():
    return map(int,input().split())

N,W=get()
x=[[0,0] for _ in range(N)]
for i in range(N):
    x[i][0],x[i][1]=get()
x.sort()
w=[0]*N
v=[0]*N
for i in range(N):
    w[i], v[i] = x[i]

if W>=sum(w):
    print(sum(v))
else:
    dp=[0]*(W+1)
    for i in range(N):
        for j in range(W+w[i]-1,w[i]-1,-1):
            if j >= W:
                dp[W]=max(dp[W],dp[j-w[i]]+v[i])
            else:
                dp[j]=max(dp[j],dp[j-w[i]]+v[i])
    print(dp[W])


Measured memory_bytes: 47336
loop do
	s = gets.chomp
	break if s == ?#
	cand = [s]
	('a'..'z').to_a.reverse.each_cons(2) do |from, to|
		next_cand = []
		cand.each do |s|
			if s =~ /#{to}/
				cs = s.split ""
				flag = true
				(0..cs.size-1).each do |i|
					if flag && cs[i] == to
						copy = cs.dup
						copy[i] = from
						next_cand << copy.join
					elsif cs[i] == from
						flag = false	
					end
				end
				next_cand << s if flag
			else
				next_cand << s if s !~ /#{from}/
			end
		end
		cand= next_cand
	end	
	cand.sort!
	p n = cand.size
	if n <= 10
		puts cand
	else
		puts cand[0..4]
		puts cand[-5..-1]
	end
end

Measured memory_bytes: 22492
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int x ,y;
	        while(true) {
	            x = sc.nextInt();
	            y = sc.nextInt();
	            
	            if(x == 0 && y==0) break;
	            if(x>y) {
	            	System.out.println(y+" "+ x);
	            }
	            else
	            	System.out.println(x+" "+y);
	        }
	    }
	}


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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0;i < N;i++) {
    string x;
    cin >> x;
    
    if (x == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//あかんのかな
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

inline void putints(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));
	putchar(' ');
}


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


	int K, N;
	K = getint();
	N = getint();

	if (K % 2) {
		vector<ll> A;
		A.pb(1);
		ll S = A.back() * (K / 2) + 1;
		int doko;
		rep(i, N) {
			if (S >= N / 2) {
				doko = i;
				break;
			}
			A.pb((A.back() * K) + 1);
			S += A.back() * (K / 2) + 1;
		}
		ll kazu = S - N / 2;
		
		for (int i = N - 1; i >= 0; i--) {
			if (i > doko) putints((K + 1) / 2);
			else {
				if (kazu == 0) break;
				else {
					kazu--;
					ll kari = kazu / A[i];
					if (kari > K - 1) kari = K - 1;
					kazu -= kari * A[i];
					putints(kari + 1);
				}
			}
		}
	}
	else {
		putints(K / 2);
		rep(i, N - 1) putints(K);
	}

	Would you please return 0;
}

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n = Integer.parseInt(br.readLine().trim());
        List<Integer> intList = inputIntList();
        String maxStr = Collections.max(intList).toString();
        String minStr = Collections.min(intList).toString();
        int maxNum = Integer.parseInt(maxStr);
        int minNum = Integer.parseInt(minStr);
        System.out.println(maxNum - minNum);

    }

}



Measured memory_bytes: 32668
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
char a[100005];
int main()
{
    ios::sync_with_stdio(false);
    double c;
    cin>>c;
    printf("%.20f",6.28318530717958623200*c);

}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    for(int i=1;i<=b;i++){
        if(a*i%b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int main() {
  int N,K;
  cin>>N>>K;
  long long h[N];
  for (int i=0;i<N;i++) {cin>>h[i];}
  sort(h,h+N);
  long long ans=linf;
  for (int i = 0; i <= N-K; i++) {
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- replicateM 8 getLine
  solve xs

solve :: [String] -> IO ()
solve xs = do
  let r90 = rot90 xs
  putStrLn "90"
  mapM_ putStrLn r90
  let r180 = rot90 r90
  putStrLn "180"
  mapM_ putStrLn r180
  let r270 = rot90 r180
  putStrLn "270"
  mapM_ putStrLn r270

rot90 :: [String] -> [String]
rot90 = map reverse . transpose

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;

    if(N>=K){
        cout<<K*X+(N-K)*Y<<endl;
    }
    else{
        cout<<N*X<<endl;
    }
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	int a,free = 0;
	bool c[8] = {};
	REP(i,n){
		cin >> a;
		if(a >= 3200) free++;
		else c[a / 400] = true;
	}
	int cnt = 0;
	REP(i,8){
		if(c[i] == true) cnt++;
	}
	if(cnt == 0) cout << 1 << " " << cnt + free << endl;
	else cout << cnt << " " << cnt + free << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n;
int a[105000];
int b[105000];
int c[105000];
ll memo1[105000];
ll memo2[105000];

int main()
{
	cin >> n;
	int ai, bi, ci;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	for (int i = 0; i < n; i++) {
		int k = b[i];
		int* l = upper_bound(c, c + n, k);
		//cout << (int)(l - c) << endl;
		memo1[i] = n - (int)(l - c);
		//cout << memo1[i] << endl;
	}
	for (int i = n - 1; i >= 0; i--) {
		memo2[i] = memo1[i] + memo2[i + 1];
		//cout << memo2[i] << endl;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int k = a[i];
		int *l=upper_bound(b, b + n, k);
		ans += memo2[(int)(l - b)];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2944
#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string s; cin >> s;
    int minv = 1e8;

    for(int i=0; i<s.size()-1; ++i){
        if(s[i] != s[i+1]){
            chmin(minv, max(i+1, (int)s.size()-i-1));
        }
    }

    if(minv == 1e8) minv = s.size();
    cout << minv << endl;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


const int mod = 1e9 + 7;

ll cal(ll r, ll c, char op)
{
    if (op == '*')
        return r * c;
    if (op == '+')
        return r + c;
    return 0;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, k, ans;
    ans = 0;
    cin >> n >> k;
    while(n > 0)
    {
        ans ++;
        n /= k;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
  	var n = Number(input[0])
	var arr = input[1].split(" ").map(Number)
	var m = new Array(n+1).fill(0);
	for(var i=0;i<arr.length;i++){
		m[arr[i]]++;
	}
	var sum = 0
	for(i=0;i<n+1;i++){
		sum += m[i]*(m[i]-1)/2;

	}
	for(i=0;i<arr.length;i++){
		console.log(sum-m[arr[i]]+1)
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 38964
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b,k;cin>>a>>b>>k;
	for(int i=120;i>0;i--){
		if(a%i==0 && b%i==0){
			k--;
			if(k==0) cout<<i<<endl;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define GO ll t; cin>>t; while(t--)
#define mod  1000000007
#define vect vector<long long int>
#define fore(p) for(auto& x:p)
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(), x.rend()
#define PY 3.141592653589793238
ll power(ll a,ll b){
    ll res = 1;
    while(b > 0)
    {
        if(b%2 == 11) res *= a;
        a *= a;
        b /= 2;
    }
    return res;
}
int main() 
{sevensins
    ll i,j,k,l,n;
    cout.precision(10);
    //GO
    {
        cin>>n>>k;
        
        vect v(n);
        
        fore(v)
        cin>>x;
        
        vect dp(n,1e9);
        dp[0]=0;
        for(i=0;i<n;i++)
        {   
            for(j=i+1;j<k+i+1;j++)
            if(j<n)
            dp[j] = min(dp[j] , dp[i] + abs(v[i]-v[j]));
        }
        fore(dp)
        cerr << x <<" ";
        
        cout <<dp[n-1]<<"\n";
    }
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int ans[2005];
int main() {
	int n, x, y;
	scanf("%d %d %d", &n, &x, &y);
	for (int i = 1; i < n; i++)
		ans[i] = n - i;
	for (int i = 1; i <= n; i++)
	{
		if (i >= y)
			continue;
		for (int j = i + 1; j <= n; j++) {
			if (j <= x)
				continue;
			int t = j - i;
			if (i <= x && j >= x && j <= y) {
				int r = (y - j) + 1 + x - i;
				ans[t]--;
				int te = min(t, r);
				ans[te]++;
			}
			else if (i >= x && i <= y && j >= x && j <= y) {
				int r = y - j + i - x + 1;
				ans[t]--;
				int te = min(t, r);
				ans[te]++;
			}
			else if (i >= x && i <= y && j >= y) {
				int r = j - y + i - x + 1;
				ans[t]--;
				int te = min(t, r);
				ans[te]++;
			}
			else if (i <= x && j >= y) {
				int r = j - y + x - i + 1;
				ans[t]--;
				int te = min(t, r);
				ans[te]++;
			}
		}
	}
	for (int i = 1; i < n; i++)
		printf("%d\n", ans[i]);
}

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

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

	size_t c = s.find("C"), f = s.rfind("F");

	if ( c > f || c == -1 || f == -1 ) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
string s[400];
bool done[400][400];
int h, w; 

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

void dfs(int i, int j, long long &white, long long &black) {
    done[i][j] = true;
    if (s[i][j] == '.') white++; else black++;
    for (int k = 0; k < 4; k++) {
        int i1 = i + dx[k], j1 = j + dy[k];
        if (0 <= i1 && i1 < h && 0 <= j1 && j1 < w &&
            !done[i1][j1] && s[i][j] != s[i1][j1]) {
            dfs(i1, j1, white, black);
        }
    }
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> s[i];
    long long ans = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            if (done[i][j]) continue;
            long long white = 0, black = 0;
            dfs(i, j, white, black);
            ans += white * black;
            //cerr << i << ' ' << j << ' ' << white << ' ' << black << endl;
        }
    cout << ans << endl;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define rep(i, s, n) for(int i = s; i < n; i++)
#define rrep(i, s, n) for(int i = s; i > (s)-(n); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int x, a, b;
  cin >> x >> a >> b;

  pr((x-a)%b);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//const int MOD = 1000000007;
const int MOD = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    bool operator==(const mint a){
        return (x == a.x);
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){
    int N; cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D[i];

    if (D[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i < N; i++){
        if (D[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
 
    vector<int> counter(N,0);
    rep(i,N) counter[D[i]]++;

    mint ans = 1;
    for (int i = 2; i < N; i++){
        rep(j,counter[i]){
            ans *= counter[i-1];
        }
    }

    cout << ans << endl; 

}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
typedef std::pair<int, int> pii;
using namespace std;

int const INF = 1 << 30;
int const INIT = 1 << 28;
int n;
vector<pii> a, b, c;
vector<int> p;

bool d(int x) {
    vector<pii> q, r, s;
    int qq[] = {x, 0, 0};
    int rr[] = {0, x, 0};
    int ss[] = {0, 0, x};
    for(int i=0; i<3; i++) {
        vector<pii> result(n);
        for(int j=0; j<n; j++) result[j] = make_pair(0, j);
        q = a, r = b, s = c;
        q[0].first += qq[i];
        r[0].first += rr[i];
        s[0].first += ss[i];

        sort(q.begin(), q.end(), greater<pii>());
        sort(r.begin(), r.end(), greater<pii>());
        sort(s.begin(), s.end(), greater<pii>());
        int sq = INF, sr = INF, ss = INF;
        int gq = -1, gr = -1, gs = -1;
        for(int j=0; j<n; j++) {
            int nq = q[j].first;
            int nr = r[j].first;
            int ns = s[j].first;
            if(nq < sq) sq = nq, gq = j;
            if(nr < sr) sr = nr, gr = j;
            if(ns < ss) ss = ns, gs = j;
            result[q[j].second].first += p[gq];
            result[r[j].second].first += p[gr];
            result[s[j].second].first += p[gs];
        }
        sort(result.begin(), result.end(), greater<pii>());
        int rank = -1;
        int temp = INF, idx = -1;
        for(int j=0; j<n; j++) {
            int cur = result[j].first;
            if(cur < temp) temp = cur, idx = j;
            if(result[j].second == 0) rank = idx+1;
        }
        if(rank < 9) return true;
    }
    return false;
}

int main() {
    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    p.resize(n);
    for(int i=0; i<n; i++) cin >> p[i];
    for(int i=0; i<n; i++) {
        int x, y, z; cin >> x >> y >> z;
        a[i] = make_pair(x, i);
        b[i] = make_pair(y, i);
        c[i] = make_pair(z, i);
    }
    int ub = INIT, lb = -1;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(d(mid)) ub = mid;
        else lb = mid;
    }
    if(ub < INIT) cout << ub << endl;
    else cout << "Saiko" << endl;
    return 0;
}

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

main() {
    int N; string S; cin >> N >> S;
    int x=0; int ans=0;
    rep(i,N){
        if(S[i]=='I')x++;
        else x--;
        ans=max(ans,x);
    }
    cout << ans << endl;
    return 0;
}

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

int h,w;
char canvas[55][55];
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};

bool hamideteru(int x, int y){
    return 0>x||x>=w||0>y||y>=h;
}

bool koritu(int x, int y){
    bool krt=true;
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(!hamideteru(nx,ny)&&canvas[ny][nx]=='#')krt=false;
    }
    return krt;
}
int main(){
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",canvas[i]);

    for(int x=0;x<w;x++){
        for(int y=0;y<h;y++){
            if(canvas[y][x]=='#'&&koritu(x,y)){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}

Measured memory_bytes: 256