akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;

struct Tuple {
    LL index;
    /* any other attributes below */
    string s;
    LL p;
};

int main() {
    LL N;
    cin >> N;
    vector<Tuple> X(N);
    REP(i, N) {
        string s;
        LL p;
        cin >> s >> p;
        X[i] = Tuple{i + 1, s, p};
    }

    sort(ALL(X), [] (auto& x, auto& y) {return x.p > y.p;});
    stable_sort(ALL(X), [] (auto&& x, auto& y) {return x.s < y.s;});

    REP(i, N) {
        cout << X[i].index << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split(" "))

if N == 1:
    if A != B:
        print(0)
        exit()
    print(1)
    exit()
if A > B:
    print(0)
    exit()
MIN = A + A * (N-2) + B
MAX = A + B * (N-2) + B
print(MAX-MIN+1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int day, jp_p, mt_p;
	int jp_d, mt_d;
	int jp, mt;
	
	scanf("%d %d %d %d %d", &day, &jp_p, &mt_p, &jp_d, &mt_d);
	
	if (jp_p % jp_d != 0){
		jp = 1 + (jp_p / jp_d);
	}
	else {
		jp = jp_p / jp_d;
	}
	
	if (mt_p % mt_d != 0){
		mt = 1 + (mt_p / mt_d);
	}
	else {
		mt = mt_p / mt_d;
	}
	
	if (jp >= mt){
		printf("%d\n", day - jp);
	}
	else {
		printf("%d\n", day - mt);
	}
	
	return (0);
}

Measured memory_bytes: 596
s = input()
if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:]) <= 12:
  print("AMBIGUOUS")
elif 1 <= int(s[:2]) <= 12:
  print("MMYY")
elif 1 <= int(s[2:]) <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int[] H = new int[500005];

    public static void main(String[] args) {
        read();
        buildMaxHeap();
        for (int i = 1; i <= n; i++) {
            System.out.print(" " + String.valueOf(H[i]));
        }
        System.out.print("\n");
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            H[i] = sc.nextInt();
        }
    }

    public static void maxHeapify(int i) {
        int l = i * 2;
        int r = i * 2 + 1;

        int largest;
        if (l <= n && H[l] > H[i]) {
            largest = l;
        } else {
            largest = i;
        }
        if (r <= n && H[r] > H[largest]) {
            largest = r;
        }

        if (largest != i) {
            int tmp = H[i];
            H[i] = H[largest];
            H[largest] = tmp;

            maxHeapify(largest);
        }
    }

    public static void buildMaxHeap() {
        for (int i = n / 2; i >= 1; i--) {
            maxHeapify(i);
        }
    }
}

Measured memory_bytes: 173652
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(ll i = ll(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll D;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
	
	cin >> D;
	if (D == 25) {
		cout << "Christmas" << endl;
	} else if (D == 24) {
		cout << "Christmas Eve" << endl;
	} else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	} else {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	
	return 0;
}


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

public class Program
{

	static void Main(string[] args)
	{
		// 文字の入力
		var S = Console.ReadLine();
		var answerList = new List<char>() { 'A', 'C', 'G', 'T' };
		var count = 0;
		var maxCount = 0;
		foreach (var c in S)
		{
			if (answerList.Any(x => x == c))
			{
				count++;
			}
			else
			{
				if (maxCount < count)
				{
					maxCount = count;
				}
				count = 0;
			}
		}

		if (maxCount < count)
		{
			maxCount = count;
		}

		Console.WriteLine(maxCount);
	}

}


Measured memory_bytes: 11220
import string

N = int(input())
S = input()
cnt = 0
for i in range(1, N):
  s1 = S[:i]
  s2 = S[i:]
  tmp = 0
  for j in string.ascii_lowercase:
    if j in s1 and j in s2:
      tmp += 1
  cnt = max(cnt, tmp)
print(cnt)

Measured memory_bytes: 3772
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li N;
	li D;
	cin>>N>>D;

	li cnt=0,x,y;

	Rep(i,N){
		cin>>x>>y;
		if(D*D>=x*x+y*y){cnt++;}//cout<<x<<' '<<y<<endl;}
	}

	cout<<cnt;



}

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

void shuffle(char str[201], int n)
{
  char *holder = malloc(strlen(str) + 1);;
  strcpy(holder, str+n);
  strncat(holder, str, n);
  strcpy(str, holder);
  free(holder);
}

int main(void)
{
  int n, shuffles, i;
  while (1)
    {
      char str[201];
      scanf(" %200s", str);
      if (strcmp(str, "-") == 0)
	return 0;
      scanf(" %d", &shuffles);
      for (i = 0; i < shuffles; i++)
	{
	  scanf(" %d", &n);
	  shuffle(str, n);
	}
      printf("%s\n", str);
    }
  return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int res,ad,n,m,ll,rr,uu,dd,L,R,U,D,sx,sy,dp[105][105][105],row[105][105],col[105][105];
char s[105][105];
int main()
{
    memset(dp,-1,sizeof dp);
    dp[0][0][0]=0;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i)
        scanf("%s",s[i]+1);
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j) {
            row[i][j]+=row[i][j-1]+(s[i][j]=='o');
            col[i][j]+=col[i-1][j]+(s[i][j]=='o');
            if (s[i][j]=='E')
                sx=i,sy=j;
        }
    L=sy-1,R=m-sy,U=sx-1,D=n-sx;
    for (int l=0;l<=L;++l)
        for (int r=0;r<=R;++r)
            for (int u=0;u<=U;++u)
                for (int d=0;d<=D;++d) {
                    if (dp[r][u][d]==-1)
                        continue;
                    res=max(res,dp[r][u][d]);
                    ll=max(sy-l,r+1);
                    rr=min(sy+r,m-l);
                    dd=max(sx-u,d+1);
                    uu=min(sx+d,n-u);
                    if (u+d<D) {
                        ad=row[sx+d+1][rr]-row[sx+d+1][ll-1];
                        dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+ad);
                    }
                    if (u+d<U) {
                        ad=row[sx-u-1][rr]-row[sx-u-1][ll-1];
                        dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+ad);
                    }
                    if (l+r<R) {
                        ad=col[uu][sy+r+1]-col[dd-1][sy+r+1];
                        dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+ad);
                    }
                    if (l+r<L) {
                        ad=col[uu][sy-l-1]-col[dd-1][sy-l-1];
                        dp[r][u][d]=max(dp[r][u][d],dp[r][u][d]+ad);
                    }
                }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 4864
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
 
using namespace std;
typedef long long ll;
 
int main()
{
  int n;
  cin >> n;
  int sum = 0;
  int max = 0;
  int p[15];
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
    sum += p[i];
    if (max < p[i])
    {
      max = p[i];
    }
  }
  cout << sum - (max / 2) << endl;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse

int main(){
    int R,G,B,N,Co=0;
    cin>>R>>G>>B>>N;
    for(int i=0;i<=N/R;i++){
        for(int j=0;j<=N/G;j++){
            int p=N-i*R-j*G;
            if(p<0)continue;
            if(p%B==0)Co++;
        }
    }
    cout<<Co<<endl;
    return 0;
}

//a=97,z=122

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



Measured memory_bytes: 256
from collections import Counter

n = int(input())
cnt = dict(zip(map(chr, range(97, 123)), [50] * 26))

for _ in range(n):
    c = Counter(input())
    for k in cnt.copy().keys():
        if c[k] == 0:
            del cnt[k]
        else:
            cnt[k] = min(cnt[k], c[k])

if len(cnt) == 0:
    print()
else:
    res = ''
    for k, v in sorted(cnt.items()):
        res += k * v
    print(res)


Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
	int a,b,i,j,k;
	for(k=0;k<300;k++){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0){
			break;
		}else{
			for(i=0;i<a;i++){
				if(i%2==0){
					for(j=0;j<b;j++){
						if(j%2==0){
							printf("#");
						}else{
							printf(".");
						}
					}
				}else{
					for(j=0;j<b;j++){
						if(j%2==0){
							printf(".");
						}else{
							printf("#");
						}
					}
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2544
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
m = LIST()
gcd_num = m[0]
for i in range(1, n):
  gcd_num = gcd(gcd_num, m[i])

def make_divisors(n):
   divisors = []
   for i in range(1, int(n**0.5)+1):
       if n % i == 0:
           divisors.append(i)
           if i != n // i:
               divisors.append(n//i)
   divisors.sort()
   return divisors

print("\n".join(map(str, make_divisors(gcd_num))))



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll,pair<int, int> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT32_MAX;
const int MAX_N = int(1e5) + 5;
const int MAX_V = 305;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

ll n, d[305][305];

bool wf() {
    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                if (d[i][j] > d[i][k] + d[k][j]) {
                    return false;
                }
            }
        }
    }
    return true;
}

struct UF {
    int p[305], r[305];

    void init(int _n) {
        REP(i, _n) {
            p[i] = i;
            r[i] = 1;
        }
    }
    int find(int x) {
        if (p[x] == x)
            return x;
        else
            return p[x] = find(p[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x==y)return;
        if(r[x]<r[y])swap(x,y);
        if(r[x] == r[y])r[x]++;
        p[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

struct edge {
    ll to, cost;
};

int V;
vector<edge> G[MAX_V];
ll dmin[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dmin, dmin + V, LLINF);
    dmin[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dmin[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (dmin[e.to] > dmin[v] + e.cost) {
                dmin[e.to] = dmin[v] + e.cost;
                que.push(P(dmin[e.to], e.to));
            }
        }
    }
}

ll solve(){
    vector<P3> es;
    REP(i,n){
        FOR(j,i+1,n){
            if(i==j)continue;
            es.push_back(P3(d[i][j],{i,j}));
        }
    }
    sort(es.begin(),es.end());
    UF g;
    g.init(n);
    ll sum = 0;
    REP(i,es.size()){
        int u = es[i].second.first,v = es[i].second.second;
        if(!g.same(u,v)){
            sum += es[i].first;
            g.unite(u,v);
            G[u].push_back({v,es[i].first});
            G[v].push_back({u,es[i].first});
        }
        else{
            dijkstra(u);
            if(dmin[v]>d[u][v]){
                sum += es[i].first;
                G[u].push_back({v,es[i].first});
                G[v].push_back({u,es[i].first});
            }
        }
    }
    return sum;
}

int main() {
    cin >> n;
    REP(i, n) {
        REP(j, n) { cin >> d[i][j]; }
    }
    if (!wf())
        cout << -1 << endl;
    else {
        V = n;
        cout << solve() << endl;
    }
    return 0;
}


Measured memory_bytes: 2168
n,m=map(int,input().split())
p=list(map(int,input().split()))[1:]
for i in range(n-1):
    k=list(map(int,input().split()))[1:]
    c=[]
    for j in range(len(p)):
        if p[j] in k:
            c.append(p[j])
    else:
        p=c
print(len(p))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 5e5 + 5, M = 5e4 + 9, INF = 1e9, MOD = 1e9 + 7;

int x[N], y[N];

void runtestcase() {
	int n;
	cin >> n;
	bool can = 0;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < n; ++i) {
		if(i + 3 > n) continue;
		int cnt = 0;
		cnt += (x[i] == y[i]);
		cnt += (x[i + 1] == y[i + 1]);
		cnt += (x[i + 2] == y[i + 2]);
		if(cnt == 3) {
			can = 1;
			break;
		}

	}
	if(can)
		cout << "Yes";
	else
		cout << "No";
}


int main() {
    fastIO;
#ifdef LOCAL
    freopen("input.in", "rt", stdin);
//    freopen("cache.out", "wt", stdout);
#endif
  int t = 1, tt = 1;
//	cin >> t;
  while(t) {
//		cout << "Case #" << tt << ':' << ' ';
    runtestcase();
    if(t)
    	cout << '\n';
    --t, ++tt;
  }
}


Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////



int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    a[n] = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a[i]/2;
        a[i] %= 2;

        int tmp = min(a[i], a[i+1]);
        ans += tmp;
        a[i] -= tmp;
        a[i+1] -= tmp;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (auto& i : v) cin >> i;
  for (auto& i : c) cin >> i;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > c[i])
      ans += v[i]-c[i];
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  string s;
  int n;
  bool easy = true;
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i = i + 2) {
    if (s[i] == 'L') { easy = false;}
  }
  for (int i = 1; i < n; i = i + 2) {
    if (s[i] == 'R')
    {
      easy = false;
    }
  }
  fputs(easy ? "Yes" : "No", stdout);
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,a[100001],k=1;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		a[t]++;
	} 
	if(n&1){
		if(a[0]!=1){
			cout<<0;
			return 0;
		}
		rep(i,n-1){
			if(a[i]){
				if(i&1||a[i]!=2){
					cout<<0;
					return 0;
				}
			}
			else{
				if(!i&1){
					cout<<0;
					return 0;
				}
			}
		}
	}
	else{
		rep(i,n-1){
			if(a[i]){
				if(!i&1||a[i]!=2){
					cout<<0;
					return 0;
				}
			}
			else{
				if(i&1){
					cout<<0;
					return 0;
				}
			}
		}
	}
	rep(i,n/2){
		k*=2;
		k%=INF;
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main()
{
	int n;
	long long int d;
	cin >> n >> d;
	long long int x,y;
	int sum = 0;
	while(n--){
		cin >> x >> y;
		long long int ans = x * x + y * y;
		if(ans <= (d*d))
			sum++;
	}
	cout << sum << endl;	
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int mp[1005][1005];

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for(int i = 0; i < b; ++i) {
        for(int j = a; j < w; ++j) {
            mp[i][j] = 1;

        }
    }
    for(int i = b; i < h; ++i) {
        for(int j = 0; j < a; ++j) {
            mp[i][j] = 1;

        }
    }

    for(int i = 0; i < h; ++i) {
        int c = 0;
        for(int j = 0; j < w; ++j) {
            if(mp[i][j] == 0) ++c;

        }
        if(min(c, w - c) != a) {
            cout << "No" << endl;
            return 0;

        }
    }

    for(int i = 0; i < w; ++i) {
        int c = 0;
        for(int j = 0; j < h; ++j) {
            if(mp[j][i] == 0) ++c;

        }
        if(min(c, h - c) != b) {
            cout << "No" << endl;
            return 0;

        }
    }

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cout << mp[i][j];

        }
        cout << endl;
    }
    return 0;
}


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

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

    double p[n];
    for (int i=0;i<n;i++)
        cin >> p[i];

    double dp[n+1][n+1];
    dp[0][0]=1;
    for (int i=1; i<=n; i++) {
        dp[i][0]=dp[i-1][0]*p[i-1];
        dp[0][i]=dp[0][i-1]*(1-p[i-1]);
    }

    for (int i=1; i<=n; i++)
        for (int j=1; j<=n-i; j++)
            dp[i][j]=dp[i-1][j]*p[i+j-1] + dp[i][j-1]*(1-p[i+j-1]);

    double answer=0;
    for (int i=0; i<=n; i++)
        if (i>n-i)
            answer+=dp[i][n-i];

    cout.precision(10);
    cout << answer;

}


Measured memory_bytes: 70016
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        String[] x = input.split(" ");
        for(int i = 0 ; i < x.length ; i++){
            if(x[i].equals("0")){
                System.out.println(i + 1);
            }
        }
    }
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
#define LL long long
namespace io {
  template <typename T> inline void read(T &x) {
    bool flag = false;  char c = getchar();
    while ((c < '0' || c > '9') && c != '-')  c = getchar();
    c == '-' ? flag = true, x = 0 : x = c - '0';
    c = getchar();
    while (c >= '0' && c <= '9')  x = (x << 3) + (x << 1) + c - '0', c = getchar();
    if (flag)  x = -x;
  }
  template <typename T> inline void write(T x) {
    char st[10010];
    int cnt = 0;
    if (x < 0)  x = -x, putchar('-');
    if (x == 0)  putchar('0');
    while (x) { st[++cnt] = x % 10 + 48;  x /= 10; }
    while (cnt) { putchar(st[cnt--]); }
  }
}
using namespace io;
int main() {
    int s, k, ans = 0;
    read(k); read(s);
    for (int i = k; i >= 0; --i) {
        if (i > s) {
            continue;
        }
        for (int j = k; j >= 0; --j) {
            if (i + j > s) {
                continue;
            }
            int t = s - i - j;
            if (t >= 0 && t <= k) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int m, d;

int main(void)
{
	cin >> m >> d;
	
	int ans = 0;
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= d; j++){
			if(j <= 9) continue;
			int a = j/10, b = j%10;
			if(a >= 2 && b >= 2 && i == a*b) ans++;
		}
	}
	cout << ans  << endl;
	
	return 0;
}

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

int main(){
  int N;
  string S;

  cin >> N >> S;

  int ans = 0;

  rep(i,N-2){
    if((S.at(i) == 'A') && (S.at(i+1) == 'B') && (S.at(i+2) == 'C')) ans++;
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a1 = (n / 1.08).to_i
a2 = (n / 1.08).ceil.to_i

if (a1 * 1.08).floor == n
  puts a1
elsif (a2 * 1.08).floor == n
  puts a2
else
  puts ":("
end

Measured memory_bytes: 1788
//  ©   ___MRX___

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

#define ll long long int

int main()
{
    int n, i, total = 0, largest;
    cin >> n;
    vector<int> pg(n);

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

    largest = *max_element(pg.begin(), pg.end());

    largest < total - largest ? cout << "Yes" : cout << "No";
    cout << '\n';

    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, k;
    cin >> a >> b >> k;

    setint s;
    rep(i, k)
    {
        if (a + i > b)
            break;
        s.insert(a + i);
    }
    rep(i, k)
    {
        if (b - i < a)
            break;
        s.insert(b - i);
    }

    for (auto x : s)
    {
        cout << x << endl;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import sys
import math
input=sys.stdin.readline

n,h=map(int,input().split())

once=[]
infinity=[]

for i in range(n):
  a,b=map(int,input().split())
  once.append(b)
  infinity.append(a)
  
once.sort(reverse=True)

pin=max(infinity)

once2=[]
for i in range(n):
  if once[i]>pin:
    once2.append(once[i])
  
  else:
      break

ans=0
for i in once2:
    ans+=1
    h-=i
    if h<=0:
        print(ans)
        exit()

ans+=math.ceil(h/pin)


print(ans)

Measured memory_bytes: 85560
#include<cstdio>

using namespace std;

void calcChange(int prc,int back[]){
	back[3]=prc/500;	prc%=500;
	back[2]=prc/100;	prc%=100;
	back[1]=prc/50;		prc%=50;
	back[0]=prc/10;
}

int main(){
	for(int t=0,pay;scanf("%d",&pay),pay;t++){
		if(t)	puts("");

		int c[4];
		for(int i=0;i<4;i++)	scanf("%d",c+i);

		int mincoins=1<<30,ans[4];
		for(int i=0;i<=c[0];i++)for(int j=0;j<=c[1];j++)
		for(int k=0;k<=c[2];k++)for(int l=0;l<=c[3];l++){
			int prc=10*i+50*j+100*k+500*l,back[4];
			if(prc>=pay){
				calcChange(prc-pay,back);
				if((back[0]==0 || i==0)
				&& (back[1]==0 || j==0)
				&& (back[2]==0 || k==0)
				&& (back[3]==0 || l==0)){
					int coins=(c[0]+c[1]+c[2]+c[3])-(i+j+k+l)+(back[0]+back[1]+back[2]+back[3]);
					if(coins<mincoins){
						ans[0]=i,ans[1]=j,ans[2]=k,ans[3]=l;
						mincoins=coins;
					}
				}
			}
		}

		int p[]={10,50,100,500};
		for(int i=0;i<4;i++)	ans[i]&&printf("%d %d\n",p[i],ans[i]);
	}

	return 0;
}

Measured memory_bytes: 764
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int x, y, z, k; readV(x, y, z, k);
  long[] a; readA(x, a);
  long[] b; readA(y, b);
  long[] c; readA(z, c);

  long[] d;
  foreach (ai; a)
    foreach (bi; b)
      d ~= ai+bi;

  d.sort!"a>b";
  d = d[0..min(d.length, k)];

  long[] e;
  foreach (ci; c)
    foreach (di; d)
      e ~= ci+di;

  e.sort!"a>b";

  foreach (i; 0..k)
    writeln(e[i]);
}


Measured memory_bytes: 59900
#include<stdio.h>
int main(void)
{
	int N,L[10],a,i,sum = 0;
	
	scanf ("%d",&N);
	
	scanf("%d",&L[0]);
	
	for(i = 1;i < N;i++){
		scanf("%d",&L[i]);
		
		if(L[i] > L[0]) {
			a = L[i];
			L[i] = L[0];
			L[0] = a;
		}
		sum += L[i];
	}
	
	if(L[0] < sum){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll dp[110][10010];
ll v[1010], w[1010];


int main(){
    int n, W;
    cin >> n >> W;
    rep(i, n) cin >> v[i] >> w[i];
    rep(i, n){
        rep(j, W + 1){
            if (j - w[i] >= 0) dp[i + 1][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
        }
    }

    cout << dp[n][W] << endl;
    
    return 0;
}


Measured memory_bytes: 10904
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int batasprima=5000;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int match[205],k,ans;
vector <int> daftar,adj[205],prime;
bitset<205> visited;
void sieve(){
	bool isprime[batasprima+5];
	memset(isprime,true,sizeof(isprime));
	for(int i=2;i<=batasprima;i++)
	{
		if(!isprime[i])
			continue;
		prime.pb(i);
		for(int j=i+i;j<=batasprima;j+=i)
			isprime[j]=false;
	}
}
bool isprime(int angka){
	if(angka<=2)
		return false;
	for(auto isi:prime)
	{
		if(angka%isi==0&&angka!=isi)
			return false;
	}
	return true;
}
bool matching(int pos){
	if(visited[pos])
		return false;
	visited[pos]=true;
	for(auto isi:adj[pos])
	{
		if(match[isi]==-1||matching(match[isi]))
		{
			match[isi]=pos;
			match[pos]=isi;
			return true;
		}
	}
	return false;
}
void buatgraph(){	
	for(int i=0;i<daftar.size();i++)
	{
		for(int j=0;j<daftar.size();j++)
		{
			if(isprime(abs(daftar[i]-daftar[j])))
				adj[i].pb(j);
		}
	}
}
void hitungk(){
	k=0;
	memset(match,-1,sizeof(match));
	for(int i=0;i<daftar.size();i++)
	{
		if(match[i]!=-1)
			continue;
		visited.reset();
		if(matching(i))
			k++;
	}
}
void hitungans(){
	int genap=0,ganjil=0;
	for(auto isi:daftar)
	{
		if(isi&1)
			ganjil++;
		else
			genap++;
	}
	assert(ganjil>=k&&genap>=k);
	assert(ganjil%2==genap%2);
	ans=k+((ganjil-k)/2+(genap-k)/2)*2+((ganjil-k)%2)*3;
}
void isidaftar(){
	int n,tadi=0;
	scan(n);
	for(int i=0;i<n;i++)
	{
		int input;
		scan(input);
		assert(tadi<input);
		tadi=input;
		if(daftar.size()&&daftar.back()==input)
			daftar[daftar.size()-1]=input+1;			//nanti mau sa coba
		else
			daftar.pb(input),daftar.pb(input+1);
	}
	assert(daftar.size()<=200);
}
int main()
{
	sieve();
	isidaftar();
	buatgraph();
	hitungk();
	hitungans();
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int mn = a[0];
    int mx = a[n - 1];
    int ans = 1e9;
    for (int i = mn; i <= mx; i++) {
        int total = 0;
        for (int j = 0; j < n; j++) {
            total += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, total);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mo=1e9+7;
using namespace std;
typedef long long ll;
const int N=92;
ll f[N],x,y;
vector<pair<ll,ll>>v[N];
int Q,i,ans;
int main(){
	for(i=2,f[1]=1;i<N;++i)f[i]=f[i-1]+f[i-2];
	v[2]={make_pair(1,2)};
	for(i=3;i<N;++i){
		v[i]=v[i-1];
		for(auto&u:v[i])swap(u.first,u.second),u.second+=u.first;
		v[i].push_back(make_pair(f[i],f[i]*2+f[i-1]));
	}
	x=3;y=4;for(i=3;i<N;++i)v[i].push_back(make_pair(x,y)),swap(x,y),y+=x;
	for(scanf("%d",&Q);Q--;){
		scanf("%lld%lld",&x,&y);if(x>y)swap(x,y);
		if(x==1){printf("1 %lld\n",y%mo);continue;}
		if(x==2 && y==2){puts("1 4");continue;}
		for(i=3;f[i]<=x && f[i+1]<=y;++i);--i;ans=0;
		for(auto u:v[i])if(x>=u.first && y>=u.second && u.second<u.first*2)ans=(ans+(y-u.second)/u.first+1+
			(x>=u.second && y>=u.first))%mo;
		printf("%d %d\n",i-1,ans);
	}
	return 0;
}

Measured memory_bytes: 4224
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,n,i,x;
	cin>>a>>b;
	n=b-a;
	x=0;
	for(i=1;i<=n;i++){
		x=x+i;
	}
	x=x-b;
	cout<<x<<endl;

	return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    	sum += a[i];
    }
    int ans = INT_MAX;
    int temp = 0;
    for(int i = 0; i < n - 1; i++) {
    	temp += a[i];
    	ans = min(ans, abs(2 * temp - sum));
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int n;
		Scanner sc =new Scanner(System.in);
		int i;
		n=sc.nextInt();
		for(i=n;i>=1;i--)
		{
		    double n1=Math.sqrt(i);
		    int n2= (int)Math.floor(n1);
		    int n3= (int)Math.ceil(n1);
		        if(n2==n3)
		        {
		            break;
		        }
		}
	
		    System.out.println(i);
		
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main() {
    int hills[10];
    int i,j;
    for (i = 0; i < 10; i++) {
        scanf("%d", &hills[i]);
    }
    for (i = 0; i < 10; i++) {
        for(j = 0; j < 10; j++) {
            if(hills[i] < hills[j]) {
                int b = hills[j];
                hills[j] = hills[i];
                hills[i] = b;
            }
        }
    }
    for(i = 9; i > 6; i--) {
        printf("%d\n",hills[i]);
    }
    return 0;
}

Measured memory_bytes: 600
n,m=map(int, input().split())

ok=0
ac = [0]*n
penalty = [0]*n

for i in range(m):
    p,s = input().split()
    p=int(p)
    if s=="WA":
        if ac[p-1]==0:
            penalty[p-1]+=1
    elif s=="AC":
        if ac[p-1]==0:
            ok+=1
            ac[p-1]=1
ans=0
for i in range(n):
    if ac[i]==1:
        ans+=penalty[i]
print(ok,ans)

Measured memory_bytes: 4596
function main(input) {
    var s = input[0].split(" ").map(v=>v-0);
    var a = s[0], b=s[1], k=s[2];
    var ans = [];
    for(var i=a;i<a+k&&i<=b;i++){
        ans.push(i);
    }
    for(var i=b-k+1;i<=b;i++){
        if(i>=a+k)
            ans.push(i);
    }
    
    console.log(ans.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  cout << s.substr(0, s.size() - 8) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3632
#coding=UTF-8

mojir=input()
hyo=mojir.split(' ')

N=int(hyo[0])
K=int(hyo[1])

mojir=input()
hyo=mojir.split(' ')
D=[int(mono) for mono in hyo]

kouho=N

def usecheck(gaku):
    gakustr=str(gaku)
    keta=len(gakustr)
    dame=None
    for idx in range(0,keta,1):
        if gakustr[idx] in hyo:
            dame=idx
            break

    if dame == None:
        return None
    else:
        return (keta-dame)

#積極的に枝刈りを
while True:
#    print(kouho)
    dameketa=usecheck(kouho)
    if dameketa == None:
        break

    kouho=(kouho//(10**(dameketa-1)) +1)*(10**(dameketa-1))

print(kouho)


Measured memory_bytes: 3064
// 7/1 解き直し
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

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

    // vector<int> tail;
    // rep(i, N) {
    //     if (tail.empty() || tail.top()) {
    //     }
    // }

    vector<int> dp(N, -1);
    rep(i, N) {
        int left = -1;  // A[i]より小さいギリギリ
        int right = N-1;  // A[i]より大きいギリギリ

        while (right - left > 1) {
            int mid = (left + right) / 2;
            // if (dp[mid] >= A[i]) right = mid;
            if (dp[mid] < A[i]) right = mid;
            else left = mid;
        }

        dp[right] = A[i];
    }

    int res = 0;
    rep(i, N) {
        if (dp[i] != -1) res++;
        // cout << dp[i] << endl;
    }

    cout << res << endl;
}

Measured memory_bytes: 4020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	if (a*b == 15)cout << "*" << endl;
	else if (a + b == 15)cout << "+" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 764
n = int(input())
h = list(map(int, input().split()))[::-1]
last = h[0]
for i in range(1, n):
  if h[i] <= last:
      last = h[i]
  elif last+1 == h[i]:
      continue
  else:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 14396
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			if ((n|m|a)!=0) {
				solve(n,m,a);
			} else {
				break;
			}
		}
	}

	private static void solve(int n,int m,int a) {
		List<Tri> list = new ArrayList<>();
		for (int i = 0;i < m;i++) {
			list.add(new Tri(sc.nextInt(),sc.nextInt(),sc.nextInt()));
		}
		Collections.sort(list);

		int[] ar = new int[110];
		for (int i = 0;i < 110;i++) ar[i] = i;

		for (int i = 0;i < list.size();i++) {
			Tri t = list.get(i);
			int p = t.p;
			int q = t.q;
			int tmp = ar[p];
			ar[p] = ar[q];
			ar[q] = tmp;
		}

		for (int i = 0;i < 110;i++) {
			if (ar[i]==a) System.out.println(i);
		}
	}
}

class Tri implements Comparable<Tri> {
	public int h;
	public int p;
	public int q;

	public Tri(int h,int p,int q) {
		this.h = h;
		this.p = p;
		this.q = q;
	}

	@Override
	public int compareTo(Tri tri) {
		return tri.h - this.h;
	}
}

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

int main() {
	int N, x; cin >> N >> x;
	vector<int>a(N);
	for (int i = 0; i < N; i++)cin >> a[i];

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (x >= a[i]) {
			x -= a[i];
			ans++;
		}
		else x = 0;
	}

	if (x)ans--;

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N%2==0) {
			System.out.println(N);
		} else {
			System.out.println(N*2);
		}
	}
}


Measured memory_bytes: 21716
#include <stdio.h>

int main()
{
	long long int N, A, B, cnt=0;
	scanf("%lld %lld %lld", &N, &A, &B);
	long long int multi = 0;
	multi = N / (A + B);
	N = N % (A + B);
	cnt = cnt + multi*A;
	N = N - A;
	if (N < 0)
	{
		N = N + A;
		while (N > 0)
		{
			N--;
			cnt++;
		}
	}
	else
	{
		cnt = cnt + A;
	}
	printf("%lld", cnt);
	return 0;
}

Measured memory_bytes: 128
# if the remainders (mod 2019) are equal, the difference will be divisible
# x = Q*2019+5 y = R*2019+5 then x-y=(Q-R)*2019
# unless Q-R<=0
# where the substring itself is (Q-R)*2019/10**(something)
from collections import Counter
s = input()[::-1]
partial = 0
remainders = list()
num = (int(character) for character in s)
for i, int_char in enumerate(num):
  partial = (partial+(int_char*pow(10,i,2019))%2019)%2019
  remainders.append(partial)
histo = Counter(remainders)
non_single_count = int(sum(count*(count-1)/2 for value, count in histo.items() if value!=0))
single_count = int(sum(count+count*(count-1)/2 for value, count in histo.items() if value==0))
print(non_single_count+single_count)

Measured memory_bytes: 16980
l, r = list(map(int, input().split()))

ans = 3000

for i in range(l, r):
  for j in range(i + 1, r + 1):
    if (i * j) % 2019 < ans:
      ans = (i * j) % 2019
    if ans == 0:
      print(ans)
      exit() 
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}

ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
ll nax=1e6+2;
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n,k;
  cin>>n>>k;
  set<ll> s;
  pair<ll,ll> p[k+1];
  for(int i=0;i<k;i++){
        int l,r;cin>>l>>r;
        p[i].ff=l,p[i].ss=r;
  }
  ll mini=*(s.begin());
  ll maxi=*(--s.end());
  
  ll dp[n + 1]={},pp[k+2]={}; 
    int temp = 0; 
    dp[0] = 1; 
    for (int i = 1; i < n; i++) 
    { 
         // dp[i]+=dp[i-1];
        for(int j=0;j<k;j++){
              ll x=0;
              mini=p[j].ff,maxi=p[j].ss;
              //cout<<mini<<" "<<maxi<<endl;
              if(i-mini<0) continue;
              
              if(i-mini>=0) pp[j]+=(dp[i-mini]);//x+=dp[i-1]%998244353;
              //if(i-1>=0) 
              if(i-1-maxi>=0) pp[j]-=(dp[i-1-maxi]);
              pp[j]+=998244353;
                  pp[j]%=998244353;
              dp[i]+=pp[j];
              dp[i]%=998244353;
        }
      //  cout<<dp[i]<<" ";
    } 
    cout<<dp[n-1];
}



  


Measured memory_bytes: 5200
a, b, c, d = map(int, input().split())
c1 = 0
c2 = 0
while a > 0:
    a -= d
    c1 += 1

while c > 0:
    c -= b
    c2 += 1

if c1 >= c2:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 9176
import Data.Array.ST
import Data.Array.IArray
import Control.Monad.ST

solve :: [Int] -> Int -> String -> Int
solve [r,s,p] k ts = let a' = runSTArray $ thaw a >>= go 1
                      in sum . map f $ elems a'
  where
    a = listArray (1,n) ts :: Array Int Char
    n = length ts
    f :: Char -> Int
    f t | t == 'r' = p
        | t == 's' = r
        | t == 'p' = s
        | otherwise = 0
    go :: Int -> STArray s Int Char -> ST s (STArray s Int Char)
    go i a
      | i > n = return a
      | otherwise = do
          x <- readArray a i
          if i <= k
             then go (i+1) a
             else do
                 y <- readArray a (i-k)
                 if x == y
                    then do writeArray a i 'x'
                            go (i+1) a
                    else go (i+1) a

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    rsp <- map read . words <$> getLine :: IO [Int]
    t <- getLine
    print $ solve rsp k t

Measured memory_bytes: 8060
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

S = input()
N = len(S)
if is_kaibun(S):
    n = (N - 1) / 2
    if is_kaibun(S[0:int(n)]):
        nn = (N + 3 / 2)
        if is_kaibun(S[int(nn):N]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  int n, k;
  cin >> n >> k;
  double table[10000];
  double ans = 0;
  cout << fixed << setprecision(12) ;

  table[0] = 1.0000000000;
  for (int i = 0; i < 10000-1; ++i) {
    table[i+1] = table[i] * (0.5);
  }

  for (int i = 1; i <= n; ++i) {
    int t = i, cnt = 0;
    for (;t < k; t*=2) {
      cnt += 1;
    }
    double tt = (double)1 / n;
    // cout << (double)1 / n << endl;
    ans += (double)(tt * table[cnt]);
    // cout << ans << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
ini=map(int,raw_input().split())
a=map(int,raw_input().split())

sum=0

for i in range(ini[0]):
  if a[i]==0:
    pass
  else:
    if a[i]-a[i-1]>=ini[1]:
      sum+=ini[1]
    else:
      sum+= a[i]-a[i-1]

sum+=ini[1]

print sum

Measured memory_bytes: 20060