akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

int a[300000];
int b[300000];
unsigned long long ans;

int main() {

	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i];
		if (a[i] >= i) {
			cout << -1 << endl;
			return 0;
		}
		if (a[i] > a[i - 1] + 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 2; i <= n; i++) {
		if (a[i] == a[i - 1] + 1)b[i - 1] = 0;
	}
	for (int i = 1; i <= n; i++)ans += b[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip> 
int main(void){
  using namespace std;
  long long a, b, c;

  cin >> a >> b >> c;
  
  if(4*a*b < (c-a-b)*(c-a-b) && c-a-b >0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    unordered_set<int> berry_col;

    vector<vector<int>> ans(h, vector<int>(w, 0));
    queue<pair<int, int>> q;
    int running = 1;

    rep(i,h){
        rep(j,w){
            if(grid[i][j] == '#'){
                berry_col.insert(j);
                ans[i][j] = running++;
                q.push({i,j});
            }
        }
    }

    while(!q.empty()){
        auto p = q.front(); q.pop();
        int run = ans[p.first][p.second];
        int k = 1;
        while(p.first + k < h && ans[p.first+k][p.second] == 0){
            ans[p.first+k][p.second] = run;
            k++;
        }
        k = 1;
        while(p.first - k >= 0 && ans[p.first-k][p.second] == 0){
            ans[p.first-k][p.second] = run;
            k++;
        }
    }

    for(auto bercol : berry_col){
        int k = 1;
        while(bercol + k < w && ans[0][bercol + k] == 0){
            for(int i = 0; i < h; i++){
                ans[i][bercol+k] = ans[i][bercol];
            }
            k++;
        }
        k = 1;
        while(bercol - k >= 0 && ans[0][bercol - k] == 0){
            for(int i = 0; i < h; i++){
                ans[i][bercol-k] = ans[i][bercol];
            }
            k++;
        }
    }
    cout << endl;
    for(auto v : ans){
        for(auto a : v){
            cout << a << " ";
        }
        cout << endl;
    }


}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  if (s == "keyence") {
    cout << "YES" << endl;
    return 0;
  }
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      string t;
      t = s.substr(0, i);
      t += s.substr(j, n-j);
      if (t == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A,B;
  cin >> A >> B;
  
  int count = 0,num = 0;
  
  for (int i = 0; i < 30; i++) {
    if(i == 0){
      num += A;
    }else{
      num += A - 1;
    }
    count++;
    if(num >= B){
      if(B == 1){
              cout << "0" << endl;
      }else{
      cout << count << endl;
      }
      break;
    }

  }
 
}

Measured memory_bytes: 3608
n,m = map(int,input().split())
a = list(map(int,input().split()))
s = [0 for i in range(0,n+1)]
d = {0:1}
ans = 0
for i in range(0,len(a)):
    s[i+1] += a[i] + s[i]
    r = s[i+1]%m
    ans += d.get(r,0)
    d[r] = d.get(r,0) + 1
print(ans)


Measured memory_bytes: 15016
#include<cstdio>
#include<cstring>

const int N=12,INF=0x3f3f3f3f;
int g[N][N],n;

void minz(int &a,int b) { if(a>b) a=b; }

int main()
{
	int i,j,k,x,sum,cn;
	scanf("%d",&n);
	while(n) {
		memset(g,0x3f,sizeof(g));
		cn=0;
		for(i=0;i<n;i++) {
			scanf("%d%d%d",&j,&k,&x);
			if(j>cn) cn=j;
			if(k>cn) cn=k;
			g[j][k]=g[k][j]=x;
		}
		for(i=0;i<=cn;i++) g[i][i]=0;
		for(k=0;k<=cn;k++)
			for(i=0;i<=cn;i++) for(j=0;j<=cn;j++)
				minz(g[i][j],g[i][k]+g[k][j]);
		x=INF;
		for(i=0;i<=cn;i++) {
			sum=g[i][0];
			for(j=1;j<=cn;j++) if(g[i][j]<INF) sum+=g[i][j];
			if(sum<x) k=i,x=sum;
		}
		printf("%d %d\n",k,x);
		scanf("%d",&n);
	}
	return 0;
}


Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  int count = 0;
  int countv = 0;
  cin >> N;
  vector<int> vec(N);
  int hb,ha;
  cin >> hb;
  for( int i = 1; i < N ; i++){
    cin >> ha;
    if( hb < ha ){
      vec.at(countv) = count;
      countv++;
      count = 0;
    }else{
      count++;
    }
    hb = ha;
  }
  vec.at(countv) = count;
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  count = vec.at(0);
  
  cout << count << endl;
}

Measured memory_bytes: 640
L = int(input())

# 必要な頂点数を出す
N = 0
for i in range(21):
    if 2 ** i > L:
        break
    else:
        N = i
N += 1

# ここから頂点番号は0-indexedとし、出力時に1-indexedにする
G = []
# 頂点iと頂点i+1との間にコスト0の辺とコスト2^(頂点番号)の辺を張る
for i in range(N - 1):
    G.append((i, i + 1, 0))
    G.append((i, i + 1, 2 ** i))

# 表現できてないコストを列挙
R = list(range(2 ** (N - 1), L))
marker = 0  # どこまで表現したかを表すマーカー
B = bin(len(R))[2:][::-1]  # どこにバイパスを張るか

# バイパスを張っていく
for i in range(len(B) - 1, -1, -1):
    if B[i] == '0':
        continue

    G.append((i, N - 1, R[marker]))
    marker += 2 ** i

print(N, len(G))
for u, v, w in G:
    print(u + 1, v + 1, w)


Measured memory_bytes: 21876
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))

K = INT()
dic = []
res = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        dic.append(math.gcd(i, j))

for i in range(1, K+1):
    for temp in dic:
        res += math.gcd(temp,i)

print(res)



Measured memory_bytes: 74604
// 提出時に消す


import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();

        if (d <= s * t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

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

int q(const void *a,const void *b)
{
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    for(c=1;c<=3;++c){
        if(a*b*c%2){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

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

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

    long total1 = 0;
    long ans1 = 0;
    for (int i = 0; i < n; i++) {
        total1 += a.at(i);
        if (i % 2 == 0) {
            if (total1 <= 0) {
                ans1 += total1 * (-1) + 1;
                total1 = 1;
            }
        } else {
            if (total1 >= 0) {
                ans1 += total1 + 1;
                total1 = -1; 
            }
        }
    }

    long total2 = 0;
    long ans2 = 0;
    for (int i = 0; i < n; i++) {
        total2 += a.at(i);
        if (i % 2 == 1) {
            if (total2 <= 0) {
                ans2 += total2 * (-1) + 1;
                total2 = 1;
            }
        } else {
            if (total2 >= 0) {
                ans2 += total2 + 1;
                total2 = -1; 
            }
        }
    }

    cout << min(ans1, ans2) << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int n;
string str;
ll dp[100005][13];
const int MOD = 1e9 + 7;

int main(){
    int i, j, k;
    ll res = 0;

    cin >> str;
    n = str.length();

    dp[0][0] = 1;
    rep(i,n){
        int c;
        if(str[i] == '?') c = -1;
        else c = str[i] - '0';

        rep(j,10){
            if(c != -1 && c != j) continue;
            rep(ki ,13){
                dp[i+1][(ki*10 + j) % 13] += dp[i][ki];
            }
        }
        rep(j,13) dp[i+1][j] %= MOD;
    }
    res = dp[n][5];
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>

int main(void)
{
	int n, s, sum, max, min;
	int i, j;

	while (1) {
		scanf("%d", &n);
		if (n == 0)
			break;
		max = 0;
		for (i = 0; i < 5; i++) {
			scanf("%d", &s);
			max += s;
		}
		min = max; sum = 0;
		for (i = 1; i < n; i++) {
			sum = 0;
			for (j = 0; j < 5; j++) {  
				scanf("%d", &s);
				sum += s;
			}
			if (sum > max)
				max = sum;
			else if (sum < min)
				min = sum;
			
		}
		printf("%d %d\n", max, min);
	}
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X, Y;
  cin >> X >> Y;
  if(Y % 2 == 0 && Y >= X*2 && Y <= X*4){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(c >= a && c <= b) System.out.println("Yes"); else System.out.println("No");
        
    }
}


Measured memory_bytes: 23764
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

s = s()

for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        print("Bad")
        exit()
print("Good")


Measured memory_bytes: 6096
N = gets.to_i
as = gets.split.map(&:to_i)
max_digits = 61
d_c = Array.new(max_digits, 0)
MOD = 10 ** 9 + 7

def mod_pow(a, n, mod)
  ret = 1
  while n > 0
    if n[0] == 1
      ret = ret * a % mod
    end
    a = a * a % mod
    n = n >> 1
  end
  ret
end

as.each do |a|
  (0...max_digits).each do |i|
    if a[i] == 1
      d_c[i] += 1
    end
  end
end
ans = 0
d_c.each.with_index do |c, d|
  zero_c = N - c
  n = mod_pow(2, d, MOD)
  ans = (ans + ((zero_c * c % MOD) * n % MOD)) % MOD
end
puts ans


Measured memory_bytes: 36900
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;
map<ll,ll> m;


int main()
{
	ll n;
	string s;
	cin >> n >> s;
	bool flag = false;

	for (int i = 0; i < s.length()-1; i++) {
		if (s[i] == s[i + 1]) {
			int tmp = i;
			while (1) {
				if (s[tmp] == s[tmp+1]) {
					s.erase(tmp+1, 1);
				}
				else {
					break;
				}
				if (tmp == s.length()-1) {
					break;
				}
			}
		}
	}
	cout << s.length() << endl;


	return 0;
}





Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	int s,t,c;
}ab;
ab num[100005];
typedef struct nod
{
	int val;
	int f;
}tim;
tim ans[2*100005];
bool cmp(nod p,nod q)
{
	if(p.val == q.val)
	return p.f < q.f;
	return p.val < q.val;
}
bool cmps(node p,node q)
{
	return p.t < q.t;
}
bool id[31][200005];
int main(void)
{
	int n,c;
	memset(id,0,sizeof(id));
	scanf("%d %d",&n,&c);
	for(int i = 0;i < n;i++)
	{
	  scanf("%d %d %d",&num[i].s,&num[i].t,&num[i].c);
	  num[i].s = 2*num[i].s - 1,num[i].t = 2*num[i].t;
	}
	sort(num,num+n,cmps);
	for(int i = 0;i < n;i++)
	{
	  if(id[num[i].c][num[i].s+1])
	     num[i].s++;
	  id[num[i].c][num[i].t] = true;
	}
	int cn = 0;
	for(int i = 0;i < n;i++)
	{
		ans[cn++] = nod{num[i].s,1};
		ans[cn++] = nod{num[i].t,0};
		//printf("%d %d\n",num[i].s,num[i].t);
	}
	sort(ans,ans+cn,cmp);
	int t = 0,maxx = 0;
	for(int i = 0;i < cn;i++)
	{  //printf("%d %d\n",ans[i].val,ans[i].f);
		if(ans[i].f)
		t++,maxx = max(maxx,t);
		else t--;
	}
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll X;
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> X;
    vll x(n);
    rep(i, 0, n) cin >> x[i];
    sort(all(x));
    ll ans = abs(x[0] - X);
    rep(i, 0, n) {
        ans = gcd(ans, abs(x[i]-X));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


int N;
std::vector<std::pair<int, int>>  range;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;

	int now = 0;
	for (size_t i = 0; i < N; i++)
	{
		range.emplace_back();
		in >> range[i].first >> range[i].second;
	}

	sort(range.begin(), range.end(), std::greater<>{});

	auto ff = range[0];
	//range.erase(std::remove_if(all_range(range), [ff](auto p) { return p.first <= ff.first && ff.second <= p.second; }), range.end());

	std::multiset<int> right;
	for (auto& v : range) {
		right.insert(v.second);
	}

	int max_score = 0;
	for (size_t i = 0; i < range.size(); i++)
	{
		max_score = std::max(max_score, std::max(0, std::min(*right.begin(), ff.second) - ff.first + 1) + std::max(0, range[i].second - range[i].first + 1));
		max_score = std::max(max_score, std::max(0, ff.second - ff.first + 1) + std::max(0, std::min(*right.begin(), range[i].second) - range[i].first + 1));
		
		right.erase(right.find(range[i].second));
		ff.second = std::min(ff.second, range[i].second);

	}
	out << max_score << '\n';

	return 0;
}
#endif


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a >= 13 ? b:(a>=6 && a <=12 ? b/2 : 0));
	return 0;
}

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

int main()
{
  int N;cin>>N; 
  double ans = 0.0;
  for (int i=0;i<N;i++)
  {
    double a;cin>>a;
    ans  += 1.0/a;
  }
  ans = 1/ans;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int MAX = (int) 1e5;
            int N = sc.nextInt();
            long M = sc.nextLong();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }
            long[] csNum = new long[MAX + 2];
            for (int i = 0; i < N; i++)
                csNum[A[i]]++;
            for (int i = MAX - 1; i >= 0; i--)
                csNum[i] += csNum[i + 1];
            long[] csSum = new long[MAX + 2];
            for (int i = 0; i < N; i++)
                csSum[A[i]] += A[i];
            for (int i = MAX - 1; i >= 0; i--)
                csSum[i] += csSum[i + 1];

            int ok = 0, ng = MAX * 2 + 1;
            while (Math.abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                long sum = 0;
                for (int i = 0; i < N; i++) {
                    sum += csNum[Math.min(MAX + 1, Math.max(0, mid - A[i]))];
                }
                if (sum >= M)
                    ok = mid;
                else
                    ng = mid;
            }

            long ans = 0, num = 0;
            for (int i = 0; i < N; i++) {
                ans += A[i] * csNum[Math.min(MAX + 1, Math.max(0, ok + 1 - A[i]))]
                        + csSum[Math.min(MAX + 1, Math.max(0, ok + 1 - A[i]))];
                num += csNum[Math.min(MAX + 1, Math.max(0, ok + 1 - A[i]))];
            }
            ans += (M - num) * ok;
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 51756
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	lint N,ans;
	vl d;
	cin >> N;
	ans = N;
	rep(i,N) {
		lint x;
		cin >> x;
		d.push_back(x);
	}
	sort(all(d));
	repInRange(i,1,N) {
		if (d[i-1] == d[i])
			--ans;
	}
	out1(ans);
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] S = new String[N];
        for(int i=0;i<N;i++){
            S[i] = sc.next();
        }
        
        for(int i=0;i<N-1;i++){
            for(int k=0;k<N-1-i;k++){
                String s1 = S[k];
                String s2 = S[k+1];
                for(int j=0;j<L;j++){
                    String x = s1.substring(j,j+1);
                    String y = s2.substring(j,j+1);
                    if(x.compareTo(y)<0){
                        break;
                    }else if(x.compareTo(y)>0){
                        S[k] = s2;
                        S[k+1] = s1;
                        break;
                    }
                }
            }
        }
        
        StringBuilder str = new StringBuilder();
        for(int i=0;i<N;i++){
            str.append(S[i]);
        }
        
        System.out.println(new String(str));
        
    }
}


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

const int MAX_N = 1<<15;

vector<int> sq;

void make() {
  for(int i = 0; i*i <= MAX_N; ++i) {
    sq.push_back(i*i);
  }
}

int solve(int n) {
  int res = 0;
  for(int i = 0; i < sq.size(); ++i) {
    for(int j = i; j < sq.size(); ++j) {
      for(int k = j; k < sq.size(); ++k) {
	int t = n - (sq[i] + sq[j] + sq[k]);
	if(t < 0) break;
	vector<int>::iterator it = lower_bound(sq.begin(), sq.end(), t);
	if(it == sq.end()) continue;
	if(*it != t) continue;
	if(*it >= sq[k]) ++res;
      }
    }
  }
  return res;
}

int main() {
  make();
  int n;
  while((cin >> n) && n) cout << solve(n) << endl;
  return 0;
}

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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 100;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -1e9), best_t(w);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


Measured memory_bytes: 4516
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        
        TreeSet <Integer> tree = new TreeSet <Integer> ();
        for(int i=0; i<N; i++){
            tree.add(new Integer(a[i]));
        }
        System.out.println(tree.size());
    }
}

Measured memory_bytes: 35896
w,h,n = map(int,input().split())
p = [[int(i) for i in input().split()] for i in range(n)]
a = 0
b = 0
c = w
d = h

for i in range(n):
    if p[i][2] == 1:
        a = max(a, p[i][0])            
    elif p[i][2] == 2:
        c = min(c, p[i][0])
    elif p[i][2] == 3:
        b = max(b, p[i][1])
    else:
        d = min(d, p[i][1])

if c > a and d > b:
    ans = (c-a)*(d-b)
else:
    ans = 0

print(ans)

Measured memory_bytes: 3064
import sys
a,b,o,ab = 0,0,0,0
for line in sys.stdin.readlines():
  w = float(line)
  if w <= 48:
    print('light fly')
  elif 48 < w <= 51:
    print('fly')
  elif 51 < w <= 54:
    print('bantam')
  elif 54 < w <= 57:
    print('feather')
  elif 57 < w <= 60:
    print('light')
  elif 60 < w <= 64:
    print('light welter')
  elif 64 < w <= 69:
    print('welter')
  elif 69 < w <= 75:
    print('light middle')
  elif 75 < w <= 81:
    print('middle')
  elif 81 < w <= 91:
    print('light heavy')
  else:
    print('heavy')

Measured memory_bytes: 7384
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <math.h>
#include <complex>
using namespace std;

int main() {
    int a, b, t;
    scanf("%d%d%d", &a, &b, &t);
    printf("%d\n", b*(t/a));
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;



int main(){
    llint N;
    cin>>N;
    map<llint,llint> mp;
    llint A[200009]={0};

    rep(i,200008) A[i]=0;

    rep(i,N){
        llint a;
        cin>>a;
        mp[a]++;
        A[i]=a;
    }
    llint count=0;
    for (auto itr = mp.begin(); itr != mp.end() ; itr++)
    {
        llint j=itr->second;
        j>0?count+=j*(j-1)/2:count+=0;
    }

    rep(i,N){
        llint l=mp[A[i]];
        
        if(l>2){cout<<count-(l*(l-1)/2)+((l-1)*(l-2)/2)<<endl;}
        else if(l==2)cout<<count-1<<endl;
        else cout<<count<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 13084
import java.util.Scanner;

class Solver {
    void solve(Scanner in) {
        int plugs = in.nextInt();
        int expected = in.nextInt();
        int needs = (int) Math.ceil((expected - 1.) / (plugs - 1.));
        System.out.println(needs);
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 23764
#abc167_e

n = int(input())

pos = []
neg = []

for _ in range(n):
    s = input()
    low_pos = 0
    increase= 0
    for v in s:
        if v=="(":
            increase += 1
        else:
            increase -= 1
            low_pos = min(low_pos, increase)
    
    if increase >= 0:
        pos.append((low_pos, increase))
    else:
        #reverse left from right
        low_pos, increase =  low_pos - increase, -increase        
        neg.append((low_pos, increase))
    
pos.sort()
pos.reverse() #lowが高い順にする.
neg.sort()
neg.reverse() #lowが高い順にする.

now_pos = 0
for low_pos, increase in pos:
    if now_pos + low_pos < 0:
        print("No")  #impossible
        exit()
    else:
        now_pos += increase

right_pos = 0       
for low_pos, increase in neg:
    if right_pos + low_pos < 0:
        print("No")  #impossible
        exit()
    else:
        right_pos += increase

if right_pos != now_pos:
    print("No")
    exit()
else:
    print("Yes")

Measured memory_bytes: 80368
#include <stdio.h>

int main(void)
{
  int n,m,c,i,j,tmp,ans=0;

  scanf("%d %d %d\n",&n,&m,&c);

  int b[m],a[n][m];

  for(i=0;i<m;i++){
    scanf("%d ",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
    scanf("%d ",&a[i][j]);
  };
  }

  tmp = c;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c = c + a[i][j] * b[j];
    }
    if(c>0){
      ans = ans + 1;
    }
    c = tmp;
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
from itertools import product

def main():
    n = int(input())
    n_copy = n

    if n == 1:
        print(1)
        exit()

    if n % 2 == 0:
        ans = 2 * n - 1
        n *= 2
    else:
        ans = n - 1

    factors = []
    for p in range(2, n):
        if p * p > n:
            if n > 1:
                factors.append(n)
            break

        if n % p == 0:
            cnt = 0
            while n % p == 0:
                cnt += 1
                n //= p
            factors.append(p ** cnt)

    for tf in product([True, False], repeat=len(factors)):
        a, b = 1, 1
        for i in range(len(factors)):
            if tf[i]:
                a *= factors[i]
            else:
                b *= factors[i]

        if a == 1 or b == 1:
            continue

        if a < b:
            a, b = b, a

        # Euclidean Algorithm
        # a*x - b*y = 1
        # quotient: 商
        l = []
        quo = []
        while a % b > 1:
            l.append(a)
            a = b
            quo.append(0)
            quo[-1], b = divmod(l[-1], b)
        x, y = 1, a//b
        flag = True
        while l:
            if flag:
                x += y * quo.pop()
                b = l.pop()
            else:
                y += x * quo.pop()
                a = l.pop()
            flag = not flag

        if ans > b * y:
            ans = b * y

    print(ans)

main()

Measured memory_bytes: 68820
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

struct KMP {
    vector<long long> pat;
    vector<int> fail;

    KMP(const vector<long long> &p) { init(p); }
    void init(const vector<long long> &p) {
        pat = p;
        int m = (int)pat.size();
        fail.assign(m+1, -1);
        for (int i = 0, j = -1; i < m; ++i) {
            while (j >= 0 && pat[i] != pat[j]) j = fail[j];
            fail[i+1] = ++j;
        }
    }

    // the period of S[0:i]
    int period(int i) { return i - fail[i]; }
    
    // the index i such that S[i:] has the exact prefix p
    vector<int> match(const vector<long long> &S) {
        int n = (int)S.size(), m = (int)pat.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; ++i) {
            while (k >= 0 && S[i] != pat[k]) k = fail[k];
            ++k;
            if (k >= m) res.push_back(i - m + 1), k = fail[k];
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    
    int f[n] = {};
    rep(i,30){
        vector<ll> aa(n*2), bb(n);
        rep(j,n){
            bb[j] = b[j] & (1<<i);
            aa[j] = a[j] & (1<<i);
            aa[j+n] = aa[j];
        }

        KMP kmp(bb);
        auto v = kmp.match(aa);
        for (auto k : v){
            f[k]++;
        }
        rep(j,n*2) aa[j] ^= (1<<i);
        v = kmp.match(aa);
        for (auto k : v){
            f[k]++;
        }
    }

    rep(i,n){
        if(f[i] == 30){
            cout << i << ' ' << (a[i] ^ b[0]) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 11480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }
} ; //comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end()); // 不要だが時間計測のため
    mint ans = 0;
    mint total = 0;
    rep(i, N) total += A[i];
    ans = total * total;
    rep(i, N) ans -= (mint)A[i] * A[i];
    ans /= 2;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>

using namespace std;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if(a+b >= x)
    {
        if(a > x)
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
    }
    else
    {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> in(N,0);
  vector<vector<int>> G(N,vector<int>(0)); 
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G.at(a).push_back(b);
    in[b]++;
  }
  queue<int> Q;
  vector<int> topo(0);
  for(int i=0; i<N; i++){
    if(in[i] == 0){
      Q.push(i);
      topo.push_back(i);
    }
  }
  while(Q.size()){
    int x = Q.front();
    Q.pop();
    for(int i=0; i<G[x].size(); i++){
      in[G[x][i]]--;
      if(in[G[x][i]] == 0){
        Q.push(G[x][i]);
        topo.push_back(G[x][i]);
      }
    }
  }
  
  /*for(int i=0; i<N; i++){
    cout << topo[i] << " ";
  }*/
  
  vector<int> dist(N,0);
  for(int i=0; i<N; i++){
    int t = topo[i];
    for(int j=0; j<G[t].size(); j++){
      dist[G[t][j]] = max(dist[G[t][j]], dist[t]+1);
    }
  }
  
  cout << *max_element(dist.begin(),dist.end()) << endl;
  
}

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

int main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if(t==s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MOD 1000000007
#define ONLINE_JUDGE

using namespace std;
long long dp[100001][101];
void ravi()
{
	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);
#endif
}
long long fun(int n,vector<pair<long long,long long>> &vc,int w,int pos)
{
    if(pos == n)
        return 0;
    if(dp[w][pos] != -1)
        return dp[w][pos];
    if(w >= vc[pos].first)
    {
        long long ans1 = fun(n,vc,w,pos+1);
        long long ans2 = vc[pos].second + fun(n,vc,w-vc[pos].first,pos+1);
        return dp[w][pos] = max(ans1,ans2);
    }
    else
    {
        long long ans1 = fun(n,vc,w,pos+1);
        return dp[w][pos] = ans1;
    }
    
}
int main()
{
    ravi();
    int n,w;
    cin>>n>>w;
    vector<pair<long long,long long>> vc;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        vc.push_back(make_pair(a,b));
    }
    cout<<fun(n,vc,w,0);
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll l[1000];
ll r[1000];

int main() {
	while (cin >> n&&n) {
		rep(i, n)cin >> l[i + 1];
		ll ans[3] = {};
		double h = INF;
		rep(s, 16) {
			rep(a, 16) {
				rep(c, 16) {
					ll cnt[1000] = {};
					r[0] = s;
					rep(i, n)r[i + 1] = (a*r[i] + c) % 256;
					FOR(i, 1, n + 1)cnt[(r[i] + l[i]) % 256]++;
					double hh = 0;
					rep(i, 256) {
						if (cnt[i] == 0)continue;
						hh -= (double)cnt[i] / (double)n*log((double)cnt[i] / (double)n);
					}
					if (hh - h < -EPS) {
						h = hh;
						ans[0] = s;
						ans[1] = a;
						ans[2] = c;
						//cout << s << " " << a << " " << c << " ";
						//printf("%.10lf\n", hh);
					}
					//if (s == 0 && a == 0) {
					//	cout << a << " " << c << " ";
					//	printf("%.10lf\n", hh);
					//	rep(i, n)cout << r[i + 1] << " ";
					//	cout << endl;
					//}
				}
			}
		}
		cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	}
}


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

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

using namespace std;

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

// 大きな値
const long long INF = 1LL << 30;

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<int> dp(n + 10, INF);
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }

  int result = dp[n - 1];
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
#define LEN 1000005
typedef struct pp{ char name[100]; int t; }P;
P Q[LEN+1];
int main(){ 
  int elaps=0,c;
  int i,q,n,sum=0;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name); 
    scanf("%d", &Q[i].t);
  }
  i=1;
  sum=n;
  while(1){
    if(Q[i].t<=q){
      sum--;
      elaps+=Q[i].t;
      printf("%s %d\n",Q[i].name,elaps);
      if(sum==0)break;
    }
    else{
      elaps+=q;
      Q[i].t-=q;
      Q[i+sum].t=Q[i].t;
      strcpy(Q[i+sum].name,Q[i].name);
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 21084
#include <stdio.h>
int main(){
	int numA, numB, numC;
	scanf("%d %d %d", &numA, &numB, &numC);
		if(numA == numB && numB == numC && numA == numC){printf("No");}
		else if(numA != numB && numB != numC && numA != numC){printf("No");}
		else if(numA == numB && numB != numC){printf("Yes");}
		else if(numB == numC && numB != numA){printf("Yes");}
		else if(numA == numC && numA != numB){printf("Yes");}
	return 0;}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

list<int> blocks;
void arrange(){
	int s = 0;
	for(list<int>::iterator it = blocks.begin(); it != blocks.end(); ++it){
		(*it)--;
		s++;
	}
	blocks.remove(0);
	blocks.push_back(s);
}

int main() {
	int n;
	while(cin >> n && n){
		blocks.clear();
		int sum = 0, b, bn = 0;
		bool flag = false;
		
		for(int i = 0; i < n; ++i){
			cin >> b;
			blocks.push_back(b);
			sum += b;
		}
		for(int i = 1; ; ++i){
			if(sum == (i * (i + 1) / 2)){
				flag = true;
				bn = i;
				break;
			}
			if(sum < (i * (i + 1) / 2))
				break;
		}
		if(!flag){
			cout << "-1" << endl;
			continue;
		}
		
		int cnt = 0;
		while(cnt < 10000){
			list<int>::iterator it = blocks.begin();
			bool ok = false;
			for(int i = 1; i <= bn; ++i){
				if(*it != i)
					break;
				if(*it == bn){
					cout << cnt << endl;
					ok = true;
				}
				it++;
			}
			if(ok)
				break;
			arrange();
			cnt++;
		}
		if(cnt >= 10000)
			cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
//#include <stdio.h>
using namespace std;

int main(){
	int H, W;
	while(1){
		cin >> H >> W;
		if (H == 0 && W ==0)  break;
		for (int i=0;i < H;i++){
			for (int j=0; j<W; j++){
				if (i != 0 && i != H-1 && j != 0 && j != W-1 ) cout << ".";
				else cout << "#";
			}
			cout << endl ;
		}
		cout << endl ;
	}
	return 0;
}

Measured memory_bytes: 1152
import copy

def can_empty(A):
    while 1:
        # Fall processing
        for w in xrange(W):
            seq = ("".join(A[h][w] for h in xrange(H))).replace(".","")
            seq += "."*(H-len(seq))
            for h in xrange(H):
                A[h][w] = seq[h]

        # Banish processing
        B = [[0]*W for _ in xrange(H)]
        for h in xrange(H):
            cnt = 1
            c = A[h][0]
            for w in xrange(1,W):
                if A[h][w] == c: cnt += 1
                else:
                    if cnt >= n and c != ".":
                        for wi in xrange(w-cnt,w):
                            B[h][wi] = 1
                    c,cnt = A[h][w],1
            if cnt >= n and c != ".":
                for wi in xrange(W-cnt,W):
                    B[h][wi] = 1
                c,cnt = A[h][w],1
        for w in xrange(W):
            cnt = 1
            c = A[0][w]
            for h in xrange(1,H):
                if A[h][w] == c: cnt += 1
                else:
                    if cnt >= n and c != ".":
                        for hi in xrange(h-cnt,h):
                            B[hi][w] = 1
                    c,cnt = A[h][w],1
            if cnt >= n and c != ".":
                for hi in xrange(H-cnt,H):
                    B[hi][w] = 1
                c,cnt = A[hi][w],1

        banish = False
        for h in xrange(H):
            for w in xrange(W):
                if B[h][w]:
                    A[h][w] = "."
                    banish = True
        if not banish: return False
        if A == goal: return True
        

# Entry point
H,W,n = map(int,raw_input().split())
_A = [list(raw_input()) for _ in xrange(H)][::-1]
goal = [["."]*W for _ in xrange(H)]
ans = False
for h in xrange(H):
    A = copy.deepcopy(_A)
    for w in xrange(W):
        if w < W-1:
            if A[h][w] == A[h][w+1]: continue
            A[h][w],A[h][w+1] = A[h][w+1],A[h][w]
            if can_empty(copy.deepcopy(A)):
                ans = True
                break
            A[h][w],A[h][w+1] = A[h][w+1],A[h][w]
    if ans: break
print "YES" if ans else "NO"

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

template<typename T>
class BinaryIndexedTree{
    public:
        BinaryIndexedTree(int sz){
            data.assign(++sz, 0);
        }

        // [0, k]
        T sum(int k){
            T ret = 0;
            for(++k; k > 0; k -= k & -k) ret += data[k];
            return (ret);
        }

        void add(int k, T x){
            for(++k; k < data.size(); k += k & -k) data[k] += x;
        }

    private:
        vector<T> data;
};

//f(x in [MIN, l]) = false, f(x in [r, MAX]) = true
long long binsearch(long long l, long long r, std::function<bool(long long)> f){
    if(f(l)) return l;
    while(r - l > 1){
        long long m = (l + r) / 2;
        if(f(m)) r = m;
        else l = m;
    }
    return r;
}

ll N, P[100010];
ll Q[100010];

signed main(){
    cin >> N;
    REP(i, N){
        cin >> P[i + 1];
        Q[P[i + 1]] = i + 1;
    }
    ll ans = 0;
    BinaryIndexedTree<ll> bit(N + 2);
    bit.add(Q[N], 1);
    for(ll i = N - 1; i >= 1; i--){
        ll L1 = binsearch(1, N + 1, [&](ll x) -> bool{return bit.sum(Q[i]) - bit.sum(x - 1) < 1;});
        ll L2 = binsearch(1, N + 1, [&](ll x) -> bool{return bit.sum(Q[i]) - bit.sum(x - 1) < 2;});
        ll R1 = binsearch(1, N + 1, [&](ll x) -> bool{return bit.sum(x) - bit.sum(Q[i] - 1) >= 1;}) - 1;
        ll R2 = binsearch(1, N + 1, [&](ll x) -> bool{return bit.sum(x) - bit.sum(Q[i] - 1) >= 2;}) - 1;
        ans += i * (L1 - L2) * (R1 - Q[i] + 1);
        ans += i * (R2 - R1) * (Q[i] - L1 + 1);
        bit.add(Q[i], 1);
    }
    PRINT(ans);
    return 0;
    return 0;
}

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

int main() {
	int n, ma = 0, h[100010] = { 0 };
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> h[i];
		if (i == 0) {
			ma = h[i];
			continue;
		}
		if (h[i] - ma < -1) {
			cout << "No" << endl;
			return 0;
		}
		ma = max(ma, h[i]);
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640