akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    vector<ll> a(n+10);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<ll> dp(n+10,INF);
    dp[0]=-1;
    vector<vector<P>> v(n+10);
    for(int i=0;i<n;i++){
        auto itr=lower_bound(all(dp),a[i]);
        *itr=a[i];
        int co=itr-dp.begin();
        v[co].push_back(P(a[i],i));
    }
    ll b=INF,id=INF;
    ll ans=0;
    for(int i=n;i>=0;i--){
        ll ma=0,bb=INF,id2=INF;
        for(auto e:v[i]){
            if(b>e.first&&id>e.second){
                if(ma<e.first){
                    bb=e.first;
                    id2=e.second;
                    ma=e.first;
                }
            }
        }
        ans+=ma;
        id=id2;
        b=bb;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 9832
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++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 FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

int main()
{
	int n;
	cin >> n;
	vector<string> s;

	REP(i, n) {
		string t;
		cin >> t;
		sort(All(t));
		s.push_back(t);
	}
	sort(All(s));

	ll ans = 0;
	ll cnt=0;
	REPS(i,n-1) {
		//cout << "今" << now << endl;
		if (s[i] == s[i - 1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans += cnt;
	}

	cout << ans << endl;

}

Measured memory_bytes: 5748
#include <iostream>

typedef unsigned short     ushort;

ushort Ceil( ushort m, ushort n )
{
    return ( ( m == 0 ) ? 0 : (m-1)/n +1 );
}

int main( void )
{
    ushort A, B, C, D;
    std::cin >> A >> B >> C >> D;
    
    std::cout << ( Ceil(C,B) <= Ceil(A,D) ? "Yes" : "No" ) << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,K;
  cin >> N >> D;

  K = 0;

  if(N%(2*D + 1) == 0){
    K = N/(2*D + 1);
  }
  else{
    K = N/(2*D + 1) + 1;
  }

  cout << K << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
    int h, w;

    cin >> h >> w;

    //printf("h %d w %d\n", h, w);

    char s[h][w];

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

    int count;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.'){
                count = 0;
                if(i - 1 >= 0){
                    if(s[i - 1][j] == '#'){
                        count++;
                    }
                    if(j - 1 >= 0 and s[i - 1][j - 1] == '#'){
                        count++;
                    }
                    if(j + 1 < w  and s[i - 1][j + 1] == '#'){
                        count++;
                    }    
                }
                if(i + 1 < h){
                    if(s[i + 1][j] == '#'){
                        count++;
                    }
                    if(j - 1 >= 0 and s[i + 1][j - 1] == '#'){
                        count++;
                    }
                    if(j + 1 < w  and s[i + 1][j + 1] == '#'){
                        count++;
                    }    
                }
                if(j - 1 >= 0 and s[i][j - 1] == '#'){
                    count++;
                }
                if(j + 1 < w and s[i][j + 1] == '#'){
                    count++;
                }
                s[i][j] = '0' + count;
            } 
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            printf("%c", s[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

#define ran 111

char s1[ran], s2[ran];
int len1, len2;

int main() {
	scanf("%s%s", s1, s2);
	
	bool f = true;
	len1 = strlen(s1);
	len2 = strlen(s2);
	if(len1==len2-1) {
		for(int i=0;i<len1;i++)
			if(s1[i]!=s2[i]) f = false;
	} else f = false;
	
	puts(f ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
 
 
int rottbl[6][24] = {
    {2,0,3,1,8,9,6,7,12,13,10,11,16,17,14,15,4,5,18,19,20,21,22,23},
    {0,1,7,5,4,20,6,21,10,8,11,9,2,13,3,15,16,17,18,19,14,12,22,23},
    {0,9,2,11,4,5,6,7,8,21,10,23,14,12,15,13,3,17,1,19,20,18,22,16},
    {0,1,2,3,4,5,18,19,8,9,6,7,12,13,10,11,16,17,14,15,22,20,23,21},
    {13,15,2,3,1,5,0,7,8,9,10,11,12,23,14,22,18,16,19,17,20,21,4,6},
    {19,1,17,3,6,4,7,5,0,9,2,11,12,13,14,15,16,22,18,20,8,21,10,23},
};
 
int chtbl[128];
 
int outtbl[54] = {
    24,24,0,1,24,24,24,24,25,
    24,24,2,3,24,24,24,24,25,
    4,5,8,9,12,13,16,17,25,
    6,7,10,11,14,15,18,19,25,
    24,24,20,21,24,24,24,24,25,
    24,24,22,23,24,24,24,24,25,
};
 
 
string rot(const string &s, char ch){
    string t = s;
    for(int i = 0; i < 24; ++i){
        t[i] = s[rottbl[chtbl[ch]][i]];
    }
    return t;
}
 
void output(const string &s){
    for(int i = 0; i < 54; ++i){
        cout << s[outtbl[i]];
    }
}
 
 
int main(){
    chtbl['U'] = 0;
    chtbl['F'] = 1;
    chtbl['R'] = 2;
    chtbl['D'] = 3;
    chtbl['B'] = 4;
    chtbl['L'] = 5;
 
    string s = "rrrrggggyyyybbbbwwwwoooo.\n";
     
    string input;
    cin >> input;
    for(int i = 0; i < input.size(); ++i){
        s = rot(s, input[i]);
    }
    output(s);
}

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

int main()
{
  int a, s, d;
  cin >> a >> s >> d ;
   if(a+s==d || a+d==s || s+d==a)
     cout << "Yes" << endl;
     else
       cout << "No" << endl;
    
  

}  


Measured memory_bytes: 256
a = [ int(input()) for _ in range(5)]
n = float("inf")
for i in range(5):
    if 0 < a[i] % 2 < 10:
        n = min(n,a[i] % 10)
else:
    if n == float("inf"):
        n = 10
print(sum([(-a[i]//10)*-10 for i in range(5)]) -(10-n))

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

int main(){
  int N, T;
  cin >> N >> T;
  
  int c[N], t[N];
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
  }
  
  int ans = 10000;
  for (int i = 0; i < N; i++) {
    if(t[i]<=T) ans = min(ans, c[i]);
  }
  
  if (ans==10000) cout << "TLE" << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
def f_laminate(INF=float('inf')):
    # 参考: https://atcoder.jp/contests/abc145/submissions/8491285
    N, K = map(int, input().split())
    H = [0] + list(map(int, input().split()))

    # editorial と同じ DP テーブル
    dp = [[INF] * (N - K + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for x in range(1, N + 1):
        for y in range(1, N - K + 1):
            for i in range(x):
                dp[x][y] = min(dp[x][y], dp[i][y - 1] + max(0, H[x] - H[i]))

    ans = INF
    for i in range(N + 1):
        ans = min(ans, dp[i][N - K])
    return ans

print(f_laminate())

Measured memory_bytes: 46812
/*
 AUTHOR : ANSHU BABU RAJPUT
 
    JAI MAA SARASWATI
    OM NAMAH SHIVAY
    JAI SHRI KRISHNA
    JAI SHRI RAM
    BHARAT MATA KI JAI

    #PKMKB	
    #CKMKB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long 
#define endl    ("\n")
#define ff       first
#define ss      second
#define pb   push_back
#define pf  push_front
#define ppb   pop_back
#define ppf  pop_front
#define mp   make_pair
#define mod 1000000007

#define L(x)    x.length()
#define B(x)     x.begin()
#define E(x)       x.end()
#define F(x)     x.front()
#define SZ(x)     x.size()
#define CLR(x)   x.clear()

#define all(x)                      x.begin(),x.end()
#define sortD(x) sort(x.begin(),x.end(),greater<int>)
#define rev(x)             reverse(x.begin(),x.end())

#define intV vector<int>

#define PI          (3.141592653589)
#define PMAX     priority_queue<int>
#define PMIN             priority_queue<int,vi,greater<int>>
#define setbits(x)                   __builtin_popcountll(x)
#define zrobits(x)                        __builtin_ctzll(x)

#define KING(i, n) for (int(i) = 0; (i) < n; (i)++)
#define MAHAKAL(i, n) for (int(i) = n-1; (i) >= 0; (i)--)

#define Anshu        int t; cin>>t; while(t--)
#define SITARAM(n,type) type* input=new type[n]

mt19937                          rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void ViLiFY_KiNG()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
#endif
}
 
int32_t main()
{
    ViLiFY_KiNG();
    int n,k;
    cin>>n>>k;

    SITARAM(n,int);
    KING(i,n) {
        cin>>input[i];
    }
    sort(input,input+n);

    int sum = 0;
    KING(i,k) {
        sum += input[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3668
#45 ABC135D 桁DP
s=input()
n=len(s)
dp=[[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
	if s[i]=="?":
		c=-1
	else:
		c=int(s[i])
	for j in range(10):
		if c!=-1 and c!=j:
			continue
		for ki in range(13):
			dp[i+1][(ki*10+j)%13]+=dp[i][ki]
	for j in range(13):
		dp[i+1][j]%=(10**9+7)
print(dp[n][5]%(10**9+7))

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

int main(){  
	int n, m, p, x, sum, res;
	while(cin >> n >> m >> p, n | m | p){
		sum = 0;
		for(int i = 1;i <= n;i++){
			cin >> x;
			sum += x;
			if(i == m)res = x;
		}
		if(res == 0)cout << 0 << endl;
		else cout << sum*(100 - p)/res << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys

def main():
    # a = sys.stdin.readline().strip()
    n, l = [int(i) for i in sys.stdin.readline().strip().split()]
    # [[int(i) for i in sys.stdin.readline().strip().split()] for _ in range(2)]

    mi = l
    ma = l + n - 1

    if mi <= 0 <= ma:
        return (mi + ma) * n // 2
    elif ma < 0:
        return (mi + ma-1) * (n-1) // 2
    elif mi > 0:
        return (mi+1 + ma) * (n-1) // 2

print(main())


Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var count1 = 0
    var count2 = 0
    var count4 = 0
    repeat(n) {
        val a = sc.nextInt()
        when {
            a % 4 == 0 -> count4++
            a % 2 == 0 -> count2++
            else -> count1++
        }
    }

    var pre = when {
        count1 > 0 -> {
            count1--
            1
        }
        count2 > 0 -> {
            count2--
            2
        }
        else -> {
            count4--
            4
        }
    }

    while (count1 > 0 || count2 > 0 || count4 > 0) {
        when (pre) {
            2 -> {
                pre = when {
                    count2 > 0 -> {
                        count2--
                        2
                    }
                    count4 > 0 -> {
                        count4--
                        4
                    }
                    else -> {
                        println("No")
                        return
                    }
                }
            }
            1 -> {
                pre = when {
                    count4 > 0 -> {
                        count4--
                        4
                    }
                    else -> {
                        println("No")
                        return
                    }
                }
            }
            else -> {
                pre = when {
                    count1 > 0 -> {
                        count1--
                        1
                    }
                    count2 > 0 -> {
                        count2--
                        2
                    }
                    else -> {
                        count4--
                        4
                    }
                }
            }
        }
    }
    println("Yes")
}

Measured memory_bytes: 53820
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int S = sc.nextInt();
		Time t = new Time(S);
		System.out.println(t);
	
	}
	
	
	static class Time{
		int h, m, s, allTime;
		Time(int temp){
			this.allTime = temp;
		}
		public String toString(){
			h = allTime/3600;
			m = (allTime - h * 3600) / 60;
			s = allTime - (3600 * h + m * 60);
			return h + ":" + m + ":" + s; 
		}
	}

}

Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)
ll n,q,a[100010],x,s[100010]={},s2[100010]={};

void init(){
  ifr(i,n) s[i]=s[i+1]+a[i];
  fr(i,n) s2[i+2]=s2[i]+a[i];
}

ll solve(ll x){
  ll l=-1,r=1e9,m,i1,i2,i3,i4;
  while(r-l>1){
    m=(l+r)/2;
    i1=lb(a,a+n,x-m)-a;
    i2=lb(a,a+n,x+m)-a-1;
    i3=ub(a,a+n,x+m)-a-1;
    if(2*i3-i1+3<n) l=m;
    else if(2*i3-i1+3==n) return s[i3+1]+s2[i1];
    else if(2*i3-i1+2==n) return s[i3+1]+s2[i1+1];
    else if(2*i2-i1+3==n) return s[i2+1]+s2[i1];
    else if(2*i3-i1+2==n) return s[i3+1]+s2[i1+1];
    else r=m;
  }
}

int main(){
  cin>>n>>q;
  fr(i,n) cin>>a[i];
  init();
  fr(i,q){
    cin>>x;
    cout<<solve(x)<<endl;
  }
}

Measured memory_bytes: 4096
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, X;
    cin >> N >> X;
    vector<int> L(N,0), C(N+1,0);
    for (int i=0;i<N;i++) cin >> L[i];
    for (int i=1;i<=N;i++) C[i] = C[i-1] + L[i-1];
    auto itr = upper_bound(C.begin(), C.end(), X);
    cout << itr - C.begin() << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-17 23:47:50
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int y, m, d;
    y = m = d = 0;
    for (int i = 0; i <= 3; i++) {
        y += (s[i]-'0')*pow(10, 3-i);
    }
    for (int i = 5; i <= 6; i++) {
        m += (s[i]-'0')*pow(10, 6-i);
    }
    for (int i = 8; i <= 9; i++) {
        d += (s[i]-'0')*pow(10, 9-i);
    }

    string ans;
    if (y >= 2019 && m >= 5) ans = "TBD";
    else ans = "Heisei";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int p[100005];
int root(int n)
{
	if (p[n] != n)
		p[n] = root(p[n]);
	return p[n];
}
void uni(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x != y)
		p[x] = y;
	return;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a, b;
	for (i = 0; i < n; i++)
		p[i] = i;
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a, &b);
		uni(a - 1, b - 1);
	}
	a = 0;
	for (i = 0; i < n; i++)
		if (root(i) == i)
			a++;
	printf("%d\n", a - 1);
	return 0;
}

Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

ll store[100005];

ll get(ll i, vector<ll> v[])
{
    if(store[i]!=-1)
        return store[i];
    
    ll ans = 1;
    for(auto it = v[i].begin();it!=v[i].end();it++)
        ans = max(ans, 1+get(*it,v));
    return store[i] = ans;    
}

int main()
{
   FAST/**/
   
   //ll n;
   //cin>>n;
   
   memset(store,-1,sizeof(store));
   
   ll n,m;
   cin>>n>>m;
   
   vector<ll> v[n];
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       a--,b--;
       v[a].pb(b);
   }
   
   ll ans = 1;
   for(ll i=0;i<n;i++)
   {
      //cout<<"at "<<i+1<<" len = "<<get(i,v)<<"\n";
       ans = max(ans, get(i,v));
   }
   cout<<ans-1;       
   
   return 0;
}

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

int N,X,Y,ans[2100];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>X>>Y;
    for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++){
    	int x=min(j-i,min(abs(i-X)+abs(j-Y),abs(i-Y)+abs(j-X))+1);
    	ans[x]++;
    }
    for(int i=1;i<N;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	x, y := make([]int, 4), make([]int, 4)
	x[0], y[0], x[1], y[1] = nextInt(), nextInt(), nextInt(), nextInt()

	dx, dy := x[1]-x[0], y[1]-y[0]
	x[2], y[2], x[3], y[3] = x[1]-dy, y[1]+dx, x[0]-dy, y[0]+dx
	puts(x[2], y[2], x[3], y[3])
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <stdio.h>

#define N (30)
#define M (30)

int main(){

    int i, j, l;
    int n, m;
    int k[N];
    int a[N][M];
    int like[M];
    int like_all;

    // 値の入力
    scanf("%d %d", &n, &m);
//    printf("%d %d\n", n, m);
    for(i=0 ; i<n ; i++){
        scanf("%d", &k[i]);
//        printf("%d ", k[i]);
        for(j=0 ; j<k[i] ; j++){
            scanf("%d", &a[i][j]);
//            printf("%d ", a[i][j]);
        }
//        printf("\n");
    }

    for(i=0 ; i<n ; i++){
        for(j=0 ; j<k[i] ; j++){
            for(l=1 ; l<=m ; l++){
                if(a[i][j] == l){
                    like[l]++;
                }
            }
        }
    }

    for(l=1 ; l<=m ; l++){
        if(like[l] == n){
            like_all++;
        }
    }

    printf("%d", like_all);

}

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

namespace CSharpSample01
{
	class Program
	{



	static void Main(string[] args)
		{
			var valueList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			
			// 丘の数
			var N = valueList[0];
			// 道の数
			var M = valueList[1];

			// 高さ一覧
			var hightList = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			var arrayHight = new long[N];

			// 初期化
			for(int i = 0; i < N; i++)
			{
				arrayHight[i] = hightList[i];
			}


			var dicRoad = new Dictionary<int, List<int>>();
			for (int i = 0; i < M; i++)
			{
				// 道
				var road = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

				if (!dicRoad.ContainsKey(road[0]))
				{
					dicRoad[road[0]] = new List<int>();

				}
				dicRoad[road[0]].Add(road[1]);

				if (!dicRoad.ContainsKey(road[1]))
				{
					dicRoad[road[1]] = new List<int>();
				}
				dicRoad[road[1]].Add(road[0]);
			}

			var answer = 0;

			// 確認
			for (int i = 1; i <= N; i++)
			{
				// 道が存在しない場合
				if(!dicRoad.ContainsKey(i))
				{
					answer++;
				}
				else
				{
					// 一意のリストを取得
					var list = dicRoad[i].Distinct();
					var flag = true;

					foreach(var road in list)
					{
						if(arrayHight[i - 1] <= arrayHight[road - 1])
						{
							flag = false;
							break;
						}
					}

					if (flag)
					{
						answer++;
					}
				}
			}

			Console.WriteLine(answer);

		}
	}
}

Measured memory_bytes: 58108
#include <iostream>
#include <cstdio>
#include <deque>
#include <vector>
#include <cstring>
#include <cassert>
using namespace std;
#define pb push_back
typedef long long LL;
const int MAXN=200000;
const LL mods=1000000007LL;
struct M {
	LL x;
	M(LL angka){
		if(angka>=mods||angka<=-mods)
			angka%=mods;
		if(angka<0)
			angka+=mods;
		x=angka;
	}
	M(){
		x=0;
	}
	M operator + (const M &other) const{
		return M(x+other.x);
	}
	M operator - (const M &other) const{
		return M(x-other.x);
	}
	M operator * (const M &other) const{
		return M(x*other.x);
	}
	M operator -() const{
		return M(-x);
	}
	bool operator == (const M &other) const{
		return (x==other.x);
	}
};
struct trio{
	M fi,se,th;
	trio(M _fi,M _se,M _th){
		fi=_fi;
		se=_se;
		th=_th;
	}
	trio(){
	}
};
int n,par[MAXN+5],nodeque=0,root=0,height[MAXN+5]={},sum[MAXN+5]={},best[MAXN+5],maxheight=0,terjauh[MAXN+5]={};
deque <trio> *daftar[MAXN+5];
M pangkat[MAXN+5],ans;
void isipangkat(){
	pangkat[0]=1;
	for(int i=1;i<=n+1;i++)
		pangkat[i]=pangkat[i-1]*2;
}
trio gabung(trio a,trio b){
	trio ret;
	ret.fi=a.fi*b.fi;
	
	ret.se=a.fi*b.se+a.se*b.fi;
	
	ret.th=ret.th+a.se*b.se;
	ret.th=ret.th+a.th*b.se;
	ret.th=ret.th+a.se*b.th;
	ret.th=ret.th+a.th*b.th;
	ret.th=ret.th+a.fi*b.th;
	ret.th=ret.th+a.th*b.fi;
	return ret;
}
void solve(){
	for(int i=0;i<=n;i++)
		daftar[i]=NULL;
	for(int i=n;i>=0;i--)
	{
		//cout<<"now "<<i<<endl;
		if(best[i]==-1)			//tandanya tidak punya pi deque
			daftar[i]=new(deque<trio>);
		//cout<<"inis"<<endl;
		daftar[i]->push_front(trio(1,1,0));
		for(int j=0;j<=terjauh[i];j++)
		{
			(*daftar[i])[j].fi=(*daftar[i])[j].fi+(*daftar[i])[j].th;
			(*daftar[i])[j].th=0;
		}
		//cout<<"done merging fi and th"<<endl;
		//cout<<"done asserting"<<endl;
		if(i)			//update ke parentnya
		{
			if(best[par[i]]<(int) daftar[i]->size())
			{
				best[par[i]]=daftar[i]->size();
				swap(daftar[i],daftar[par[i]]);
			}
			if(daftar[i]!=NULL)
			{
				//cout<<"UNNULL"<<endl;
				terjauh[par[i]]=max(terjauh[par[i]],(int) daftar[i]->size());
				for(int j=0;j<daftar[i]->size();j++)
				{
					trio a,b;
					a=(*daftar[i])[j];
					b=(*daftar[par[i]])[j];
					(*daftar[par[i]])[j]=gabung(a,b);
				}
			}
		}
	}
}
int main()
{
	memset(best,-1,sizeof(best));
	scanf("%d",&n);
	height[0]=0;
	sum[height[0]]++;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&par[i]);
		height[i]=height[par[i]]+1;
		maxheight=max(maxheight,height[i]);
		sum[height[i]]++;
	}
	isipangkat();
	solve();
	for(int i=0;i<daftar[0]->size();i++)
		ans=ans+pangkat[n-sum[i]+1]*(*daftar[0])[i].se;
	cout<<ans.x<<endl;
}

Measured memory_bytes: 241664
k = %[Man Oku Cho Kei Gai Jo Jou Ko Kan Sei Sai Gok Ggs Asg Nyt Fks Mts].split.to_a
k.unshift("")
while gets
  m, n = $_.split.map(&:to_i)
  break if m == 0 && n == 0
  v = m ** n
  x = []
  a = v.to_s.size
  (0..a).step(4){ |i| x[i/4] = v / 10**i % 10000 }
  a /= 4
  a.downto(0){ |i| print x[i], k[i] if x[i] > 0 }
  puts
end

Measured memory_bytes: 8744
#include<iostream>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
using namespace std;
typedef pair<char,int> P;
const int INF = 1e8;

int n,l, id[30], sum;
P ant[30];

int main(){
  while(cin >> n >> l, n){
    l <<= 1;
    rep(i,n){
      cin >> ant[i].fs >> ant[i].sc; ant[i].sc <<= 1;
      id[i] = i;
    }

    sum = 0;
    while(true){
      int pos = -1, t = INF;
      rep(i,n-1){
	if(ant[id[i]].fs == 'R' && ant[id[i+1]].fs == 'L'){
	  int d = ant[id[i+1]].sc - ant[id[i]].sc; d>>=1;
	  if(pos < 0 || t > d){
	    pos = i; t = d;
	  }
	}
      }

      if(pos<0){
	int len = 0, res = 0;
	rep(i,n){
	  if(ant[id[i]].fs == 'L'){
	    if(len < ant[id[i]].sc){
	      len = ant[id[i]].sc; res = id[i];
	    }
	  }else{
	    if(len < l - ant[id[i]].sc){
	      len = l - ant[id[i]].sc; res = id[i];
	    }
	  }
	}
	cout << (sum + len)/2 << " " << res+1 << endl;
	break;
      }

      rep(i,n){
	if(ant[id[i]].fs == 'L')ant[id[i]].sc -= t;
	else ant[id[i]].sc += t;
      }
      if(ant[id[pos]].sc&1)swap(id[pos],id[pos+1]);
      else swap(ant[id[pos]].fs,ant[id[pos+1]].fs);
      sum += t;
    }
  }
}
	       

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

signed main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    int right = 0;
    int sum = 0;
    for(int left = 0; left < N; left++){
        while(right < N && ((sum ^ a[right]) == (sum + a[right]))){
            sum += a[right];
            right++;
        }
        ans += (right - left);
        if(left == right) right++;
        else sum -= a[left];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s;
	while(getline(cin,s)){
		while(1){
			for(int j=0;j<s.size();j++){
				if(s[j]>=97&&s[j]<=122){
					s[j]+=1;
					if(s[j]==123)
					s[j]=97;
				}
			}
			if(s.find("the")!=string::npos)
			break;
			if(s.find("this")!=string::npos)
			break;
			if(s.find("that")!=string::npos)
			break;
		}
			printf("%s\n",s.c_str());
	}
}

Measured memory_bytes: 3132
#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[max];
int n,dp[max];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                a[i].p = nil;
                a[i].l = nil;
                a[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        a[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(a[node].p == nil) {
                printf("root, ");
        }else if(a[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=nil) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(a[node].r!=nil) {
                depth(a[node].r, dep);
        }
        if(a[node].l!=nil) {
                depth(a[node].l, dep+1);
        }
}

Measured memory_bytes: 5296
def solve():
    input_string = input()
    part_string = input()

    for i in range(len(input_string) - len(part_string), -1, -1):
        possible_part_string = input_string[i:i+len(part_string)]
        for j in range(len(part_string) + 1):  # 1つ多くループしているのは最後の処理のため
            if j == len(part_string):
                result = input_string[:i] + part_string + input_string[i + len(part_string):]
                result = result.replace("?", "a")
                print(result)
                return
            if possible_part_string[j] == "?":
                continue
            elif possible_part_string[j] != part_string[j]:
                break

    print("UNRESTORABLE")
solve()

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n,m,a,b;
	int v[200010]={};
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>m;
	rep(i,0,m){
		cin>>a>>b;
		if(a==1)v[b]++;
		if(b==n)v[a]++;
	}
	rep(i,0,200001){
		if(v[i]>=2){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(void){
    
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    long long numberOfR = 0;
    long long numberOfG = 0;
    long long numberOfB = 0;
    
    for (int i = 0; i < n; i++){
        
        if (s[i] == 'R') numberOfR++;
        else if (s[i] == 'G') numberOfG++;
        else numberOfB++;
    }
    
    long long ans1 = numberOfR * numberOfG * numberOfB;

    
    long long ans2 = 0;
    for (int i = 0; i < n-2; i++){
        
        for (int j = i+1; j < n-1; j++){
            
            int k = 2 * j -i;
            
            if (k >= n) continue;
            
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans2++;
        }
    }
    
    long long ans = ans1 - ans2;
    
    cout << ans << endl;
}


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

int main(void)
{
  std::string n;
  std::cin >> n;

  int sum = 0;
  for (int i = 0; i < n.size(); i++) {
    sum += n[i] - '0';
  }

  if (sum % 9 == 0) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3732
import java.util.*;
 
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String K = "keyence";
		String S = sc.next();
        boolean fl = false;
        int l = S.length();
      	
      	for(int i=7;0<=i;i--){
        	if(S.substring(0,i).equals(K.substring(0,i))){
        		if(S.substring(l-(7-i)).equals(K.substring(i))){
                	System.out.println("YES");
                    fl = true;
                  	break;
                }
            }        
        }
      	if(!fl){
          System.out.println("NO");
        }
     } 
}  

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N;
P B[1111];
int dp[1111][1111];
int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      cin >> B[i].first >> B[i].second;
    }
    sort(B,B+N);

    int sum = 0;
    for(int i=0;i<N-1;i++){
      sum += B[i].first;
    }
    int ktime = B[N-1].first - sum;
    if( ktime > 0 ) {
      memset(dp,0,sizeof(dp));
      dp[0][0] = 1;
      int rt = 0;
      for(int i=0;i<N;i++){
	for(int w=0;w<=ktime;w++){
	  if( dp[i][w] == 0 ) continue;
	  rt = max(rt,w);
	  dp[i+1][w+B[i].second] = 1;
	  dp[i+1][w] = 1;
	}
      }
      int res = sum + B[N-1].first;
      for(int i=0;i<N;i++) res += B[i].second;
      cout << res + ktime-rt << endl;
    } else {
      int res = sum + B[N-1].first;
      for(int i=0;i<N;i++) res += B[i].second;
      cout << res << endl;
    }
  }
}

Measured memory_bytes: 6000
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (na,nb,m) = get!(usize, usize, usize);
    let a = get!([usize]);
    let b = get!([usize]);
    let xyc = get!(usize, usize, usize; m);

    let mut mna = std::usize::MAX;
    let mut mnb = std::usize::MAX;

    for &e in &a {
        mna = min!(mna,e);
    }
    for &e in &b {
        mnb = min!(mna,e);
    }
    let mut mn = mna+mnb;

    for (x,y,c) in xyc {
        mn = min!(mn, a[x-1]+b[y-1]-c);
    }
    println!("{}", mn);
}


Measured memory_bytes: 17656
import sys
H,W = map(int , input().split())
l = []
for i in range(H):
    l.append(list(input()))

for i in range(H):
    if i == 0:
        for j in range(W):
            if j == 0 :
                if l[i][j] == '#':
                    if l[i+1][j] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()
            if j == W -1 :
                 if l[i][j] == '#':
                    if l[i+1][j] == '.' and l[i][j-1] == '.':
                        print("No")
                        sysexit()
            else :
                if l[i][j] == '#':
                    if l[i+1][j] == '.' and l[i][j-1] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()
    if i == H -1:
        for j in range(W):
            if j == 0 :
                if l[i][j] == '#':
                    if l[i-1][j] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()
            if j == W -1 :
                 if l[i][j] == '#':
                    if l[i-1][j] == '.' and l[i][j-1] == '.':
                        print("No")
                        sys.exit()
            else :
                if l[i][j] == '#':
                    if l[i-1][j] == '.' and l[i][j-1] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()
    else :
        for j in range(W):
            if j == 0 :
                if l[i][j] == '#':
                    if l[i-1][j] == '.' and  l[i+1][j] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()
            if j == W -1 :
                 if l[i][j] == '#':
                    if l[i-1][j] == '.' and  l[i+1][j] == '.' and l[i][j-1] == '.':
                        print("No")
                        sys.exit()
            else :
                if l[i][j] == '#':
                    if l[i-1][j] == '.' and  l[i+1][j] == '.' and l[i][j-1] == '.' and l[i][j+1] == '.':
                        print("No")
                        sys.exit()

print("Yes")       
            

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i += 2) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
 
long N;
long A[300001];
long ans;
 
int compare_long(const void *a, const void *b) {
	return *(long*)b - *(long*)a;
}
 
int main() {
	long i, j;
	long sum = 0;
	
	sl(N);
	for(i=0;i<N;i++) {
		sl(A[i]);
		sum += A[i];
	}
	qsort(A, N, sizeof(long), compare_long);
	
	for(i=0;i<N;i++) {
		if(A[i] > (sum - A[i]) * 2) {
			break;
		}
		sum -= A[i];
	}
	
	pl(i + 1);
	
	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<queue>


using namespace std;
#define mod 1000000007
#define ll long long 

ll n,x, y, k;

ll arr[29][29];
vector<ll> g[100009];
ll dp[100009][3];

ll solve(ll curr, ll par, ll flag) {
	
	if(dp[curr][flag] != -1)
		return dp[curr][flag];

	ll ans = 1; // we can always color it white. so at least one way to color current one.

	for(auto child: g[curr]) {
		if(child == par) continue;
		ll child_count = 0;
		child_count += solve(child, curr, 0);
		child_count %= mod;
		if(flag == 0) 
			child_count += solve(child, curr, 1);
		child_count %= mod;
		ans *= child_count;
		ans %= mod;
	}

	return dp[curr][flag] = ans%mod;
}


int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n;
    for(int i = 0; i < n - 1; i++) {
    	scanf("%lld %lld", &x, &y);
    	g[x].push_back(y);
    	g[y].push_back(x);
    }
    cout<<(solve(1, -1, 0)%mod + solve(1, -1, 1)%mod)%mod<<endl;
}

Measured memory_bytes: 16384
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    if(c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 >= 1000) cout << 1 << endl;
    else                                                                        cout << 0 << endl;
}


Measured memory_bytes: 3088
N=input()
H=map(int, raw_input().split())

if len(H)==1:
	print "Yes"
	quit()

for i in range(N):
	if i==0:
		if H[i]<=H[i+1]:
			pass
		else:
			H[i]-=1
			if H[i]>H[i+1]:
				print "No"
				quit()
	else:
		if H[i-1]<H[i]:
			H[i]-=1
		elif H[i-1]==H[i]:
			pass
		else:
			print "No"
			quit()
else:
	print "Yes"
	

Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r + 1 - l;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[100],y[100],h[100],x1,y1,h1,i,j,flg,xx,yy,hh,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d %d",&x[i],&y[i],&h[i]);
	}
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			if(h[i]<h[j])	{
				swap(h[i],h[j]);	swap(x[i],x[j]); swap(y[i],y[j]);
			}
		}
	}
	for(i=0;i<=100;i++)	{
		for(j=0;j<=100;j++)	{
			xx=x[0]-j;	if(xx<0)	xx=-xx;
			yy=y[0]-i;	if(yy<0)	yy=-yy;
			h1=h[0]+xx+yy;
			if(h1==0)	flg=0;
			else {
				flg=1;
				for(k=1;k<n;k++)	{
					xx=x[k]-j;	if(xx<0)	xx=-xx;
					yy=y[k]-i;	if(yy<0)	yy=-yy;
					hh=h[k]+xx+yy;	
					if(h[k]!=0)	{
						if(hh!=h1)	{
							flg=0;
							break;
						}
					}
					else {
						if(hh<h1)	{
							flg=0;
							break;
						}
					}
				}
			}
			if(flg==1)	{
				x1=j;	y1=i;
				j=100;	i=100;
			}
		}
	}
	printf("%d %d %d\n",x1,y1,h1);
	return 0;
}

Measured memory_bytes: 128
x1, y1, x2, y2 = map(int, input().split())

x = x1 - x2
y = y1 - y2
x3 = x2 + y
y3 = y2 - x
x4 = x1 + y
y4 = y1 - x
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(void){
int a,n;cin>>a>>n;
int x[n];
for(int i=0;i<n;i++)
    cin>>x[i];
for(int i=0;i<n;i++)
    {a-=x[i];
    if(a<0)
        {cout<<-1<<endl;return 0;}}
cout<<a<<endl;

return 0;}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int E = s.nextInt();
		int Y = s.nextInt();
		
		if (E == 0){
			if (Y <= 1911){
				System.out.print("M");
				System.out.println(Y - 1867);
			}else if(Y <= 1925){
				System.out.print("T");
				System.out.println(Y - 1911);
			}else if(Y <= 1988){
				System.out.print("S");
				System.out.println(Y - 1925);
			}else{
				System.out.print("H");
				System.out.println(Y - 1988);
			}
		} else if(E == 1){
			System.out.println(1867 + Y);
		}else if(E == 2){
			System.out.println(1911 + Y);
		}else if(E == 3){
			System.out.println(1925 + Y);
		}else{
			System.out.println(1988 + Y);
		}
	}
}

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

using namespace std;

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

int in() { int x; scanf("%d", &x); return x; }
template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

const int MAX = 10010;
int H, W, N;
int a[MAX];
int rest[MAX], m[MAX][MAX];

int cur = 0;
int func() {
  rest[cur]--;
  if (0 <= rest[cur]) {
    return cur;
  } else {
    cur++;
    rest[cur]--;
    return cur;
  }
}

int main() {
  H = in();
  W = in();
  N = in();
  REP(i,N) {
    a[i] = in();
    rest[i] = a[i];
  }

  // REP(y,H) REP(x,W) cout << func() + 1 << endl;

  REP(x,W) {
    if (x % 2 == 0) {
      REP(y,H) m[y][x] = func() + 1;
    } else {
      for (int y = H - 1; 0 <= y; y--) m[y][x] = func() + 1;
    }
  }

  REP(y,H) {
    REP(x,W) {
      if (x == W - 1) {
        printf("%d", m[y][x]);
      } else {
        printf("%d ", m[y][x]);
      }
    }
    puts("");
  }

  return 0;
}



Measured memory_bytes: 2688
#include <cstdio>
#define Maxn 1000
char s[Maxn+5];
bool c[Maxn+5];
int n,k;
int main(){
	scanf("%s",s+1);
	scanf("%d",&k);
	while(s[++n]!='\0');
	n--;
	for(int i=1;i<=n;i++){
		s[i+n]=s[i];
		s[i+(n<<1)]=s[i];
	}
	int ans_1=0,ans_2=0,ans_3=0;
	for(int i=1;i<=n*3;i++){
		if(s[i]==s[i-1]){
			if(c[i-1]){
				continue;
			}
			c[i]=1;
			if(i<=n){
				ans_1++;
			}
			if(i<=(n<<1)){
				ans_2++;
			}
			ans_3++;
		}
	}
	printf("%lld\n",ans_1+1ll*(k-1)/2*(ans_3-ans_1)+1ll*((k-1)%2)*(ans_2-ans_1));
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.Math;
import java.math.BigDecimal;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int target = sc.nextInt();
        int[] array = new int[120000];
        for(int i = 0; i < 120000; i++){
            array[i] = 0;
        }
        array[0] = 1;
        for(int i = 2; i < 120000; i++){
            for(int j = 2; i * j < 120000; j++){
                array[i * j - 1] = 1;
            }
        }
        for(int i = target; i < 120000; i++){
            if(array[i - 1] == 0){
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
int main() {
cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  if(n<4)putout(0);
  else{
    vec five(26);
    loop(i,26)five[i]=pow(5,i+1);
    if(n%2==0){
      ll t=n/2;
      vec ans(26);
      loop(i,26)ans[i]=t/five[i];
      putout(sum(ans));
    }
    else{
      putout(0);
    }
  }
}

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

int main () {
	int n, x, m[110];
	cin >> n >> x;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
	}

	sort(m, m + n);
	x -= sum;

	cout << n + x / m[0] << endl;
}

Measured memory_bytes: 256