akhauriyash/Code-Regression huggingface dataset:
/*
 * 2526.cc: Pie Chart is as easy as pie.
 */

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

/* constant */

const double PI = acos(-1);

/* typedef */

typedef vector<int> vi;

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  Pt<T> rot90() { return Pt<T>(-y, x); }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<double> pt;

/* global variables */

/* subroutines */

/* main */

int main() {
  pt c;
  int r, n;
  cin >> r >> c.x >> c.y >> n;

  int psum = 0;
  
  for (int i = 0; i < n; i++) {
    int pi;
    cin >> pi;

    double th0 = (25 - psum) * PI / 50;
    double th1 = (25 - (psum + pi)) * PI / 50;

    pt a(cos(th0) * r, sin(th0) * r), b(cos(th1) * r, sin(th1) * r);

    double f = PI * r * pi;
    double t0 = b.cross(a) / 2;
    double t1 = (b - c).cross(a - c) / 2;
    double ar = f - t0 + t1;
    //printf("  %lf->%lf\n", f, ar);

    if (i > 0) putchar(' ');
    printf("%d", (int)(ar / f * 100));

    psum += pi;
  }
  putchar('\n');

  return 0;
}

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

int n,a[MAXN][3],f[MAXN][3];

int main(){
	cin>>n;
	For(i,n){
		rep(j,3){
			cin>>a[i][j];
		}
	}
	For(i,n){
		f[i][0]=max(f[i-1][1],f[i-1][2])+a[i][0];
		f[i][1]=max(f[i-1][0],f[i-1][2])+a[i][1];
		f[i][2]=max(f[i-1][0],f[i-1][1])+a[i][2];
	}
	cout<<Max(f[n][0],f[n][1],f[n][2])<<endl;
	re 0;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

int main()
{
	fast;
	ll a, b;
	cin >> a >> b;
	if (a < b)
		cout << 0;
	else
		cout << 10;
	return 0;
}


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

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double density = 0.0;
    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; 100 * a * i <= f; ++i)
    {
        for (int j = 0; 100 * (a * i + b * j) <= f; ++j)
        {
            int water = 100 * (a * i + b * j);
            for (int k = 0; water + k * c <= f; ++k)
            {
                for (int l = 0; water + k * c + l * d <= f; ++l)
                {
                    int sugar = k * c + l * d;
                    if (sugar <= e * water / 100)
                    {
                        if (double(100 * sugar) / double(water + sugar) >= density)
                        {
                            density = max(density, double(100 * sugar) / double(water + sugar));
                            ans1 = water + sugar;
                            ans2 = sugar;
                        }
                    }
                }
            }
        }
    }
    cout << ans1 << " ";
    cout << ans2 << endl;
}

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

int n, cnt = 0;
vector<int> v;

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 2; i < n; ++i) {
    if(v[i - 1] > v[i] && v[i - 1] < v[i - 2]) ++cnt;

    if(v[i - 1] < v[i] && v[i - 1] > v[i - 2]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        String[] str = new String[w.length()];
        int count = 2;

        for (int i = 0; i < w.length(); i++) {
            str[i] = w.split("")[i];
        }

        Arrays.sort(str);
        PrintWriter out = new PrintWriter(System.out);

        if (w.length() > 1) {
            if (!str[1].equals(str[0])) {
                out.println("No");
                sc.close();
                out.flush();
                return;
            }
        } else {
            out.println("No");
            sc.close();
            out.flush();
            return;
        }

        for (int i = 2; i < w.length(); i++) {
            if (str[i].equals(str[i - 1])) {
                count++;
            } else {
                if (count % 2 == 0) {
                    count = 1;
                } else {
                    out.println("No");
                    sc.close();
                    out.flush();
                    return;
                }
            }
        }

        if (count % 2 == 0) {
            out.println("Yes");
        } else {
            out.println("No");
            sc.close();
            out.flush();
        }
        sc.close();
        out.flush();
    }
}

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

using namespace std;

const int MX = 200005;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct NODE
{
	int s[2], x;
};

struct SEGT
{
	#define mid ((l+r)>>1)

	int cnt;
	NODE tre[MX*100];

	void upd(int a)
	{
		tre[a].x = tre[tre[a].s[0]].x + tre[tre[a].s[1]].x;
	}

	void add(int &a, int l, int r, int p, int x)
	{
		tre[++cnt] = tre[a], a = cnt;
		if(l == r) tre[a].x += x;
		else if(p <= mid) add(tre[a].s[0], l, mid, p, x), upd(a);
		else add(tre[a].s[1], mid+1, r, p, x), upd(a);
	}

	int qur(int a, int l, int r, int ql, int qr)
	{
		if(!a) return 0;
		else if(ql<=l && r<=qr) return tre[a].x;
		else if(ql>r || qr<l) return 0;
		else return qur(tre[a].s[0], l, mid, ql, qr) + qur(tre[a].s[1], mid+1, r, ql, qr);
	}

	int mer(int x, int y, int l, int r, int limy, int &num)
	{
		if(r <= limy) {num += tre[y].x; return x;}
		else if(!y) return x;
		else if(!x && l>limy) return y;
		else
		{
			int p = ++cnt;
			tre[p].s[0] = mer(tre[x].s[0], tre[y].s[0], l, mid, limy, num);
			tre[p].s[1] = mer(tre[x].s[1], tre[y].s[1], mid+1, r, limy, num);
			upd(p);
			return p;
		}
	}

	#undef mid
} T;

int n;
int fst[MX], nxt[MX*2], v[MX*2], lnum;

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	read(n);
	for(int i=1; i<n; i++)
	{
		int a, b;
		read(a), read(b);
		addeg(a, b);
		addeg(b, a);
	}
}

int anc[MX], rot[MX], sub[MX], ans[MX];

void dfs(int x, int f, int mx)
{
	anc[x] = mx;
	for(int i=fst[x]; i; i=nxt[i])
		if(v[i] != f)
		{
			dfs(v[i], x, max(mx, x));
			int num = 0;
			rot[x] = T.mer(rot[x], rot[v[i]], 1, n, v[i], num);
			T.add(rot[x], 1, n, v[i], num+1);
		}
}

void calc(int x, int f)
{
	ans[x] = ans[f] - ((x<anc[f]) ? T.qur(rot[x], 1, n, 1, anc[f]-1)+1 : 0) + T.qur(rot[x], 1, n, 1, anc[x]-1) + 1;
	for(int i=fst[x]; i; i=nxt[i])
		if(v[i] != f)
			calc(v[i], x);
}

void work()
{
	dfs(1, 0, 0);
	calc(1, 0);
	for(int i=2; i<=n; i++) printf("%d ", ans[i]-1);
	putchar('\n');
}

int main()
{
	input();
	work();
	return 0;
}


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> acc(n + 1);
    for (int i = 0; i < n; i++) acc[i + 1] = (acc[i] + a[i]) % k;
    // for (int i = 0; i < n; i++) for (int j = i + 1; j <= n; j++) {
    //     if ((acc[j] - acc[i] + k) % k == j - i) {
    //         cout << i+1 << " " << j << endl;
    //     }
    // }
    vector<int> v(n + 1);
    for (int i = 0; i <= n; i++) v[i] = (acc[i] - i % k + k) % k;
    long long ans = 0;
    map<int, int> cnt;
    for (int i = 0; i <= n; i++) {
        if (i >= k) cnt[v[i - k]]--;
        ans += cnt[v[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
import sys
input = sys.stdin.readline
N = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
dp = [0] * (N + 1)
res = 0
for i in range(N, -1, -1):
  for j in range(3):
    if a[j] < b[j] and (i - a[j] >= 0): dp[i - a[j]] = max(dp[i - a[j]], dp[i] + b[j])
  res = max(res, i + dp[i])
#print(res)
d = []
for i in range(3):
  if a[i] > b[i]: d.append((b[i], a[i]))
if len(d) == 0: print(res)
elif len(d) == 1: print(res // d[0][0] * d[0][1] + res % d[0][0])
elif len(d) == 2:
  dp = [0] * (res + 1)
  rres = 0
  for i in range(res, -1, -1):
    for x, y in d:
      if i - x >= 0: dp[i - x] = max(dp[i - x], dp[i] + y)
    rres = max(rres, i + dp[i])
  print(rres)
else:
  dp = [0] * (res + 1)
  rres = 0
  for i in range(res, -1, -1):
    for j in range(3):
      if a[j] > b[j] and (i - b[j] >= 0): dp[i - b[j]] = max(dp[i - b[j]], dp[i] + a[j])
    rres = max(rres, i + dp[i])
  print(rres)

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

void swap(int *nx,int *ny){
int temp=*nx;
*nx=*ny;
*ny=temp;
}

void sort3(int *n1,int *n2,int *n3){
if(*n1>*n2)
swap(n1,n2);
if(*n2>*n3)
swap(n2,n3);
if(*n1>*n2)
swap(n1,n2);
}

int main(void){
int a,b,c;
scanf ("%d %d %d", &a, &b, &c);
sort3(&a, &b, &c);
printf("%d %d %d\n", a, b, c);

return 0;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int a,b,c,d;
	string s;
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';

	if(a+b+c+d==7)printf("%d+%d+%d+%d=7",a,b,c,d);
	else if(a+b+c-d==7)printf("%d+%d+%d-%d=7",a,b,c,d);
	else if(a+b-c+d==7)printf("%d+%d-%d+%d=7",a,b,c,d);
	else if(a+b-c-d==7)printf("%d+%d-%d-%d=7",a,b,c,d);
	else if(a-b+c+d==7)printf("%d-%d+%d+%d=7",a,b,c,d);
	else if(a-b+c-d==7)printf("%d-%d+%d-%d=7",a,b,c,d);
	else if(a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
	else if(a-b-c-d==7)printf("%d-%d-%d-%d=7",a,b,c,d);

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    # 右からi文字目から最後の数字までを数値化したものについてmodを計算していく
    mod_count = [1] + [0] * 2019
    tmp_mod_val = 0
    cnt = 0
    i = 0
    for s in reversed(input()):
        tmp_mod_val += int(s) * pow(10, i, 2019)
        tmp_mod_val %= 2019
        cnt += mod_count[tmp_mod_val]
        mod_count[tmp_mod_val] += 1
        i += 1

    print(cnt)


main()


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

int main(){
    int n, k, ans, m = 1;
    cin >> n >> k;
    if(n==1){
        ans = k;
    }else if(k==1){
        ans = 1;
    }else{
        for(int i = 1; i <= n-1; i++){
            m = m * (k-1);
        }
        ans = k*m;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct edge{
    ll cost;
    ll from;
    ll to;
    bool operator<(const edge &another) const {
        return cost > another.cost;
    };
};
priority_queue<edge> node;
int main(){
    int n;cin >> n;
    UnionFind UF(n);
    vector<LP> x,y;
    REP(i,n){
        ll xx,yy; cin >> xx >> yy;
        x.push_back(make_pair(xx,i));
        y.push_back(make_pair(yy,i));
    }
    sort(all(x));
    sort(all(y));
    REP(i,n-1){
        ll xcost = x[i+1].first - x[i].first;
        ll xfrom = x[i].second;
        ll xto   = x[i+1].second;
        ll ycost = y[i+1].first - y[i].first;
        ll yfrom = y[i].second;
        ll yto   = y[i+1].second;
        node.push(edge{xcost, xfrom, xto});
        node.push(edge{ycost, yfrom, yto});
    }
    ll ans=0;
    REP(i,n-1){
        edge e = node.top(); node.pop();
        while(UF.findSet(e.from, e.to)){
            e = node.top();
            node.pop();
        }
        ans += e.cost;
        UF.unionSet(e.from, e.to);
    }
    cout << ans << endl;

}

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

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

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
unordered_map<int,int> GetPrimeFactors(int n) {
  unordered_map<int,int> mp;
  // divide by 2, 3, 5, ...
  while(n%2 == 0) {
    ++mp[2];
    n /= 2;
  }
  for(int i=3; i*i<=n; i+=2) {
    while(n%i == 0) {
      ++mp[i];
      n /= i;
    }
  }
  if(n!=1) ++mp[n];

  return mp;
}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  vector<unordered_map<int, int>> v(n);
  int tmp;
  unordered_map<int, bool> have_seen_factor, shared_in_all;
  bool pairwise = true, setwise = false;
  for(int i = 0; i < n; ++i) {
    cin >> tmp;
    v[i] = GetPrimeFactors(tmp);
    if(i) {
      for(auto& itr : v[i]) {
        if(have_seen_factor[itr.first]) pairwise = false;
      }
      if(!setwise) {
        bool have_shared = false;
        for(auto& itr : shared_in_all) {
          if(!itr.second) continue;
          if(v[i][itr.first] > 0) {
            have_shared = true;
            continue;
          }
          itr.second = false;
        }
        if(!have_shared) setwise = true;
      }
    } else {
      for(auto& itr : v[i]) {
        shared_in_all[itr.first] = true;
      }
    }
    if(pairwise) {
      for(auto& itr : v[i]) {
        have_seen_factor[itr.first] = true;
      }
    }
  }
  if(pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if(setwise) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime";

  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 270044
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>

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

using namespace std;
typedef long long ll;

bool is_d(char c) {
    if('1' <= c && c <= '9') return true;
    return false;
}

int func(string s) {
    int res = 0;
    for(int i=s.size()-1;i>=0;i--) {
        if(s[i] == 'i') {
            if(i==0) res++;
            else {
                if(is_d(s[i-1])) {
                    res += (s[i-1]-'0');
                    i--;
                }
                else res++;
            }
        }
        if(s[i] == 'x') {
            if(i == 0) res += 10;
            else {
                if(is_d(s[i-1])) {
                    res += (s[i-1]-'0')*10;
                    i--;
                }
                else res += 10;
            }
        }
        if(s[i] == 'c') {
            if(i == 0) res += 100;
            else {
                if(is_d(s[i-1])) {
                    res += (s[i-1]-'0')*100;
                    i--;
                }
                else res += 100;
            }
        }
        if(s[i] == 'm') {
            if(i == 0) res += 1000;
            else {
                if(is_d(s[i-1])) {
                    res += (s[i-1]-'0')*1000;
                    i--;
                }
                else res += 1000;
            }
        }
    }
    return res;
}

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

    string S = "mcxi";

    rep(i,n) {
        string s,s2;
        cin >> s >> s2;

        int res = func(s) + func(s2);
        stringstream ss;
        ss << res;

        string ret = ss.str();
        if(ret.size() == 1) ret = "000" + ret;
        if(ret.size() == 2) ret = "00" + ret;
        if(ret.size() == 3) ret = "0" + ret;

        rep(i,4) {
            if(ret[i] == '0') continue;
            if(ret[i] == '1') cout << S[i];
            else {
                cout << ret[i] << S[i];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    cout << A * B / gcd(A, B) << 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);

		int h = sc.nextInt();
		int a = sc.nextInt();

		int cnt = 0;

		while(true) {
			cnt ++;
			h -= a;
			if(h<=0) {
				break;
			}
		}

		System.out.println(cnt);

	}
}


Measured memory_bytes: 22100
#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;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

string s[10];
bool seen[10][10];
int dx[2] = {1,0};
int dy[2] = {0,1};

int main(){
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    rep(i, h) rep(j, w){
        char c;
        cin >> c;
        if (c == '#') cnt++;
    }

    if (cnt == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}


Measured memory_bytes: 256
#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[i];

    sort(A.begin(), A.end(), greater<int>());

    int alice_score = 0, bob_score = 0;
    
    for(int i = 0; i < n; i++){
        if(i%2)
            bob_score += A[i];
        else
            alice_score += A[i];     
    }
    int final_ans = alice_score - bob_score;    
        cout<<final_ans;

return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, Cnt, m;
string s;
int main() {
    cin >> n >> s;
    string ans;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == ')') {
            ++Cnt;
        } else {
            --Cnt;
        }
        if (Cnt < 0) {
            m -= Cnt;
            Cnt = 0;
        }
    }
    for (int i = 0; i < Cnt; ++i) {
        ans.push_back('(');
    }
    ans += s;
    for (int i = 0; i < m; ++i) {
        ans.push_back(')');
    }
    cout << ans << endl;
    return 0;
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,k; cin >> n >> k; vector<long double> exp(n);
  vector<long double> sum(n+1); sum[0] = 0; long double expmax = 0;
  
  rep(i,n){ ll x; cin >> x; exp[i] = (x+1)/2.0; 
          sum[i+1] = sum[i] + exp[i];}
  
  for(ll i=0; i < n - k + 1; i++){
    expmax = max(expmax,sum[k+i] - sum[i]);
  }
  cout <<fixed << setprecision(6);
  cout << expmax << endl;
}
                 
  

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


ll N;

ll rec(ll n) {
  if(n>N) return 0;
  
  ll cnt[3]={};
  ll t=n;
  while(t>0) {
    cnt[t%10/2-1]++;
    t/=10;
  }
  
  ll res=cnt[0]&&cnt[1]&&cnt[2];
  
  for(ll i=3; i<=7; i+=2) {
    res+=rec(n*10+i);
  }
  
  
  return res;
}



int main(void) {
  cin >> N;
  pt(rec(0));
}






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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << ((double)w * h / 2) << endl;
    if (w%2==0&&h%2==0&&w/2==x&&h/2==y) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3772
n,k=map(int,input().split())
ans=0
def cal(p,q):
    cnt=0
    while p<q:
        p*=2
        cnt+=1
    return cnt

if n<=k-1:
    x=n
else:
    x=k-1
    ans+=((n-k+1)/n)
for i in range(1,x+1):
    key=cal(i,k)
    ans+=(1/n)*(1/(2**key))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  ll ans = 0;
  int r;
  ll cntA = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == 'A')
    {
      cntA = 1;
      r = i + 1;
      while (r + 1 < s.size())
      {
        cerr << "i: " << i << "   r: " << r << "   cntA: " << cntA << endl;
        if (s[r] == 'A')
          cntA++;
        else if (s[r] == 'B' && s[r + 1] == 'C')
        {
          ans += cntA;
          r++;
        }
        else
        {
          cntA = 0;
          break;
        }
        r++;
      }
      i = r;
    }
  }
  cout << ans << endl;
  return 0;
}

// 操作を言い換えるとA BC をBC Aに入れ替えているのでA, BCのswapをする操作である．ABCBCは2回行える．BBとかCCとかCBとかあると,Aは乗り越えることが出来ない．あるAが何個BCを乗り越えるかを考えればよい．AABCABCの最初のAは2回BCを乗り越えることが出来る．2個目のBCも同様である．3個目のAは1回乗り越えることが出来る．あるAについて移動できる先は右端を伸ばして判定していくが尺取り法的なやり方でこれは出来る．伸ばしていってBCかA以外の組が出てきたら止めてそこから左端を右に動かしていく．


Measured memory_bytes: 720
# 問題 https://abc076.contest.atcoder.jp/tasks/abc076_c
S = input()
T = input()
Tlen = len(T)
Slen = len(S)
# Tの入りうる箇所の探索
# Tは入りうる箇所の一番うしろに入れて
# 前の?をすべてaで埋め尽くせばよい

for i in range(Slen-Tlen, -1, -1):
    # print(i)
    for s, t in zip(S[i:i + Tlen], T):
        flg = True
        if s != t and s != '?':
            flg = False
            break
    if flg:
        insertidx = i
        break
else:
    print('UNRESTORABLE')
    # import sys
    exit()

ans = S[:insertidx] + T + S[insertidx + Tlen:]
ans = ans.replace('?', 'a')
print(ans)


Measured memory_bytes: 3060
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
  //  cin >> TESTS;
    while (TESTS--)
    {
        ll n;
        cin >> n;
        ll a=n/500;
        ll b=n%500;
        ll c=b/5;
        ll d=b%5;

        ll ans=a*1000+5*c;
        cout<< ans << endl;


    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using ll =long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

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

    vector<string> a(h);
    rep(i,h) cin >> a[i];


    queue<P> q;
    vector<vector<int>> d(h,vector<int>(w,-1));
    
    rep(i,h) rep(j,w){
        if(a[i][j]=='#'){
            q.push(make_pair(i,j));
            d[i][j]=0;
        }
    }
    int ans = 0;
    while(!q.empty()){
        P p = q.front();
        q.pop();
        //a[p.first][p.second] = '#';
        //cout << "e1" << endl;
        rep(i,4){
            int nx=p.first + dx[i];
            int ny=p.second + dy[i];

            if(nx>=0 && nx<h && ny>=0 && ny<w && a[nx][ny]!='#' && d[nx][ny]==-1){
                d[nx][ny] = d[p.first][p.second] + 1;
                ans = d[nx][ny];
                a[nx][ny] = '#';
                q.push(make_pair(nx,ny));
            }
        }
        //cout << "e2" << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include <iostream>
using namespace std;
int main(void){
    int a;
    int answer = 0;
   cin >> a ;
   
   for (int i = 1;i<=1000000;i++)
   {
       if( a== 4||a==2|| a==1)
       {
           answer = 4;
           break;
       }
       if(a %2 == 0)
       {
           a = a/2;
       }
       else
       {
           a = a*3+1;
       }
       
       if( a==4)
       {
           answer = i + 4;
           break;
       }
   }
  
   cout << answer ;
   
}

Measured memory_bytes: 256
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    immutable int MD = 10 ^^ 9 + 7;
    
    auto s = readln.chomp.to!(dchar[]);
    
    s.reverse();
    
    debug { s.writeln; }
    
    int[] digs;
    foreach (i; 0 .. 10) { digs ~= i; }
    
    auto dp = new int[][] (s.length + 1, 13);
    dp[0][0] = 1;
    int mult = 1;
    foreach (i, c; s) {
        int[] toCheck;
        
        if (c == '?') {
            toCheck = digs;
        } else {
            int e = c - '0';
            toCheck ~= e;
        }
        
        foreach (d; toCheck) {
            int added = (d.to!long * mult) % 13;
            foreach (j; 0 .. 13) {
                dp[i+1][(j + added) % 13] = (dp[i+1][(j + added) % 13] + dp[i][j]) % MD;
            }
        }
        
        mult = (mult.to!long * 10) % 13;
    }
    
    debug { dp.each!writeln; }
    
    dp[s.length][5].writeln;
}

Measured memory_bytes: 12072
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, m;

int digits[10];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0 ; i < 10 ; i++)
		digits[i] = -1;
		
		
	for (int i = 0 ; i < m ; i++) {
		int pos;
		int num;
		scanf("%d%d", &pos, &num);
		if ((digits[pos] == -1) || (digits[pos] == num)) {
			digits[pos] = num;
		} else {
			printf("-1\n");
			return 0;
		}
	}
	
	if ((digits[1] == 0) && (n != 1)) {
		printf("-1\n");
		return 0;
	}
	
	if (n != 1) {
		if (digits[1] == -1) {
			digits[1] = 1;
		}
	}
	
	for (int i = 1 ; i <= n ; i++) {
		if (digits[i] == -1) {
			digits[i] = 0;
		}
	}
	
	for (int i = 1 ; i <= n ; i++) {
		printf("%d", digits[i]);
	}
	printf("\n");
	
	return 0;
}

//1 1
//1 0

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    string a,b,c;
    for(int i=0;i<3;i++)
    {
        cin >> s;
        if(i==0) a = s[0];
        if(i==1) b = s[1];
        if(i==2) c = s[2];
    }
    cout << a << b << c << endl;
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline

def main():
    N, M, P = map(int, input().split())
    Edges = [list(map(int, input().split())) for _ in range(M)]
    INF = 10**18

    graph1 = [[] for _ in range(N+1)]
    graph2 = [[] for _ in range(N+1)]
    for a, b, c in Edges:
        graph1[a].append(b)
        graph2[b].append(a)

    checked1 = [False]*(N+1)
    checked1[1] = True
    q = [1]
    while q:
        qq = []
        for p in q:
            for np in graph1[p]:
                if not checked1[np]:
                    checked1[np] = True
                    qq.append(np)
        q = qq
    
    checked2 = [False]*(N+1)
    checked2[N] = True
    q = [N]
    while q:
        qq = []
        for p in q:
            for np in graph2[p]:
                if not checked2[np]:
                    checked2[np] = True
                    qq.append(np)
        q = qq
    
    Canuse = [False]*(N+1)
    for i in range(1, N+1):
        if checked1[i] and checked2[i]:
            Canuse[i] = True



    D = [INF for _ in range(N+1)]
    D[1] = 0
    for i in range(2*N+100):
        update = False
        for a, b, c in Edges:
            if not Canuse[a] or not Canuse[b]: continue
            if D[b] > D[a] + P - c:
                D[b] = D[a] + P - c
                update = True


    if update:
        print(-1)
    else:
        print(max(-D[N], 0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 47084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    int re = 0, ree = 'A'^'B';
    while(!s.empty() && k){
        if((s.back()^re) == 'A'){
            s.back() = 'B'^re;
        }else {
            s.pop_back();
            re ^= ree;
        }
        k--;
    }
    if(s.empty() && n&1){
        printf("%c", k&1 ? 'B' : 'A');
        for (int i = 1; i < n; ++i) {
            printf("%c", (n-1-i)&1 ? 'B' : 'A');
        }
        puts("");
        return 0;
    }
    reverse(s.begin(),s.end());
    for (int i = 0; i < n; ++i) {
        if(i < s.size()){
            printf("%c", s[i]^re);
        }else {
            printf("%c", (n-1-i)&1 ? 'B' : 'A');
        }
    }
    return 0;
}

Measured memory_bytes: 772
#include <stdio.h>

#define N 100
#define INF 10000000

int p[N+1];
int m[N+1][N+1];

int mini(int,int);

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

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

 
  for(i=1;i<=n;i++)m[i][i] = 0;

  for(v=2;v<=n;v++){
    for(i=1;i<=n-v+1;i++){
      j = i + v - 1;
      m[i][j] = INF;

      for(k=i;k<=j-1;k++){
        m[i][j] = mini(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);  
  return 0;
}

int mini(int a,int b){
  if( a > b )return b;

  else return a;
}




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

int main()
{
	int d;
	cin >> d;
	if(d==25){
		cout << "Christmas";
	}
	else if(d==24){
		cout << "Christmas Eve";
	}
	else if(d==23){
		cout << "Christmas Eve Eve";
	}
	else{
		cout << "Christmas Eve Eve Eve";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    ll N;
    cin >> N;
    vector <ll> a(N), b(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        b.at(i) = a[i] - (i + 1);
    }
    sort(b.begin(), b.end());
    ll item = b[N/2];
    ll ans = 0;
    for(int i = 0; i <N; i++)
        ans += abs(a[i] - (i + 1 + item));
    cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  k -= (n - 1) * (n - 2) / 2;
  if (k > 0) {
	  cout << "-1\n";
	  return 0;
	}
  k *= -1;
  cout << n - 1 + k  << endl;
  for (int i = 2; i <= n; i++) {
	  cout << 1 << " " << i << endl;
	}
  for (int i = 2; i <= n; i++) {
	  for (int j = i + 1; j <= n; j++) {
		  if (k == 0) {
			  return 0;
			}
		  cout << i << " " << j << endl;
		  k--;
		}
	}
  return 0;
}


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

int main() {
int r,d,x;
cin >> r >> d >> x;
vector<int> vec(11);
vec.at(0) = x;
for (int i = 0;i < 10;i++) {
    vec.at(i+1) = r * vec.at(i) -d; 
    cout << vec.at(i+1) << endl;
}


return 0;
}


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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int done[100000];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int N; cin >> N;
	F0R(i,N) {
		int A; cin >> A;
		if ((N-1-A) % 2 != 0) {
			cout << 0;
			return 0;
		}
		done[A]++;
	}
	ll ans = 1;
	F0R(i,N) {
		if (done[i]>2) {
			cout << 0;
			return 0;
		} else if (i == 0 && done[i]>1) {
			cout << 0;
			return 0;
		} else if (done[i] == 2) ans = (ans*done[i]) % MOD;
	}
	cout << ans;
}

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

int main()
{   
    int n,T;
    cin>>n>>T;
    int c[n],t[n];
    int ans=1000;
    int flag=0;
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
        if(t[i]<=T){
            flag=1;
            if(c[i]<ans) ans=c[i];
        }
    }
    if(flag==1) cout<<ans<<endl;
    else cout<<"TLE"<<endl;
    


}

Measured memory_bytes: 256
from collections import deque
n = int(input())
d = deque()
for i in range(1,10):
    d.append(i)
for i in range(n):
    ans = d[0]
    d.popleft()
    if ans % 10 != 0:
        d.append(int(str(ans) + str(ans % 10 - 1)))
    d.append(int(str(ans) + str(ans % 10)))
    if ans % 10 != 9:
        d.append(int(str(ans) + str(ans % 10 +1)))
print(ans)

Measured memory_bytes: 10936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		Score = new int[N];
	}

	public boolean hasNext() {
		return cnt < N;
	}

	int[] Score;

	public void readBody(String str) {
		// System.out.println(str);
		Score[cnt] = Integer.parseInt(str);
		cnt++;
	}

	public void solve() {
		int sum = 0;
		int min = 101;
		for (int s : Score) {
			sum += s;
			if (s % 10 != 0 && s < min)
				min = s;
		}
		if (sum % 10 != 0)
			System.out.println(sum);
		else if (min > 100)
			System.out.println(0);
		else
			System.out.println((sum - min));
	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	double r[3];
	while (cin >> r[0] >> r[1] >> r[2]){
		if (r[0] == 0 && r[1] == 0 && r[2] == 0){break;}
		sort(r, r + 3);
		double n = sqrt(r[0] * r[0] + r[1] * r[1]) / 2;
		int num; cin >> num;
		for (int i = 0; i < num; i++){
			double a; cin >> a;
			if (a > n)
				cout << "OK";
			else cout << "NA";
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3148
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll a,b;  cin >> a >> b;
  if((a*b)%2){
    cout << "Odd";
  }else{
    cout << "Even";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for(i=0;i<n;i++){
    cout << a.at(i);
  }
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    u, v, d = map(int, input().split())
    X[u-1].append((v-1, d))
    X[v-1].append((u-1, d))

T = int(input())
t = 0
x = 0
while t < T:
    if t < 5000:
        print(-1)
        t += 1
        continue
    
    y, d = max([(y, d) for y, d in X[x]])
    for i in range(d):
        print(y+1)
        t += 1
        if t >= T:
            break
    x = y


Measured memory_bytes: 3784
N = int(input())

S = []
for i in range(N):
    S.append(input())

A = [0] * 5
for s in S:
    if s[0] is 'M':
        A[0] += 1
    elif s[0] is 'A':
        A[1] += 1
    elif s[0] is 'R':
        A[2] += 1
    elif s[0] is 'C':
        A[3] += 1
    elif s[0] is 'H':
        A[4] += 1

D1 = [0,0,0,0,0,0,1,1,1,2]
D2 = [1,1,1,2,2,3,2,2,3,3]
D3 = [2,3,4,3,4,4,3,4,4,4]

ans = 0
for i in range(10):
    ans += A[D1[i]] * A[D2[i]] * A[D3[i]]

print(ans)


Measured memory_bytes: 9752
n = int(input())
l = list(map(int, input().strip().split()))
cnt = 1
for i in range(n):
  if i == 0:
    mn = l[i]
    num = mn
    continue
  mn0 = mn
  mn = min(mn0, num)
  num = l[i]
  if mn >= num:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 24744
#include <stdio.h>


int main()
{		
	long long n;
	int i;
	char s[111];
	
	scanf("%s%lld", s, &n);
	for(i = 0; s[i] && s[i] == 49; i++);
	if(n > i) printf("%c\n", s[i]);
	else puts("1");
				
	return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;

    // 冪剰余 a^n mod MOD
    const auto& modpow = [](unsigned long a, unsigned long n) -> unsigned long {
        unsigned long r{1};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };

    unsigned long N, K;
    cin >> N >> K;

    // f_N を計算
    vector<unsigned long> memo_f(K + 1);
    // 再帰のためにラムダ式がややこしくなっていますけど、気にしないでください
    const auto& f = [f_impl = [&N, &memo_f, &modpow](auto func, unsigned long k) -> unsigned long {
        
        if(memo_f[k])return memo_f[k]; // メモしてある場合、メモしてあるものを返す

        // f_N(k) = k^N - Σ f_N(k/i)
        unsigned long r{modpow(k, N)}; // k^N
        for(unsigned long i{2}; i <= k; ++i)r += MOD - func(func, k / i); // - f_N(k/i)

        return memo_f[k] = r % MOD; // メモしてreturn
        
    }](unsigned long k){return f_impl(f_impl, k);};

    // ans = Σ i f_N(k/i)
    unsigned long ans{0};
    for(unsigned long i{1}; i <= K; ++i)ans += f(K / i) * i % MOD;
    cout << ans % MOD << endl;
    
    return 0;
}

Measured memory_bytes: 4008
#include <algorithm>
#include <iostream>
#define N 20000
#define M 256
#define INF (1e9)
using namespace std;
int n,m,c[N],x[N],d[N][M],ny,t,ans;

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m) break;
    for(int i=0;i<m;i++) cin>>c[i];
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<n;i++)
      for(int j=0;j<M;j++) d[i][j]=INF;
    for(int i=0;i<m;i++){
      ny=128+c[i];
      if(ny>255) ny=255;
      if(ny<0) ny=0;
      int t=x[0]-ny;
      d[0][ny]=t*t;
    }
    for(int i=0;i<n-1;i++)
      for(int j=0;j<M;j++){
	if(d[i][j]==INF) continue;
	for(int k=0;k<m;k++){
	  ny=j+c[k];
	  if(ny>255) ny=255;
	  if(ny<0) ny=0;
	  t=x[i+1]-ny;
	  d[i+1][ny]=min(d[i+1][ny],d[i][j]+t*t);
	}
      }
    ans=INF;
    for(int i=0;i<M;i++) ans=min(ans,d[n-1][i]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 21244
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	freopen("at81d.in","r",stdin);
#endif
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
int cnt=0;
int a[100];
char s[100];
char s2[100];
ll ans=0;
ll mod=1000000007;
void inp(){
	int n;scanf("%d",&n);
	scanf("%s%s",s,s2);
	if(n==1){ puts("3"); return ; }
	int i;
	for(i=0 ;i<n;i++){
		if(s[i]==s2[i]){ a[cnt++]=1; }
		else {a[cnt++]=2; i++; }
	}
	ll ans;
	if(a[0]==1)ans=3;
	else ans=6;
	ll t=0;
	for(i = 1;i<cnt;i++){
		if(a[i]==1){
			if(a[i-1]==1){ t=2; }
			else { t=1; }
		}
		else {
			if(a[i-1]==1){ t=2; }
			else { t=3; }
		}
		ans*=t;
		if(ans>=mod)ans-=mod;
	}
	printf("%lld\n",ans);
}
//at81d.cc by xsthunder at Sun Aug 20 20:19:34 2017


Measured memory_bytes: 128
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jan 19 13:31:52 2019
//
package main

import "fmt"

type pair struct {
	x, y int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	ps := make([]pair, M)
	for i := range ps {
		fmt.Scan(&ps[i].x, &ps[i].y)
	}

	for i := 1; i <= N; i++ {
		count := 0
		for j := range ps {
			if ps[j].x == i || ps[j].y == i {
				count++
			}
		}
		fmt.Println(count)
	}
}


Measured memory_bytes: 512