akhauriyash/Code-Regression huggingface dataset:
public class Main  {
    public static void main (String[] srgs){

        // ??????????????????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);

        // ?????????????????? int ?????¨??????????????\???????????????.
        // ??????????????????????????? 0 ????????????.
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) { break; }

            // H * W ????????§?????????????????????.
            for (int i = 0; i < H; i ++) {
                if (i % 2 == 0) {
                        for (int j = 0; j < W; j ++) {
                            if (j % 2 == 0) { System.out.print("#"); }
                            if (j % 2 != 0) { System.out.print("."); }
                        }
                    System.out.print("\n");
                }
                if (i % 2 != 0) {
                        for (int j = 0; j < W; j ++) {
                            if (j % 2 == 0) { System.out.print("."); }
                            if (j % 2 != 0) { System.out.print("#"); }
                        }
                    System.out.print("\n");
                }
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 38048
#include <bits/stdc++.h>
//#include <atcoder/all>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	std::string S;
	get(S);

	if (*S.rbegin() == 's') {
		printf("%ses\n", S.c_str());
	}
	else {
		printf("%ss\n", S.c_str());
	}
} 



Measured memory_bytes: 3720
#入力
n,a,b = map(int, input().split())
s = list(input()) #1文字ずつリストに格納する
#総通過人数
pass_contest = 0
#海外学生の順位
rank_overseas = 0
for i in range(len(s)):
    if s[i] == "c":
        print("No")
    elif s[i] == "a" and pass_contest < a+b:
        print("Yes")
        pass_contest += 1
    elif s[i] == "b":
        rank_overseas += 1
        if pass_contest < a+b and rank_overseas <= b:
            print("Yes")
            pass_contest += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4712
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int d; cin >> d;
  const int N = 26;
  Vi c(N); rep(i,N) cin >> c[i];
  VVi s(d, Vi(N)); rep(i,d) rep(j,N) cin >> s[i][j];
  Vi t(d); rep(i,d) { cin >> t[i]; --t[i]; }

  auto getScore = [&]() -> int {
    Vi last(N);
    int ret = 0;
    reps(i,d) {
      ret += s[i-1][t[i-1]];
      last[t[i-1]] = i;
      rep(j,N) ret -= c[j] * (i - last[j]);
      //pl(ret)
    }
    return ret;
  };

  int m; cin >> m;
  rep(i,m) {
    int d, q; cin >> d >> q;
    --d; --q;
    t[d] = q;
    pl(getScore())
  }
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string tmp[4] = { "dream", "dreamer", "erase", "eraser" };
	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) reverse(tmp[i].begin(), tmp[i].end());
	bool ok = true;
	for (int i = 0; i < s.size();) {
		bool can = false;
		for (int j = 0; j < 4; j++) {
			string d = tmp[j];
			if (s.substr(i, d.size()) == d) {
				can = true;
				i += d.size();
			}
		}
		if (!can) {
			ok = false;
			break;
		}
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int n;
int c[100001];
int ci;

int main(void)
{
    uint32_t a1;

    scanf("%d",&n);
    c[0]=1000000001;
    ci = 0;
    for(int i=0;i<n;i++) 
    {
        int a;
        scanf("%d",&a);

        if(a<=c[ci])
        {
            ci++;
            c[ci] = a;
        }else
        {
            for(int j=ci;j>0;j--)
            {
                if(a <= c[j-1] )
                {
                    c[j] = a;
                    break;
                }
            }
        }
    }
    printf("%d\n",ci);

    return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

const string YES = "Yes";
const string NO = "No";

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool x = true;
    while (1) {
        if (x) {
            c -= b;
        } else {
            a -= d;
        }

        if (c <= 0) {
            cout << YES << endl;
            return 0;
        }
        if (a <= 0) {
            cout << NO << endl;
            return 0;
        }
        x ^= true;
    }
    return 0;
}


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




signed main() {
    string s;
    cin>>s;
    int t=0,a=0,ans=0;
    for(int i=0;i<s.size();i++){
        if(t==0){
            if(s[i]=='A')a++;
            if(s[i]=='B')t=1;
            if(s[i]=='C'){
                a=0;
            }
        }else{
            if(s[i]=='C'){
                ans+=a;
                t=0;
            }else{
                a=0;
                t=0;
                if(s[i]=='A')a=1;
            }
        }
    }
    cout<<ans;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

pair<int, int> napsacDP(int capacity, int n,
    const vector<pair<int, int>>& contents) {
  vector<vector<int>> dp(n+1, vector<int>(capacity+1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= capacity; ++j) {
      dp[i][j] = dp[i-1][j];
      if (j >= contents[i-1].second) {
        dp[i][j] = max(dp[i][j],
            dp[i-1][j-contents[i-1].second]
                + contents[i-1].first);
      }
    }
  }
  int maxval = 0;
  int maxweight = 0;
  for (int i = 0; i <= capacity; ++i) {
    if (maxval < dp[n][i]) {
      maxval = dp[n][i];
      maxweight = i;
    }
  }
  return make_pair(maxval, maxweight);
}

int main() {
  int count = 1;
  while(1) {
    int w,n;
    cin >> w;
    if (w == 0) break;
    cin >> n;
    vector<pair<int, int>> contents;
    for (int i = 0; i < n; ++i) {
      int value, weight;
      scanf("%d,%d", &value, &weight);
      contents.emplace_back(value, weight);
    }
    auto result = napsacDP(w, n, contents);
    cout << "Case " << count << ":" << endl;
    cout << result.first << endl;
    cout << result.second << endl;
    ++count;
  }
  return 0;
}

Measured memory_bytes: 5068
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d;
    string s,s1;
    cin >> a;
    cout << 48-a << endl;
    return 0;
} 


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


N = 10 ** 5
primes = prime_numbers(N)
a = [1 if n in primes and (n + 1) // 2 in primes else 0 for n in range(N + 1)]
a = list(accumulate(a))

Q, *LR = map(int, open(0).read().split())
for l, r in zip(*[iter(LR)] * 2):
    print(a[r] - a[l - 1])


Measured memory_bytes: 29012
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int INF = 1e9 + 5;
const int MXN = 110;
const int MXV = 100010;
int n, k;
int v[MXN], w[MXN];
ll dp[MXN][MXV];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    int sv = 0;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        sv += v[i];
    }
    for(int i = 0; i <= n; i++) 
        for(int j = 0; j <= sv; j++) 
            dp[i][j] = INF;
    dp[n][0] = 0;
    for(int i = n - 1; i >= 0; i--) {
        for(int j = 0; j <= sv; j++) {
            dp[i][j] = dp[i + 1][j];
            if(j - v[i] >= 0)
                dp[i][j] = min(dp[i][j], dp[i + 1][j - v[i]] + w[i]);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= sv; i++) {
        if(dp[0][i] <= k)
            ans = max(ans, (ll)i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 82524
#include <stdio.h>

/* prototype declaration */
int integral(int d);
int f(int x);

int main(int argc, const char *argv[])
{
	int d;
	while(scanf("%d",&d) != EOF)
		printf("%d\n", integral(d));	
	return 0;
}

int integral(int d)
{
	int i, s = 0, limit = 600-d;
	for(i=1; i<=limit/d; i++){
		s += d*f(i*d);	
	}
	return s;
}

int f(int x)
{
	return x*x;
}

Measured memory_bytes: 0
X, N = map(int, input().split())
P = list(map(int, input().split()))
 
ans = X
for i in range(101):
    a = X + i
    b = X - i
    if a not in P:
        ans = a
        if b not in P:
            ans = b
        break
    if b not in P:
        ans = b
        break
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ll calc( ll a, ll n )
{
    ll first = a%10;
    ll last = 0;
    while( a )
    {
        last = a%10;
        a /= 10;
    }

    ll ans = 0;
    if( first == 0 )
        return 0;

    // one digit
    if( last == first && first <= n )
        ans++;

    // two digit
    if( 10*first + last <= n )
    {
        // cout<<" n2 : "<<first<<" "<<last,nl;
        ans++;
    }

    ll now;

    // three digit
    now = ( n - 100*first - last + 10 );
    now = max( 0ll, now );
    now /= 10;
    ans += min( now, 10ll );

    // four digit
    now = ( n - 1000*first - last + 10 );
    now = max( 0ll, now );
    now /= 10;
    ans += min( now, 100ll );

    // five digit
    now = ( n - 10000*first - last + 10 );
    now = max( 0ll, now );
    now /= 10;
    ans += min( now, 1000ll );

    // six digit
    now = ( n - 100000*first - last + 10 );
    now = max( 0ll, now );
    now /= 10;
    ans += min( now, 10000ll );

    return ans;
}

int main() 
{
    fastio();

    ll n;
    cin>>n;

    ll ans = 0;
    for(ll i=1;i<=n;i++)
    {
        ans += calc(i,n);
    }
    cout<<ans,nl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;

int i,j,k;
int h,w;
vector<vector<char>> a;
int dy[]={1,-1,0,0},dx[]={0,0,1,-1};
queue<pair<int,int>> que;

int main(){
    cin>>h>>w;
    a.assign(h,vector<char>(w,'.'));

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

    vector<vector<int>> d(h, vector<int>(w,INF));
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(a[i][j]=='#'){
                que.push(make_pair(i,j));
                d[i][j]=0;
            }
        }
    }

    while(que.size()!=0){
        pair<int,int> state=que.front();
        que.pop();
        for(i=0;i<4;i++){
            pair<int,int> next=make_pair(state.first+dy[i],state.second+dx[i]);

            if(next.first>=0 && next.first<h && next.second>=0 && next.second<w && d[next.first][next.second]==INF && a[next.first][next.second]=='.'){//未探索の時
                que.push(next);
                d[next.first][next.second]=d[state.first][state.second]+1;
            }
        }
    }
    
    int ans=-1;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            ans=max(ans,d[i][j]);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 13328
#include<stdio.h>
int main(void)
{
  int N,A,B;
  long long int X[100000],hiro=0,kyori;
  scanf("%d %d %d",&N,&A,&B);
  for(int i=0;i<N;i++){
    scanf("%lld",&X[i]);
  }
  for(int i=0;i<N-1;i++){
    kyori=X[i+1]-X[i];
    if(kyori*A<B){
      hiro+=kyori*A;
    } else {
      hiro+=B;
    }
  }
  printf("%lld\n",hiro);

  return 0;
}
      


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
typedef pair<int,int> P;
struct DSU{
    int par[max_n];
    int sz;
    void init(int n){
        for(int i=1;i<=n;i++)par[i]=i;
        sz=n;
    }
    int findpar(int x){
        return x==par[x]?x:par[x]=findpar(par[x]);
    }
    void unite(int x,int y){
        x=findpar(x),y=findpar(y);
        if(x!=y)par[x]=y,sz--;
    }
    bool same(int x,int y){
        return findpar(x)==findpar(y);
    }
}D;
int n;
ll m;
int q;
vector<P> check;
int main(){
    scanf("%d%lld%d",&n,&m,&q);
    D.init(n);
    while(q--){
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        if(w==0)D.unite(u,v);
        else check.push_back(P(u,v));
    }
    if(m==n-1){
        if(check.size()==0)printf("Yes\n");
        else printf("No\n");
        return 0;
    }
    for(auto p:check){
        int u=p.first,v=p.second;
        if(D.same(u,v)){
            printf("No\n");
            return 0;
        }
    }
    int k=D.sz;
    ll mx=n-k+1ll*k*(k-1)/2;
    if(m<=mx)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1784
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    h = [0] * N  # 入り次数
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        g[L].add((R, D))
        h[R] += 1

    dist = [-1] * N

    def dfs(s):
        dist[s] = 0
        dq = deque([s])
        while dq:
            v = dq.popleft()
            for u, d in g[v]:
                if ~dist[u]:
                    if dist[u] != dist[v] + d:
                        return False
                else:
                    dist[u] = dist[v] + d
                    dq.append(u)
        return True

    # 始点からのパスを処理
    for s in range(N):
        if h[s]: continue  # sに入ってくるパスがあるので、sを始点にしない
        if ~dist[s]: continue
        if not dfs(s):
            print('No')
            return

    # サイクルを処理（どの点も入るパスがあり、処理できていない）
    for s in range(N):
        if ~dist[s]: continue
        if not dfs(s):
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


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

typedef long long ll;

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

const int maxn = 1e6 + 5;
ll ans;
int n;
int a[maxn];

bool clean(vector<int>& v) {
  for (int x: v) if (x > 1) return false;
  return true;
}

void insert(vector<int>& v, int x) {
  for (int j=0; j<32; j++) {
    if (x >> j & 1) {
      v[j]++;
    }
  }
}

void remove(vector<int>& v, int x) {
  for (int j=0; j<32; j++) {
    if (x >> j & 1) {
      v[j]--;
    }
  }
}

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

  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }

  int r=0;
  vector<int> v(32);
  for (int i=0; i<n; i++) {
    while (r<n) {
      insert(v,a[r]);
      if (clean(v)) {
	r++;
      } else {
	remove(v,a[r]); break;
      }
    }
    ans += r - i;
    //cout<<i<<" "<<r<<endl;
    remove(v,a[i]);
  }

  cout<<ans<<endl;  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> logs(n);
    rep(i, n) cin >> logs[i];

    ll floor = 0, ceil = INF;

    auto check = [&](ll mid) -> bool {
        ll t = 0;
        for (ll l : logs) {
            ll now = (l + mid - 1) / mid - 1;
            t += now;
        }
        return t <= k;
    };

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        bool b = check(mid);
        if (b) ceil = mid;
        else floor = mid;
    }

    cout << ceil << endl;


}


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

typedef long long ll;

int main(){
	ll n, temp;
	cin >> n;
	ll a[n], s = 0;
	for(int i = 0; i < n; i++){
		cin >> temp;
		s += temp;
		a[i] = s;
	}
	ll ans = 1e10;
	for(int i = 0; i < n-1; i++){
		ans = min(ans, abs(2ll*a[i] - s));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 998244353;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 3005;

ll dp[N];
ll A[N];

ll ans=0;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,s;
	cin>>n>>s;
	rep(i,0,n)	cin>>A[i];
	ll ans=0;
	rep(j,0,n){
		repb(k,s,A[j]+1){
			dp[k] += dp[k-A[j]];
			dp[k] %= M;
		}
		dp[A[j]] += (j+1);
		dp[A[j]] %= M;
		ans += dp[s];
		ans %= M;
	}
	ans %= M;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
S=list(map(str, [input() for i in range(n)]))
cont=[51]*26
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans=''
for i in range(n):
    for j in range(26):
        if cont[j]>S[i].count(alphabet[j]):
            cont[j]=S[i].count(alphabet[j])
for i in range(26):
    for j in range(cont[i]):
        ans=ans+alphabet[i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>


#include <string>


#include <algorithm>


#include <utility>


#include <iomanip>


#include <functional>


#include <queue>


#include <stack>


#include <map>


#include <vector>


#include <cmath>


#include <cctype>


#include <cstdio>


#define ll long long


#define INF 1e+9


#define MOD 1000000007


using namespace std;



int main(){


    string S;


    string T;


    cin >> S >> T;


    


    if(S.length()<T.length()){


        cout<<"UNRESTORABLE"<<endl;


        return 0;


    }


    


    int flag=0;


    for(int i=S.length()-1; i>=T.length()-1; i--){


        flag=1;


        for(int j=0; j<T.length(); j++){


            if(S[i-j]==T[T.length()-1-j] || S[i-j]=='?'){


                continue;


            }else{


                flag=0;


                break;


            }


        }


        


        


        if(flag==1){


            for(int j=0; j<T.length(); j++){


                S[i-j]=T[T.length()-1-j];


            }


            break;


        }


    }


    


    if(flag==0){


        cout<<"UNRESTORABLE"<<endl;


        return 0;


    }


    


    for(int i=0; i<S.length(); i++){


        if(S[i]=='?'){


            S[i]='a';


        }


    }


    


    cout<<S<<endl;


    return 0;


}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * (n-k+1)
s_0 = sum(p[0:k])
s[0] = s_0
for i in range(n-k):
    s[i+1] = s[i] + p[k+i] - p[i]

print((k+max(s))/2)

Measured memory_bytes: 25604
#include<cstdio>
#include<cstring>
#define maxn 100005
using namespace std;
char s[maxn];
int main()
{
	int len,flag=1;
	scanf("%s",s+1);
	len=strlen(s+1);
	int head=1,tail=len;
	for(int i=1;i<=len;i++)
	{
		char n;
		if(s[tail]=='b')n='d';
		else if(s[tail]=='d')n='b';
		else if(s[tail]=='p')n='q';
		else if(s[tail]=='q')n='p';
		if(n!=s[head])
		{
			flag=0;
			break;
		}
		head++;
		tail--;
	}
	if(flag)
	printf("Yes");
	else
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

inline int take_time(int h, int m, int s)
{
    return 3600 * h + m * 60 + s;
}

int main()
{
    for (int i = 0; i < 3; i++) {
        int sh, sm, ss;
        int eh, em, es;
        int take;

        cin >> sh >> sm >> ss >> eh >> em >> es;
        take = take_time(eh, em, es) - take_time(sh, sm, ss);

        cout << take / 3600 << " ";
        take = take % 3600;
        cout << take / 60 << " ";
        take = take % 60;
        cout << take << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  rep(i,K){
    if(A >= B){
      B =B * 2;
      continue;
    }
    if(B >= C){
      C = C * 2;
      continue;
    }
  }
  if(A < B && B < C){
     cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
a = []
a = gets.chomp.split("")
if a.count("N")>0&&a.count("S")>0
    if a.count("W")>0&&a.count("E")>0
        puts "Yes"
        exit
    elsif a.count("W")==0&&a.count("E")==0
        puts "Yes"
        exit
    end
end
if a.count("W")>0&&a.count("E")>0
    if a.count("N")>0&&a.count("S")>0
        puts "Yes"
        exit
    elsif a.count("N")==0&&a.count("S")==0
        puts "Yes"
        exit
    end
end
puts "No"

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    unordered_set<string> us;
    ll n;
    cin >> n;
    rep(i,n){
        string command,s;
        cin >> command >> s;
        if(command == "insert"){
            us.insert(s);
        }else{
            if(us.find(s) != us.end())cout << "yes\n";
            else cout << "no\n";
        }
    }
    return 0;
}


Measured memory_bytes: 31960
# coding: utf-8

# 入力１行目：4桁の整数(１文字列)
s = gets.chomp.split("")

# ソート
s.sort!

ans = "No"
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]
    if /[A-Z]/ === s[0] and /[A-Z]/ === s[2]
        ans = "Yes"
    end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    long long count;
    for(long long i = 0; i < 5; i++){
        if(x[i] == 0){
            count = i+1;
        }
    }

    cout << count << endl;
    return 0;

}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int dest = 0;
void changeDest(char s){
    switch(s){
        case 'a':
            dest = 0;
            break;
        case 'b':
            dest = 1;            
            break;
        case 'c':
            dest = 2;
            break;
        default:
            break;
        } 
}

int main(){
    string sa,sb,sc;
    int cntA = 0;
    int cntB = 0;
    int cntC = 0;
    cin >> sa >> sb >> sc;
    for(int i=0; i < sa.length() + sb.length() + sc.length();i++){
        switch(dest){
        case 0:
        changeDest(sa[cntA]);
        cntA++;
        if(cntA == sa.length()+1){
            cout << "A" << endl;
            return 0;
        }
        break;
        case 1:
        changeDest(sb[cntB]);
        cntB++;
        if(cntB == sb.length()+1){
            cout << "B" << endl;
            return 0;
        }   
        break;
        case 2:
        changeDest(sc[cntC]);
        cntC++;
        if(cntC == sc.length()+1){
            cout << "C" << endl;
            return 0;
        }   
        break;
        default:
        break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[210000],i,j,n,m,k,maxn;
int main()
{
	scanf("%d%d",&k,&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		maxn=max(maxn,a[i]-a[i-1]);
	}
	maxn=max(maxn,k-(a[n]-a[1]));
	printf("%d",k-maxn);
}

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

// Kを固定して考えると，各グループの色の割り当て方とグループの分け方・グループ数が決まる

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint
{
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if (mod <= (x += a.x))
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if (mod <= (x += mod - a.x))
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        return mint(*this) += a;
    }
    mint operator-(const mint a) const
    {
        return mint(*this) -= a;
    }
    mint operator*(const mint a) const
    {
        return mint(*this) *= a;
    }
    mint pow(long long 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
    {
        return mint(*this) /= a;
    }
};
istream &operator>>(istream &is, const mint &a)
{
    return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
    return os << a.x;
}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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];
    }
} c(200005);

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint color = m; // m色あるときに全部のブロックを1色で塗る時の色の選び方（初期値）
    for (int x = n - 1; 0 <= x; x--)
    {
        mint now = color;
        now *= c(n - 1, x);
        if (x <= k)
            ans += now;
        color *= m - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6204
a,b,c = map(int,input().split())

if a <= b <= c:
    print(a,b,c)
elif a <= c <= b:
    print(a,c,b)
elif b <= a <= c:
    print(b,a,c)
elif b <= c <= a:
    print(b,c,a)
elif c <= a <= b:
    print(c,a,b)
else:
    print(c,b,a)


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;

using namespace std;
#define N 200010
ll n,m,a[N],cnt[N],sum[N];
int main(){
    cin.tie(0);
    cin>>n>>m;
    lol(i,N)cnt[i]=0,sum[i]=0;
    lol(i,n){
	cin>>a[i];
	if(a[i]<N)cnt[a[i]]++;
    }
    lol(i,N){
	for(ll j=i-cnt[i]+1;j<=i;j++)sum[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=sum[i]==0;
    lol(i,m){
	ll x,y;cin>>x>>y; x--;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]]+1;
	    if(p>=1){
		sum[p]--;
		if(sum[p]==0)ans++;
	    }
	    cnt[a[x]]--;
	}
	a[x]=y;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]];
	    if(p>=1){
		if(sum[p]==0)ans--;
		sum[p]++;
	    }
	    cnt[a[x]]++;
	}
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6144
INF=int(1e9+7)


def main():
    Sn = list(open(0).read().split()[1:])
    for i in range(26):
        cnt = INF
        for Si in Sn:
            cnt = min(cnt, Si.count(chr(ord("a") + i)))
        if cnt == INF:
            continue
        print(chr(ord("a") + i) * cnt, end="")


main()


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

int main(){
	int N,K,h,cnt(0);
	cin >> N >> K;
	rep(i,N){
		cin >> h;
		if(h>=K) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> d(n);
    rep(i,n) {
        int m;
        cin >> m;
        rep(j,m) {
            int a;
            cin >> a;
            d[a-1] = 1;
        }
    }
    int ans = 0;
    rep(i,n) if (d[i] == 0) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

char str[10001];

int main(void)
{
	while (scanf("%s", str) != EOF){
		int joi = 0;
		int ioi = 0;
		int i;
		
		for (i = 0; i < strlen(str) - 2; i++){
			if (strncmp(str + i, "JOI", 3) == 0){
				joi++;
			}
			if (strncmp(str + i, "IOI", 3) == 0){
				ioi++;
			}
		}
		printf("%d\n", joi);
		printf("%d\n", ioi);
	}
	
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;


struct UF{
  std::vector<int> par, dep, sz;
  UF(int n){
    par.resize(n+1), dep.resize(n+1), sz.resize(n+1);
    init(n);
  }
  void init(int nu) {
    for(int iu=0;iu<=nu;iu++){
      par[iu] = iu;
      dep[iu] = 0;
      sz[iu] = 1;
    }
  }
  int find(int xu){
    if(par[xu] == xu) return xu;
    return par[xu] = find(par[xu]);
  }
  void unite(int xu, int yu){
    xu=find(xu);
    yu=find(yu);
    if(xu == yu) return;
    if(dep[xu] < dep[yu]){
      sz[yu] += sz[xu];
      par[xu] = yu;
    }else{
      par[yu] = xu;
      sz[xu] += sz[yu];
      if(dep[xu] == dep[yu]) dep[xu]++;
    }
  }
  bool same(int xu, int yu){
    return find(xu) == find(yu);
  }
};
int main(int argc, char const *argv[]) {
  ll a, b, n, m, k;std::cin >> n >> m >> k;
  UF uf(n+1);
  vector<ll> c(n+1, 0);
  vvl f = vv(m, 2, 0, ll);
  re(i, m){
    std::cin >> f[i][0] >> f[i][1];
    uf.unite(f[i][0], f[i][1]);
  }
  re(i, m) {
    if(uf.same(f[i][0], f[i][1])){
      c[f[i][0]]++;
      c[f[i][1]]++;
    }
  }
  re(i, k){
    std::cin >> a >> b;
    if(uf.same(a, b)){
      c[a]++;
      c[b]++;
    }
  }

  rep(i, 1, n+1){
    ll s = uf.sz[uf.find(i)];
    std::cout << s - 1 - c[i] << (i==n?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)



int main() {
    fast;
    int n, k;
    cin>>n>>k;
    vector<ll> arr(n);
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    sort(arr.begin(), arr.end());
    ll min = LONG_LONG_MAX;

    ll sum = 0;
    for (int i = 0; i <= n - k; ++i) {
        sum = arr[i+k-1] - arr[i];
        if(sum < min)
            min = sum;
    }
    cout<<min;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define pi =3.14159265358979323846264338327950L;
typedef long long int ll;
int mod=1e9+7;


int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    map<int,int> mp;
    while(n%2==0){
		mp[2]++;
		n/=2;
	}
    for(int i=3;i<=sqrt(n);i+=2){
		while(n%i==0){
			n/=i;
			mp[i]++;
		}
	}
	if(n>2){
		mp[n]++;
	}
	int ans=0;
	for(auto in:mp){
		ans+=floor((sqrt(1+8*in.second)-1)/2);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
ll dp[3003][3003]={};
signed main(){
    int n;cin>>n;
    int a[n]={};
    rep(i,n) cin>>a[i];
    RREP(i,n-1){
        for(int j=i;j<n;j++){
            if((n-i-j-1)%2==0){
                dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
            }else{
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
#define inf 0x3f3f3f3f
string s;

ll dp[2000050][3][3];
ll qpow(ll n,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
		ans=ans*n%mod;
		n=n*n%mod;
		k>>=1;
	}
	return ans;
}
int main()
{
	cin>>s;
	int len=s.size();
	if(len==1)
	{
		cout<<1<<endl;
		return 0;
	}
	else if(len==3)
	{

	 if(s[0]!=s[1]&&s[1]!=s[2]&&s[0]!=s[2])
	 {
	 	cout<<3;
	 	return 0;
	 }
	}
	bool flag=1;
	for(int i=0;i<len-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			flag=0;
			break;
		}
	}
	if(flag)
	{
		cout<<1;
		return 0;
	}
	for(int i=0;i<3;i++)
	dp[1][i][i]=1;
	for(int i=1;i<len;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				for(int l=0;l<3;l++)
				{
					if(k==l)continue;
					int ss=j+l;
					ss%=3;
					dp[i+1][l][ss]+=dp[i][k][j];
					dp[i+1][l][ss]%=mod;
				}
			}

		}
	}
	ll ans=qpow(3,len-1);
	int tmp=0;
	flag=1;
	for(int i=0;i<len;i++)
	{
		tmp+=s[i]-'a';
		if(i)
		{
			flag&=(s[i]!=s[i-1]);
		}
	 } 
	 if(flag)
	 ans++;
	 tmp%=3;
	 for(int i=0;i<3;i++)
	 {
	 	ans-=dp[len][i][tmp];
	 	while(ans<0)
	 	ans+=mod;
	 }
	 cout<<ans%mod<<endl;
	return 0;
}

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

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                  //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
     int n;cin>>n;
     string s;cin>>s;
     int r=0;
     fr(i,0,n-1)if(s[i]=='R')r++;
     int ans=0;
     fr(i,0,r-1){
     	if(s[i]!='R')ans++;
	 }
	 cout<<ans<<"\n";
}



Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC86
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Solve3();
        }
    }

    public class Solver
    {

        public void Solve1()
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1] % 2 == 0 ? "Even" : "Odd");

        }

        public void Solve2()
        {
            var ab = int.Parse(Console.ReadLine().Replace(" ", ""));

            Console.WriteLine(Math.Sqrt(ab) - (int)Math.Sqrt(ab) == 0 ? "Yes" : "No");

        }

        struct Txy
        {
            public long T;
            public long X;
            public long Y;
        }
        public void Solve3()
        {
            var n = int.Parse(Console.ReadLine());

            var txys = new List<Txy> { new Txy { T = 0, X = 0, Y = 0 } };
            for (int i = 0; i < n; i++)
            {
                var txy = Console.ReadLine().Split().Select(long.Parse).ToArray();
                txys.Add(new Txy { T = txy[0], X = txy[1], Y = txy[2] });
            }

            for (int i = 0; i < n; i++)
            {
                var judge = txys.ElementAt(i + 1).T - txys.ElementAt(i).T - (Math.Abs(txys.ElementAt(i + 1).X - txys.ElementAt(i).X) + Math.Abs(txys.ElementAt(i + 1).Y - txys.ElementAt(i).Y));


                if (judge >= 0 && judge % 2 == 0)
                {
 
                }
                else
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");

        }
    }
}


Measured memory_bytes: 20664
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  var S=input[0];
  console.log(Math.ceil(S/2));
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 30740
#include <iostream>

using namespace std;

int main(){
  int n, m;
  int card[2][200];
  while(cin >> n >> m){
    for(int i=0;i<2*n;i++) card[0][i] = i+1;
    for(int k=0;k<m;k++){
      int cur = k%2, next = 1-k%2;
      int K; cin >> K;
      if(K>0){
        for(int i=0;i<2*n;i++) card[next][i] = card[cur][(i+K)%(2*n)];
      } else {
        for(int i=0;i<n;i++) card[next][2*i] = card[cur][i];
        for(int i=0;i<n;i++) card[next][2*i+1] = card[cur][i+n];
      }
    }
    for(int i=0;i<2*n;i++) cout << card[m%2][i] << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    rep(i,n+1)
        rep(j,n-i+1)
        {
            int k = n-i-j;
            int x = 10000*i + 5000*j + 1000*k;
            if(x == y)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    
    cout << -1 << " " << -1 << " " << -1 << 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))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    if (A+B >= C*2) {
        ans += min(X, Y) * C*2;
        int tmp = min(X,Y);
        X -= tmp, Y -= tmp;
    }
    if (X > 0) {
        if (A > C*2) {
            ans += X * C * 2;
        }
        else {
            ans += X*A;
        }
    }
    if (Y > 0) {
        if (B > C*2) {
            ans += Y * C * 2;
        }
        else {
            ans += Y * B;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n,k = map(int, input().split())
h = [int(input()) for i in range(n)] 
h.sort()

crr_min = 10**9

for i in range(0,math.ceil((n-k+1)/2)):
    tmp1 = h[i+k-1] - h[i]
    tmp2 = h[-1-i] - h[-i-k]
    if tmp1==0 or tmp2==0:
        crr_min=0
        break

    if tmp1<crr_min:
        crr_min = tmp1

    if tmp2<crr_min:
        crr_min = tmp2


print(crr_min)

Measured memory_bytes: 7512
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	int p1=0,p2=s.size()-1;
	while(s[p1]!='A') p1++;
	while(s[p2]!='Z') p2--;
	cout<<p2-p1+1;
	return 0;	
}

Measured memory_bytes: 640
using System;
class Program
{
	static void Main(string[] args)
	{
      string[] param1 = Console.ReadLine().Split(' ');	// 1行目.
      string[] paramL = Console.ReadLine().Split(' ');
      int N = int.Parse(param1[0]);
      int X = int.Parse(param1[1]);
      
      int tmp = 0;
      int bound = 1;
      for (int i = 0; i < N; i++) {
        int L = int.Parse(paramL[i]);
        tmp += L;
        if (tmp > X)
          break;
        
        bound++;
      }
      
      Console.WriteLine(bound);
	}
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main ( ){
    int day;
    cin>>day;
    int a=day%4;
    switch(a){
    case 0:
        cout<<"Christmas Eve"<<endl;
        break;
    case 1:
        cout <<"Christmas"<<endl;
        break;
    case 2:
        cout<<"Christmas Eve Eve Eve"<<endl;
        break;
    case 3:
        cout<<"Christmas Eve Eve"<<endl;
        break;
    }

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;string s;cin>>n>>s;
	int cnt=0;
	for(int i=0;i<1000;i++){
		int a=i/100,b=(i%100)/10,c=i%10,na=-1,nb=-1,nc=-1;//na,nb,ncはsの場所を示す
		for(int j=0;j<n;j++){
			if(a==(int)(s[j]-'0')&&na==-1) na=j;
			else if(b==(int)(s[j]-'0')&&na!=-1&&nb==-1) nb=j;
			else if(c==(int)(s[j]-'0')&&na!=-1&&nb!=-1) nc=max(j,nc);
		}
		//cout<<na<<nb<<nc<<"\n";
		if(na<nb&&nb<nc&&na!=-1&&nb!=-1&&nc!=-1) {
			//cout<<i<<endl;
			cnt++;
		}
	}
	cout<<cnt<<"\n";
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Tag
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, v, b, w, t;
  scanf("%d%d%d%d%d", &a, &v, &b, &w, &t);

  int l = abs(b - a), dv = v - w;

  if (l == 0 || (ll)dv * t >= l) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K,N;
    cin>>K>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ma,k=0;
    for(int i=0;i<N-1;i++){
        ma=abs(A[i+1]-A[i]);
        if(ma>=k){
        k = ma;
        }
    }
    ma = A[0]+(K-A[N-1]);
    if(ma>=k){
        k = ma;
        }
    cout<<K-k<<endl;
}

Measured memory_bytes: 1024