akhauriyash/Code-Regression huggingface dataset:
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月07日 星期日 22时48分12秒
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;

int a[N],b[N];

void solve(){
	int n,H;
	scanf("%d%d",&n,&H);

	int id=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		if(a[i]>a[id]) id=i;
	}
	int tmp=b[id],A=a[id];
	sort(b+1,b+n+1);
	int ans=0;
	for(int i=n;i>=1 && b[i]>=A && H>0;i--){
		H-=b[i],ans++;
	}

	if(H<=0) printf("%d\n",ans);
	else{
		ans+=(H+A-1)/A;
		printf("%d\n",ans);
	}
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


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

int main(){
	int n;
	int Sn[1000];
	int sum=0;   // sum:?????°???????¨?
	int i;
	double ave;
	double a=0;   // a:?????£?????????
	
	while(1){
		scanf("%d",&n);
		if(n==0)   break;
		for(i=0;i<n;i++){
			scanf("%d",&Sn[i]);
			sum+=Sn[i];
		}
		ave=(double)sum/n;
	
		for(i=1;i<=n;i++){
			a+=pow(Sn[i-1]-ave,2);
		}
		a/=(double)n;
		printf("%.5lf\n",sqrt(a));
		sum=0;
		a=0;
	}
		return 0;
}

Measured memory_bytes: 640
n=int(input())
dic={}
M,A,R,C,H=0,0,0,0,0
for i in range(n):
    S=input()
    if S[0]=="M":
        M+=1
    if S[0]=="A":
        A+=1
    if S[0]=="R":
        R+=1
    if S[0]=="C":
        C+=1
    if S[0]=="H":
        H+=1
        
l=[M,A,R,C,H]

p=[[0,1,2],[0,1,3],[0,1,4],[0,2,3],[0,2,4],[0,3,4],[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
cnt=0
for i in range(10):
    cnt+=l[p[i][0]]*l[p[i][1]]*l[p[i][2]]
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<int, 50030> pn{};

  for ( auto i = 2; i < pn.size(); ++i )
    {
      if ( pn[i] == 0 )
        {
          for ( auto j = 2 * i; j < pn.size(); j += i )
            {
              pn[j] = 1;
            }
        }
    }

  int n;

  while ( cin >> n )
    {
      int i;
      for ( i = 1; pn[n - i] == 1; ++i );
      cout << n - i << " ";
      for ( i = 1; pn[n + i] == 1; ++i );
      cout << n + i << endl;
    }
  
  return 0;
}

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

const int MAX_V=300;
ll d[MAX_V][MAX_V];
ll dd[MAX_V][MAX_V];
bool f[MAX_V][MAX_V];


int main(){
  int V;
  cin>>V;
  ll ans=0;
  rep(i,V) rep(j,V){
    cin>>d[i][j];
    dd[i][j]=d[i][j];
    ans+=d[i][j];
  }
  for (int k=0; k<V; k++) {
    for (int i=0; i<V; i++) {
      for (int j=0; j<V; j++) {
	if(d[i][j]>d[i][k]+d[k][j]){
	  cout<<-1<<endl;
	  return 0;
	}
	if(d[i][j]==d[i][k]+d[k][j]&&i!=k&&j!=k){
	  f[i][j]=true;
	}
      }
    }
  }
  rep(i,V) rep(j,V){
    if(i==j) continue;
    if(f[i][j]){
      ans-=dd[i][j];
    }
  }
  cout<<ans/2<<endl;
  return 0;
}




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

using namespace std;

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

    vector<vector<char>> s(h, vector<char>(w));

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> s.at(i).at(j);
        }
    }
    
    int ans = 0;

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s.at(i).at(j) == '.') {
                
                vector<vector<int>> visited(h, vector<int>(w, -1));
                visited.at(i).at(j) = 0;

                queue<pair<int, int>> q;
                q.push(make_pair(i, j));
                
                while (!q.empty()) {
                    int y, x;
                    tie(y, x) = q.front();
                    q.pop();

                    if (y-1 >= 0 && s.at(y-1).at(x) == '.' && visited.at(y-1).at(x) == -1) {
                        q.push(make_pair(y-1, x));
                        visited.at(y-1).at(x) = visited.at(y).at(x) + 1;
                        ans = max(ans, visited.at(y-1).at(x));
                    }
                    if (y+1 < h  && s.at(y+1).at(x) == '.' && visited.at(y+1).at(x) == -1) {
                        q.push(make_pair(y+1, x));
                        visited.at(y+1).at(x) = visited.at(y).at(x) + 1;
                        ans = max(ans, visited.at(y+1).at(x));
                    }
                    if (x-1 >= 0 && s.at(y).at(x-1) == '.' && visited.at(y).at(x-1) == -1) {
                        q.push(make_pair(y, x-1));
                        visited.at(y).at(x-1) = visited.at(y).at(x) + 1;
                        ans = max(ans, visited.at(y).at(x-1));
                    }
                    if (x+1 < w  && s.at(y).at(x+1) == '.' & visited.at(y).at(x+1) == -1) {
                        q.push(make_pair(y, x+1));
                        visited.at(y).at(x+1) = visited.at(y).at(x) + 1;
                        ans = max(ans, visited.at(y).at(x+1));
                    }
                    
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
ll MOD = 1e9 + 7;
//vector<ld> vec;
ll INT_MAX=pow(2,31)-1;
struct rmq{
    int n; //size
    vector<int> segtree; //完全二分木を格納した配列
    const int INF = INT_MAX;
    
    rmq(int sz){
    	n = 1;
        while(n<sz) n<<=1; //配列サイズをsz以上の2冪に。
        //セグ木のサイズは2*n-1, 取り敢えず全て単位元で初期化しておく。
        segtree.assign(2*n-1,INF);
    }
    
    int find(int l, int r){
    	return find(l,r,0,n,0);
    }
    int find(int l, int r, int a, int b, int k){
    	if(b<=l || r<=a) return INF;  //区間外
        else if(l<=a && b<=r) return segtree[k];  //区間内
        //それ以外なら、子を調べてその結果をminしたものを返す。
        else return 
            min(find(l,r,a,(a+b)/2,2*k+1), 
            	find(l,r,(a+b)/2,b,2*k+2));
    }
    void update(int i, int x){
    	segtree[i+=n-1] = x; //元の配列のindexは頂点数2*n-1より、n-1足したもの。
        while(i>0){
            i = (i-1)/2;  //親に移動
     	    //子同士を比較して小さい方を親の値として更新。
            segtree[i] = min(segtree[2*i+1],segtree[2*i+2]);
        }
    }
};
	
int main(){
    int n,q;
    cin>>n>>q;
    rmq tr(n);
    for(int i=0;i<q;i++){
        int k;cin>>k;
        int x,y;cin>>x>>y;
        if(k==1){
            cout<<tr.find(x,y+1)<<endl;
        }else{
            tr.update(x,y);
        //    cout<<x<<" "<<y<<endl;
        }
    }
    
    /*tr.update(5,3); //5番目の要素を3に更新する。
    cout << tr.find(0,3) << endl; //INFが出力される
    cout << tr.find(4,6) << endl; //3が出力される*/
}



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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int MOD=1e3;
const int N=1e2+5;
const ll maxn=2e5+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};

int n,m;
int a[N],b[N],c[N],d[N];
int ans,match[N];
bool vis[N];
vector<int> g[N];
bool dfs(int u)
{
    for(auto v:g[u])
    {
        if(vis[v])
            continue;
        vis[v]=1;
        if(match[v]==-1||dfs(match[v]))
        {
            match[v]=u;
            return true;
        }
    }
    return false;
}
void init()
{
    rep(i,0,n+1) g[i].clear();
}
void solve()
{
    int ans=0;
    mem(match,-1);
    rep(i,1,n+1)
    {
        mem(vis,0);
        if(dfs(i))
            ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    IO;
    cin>>n;
    init();
    rep(i,1,n+1) cin>>a[i]>>b[i];
    rep(i,1,n+1) cin>>c[i]>>d[i];
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            if(a[i]<=c[j]&&b[i]<=d[j])
                g[i].pb(j);
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;

    if(N>K){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}


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

int main(){
   int n, q;    cin >> n >> q;
   string s;    cin >> s;
   vector<ll> ac(n+1);
   for(int i=1; i<n; i++){
       ac.at(i+1) = ac.at(i);
       if(s[i-1]=='A' && s[i]=='C') ac.at(i+1) += 1;  
   }
   ll a, b;
   for(int i=0; i<q; i++){
       cin >> a >> b;
       cout << ac.at(b) - ac.at(a) << endl;
   }

}


Measured memory_bytes: 1792
from collections import Counter
S = list(input())

if S[0] == 'A':
    if S[2:-1].count('C') == 1:
        idx = S[2:-1].index('C')
        del S[idx+2]
        del S[0]
        s = ''.join(S)
        if s.islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')


Measured memory_bytes: 3316
Module Module1

    Sub Main()

        Dim N As Integer = CInt(Console.ReadLine())
        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim P(N) As Integer

        For i As Integer = 1 To N
            P(i) = CInt(tmp(i - 1))
        Next

        Dim c As Integer = 0
        Dim min As Integer = P(1)

        For i As Integer = 1 To N
            Dim flg As Integer = 1
            If min < P(i) Then
                flg = 0
            Else
                min = P(i)
            End If
            c += flg
        Next

        Console.WriteLine(c)

    End Sub

End Module



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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main(){
  ll N;
  cin >> N;
  ll a[N];
  rep(i,0,N)cin >> a[i];
  ll ans = 0;
  rep(i,0,N-1){
    if (a[i] == a[i+1]){
      ans++;
      a[i+1] = a[i+2] + a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    string S, T = "CODEFESTIVAL2016";
    cin >> S;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
aca
accc
ca
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s[3];
int main()
{
	IOS;
	cin>>s[0]>>s[1]>>s[2];
	REP(i,3) reverse(ALL(s[i]));

	int cur=0;
	while(1){
		if(SZ(s[cur])==0){
			cout<<char('A'+cur)<<'\n';
			return 0;
		}
		char tmp=s[cur].back();
		s[cur].pop_back();
		cur=tmp-'a';
	}
	return 0;
}


Measured memory_bytes: 256
def evenstr(x):
    box1 = []
    box2 = []
    if len(x) % 2 == 1:
        return False
    else:
        v = int(len(x) / 2)
        for i in range(v):
            box1.append(x[i])
        for i in range(v, len(x)):
            box2.append(x[i])
        if box1 == box2:
            return True
        else:
            return False

    

count = 0
s = input()
p = list(s)
p.pop()
count += 1

for i in range(len(p) - 2):
    if evenstr(p):
        break
    else:
        count += 1
    p.pop()

print(len(p))
    




Measured memory_bytes: 9068
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(2*k)]
lk=l[1::2]
lk=sum(lk,[])
ls=list(set(lk))
ln=[i for i in range(1,n+1)]
a=0
for i in ln:
  if i not in ls:
    a+=1
print(a)

Measured memory_bytes: 9336
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef vector<pair<pair<int,int>,int>> viii;
typedef vector<pair<pair<ll,ll>,ll>> viiil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000
#define MOD 1000000007;

void solve() {
    int n, x;
    cin >> n >> x;
    vii c;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        c.pb({a, b});
    }
    int MX = 100005;
    int dp[n+1][MX];
    rep(i, n+1) {
        rep(j, MX) {
            dp[i][j] = INF+1;
        }
    }
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, MX) {
            if (j + c[i].second < MX) {
                dp[i + 1][j + c[i].second] = min(dp[i + 1][j + c[i].second], dp[i][j] + c[i].first);
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    
    int mx = 0;
    rep(i, MX) {
        if (dp[n][i] <= x) {
            mx = max(mx, i);
        }
    }
    
    cout << mx << endl;
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        //solve();
    }
}

int main() {
    //querySolve();
    solve();

}


Measured memory_bytes: 43056
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc148_a.cpp
 * time   : Sat May  2 18:49:14 2020
 * quest  : A - Round One
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << 6 - (a + b) << "\n";
  return 0;
}


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

int game(int x, vector<int> temp);

int main(){

int a;
cin >> a;  
vector<int> vec(a);

for(int i=0; i < a; i++){
    cin >> vec.at(i);
}

sort(vec.begin(),vec.end());

    int Alice = game (a,vec);
    int Bob = game (a - 1,vec);
    int answer = Alice - Bob ;

    cout << answer << endl;
}

int game(int x, vector<int> temp){
    int pre =0;
    
    while(x>0){
        pre += temp.at(x-1);
        x -= 2;
    }
        return pre;
}

Measured memory_bytes: 256
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            #print(d,h,R)
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            #print(mx,my)
            #print(dx,dy)
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    #print(Q,R)
    for pa in Q:
        flag=1
        for i in range(N):
            #print(pa,i,dist(pa,p[i]),R)
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)
    


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<ll> X(M);
    for (int i = 0; i < M; i++) cin >> X[i];
    sort(X.begin(), X.end());
    vector<ll> diff;
    for (int i = 1; i < M; i++) diff.push_back(X[i] - X[i - 1]);
    sort(diff.rbegin(), diff.rend());
    ll res = X.back() - X.front();
    for (int i = 0; i < diff.size() && i < N - 1; i++) {
      res -= diff[i];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2168
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
X, Y = zip(*XY)
r = float('inf')
for x0 in range(N - K + 1):
  for x1 in range(K + x0 - 1, N):
    x = X[x1] - X[x0]
    Y_s = sorted(Y[x0:x1 + 1])
    for y0 in range(len(Y_s) - K + 1):
      y = Y_s[y0 + K - 1] - Y_s[y0]
      r = min(r, x * y)
print(r)

Measured memory_bytes: 3064
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
#include <map>

int main(int argc, char const *argv[]) {

  // int maxx = 1e5;
  // int c0[maxx], c1[maxx];
  // for (size_t i = 0; i < 1e5; i++) {
  //   c0[i] = 0;
  //   c1[i] = 0;
  // }

  std::map<int,int> c0{};
  std::map<int,int> c1{};


  int N;
  std::cin >> N;



  for (size_t i = 0; i < N; i++) {
    int v;
    std::cin >> v;
    if (i%2 == 0) {
      c0[v] += 1;
    }else{
      c1[v] += 1;
    }
  }

  int c0max = 0, c1max = 0;
  int c0smax = 0, c1smax = 0;
  int v0 = 0, v1 = 0;

  for (std::map<int,int>::iterator it=c0.begin(); it!=c0.end(); ++it){
        if(it->second >= c0max){
          c0smax = c0max;
          c0max = it->second;
          v0 = (it->first);
        }else{
          if (it->second >= c0smax) {
            c0smax = it->second;
          }
        }
  }

  for (std::map<int,int>::iterator it=c1.begin(); it!=c1.end(); ++it){
        if(it->second >= c1max){
          c1smax = c1max;
          c1max = it->second;
          v1 = (it->first);

        }else{
          if (it->second >= c1smax) {
            c1smax = it->second;
          }
        }
  }

  // std::cout << "^^^^^^^^^^^^^" << '\n';
  // std::cout << c0max << '\n'<< c1max << '\n';
  // std::cout << "^^^^^^^^^^^^^" << '\n';
  //
  // std::cout << c0smax << '\n'<< c1smax << '\n';
  //
  // std::cout << v0<< "-------"<<v1 << '\n';

  // for (std::map<int,int>::iterator it=c0.begin(); it!=c0.end(); ++it) {
  //   std::cout << it->first <<"aasd" << it->second<< '\n';
  // }


    // for (const auto& [key, value] : c1){
    //       if(value > c1max){
    //         c1smax = c1max;
    //         c1max = value;
    //       }else{
    //         if (value > cs1max) {
    //           cs1max = value;
    //         }
    //       }
    //   }

  // std::cout << N<< '\n'<< c0max << '\n'<< c1max << '\n';
  int ans = N - c0max - c1max;
  if (v0 == v1) {
    if (c1max + c0smax > c1smax + c0max) {
      ans = N - c1max - c0smax;
    }else{
      ans = N - c1smax - c0max;

    }
  }

  std::cout << ans<< '\n';


  return 0;
}


Measured memory_bytes: 4992
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    for sum_w in range(W+1):
        weight = sum_w - wv[i-1][0]
        if weight < 0:
            dp[i][sum_w] = max([dp[i][sum_w], dp[i-1][sum_w]])
        else:
            dp[i][sum_w] = max([dp[i][sum_w], dp[i-1][sum_w], dp[i-1][weight]+wv[i-1][1]])
print(max(dp[N]))

Measured memory_bytes: 152928
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

int origin[107];
int arr[107];

int main()
{
    int i,j;
    int n;

    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        origin[i]=arr[i];
    }
    sort(arr,arr+n);
    int counti=0;
    for(i=0;i<n;i++)
    {
        if(origin[i]!=arr[i])
            counti++;
    }
    if(counti<=2)
        printf("YES\n");
    else
        printf("NO\n");


    return 0;
}


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

int main(){
   int n,m,a,b;
   int mx=-inf;
   int my=inf;
   bool flag=true;
   cin >> n >> m >> a >> b;
   rep(i,n){
       int x;
       cin >> x;
       mx=max(mx,x);
   }
   rep(i,m){
       int y;
       cin >> y;
       my=min(my,y);
   }
   if(a>=b) flag=false;
   if(mx>=my) flag=false; 
   if(my<=a||mx>=b) flag=false;
   if(flag) cout << "No War" <<endl;
   else cout << "War" <<endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = Cin.Ni();
        int a = Cin.Ni();

        Console.WriteLine(n * n - a);
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

class UnionFind {
  public:  
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }

    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }

    int size(int A) {
      return -Parent[root(A)];
    }

    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};

int main() {
  int N,M;
  cin >> N >> M;
  int A[M],B[M];
  rep(i,M){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  v(ll) ans(M);
  ans[M-1] = (ll)N*(N-1)/2;
  UnionFind Uni(N);
  for (int i = M - 1; i >= 1; i--){
    ans[i-1] = ans[i];
    if(Uni.root(A[i]) != Uni.root(B[i])) {
      ans[i-1] -= (ll)Uni.size(A[i]) * Uni.size(B[i]);
      Uni.connect(A[i],B[i]);
    }
  }
  rep(i,M) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

ll l[200005];
ll dpR[200005];
ll dpL[200005];

void solve() {
  int n;
  cin >> n;
  ll d;
  cin >> d;
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    ret += l[i];
  }
  ret += (n-1)*d;
  dpR[0] = l[0];
  for(int i = 1; i < n; i++) {
    dpR[i] = min(l[i], dpR[i-1] + d);
  }
  dpL[n-1] = l[n-1];
  for(int i = n-2; i >= 0; i--) {
    dpL[i] = min(l[i], dpL[i+1] + d);
  }
  for(int i = 1; i < n-1; i++) {
    ret += min(dpL[i], dpR[i]);
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>

using namespace std;

int64_t powi(int64_t base, int64_t index)
{
    if (index == 0)
    {
        return 1;
    }
    else if (index == 1)
    {
        return base;
    }
    else if (index % 2 == 0)
    {
        auto ret = powi(base, index / 2);
        return ret * ret;
    }
    else
    {
        return powi(base, index - 1) * base;
    }
}

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

    const int64_t lim = powi(2, m);

    if (k >= lim)
    {
        cout << -1 << endl;
    }
    else if (m == 1)
    {
        if (k == 0)
        {
            cout << "0 0 1 1" << endl;
        }
        else if (k == 1)
        {
            cout << -1 << endl;
        }
    }
    else
    {
        for (int i = 0; i < lim; i++)
        {
            if (i != k)
            {
                cout << i << " ";
            }
        }
        cout << k << " ";
        for (int i = lim - 1; i >= 0; i--)
        {
            if (i != k)
            {
                cout << i << " ";
            }
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 1792
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvl vector<vector<long long> >
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin();it != container.end(); it++)
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

vll v(1e6+1,0);
void Sieve()
{
	ll i,j,n=1e6;
	for(i=2;i*i<=n;i++)
	{
		if(v[i]==0)
		{
			for(j=i*i;j<=n;j+=i) if(v[j]==0) v[j]=i;
		}
	}
	for(i=1;i<=n;i++) if(v[i]==0) v[i]=i;
}

int32_t main() {
	IOS;
	ll t,f,i,j,k,n,x,y,z;
	string s;
	cin>>n;z=1;
	Sieve();
	for(i=2;i<n;i++)
	{
		x=1;y=i;
		while(y>1)
		{
			f=0;k=v[y];
			while(y%k==0)
			{
				f++;
				y/=k;
			}
			x*=(f+1);
		}
		z+=x;
	}
	cout<<z;
	return 0;
}

Measured memory_bytes: 10984
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA;

	long x, y;
	foreach (i; 0..N)
	{
		x = gcd(x, A[i]);
		y = max(y, A[i]);
	}

	debug writeln(x);
	writeln(y >= K && K % x == 0 ? "POSSIBLE" : "IMPOSSIBLE");
	stdout.flush();
	debug readln();
}

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

int main()
{
	int n,k,x;
	cin >> n >> k; 
	int ans = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		ans += min(2*x,2*(k-x)); 
	} 
	cout<< ans <<'\n';
	return 0; 
} 

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val a = StdIn.readLine().split(" ").map(_.toInt)
  val r = if (a(2) - a(1) <= 0) "delicious"
  else if (a(2) - a(1) <= a(0)) "safe"
  else "dangerous"

  println(r)

}


Measured memory_bytes: 25552
/* link - https://atcoder.jp/contests/dp/tasks/dp_b */

#include <iostream>
#define inf 1e9
using namespace std;
int solve(int arr[], int n, int k)
{
    int dp[n + 1]; // minimum cost to reach the ith stone
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        dp[i] = inf;
        // iterating all the k states behind i to reach the i in min cost

        for (int j = i - 1; j >= 1 and (i - j) <= k; j--) {
            dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
        }
    }

    return dp[n];
}

int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    cout << solve(arr, n, k);
    return 0;
}

Measured memory_bytes: 4260
// ALDS1_6_A: Counting Srot

fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn scan_vec<T: std::str::FromStr>() -> Vec<T> {
    let s: String = scan();
    s.split_whitespace().map(|a| T::from_str(a).ok().unwrap()).collect()
}

fn main() {
    let n: usize = scan();
    let a: Vec<usize> = scan_vec();
    let mut b = vec![0; a.len()];
    let mut c = vec![0; 10001];
    for i in 0..n {
        c[a[i]] += 1;
    }
    for i in 1..c.len() {
        c[i] += c[i - 1];
    }
    for j in 0..n {
        b[c[a[j]] - 1] = a[j];
        c[a[j]] -= 1;
    }
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", b[i]);
    }
    println!();
}


Measured memory_bytes: 36704
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector <int> va;
    int cnt = 0;
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        if (a < n) va.push_back(a);
        else       cnt++;
    }

    sort(va.begin(), va.end());

    int ans = 0;
    while(cnt++ < m - 1) {
        ans += n - va.back();
        va.pop_back();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

struct BIT
{
    std::vector<int> bit;
    
    BIT(int size) : bit(size, 0){ }
    
    void add(int k, int x) {
        while (k < bit.size()) {
            bit[k] += x;
            k += k &-k;
        }
    }
    int sum(int k) {
        int res = 0;
        while (k > 0) {
            res += bit[k];
            k -= k&-k;
        }
        return res;
    }
};

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0;i < n;i++)
    {
        cin >> v[i];
    }
    int odd = 0;
    int even = 0;
    for(auto e: v)
    {
        if(e % 2 == 0)
        {
            even++;
        }
        else
        {
            odd++;
        }
    }
    if(odd % 2 == 1)
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		bitset<2000010> B;
		B.set(0);
		UL S = 0;
		rep(i, N) {
			B |= (B << A[i]);
			S += A[i];
		}
		for (UL i = (S + 1) / 2; i <= S; i++) {
			if (B[i]) { cout << i << endl; return; }
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;
  	int a[2*N];
  	int ans = 0;

  	for(int i=0;i<2*N;i++){
  		cin >> a[i];
  	}
  	sort(a, a+2*N);

  	for(int i=0;i<2*N;i+=2){
  		ans += a[i];
  	}
  	cout << ans <<endl;

    
  	return 0;
}




Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)

n = 0
hn = 0
1.upto(N) do |a|
  if a % K == 0
    n += 1
  elsif a % K == K / 2
    hn += 1
  end
end

if K.odd?
  puts n ** 3
else
  puts n ** 3 + hn ** 3
end


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

using namespace std;

int a[505][3];
int ans[505];

int main() {

	int n;
	cin >> n;
	for(int i=0;i<n-1;i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];

	for(int i=0;i<n-1;i++){
		int t=0;
		for(int j=i;j<n-1;j++){
			if(t<a[j][1])
				t+=a[j][0]+(a[j][1]-t);
			else{
				int s=a[j][1];
				while(s<t)
					s+=a[j][2];
				t+=a[j][0]+(s-t);
			}
		}
		ans[i]=t;
	}

	for(int i=0;i<n;i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 256
import sys 
N = int(input())

t = []
cordinate = []

#　リストtに時間の情報、二次元配列のcordinateにx,y座標を入れる
for i in range(N):
    time,x,y = map(int, input().split())
    t.append(time)
    cordinate.append([x,y])

# 初期の時間と初期座標
time = 0
x,y = 0,0


for i in range(len(t)):
    
    # 移動先への移動にかけて良い時間
    time = abs(time - t[i])
    
    #移動先のx,y座標
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    

    
    #移動できる時間より距離が長い場合はアウト
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    #偶奇の判定
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()

    x,y = objx,objy
    time = t[i]

print("Yes")

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

int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++)
  {
    cin >> B.at(i);
  }

  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      cin >> A.at(i).at(j);
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int output = C;
    for (int j = 0; j < M; j++)
    {
      output += A.at(i).at(j) * B.at(j);
    }
    if (output > 0)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
tmp=[list(map(int,input().split())) for i in range(N-1)]
for i in range(N-1):
   time=0
   for j in range(i,N-1):
      data=tmp[j]
      if time<data[1]:
         time=data[1]+data[0]
      else:
         if time%data[2]==0:
            time+=data[0]
         else:
            time+=data[2]-(time%data[2])+data[0]
   print(time)
print(0)

Measured memory_bytes: 9236
//file_name:ABC103_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


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

    rep(i,200){
        int flag = 0;
        rep(j,s.size()){
            if(s[j]!=t[j]){
                flag = 1;
                break;
            }
        }
        if(flag==0){
            puts("Yes");
            return 0;
        }else{
            char temp = s[0];
            srep(j,1,s.size()){
                s[j-1] = s[j];
            }
            s[s.size() - 1] = temp;
        }
    }

    puts("No");

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int[] x = new int[N];
		int[] y = new int[N];
		for(int i = 0; i < N; i++)
		{
			x[i] = GetInt();
			y[i] = GetInt();
		}

		var diff = new Dictionary<Tuple<int, int>, int>(N);
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < N; j++)
			{
				if(i == j)
					continue;
				
				int current = 0;
				var pair = Tuple.Create(x[i] - x[j], y[i] - y[j]);
				diff.TryGetValue(pair, out current);
				diff[pair] = current + 1;
			}
		}
		
		int max = 0;
		foreach(var key in diff.Keys)
		{			
			max = Math.Max(max, diff[key]);
		}
		Console.WriteLine(N - max); 
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define oo 100005
using namespace std;
int n, a[oo], e, t, q[oo];
long long dp[oo], sum[oo], f[oo];
int main ()
{
    scanf("%d%d%d", &n, &e, &t);
    for(int i = 1; i <= n; ++ i)
    scanf("%d", &a[i]);
    memset(dp, 63, sizeof dp);
    sum[0] = -2 * a[1]; dp[0] = 0;
    for(int i = 1, lim = 0, l = 1, r = 1; i <= n; ++ i)
    {
        while(2 * (a[i] - a[lim + 1]) > t) ++ lim;
        while(q[l] < lim && l <= r) ++ l;
        if(l <= r) dp[i] = min(dp[i], f[l] + t + a[i]);
        if(lim > 0) dp[i] = min(dp[i], sum[lim - 1] + 3ll * a[i]);
        sum[i] = min(sum[i - 1], dp[i] - a[i] - 2ll * a[i + 1]);
        while(f[r] >= dp[i] - a[i] && l <= r) -- r;
        q[++ r] = i, f[r] = dp[i] - a[i];
    }
    printf("%lld", dp[n] + e - a[n]); return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

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 &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int mtx[210][110];
int dp[210][110];

int main() {
	string s;
	int x,y;
	for(y=0;cin>>s;y++){
		int len=s.size();
		int i;
		x=0;
//cout<<s<<endl;
//cout<<len<<endl;
//cout<<s[0]-'0'<<endl;
		for(i=0;i<len;){
			if('0'<=s[i]&&s[i]<='9'){
				if(i+1<len&&'0'<=s[i+1]&&s[i+1]<='9'){
					mtx[y][x++]=(s[i]-'0')*10+s[i+1]-'0';
					i+=3;
				}else{
					mtx[y][x]=s[i]-'0';
//cout<<y<<" "<<x<<" "<<s[i]<<endl;
					x++;
					i+=2;
				}
			}
		}
	}
	
	int maxy=y;
	/*for(y=0;y<maxy;y++){
		for(x=0;x<min(y+1,maxy-y);x++){
			cout<<mtx[y][x]<<" ";
		}
		cout<<endl;
	}
	*/
	for(y=0;y<maxy;y++){
		if(y==0)dp[0][0]=mtx[0][0];
		else if(y<maxy/2+1){
			for(x=0;x<=y;x++){
				dp[y][x]=max(dp[y-1][x],x==0?0:dp[y-1][x-1])+mtx[y][x];
			}
		}else{
			for(x=0;x<maxy-y;x++){
				dp[y][x]=max(dp[y-1][x],dp[y-1][x+1])+mtx[y][x];
			}
		}
	}
	cout<<dp[maxy-1][0]<<endl;
/*for(y=0;y<maxy;y++){
	for(x=0;x<min(y+1,maxy-y);x++){
		cout<<dp[y][x]<<" ";
	}
	cout<<endl;
}*/

	return 0;
}

Measured memory_bytes: 0