akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

constexpr ll INF = 1e18;

ll N, M;
priority_queue<p, vector<p>, greater<p> > que;
unordered_map<ll, vector<p> > G;

unordered_map<ll, ll> dist;

ll vnum(ll n, ll c) {
    return n * ((ll)1e6 + 10) + c;
}

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

    cin >> N >> M;

    dist[vnum(N, 0)] = INF;

    for (ll i = 0; i < M; i++) {
        ll p, q, c;
        cin >> p >> q >> c;
        G[vnum(p, c)].push_back(make_pair(vnum(q, c), 0));
        G[vnum(q, c)].push_back(make_pair(vnum(p, c), 0));

        G[vnum(p, c)].push_back(make_pair(vnum(p, 0), 0));
        G[vnum(p, 0)].push_back(make_pair(vnum(p, c), 1));
        G[vnum(q, c)].push_back(make_pair(vnum(q, 0), 0));
        G[vnum(q, 0)].push_back(make_pair(vnum(q, c), 1));

        dist[vnum(p, c)] = INF;
        dist[vnum(p, 0)] = INF;
        dist[vnum(q, c)] = INF;
        dist[vnum(q, 0)] = INF;
    }

    dist[vnum(1, 0)] = 0;

    que.push(p(0, vnum(1, 0)));

    while (!que.empty()) {
        auto token = que.top(); que.pop();

        if (dist[token.second] < token.first) {
            continue;
        }

        for (auto g : G[token.second]) {
            if (dist[g.first] > dist[token.second] + g.second) {
                dist[g.first] = dist[token.second] + g.second;
                que.push(p(dist[g.first], g.first));
            }
        }
    }

    ll ans = dist[vnum(N, 0)];
    cout << (ans == INF ? -1LL : ans) << endl;
    return 0;
}



Measured memory_bytes: 81752
#include <cstdio>

int main() {
	int a;
	scanf("%d", &a);
	if(a < 1200) printf("ABC\n");
	else if(a >= 1200 && a < 2800) printf("ARC\n");
	else if(a >= 2800) printf("AGC\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define int long long
inline int read(){
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ x = x * 10 + (ch ^ 48); ch = getchar(); }
	return x * f;
}
int x;
signed main(){
	x = read();
	for(int i = -1000; i <= 1000; ++i){
		for(int j = -1000; j <= 1000; ++j){
			if(i * i * i * i * i - j * j * j * j * j == x){
				return printf("%lld %lld\n", i, j) & 0;
			}
		}
	}
}

Measured memory_bytes: 3716
# -*- coding: utf-8 -*-
import sys


A,B = map(int,input().split())

for n in range(1,10**5):
    a = n*0.08 // 1
    b = n*0.10 // 1
    if a==A and b==B:
        print(n)
        sys.exit()

print(-1)

Measured memory_bytes: 3060
n,x=map(int,input().split())
List=list(map(int,input().split()))
List.sort()
ans=0
if sum(List)==x:
    print(n)
    exit()
else:
    for i in range(len(List)-1):
        if x>=List[i]:
            ans+=1
            x-=List[i]
        else:
            break
print(ans)

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

using namespace std;
int n, s;
int a[200000];
bitset<2100000> f;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) s += a[i];
    int need = s / 2 + s % 2;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        bitset<2100000> g = (f << a[i]);
        f |= g;
    }
    for (int j = need;;j++)
    if (f[j]) {
        cout << j << "\n";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a>>b;
	A = a * b;
	if (A %2==0) {
		cout << "Even";
	}
	else {
		cout << "Odd";
	}
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const ll INF = 1e18+3;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;

map<ll, ll> dp;
ll A, B, C, D, N;

ll f(ll N){
    if (N == 0)return 0;
    if (N == 1)return D;
    if (dp[N] > 0){
        return dp[N];
    }
    
    ll res = INF;
        
    if (D <= (INF + N - 1)/N){
        chmin(res, N * D);
    }
    if (N % 2 == 1){
        chmin(res, f(N/2) + A + D);
        chmin(res, f(N/2 + 1) + A + D);
    } else {
        chmin(res, f(N/2) + A);
    }
    if (1 || N%3 <= 1){
        chmin(res, f(N/3) + B + N%3 * D);
    //} else {
        chmin(res, f(N/3 + 1) + B + (3 - N%3) * D);
    }

    
    if (1 || N%5 <= 2){
        chmin(res, f(N/5) + C + N%5 * D);
    //} else {
        chmin(res, f(N/5 + 1) + C + (5 - N%5) * D);
    }
    //fprintf(stderr, "N = %d, res = %d\n", N, res);    
    return dp[N] = res;
}
int main() {
    int T;
    cin >> T;
    
    rep(i, T){
        dp.clear();
        cin >> N >> A >> B >> C >> D;
        cout << f(N) << endl;
        //exit(1);
    }    
    return 0;
}

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

int par[100010];
int r[100010];

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (r[x] < r[y]){
	par[x] = y;
    } else {
	par[y] = x;
	if (r[x] == r[y]) r[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> p(N+1);
    for (int i = 0; i < N; i++){
	cin >> p[i+1];
    }
    vector<int> x(M+1);
    vector<int> y(M+1);
    for (int i = 0; i < M; i++){
	cin >> x[i+1] >> y[i+1];
    }

    for (int i = 0; i <= N; i++) {
	par[i] = i;
	r[i] = 0;
    }

    for (int i = 0; i < M; i++){
	unite(x[i+1], y[i+1]);
    }

    int res = 0;
    for (int i = 0; i < N; i++){
	if (same(i+1, p[i+1])) res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

vector<PII> tt[30][30];
int dist[30][30];

int main(){
	int w,h;
	while(cin>>w>>h,w){
		REP(i,30)REP(j,30)tt[i][j].clear();
		memset(dist, -1, sizeof(dist));
		REP(i,2*h-1){
			int tmp;
			if(i%2==0){
				REP(j,w-1){
					cin>>tmp;
					if(tmp==0){
						tt[i/2][j].PB(MP(i/2, j+1));
						tt[i/2][j+1].PB(MP(i/2, j));
					}
				}
			}else{
				REP(j,w){
					cin>>tmp;
					if(tmp==0){
						tt[i/2][j].PB(MP(i/2+1, j));
						tt[i/2+1][j].PB(MP(i/2, j));
					}
				}
			}
		}
		priority_queue<TIII, vector<TIII>, greater<TIII> > q;
		q.push(MT(0, 0, 0));
		int flag = 0;
		while(!q.empty()){
			TIII tmp = q.top();
			q.pop();
			if(dist[tmp.T2][tmp.T3]!=-1)continue;
			dist[tmp.T2][tmp.T3]=tmp.T1;
			if(tmp.T2==h-1 && tmp.T3==w-1){
				cout << tmp.T1+1 << endl;
				flag = 1;
				break;
			}
			REP(i, tt[tmp.T2][tmp.T3].size())q.push(MT(tmp.T1+1, tt[tmp.T2][tmp.T3][i].first, tt[tmp.T2][tmp.T3][i].second));
		}
		if(!flag)cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include <cstdio>

using namespace std;

int main() {
  int N, C;
  int i, j;
  int s, t, c;
  int T[30][100010] = {};
  scanf("%d %d", &N, &C);
  for (i = 0; i < N; i++) {
    scanf("%d %d %d", &s, &t, &c);
    for (j = s-1; j < t-1; j++) {
      T[c-1][j] = 1;
    } 
  }
  /*for (j = 0; j < C; j++) {
    for (i = 0; i < 12; i++) {
      printf("%d ", T[j][i]);
    }
    printf("\n");
    }*/
  for (j = 0; j < C; j++) {
    for (i = 0; i < 100000; i++) {
      if (T[j][i] == 0 && T[j][i+1] == 1) {
	T[j][i] = 1;
      }
    }
  }
  /*for (j = 0; j < C; j++) {
    for (i = 0; i < 12; i++) {
      printf("%d ", T[j][i]);
    }
    printf("\n");
    }*/
  int ans = 0;
  for (i = 0; i < 100000; i++) {
    int ans_now = 0;
    for (j = 0; j < C; j++) {
      ans_now += T[j][i];
    }
    if (ans_now > ans) {
      ans = ans_now;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 11904
n, k = map(int, input().split())
A = list(map(int, input().split()))
pos = []
neg = []
zeros = 0
for a in A:
    if a > 0:
        pos.append(a)
    elif a < 0:
        neg.append(a)
    else:
        zeros += 1

pos.sort()
neg.sort(reverse=True)

minus_pattern = len(pos) * len(neg)
zero_pattern = zeros * (len(pos)+len(neg)) + (zeros*(zeros-1))//2

pos_length = len(pos)
neg_length = len(neg)

left = -10**18
right = 10**18

while left + 1 < right:
    num = (left+right)//2
    less_count = 0

    if num >= 0:
        pos_idx = pos_length-1
        for p in pos:
            while pos_idx >= 0 and p * pos[pos_idx] > num:
                pos_idx -= 1
            less_count += pos_idx + 1
            if p**2 <= num:
                less_count -= 1

        neg_idx = neg_length-1
        for m in neg:
            while neg_idx >= 0 and m * neg[neg_idx] > num:
                neg_idx -= 1
            less_count += neg_idx + 1
            if m**2 <= num:
                less_count -= 1

        less_count //= 2
        less_count += minus_pattern + zero_pattern

    elif num < 0:
        pos_idx = 0
        for m in neg[::-1]:
            while pos_idx < pos_length and m * pos[pos_idx] > num:
                pos_idx += 1
            less_count += pos_length - pos_idx

    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Measured memory_bytes: 112900
s = input()
rvs_s = s[::-1]

left_s = s[:(len(s)-1)//2]
rvs_left_s = left_s[::-1]

right_s = s[(len(s)+3)//2-1:]
rvs_right_s = right_s[::-1]

if s == rvs_s and left_s == rvs_left_s and right_s == rvs_right_s:
    print("Yes")
else:
    print("No")

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

vector<int> color(200,0);
vector<vector<int>> a(200);
bool BipartiteGraph (int v,int c){
    color[v]=c;
    for (auto x:a[v]){
        if (color[x]==c){
            return false;
        }
        else if (color[x]==0&&!BipartiteGraph(x,-c)){
            return false;
        }
    }
    return true;
}

int main(){
    int N;cin>>N;
    int info[N][N];
    rep(i,N){
        string S;cin>>S;
        rep(j,N){
            info[i][j]=S[j]-48;
        }
    }
    rep(i,N){
        rep(j,N){
            if(info[i][j])a[i].push_back(j);
        }
    }

    if(!(BipartiteGraph(0,1)))cout<<-1<<endl;
    else{ //warshall_floyd
        rep(i,N){
            rep(j,N){
                if(i!=j and info[i][j]==0)info[i][j]=INF;
            }
        }
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(info[i][k]==INF or info[k][j]==INF)continue;
                    info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
                }
            }
        }
        int ans=0;
        rep(i,N){
            rep(j,N){
                ans=max(ans,info[i][j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,a,b=parseMap(split(readline()))
    println(ifelse(abs(x-a)<abs(x-b),"A","B"))
end
main()

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

using namespace std;
typedef long long ll;

int main(void) {
  ll n, t, q;
  cin >> n >> t >> q;

  vector<ll> a(n + 2), d(n + 2);
  a[0] = -(1LL << 62);
  d[0] = 1;
  a[n + 1] = 1LL << 62;
  d[n + 1] = 2;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> d[i];
  }

  vector<int> x(q);
  for (int i = 0; i < q; i++) {
    cin >> x[i];
  }

  vector<ll> g(n + 2);
  int l = 0, r = 0;
  while (l < n + 2) {
    while (r < n + 2 && d[r] == 1) r++;
    ll goal = (a[r - 1] + a[r]) / 2;
    while (r < n + 2 && d[r] == 2) r++;
    for (int i = l; i < r; i++) {
      g[i] = goal;
    }
    l = r;
  }

  for (int i = 0; i < q; i++) {
    if (abs(a[x[i]] - g[x[i]]) <= t) {
      cout << g[x[i]] << endl;
    } else if (d[x[i]] == 1) {
      cout << a[x[i]] + t << endl;
    } else {
      cout << a[x[i]] - t << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5128
n, k = map(int, input().split())
H = list(map(int, input().split()))

Dp = [0]

for i in range(1, n):
    can = []
    if i < k:
        for j in range(i):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    else:
        for j in range(k):
            c = abs(H[i]-H[i-j-1]) + Dp[i-j-1]
            can.append(c)
    Dp.append(min(can))

ans = Dp[-1]
print(ans)

Measured memory_bytes: 58336
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        PriorityQueue<Long> pribig = new PriorityQueue<>(Comparator.naturalOrder());
        PriorityQueue<Long> prismall = new PriorityQueue<>(Comparator.reverseOrder());
        long big = 0;
        long small = 0;
        long b = 0;
        long ans;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (tmp == 1) {
                // koushin
                long a = sc.nextLong();
                long bb = sc.nextLong();
                b += bb;
                if (prismall.isEmpty() || prismall.peek() >= a) {
                    // prismall.peek -> pribig, a -> prismall
                    prismall.add(a);
                    small+=a;
                    if (!prismall.isEmpty() && prismall.size() > pribig.size() + 1 ) {
                        long change = prismall.poll();
                        pribig.add(change);
                        small -= change;
                        big += change;
                    }
                }else{
                    pribig.add(a);
                    big += a;
                    if (pribig.size() > prismall.size()) {
                        long odsends = pribig.poll();
                        prismall.add(odsends);
                        big -= odsends;
                        small += odsends;
                    }
                }
            }else if(tmp == 2){
                // hanbetsu
                // small = big or small = big + 1
                ans = prismall.peek();
                System.out.println(ans + " " + (-small+big +prismall.size() * ans - pribig.size()* ans + b));
            }
            
        }

        sc.close();
    }

}




Measured memory_bytes: 156648
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.typecons;

void main()
{
    auto n = readln.chomp.to!int;
    int min, max = -1;
    foreach (_; 0..n) {
        auto ab = readln.split.to!(int[]);
        if (ab[0] > max) {
            max = ab[0];
            min = ab[1];
        }
    }
    writeln(max + min);
}

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

int main(void){
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if(n <= k) {
    cout << x * n << endl;
    return 0;
  }
  cout << x * k + y * (n - k) << endl;
  return 0;
}


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

using namespace std;

typedef vector <int> vi;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    string cad;cin>>cad;
    int ans = 1;
    for( int i = 1 ; i < n ; i++ ) {
        if( cad[i] != cad[i-1] ) {
            ans++;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

int main() {
	int a, b;
	cin >> a >>b;
	cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;

const int N=1e5+10;


int n,m,q;

int last[N],nx[N<<1],to[N<<1],tot;
int d[N],c[N],v[N];
int vis[N],us[N];

void Add(int x,int y)
{
	tot++;
	to[tot]=y;
	nx[tot]=last[x];
	last[x]=tot;
}

void dfs(int x,int C,int dep,int lim)
{
	if(dep>lim) return;
	if(vis[x]&&lim-dep<=us[x]) return;
	if(!vis[x]) vis[x]=C;
	us[x]=max(us[x],lim-dep);
	for(int j=last[x];j;j=nx[j])
		dfs(to[j],C,dep+1,lim);
}


int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		Add(x,y);
		Add(y,x);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++) scanf("%d%d%d",&v[i],&d[i],&c[i]);
	for(int i=q;i;i--)
		if(d[i]>=us[v[i]]||!vis[v[i]]) dfs(v[i],c[i],0,d[i]);
	for(int i=1;i<=n;i++) printf("%d\n",vis[i]);
	return 0;
}
		
	
		

Measured memory_bytes: 4608
H,W= map(int,raw_input().split())

M = []
for i in range(H):
	M.append(raw_input())
	
flag_list_H = []
for i in range(H):
	if '#' in M[i]:
		flag_list_H.append(True)
	else:
		flag_list_H.append(False)

flag_list_W = []
for i in range(W):
	flag = False
	for j in range(H):
		if M[j][i]=='#':
			flag=True
	flag_list_W.append(flag)

for i in range(H):
	if flag_list_H[i]:
		answer = ""
		for j in range(W):
			if flag_list_W[j]:
				answer+=M[i][j]
		print answer

Measured memory_bytes: 2692
#include <cstdio>


using namespace std;

static int Al,Ar,Bl,Br,Cl,Cr,Dl,Dr;

int main(){

    float l,r;
    while (scanf("%f%f",&l,&r)!=EOF){
        if (l<0.2)
            Dl++;
        else if (l<0.6)
            Cl++;
        else if (l<1.1)
            Bl++;
        else 
            Al++;


        if (r<0.2)
            Dr++;
        else if (r<0.6)
            Cr++;
        else if (r<1.1)
            Br++;
        else 
            Ar++;
    }

    printf("%d %d\n%d %d\n%d %d\n%d %d\n",Al,Ar,Bl,Br,Cl,Cr,Dl,Dr);

    return 0;
}


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

#define pb push_back

using namespace std;

int data[20][20],n;
long long dp[1<<16];
vector<int> rem[17];

void generate(int bitmask,int lv)
{
  if (lv==n)
  {
    rem[__builtin_popcount(bitmask)].pb(bitmask);
    for(int c=0;c<n;c++)
    {
      if (bitmask&(1<<c))
      for(int c2=c+1;c2<n;c2++)
      {
        if (bitmask&(1<<c2))
        dp[bitmask]+=data[c][c2];
      }
    }
  }
  else
  {
    generate(bitmask,lv+1);
    generate(bitmask|(1<<lv),lv+1);
  }
}

void updateValue(int bitmask,vector<int> &bit1pos,int lv,int rem)
{
  if (lv==bit1pos.size())
  {
    dp[bitmask]=max(dp[bitmask],dp[rem]+dp[bitmask^rem]);
  }
  else
  {
    updateValue(bitmask,bit1pos,lv+1,rem);
    updateValue(bitmask,bit1pos,lv+1,rem|(1<<bit1pos[lv]));
  }
}

int main()
{
  scanf("%d",&n);
  for(int c=0;c<n;c++)
  for(int c2=0;c2<n;c2++)
  scanf("%d",&data[c][c2]);
  generate(0,0);
  // for(int c=0;c<1<<n;c++)
  // {
  //   char tmp[100];
  //
  //   itoa(c,tmp,2);
  //   printf("%0*s %lld\n",n,tmp,dp[c]);
  // }

  // for(int c=1;c<=n;c++)
  // {
  //   for(int c2=0;c2<rem[c].size();c2++)
  //   {
  //     for(int c3=ceil((double)c/2);c3<c;c3++)
  //     {
  //       for(int c4=0;c4<rem[c3].size();c4++)
  //       {
  //         if ((rem[c][c2]|rem[c3][c4])==rem[c][c2])
  //         dp[rem[c][c2]]=max(dp[rem[c][c2]],dp[rem[c3][c4]]+dp[rem[c][c2]^rem[c3][c4]]);
  //       }
  //     }
  //   }
  // }
  for(int c=0;c<1<<n;c++)
  {
    vector<int> tmp;

    for(int c2=0;c2<n;c2++)
    if (c&(1<<c2))tmp.pb(c2);
    updateValue(c,tmp,0,0);
  }
  printf("%lld\n",dp[(1<<n)-1]);
}
/*
generate 2^16 score if they in same group
for 1->16 (1 bit of 1 -> 16 bit of 1)
foreach find minimum of sub 2 group
eg 1 bit -> not do anything
   2 bit -> get from some 1 bit + 1 bit that not intercept
   3 bit -> get from some 1 bit + 2 bit that not intercept

000 001 010 100  011 101 110 111
  0   0   0   0 -100  20  10 -90

0000 1000 0100 0010 0001 1100 1010 1001 0110 0101 0011 1110 1101 1011 0111 1111
   0    0    0    0    0   1M   1M   1M   1M   1M   -1   3M   3M 2M-1 2M-1 1M+2M+2M-1
*/


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

using namespace std;

#define int long long

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int now = 1000000000, cnt = 10;
    int pow10[20];
    pow10[0] = 1; for (int i = 1; i <= 13; ++i) pow10[i] = pow10[i - 1] * 10;

    while(now) {
        cout << "? " << now << '\n';
        cout.flush();
        char c; cin >> c;
        if(c == 'Y') break;
        now /= 10; cnt --;
    }

    if(cnt == 10) {
        now = 1;
        while(1) {
            cout << "? " << now + 1 << '\n';
            cout.flush();
            char c; cin >> c;
            if(c == 'Y') break;
            now *= 10;
            if(now == 10000000000) break;
        }
        cout << "! " << now << '\n';
        cout.flush();
        return 0;
    }

    int ans = 0;
    for (int i = 1; i <= cnt; ++i) {
        int l = (i == 1 ? 1 : 0), r = 9;
        while(l < r) {
            int mid = l + r >> 1;
            int rem = ans + mid * pow10[cnt - i + 1] + pow10[cnt - i + 1] - 1;
            cout << "? " << rem << '\n';
            cout.flush();
            char c; cin >> c;
            if(c == 'Y') r = mid;
            else l = mid + 1;
        }
        ans += l * pow10[cnt - i + 1];
    }

    cout << "! " << ans / 10 << '\n';
    cout.flush();

    return 0;
}


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

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

int main(){
    vector<int> a(6);
    for(int i=1;i<=5;++i){
        cin>>a[i];
        if(a[i] == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
# d 現在の桁
# val 現在の値
# all 格納
def rec(d, val, all):
    # 格納
    all.append(val)
    # 10桁なら終了
    if d == 10:
        return
    # 再帰
    for i in range(-1, 2):
        add = val%10 + i
        if 0 <= add <= 9:
            rec(d+1, val*10+add, all)

# main
K = int(input())
all = []

# 1~9までを格納＆処理
for i in range(1, 10):
    rec(1, i, all)

all.sort()
print(all[K-1])

Measured memory_bytes: 12304
#include <stdio.h>
int main(void){
    int n,k,r,s,p,i,co = 0;
    char t[200000],tl[200000];
    scanf("%d", &n);
    scanf("%d", &k);
    scanf("%d", &r);
    scanf("%d", &s);
    scanf("%d", &p);
    scanf("%s", t);
    for(i = 0;i < k;i ++){
        if(t[i] == 's'){
                co += r;
                tl[i] = 'r';
        }
        else if(t[i] == 'p'){
                co += s;
                tl[i] = 's';
        }
        else if(t[i] == 'r'){
                co += p;
                tl[i] = 'p';
        }
    }
    for(i = k;i < n;i ++){
        if(t[i] == 's'){
            if(tl[i - k] != 'r'){
                co += r;
                tl[i] = 'r';
            }
        }
        else if(t[i] == 'p'){
            if(tl[i - k] != 's'){
                co += s;
                tl[i] = 's';
            }
        }
        else if(t[i] == 'r'){
            if(tl[i - k] != 'p'){
                co += p;
                tl[i] = 'p';
            }
        }
    }
    printf("%d\n", co);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int a[N];
  int m=0;
  int n=0;
  
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(m <= a[i]){
      m = a[i];
    }
    n += a[i];
  }
  
  m = m/2;
  
  cout << n-m;
  
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);

  ll ans = 0;
  FOR(k,K,N+2){
    ll tmp = N*k - k*(k-1) + 1;
    debug_print(k, tmp);
    ans += tmp;
    ans %= MOD;
  }

  OUT(ans);

  return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, bool Scaling = false> struct dinic {
  struct edge {
    int to;
    T cap;
  };
  const T inf = numeric_limits<T>::max(), eps = 1e-10;
  int n, s, t;
  vector<edge> es;
  vector<vector<int>> g;
  T scale;
  vector<int> h, ptr;
  dinic(int _n, int _s, int _t) : n(_n), s(_s), t(_t), g(n), h(n), ptr(n) {}
  void add(int from, int to, T cap, T rev_cap = 0) {
    g[from].push_back(es.size()), es.push_back({to, cap});
    g[to].push_back(es.size()), es.push_back({from, rev_cap});
  }
  bool bfs() {
    static vector<int> que(n);
    fill(begin(h), end(h), -1);
    h[t] = 0, que[0] = t;
    for (int bg = 0, ed = 1; bg < ed; ) {
      int v = que[bg++];
      for (int id : g[v])
        if (es[id ^ 1].cap > scale and h[es[id].to] == -1) {
          h[es[id].to] = h[v] + 1, que[ed++] = es[id].to;
          if (es[id].to == s) return true;
        }
    }
    return false;
  }
  T dfs(int v, T f) {
    if (v == t) return f;
    for (int& i = ptr[v]; i >= 0; --i) {
      int id = g[v][i];
      if (es[id].cap > scale and h[v] > h[es[id].to]) {
        T df = dfs(es[id].to, min(f, es[id].cap));
        if (df > eps)
          return es[id].cap -= df, es[id ^ 1].cap += df, df;
      }
    }
    return 0;
  }
  T max_flow() {
    T flow = 0, max_cap = 0;
    for (auto&& e : es) max_cap = max(max_cap, e.cap);
    for (scale = Scaling ? max_cap / 2 : eps; ; scale /= 2) {
      while (bfs()) {
        for (int v = 0; v < n; ++v) ptr[v] = (int)g[v].size() - 1;
        for (T df; (df = dfs(s, inf)) > eps; ) flow += df;
      }
      if (scale <= eps) break;
    }
    return flow;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, l;
  while (cin >> n >> m >> l, n) {
    DEBUG(n, m, l);
    vector<vector<int>> d(n, vector<int>(n, 0x3f3f3f3f));
    while (m--) {
      int u, v, w;
      cin >> u >> v >> w;
      d[u][v] = d[v][u] = w;
    }
    for (int i = 0; i < n; ++i) {
      d[i][i] = 0;
    }
    for (int k = 0; k < n; ++k) {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    struct query {
      int p, t;
      bool operator<(query b) const {
        return t < b.t;
      }
    };
    vector<query> qs(l);
    for (int i = 0; i < l; ++i) {
      cin >> qs[i].p >> qs[i].t;
    }
    sort(begin(qs), end(qs));
    dinic<int> g(2 * l + 2, 2 * l, 2 * l + 1);
    for (int i = 0; i < l; ++i) {
      g.add(g.s, i, 1);
      g.add(l + i, g.t, 1);
      for (int j = i + 1; j < l; ++j) {
        if (d[qs[i].p][qs[j].p] <= qs[j].t - qs[i].t) {
          g.add(i, l + j, 1);
        }
      }
    }
    cout << l - g.max_flow() << '\n';
  }
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    S = S;
    ll N = S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i, N) {
        ll d = S[i] - '0';
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d);
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (d == 9 ? 2 : d + 1));
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - d - 1);
    }
    cout << dp[N][0] << '\n';
}

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


Measured memory_bytes: 55964
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
#include <iomanip>
using namespace std;

//??°?????????????????°

void function()
{
	//??¢??°
}

int main()
{
	double r,S,l;
	cin >>r ;
	S = r*r*M_PI;
	l = 2 * M_PI*r;
	cout << setprecision(5);
	cout << fixed;
	cout << S <<" " <<l;
	
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define dl double
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep1(qq,pp) for(ll i=qq;i<pp;i++)
#define rep2(qqq,ppp) for(ll i=qqq;i>=ppp;i--)
#define nl "\n"
#define Y cout<<"YES\n"
#define N cout<<"NO\n"
//cout<<fixed<<setprecision(13);

int main(){
	faster;

	int n;
	
	cin>>n;
	
	if(n>=30) cout<<"Yes"<<nl;
	else cout<<"No"<<nl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll H, W;
    cin >> H >> W;

    ll ans = 1e8;

    for (ll h = 1; h < H; h++) {
        vector<ll> s;
        s.push_back(h * W);
        ll h2 = (H-h)/2;
        s.push_back(h2 * W);
        s.push_back((H-h-h2)*W);
        sort(s.begin(), s.end());
        ans = min(ans, s[2]-s[0]);
        // cout << "h:" << h << " h2:" << h2 << " H-h-h2:" << H-h-h2 << "" 

        s.clear();
        s.push_back(h*W);
        ll w = W/2;
        s.push_back((H-h)*w);
        s.push_back((H-h)*(W-w));
        sort(s.begin(), s.end());
        ans = min(ans, s[2]-s[0]);
    }

    swap(H, W);
    for (ll h = 1; h < H; h++) {
        vector<ll> s;
        s.push_back(h * W);
        ll h2 = (H-h)/2;
        s.push_back(h2 * W);
        s.push_back((H-h-h2)*W);
        sort(s.begin(), s.end());
        ans = min(ans, s[2]-s[0]);

        s.clear();
        s.push_back(h*W);
        ll w = W/2;
        s.push_back((H-h)*w);
        s.push_back((H-h)*(W-w));
        sort(s.begin(), s.end());
        ans = min(ans, s[2]-s[0]);
    }

    cout << ans << "\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;

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

	vector<P> a;
	ll dp[10]={};
	dp[0]=(h-2)*(w-2);

	P ab[100001];
	for(int i=0;i<n;++i)cin>>ab[i].first>>ab[i].second;
	sort(ab,ab+n);
	for(int i=0;i<n;++i){
		int a1=ab[i].first;
		int b1=ab[i].second;
		int d[5][5]={};
		if(a1==2){
			for(int i=0;i<5;++i)d[0][i]=10;
		}
		if(a1==1){
			for(int i=0;i<5;++i)d[0][i]=10;
			for(int i=0;i<5;++i)d[1][i]=10;
		}
		if(a1==(h-1)){
			for(int i=0;i<5;++i)d[4][i]=10;
		}
		if(a1==h){
			for(int i=0;i<5;++i)d[3][i]=10;
			for(int i=0;i<5;++i)d[4][i]=10;
		}
		if(b1==2){
			for(int i=0;i<5;++i)d[i][0]=10;
		}
		if(b1==1){
			for(int i=0;i<5;++i)d[i][0]=10;
			for(int i=0;i<5;++i)d[i][1]=10;
		}
		if(b1==(w-1)){
			for(int i=0;i<5;++i)d[i][4]=10;
		}
		if(b1==w){
			for(int i=0;i<5;++i)d[i][3]=10;
			for(int i=0;i<5;++i)d[i][4]=10;
		}



		int flg=a.size();
		while(flg>0){
			flg--;
			int a2=a[flg].first;
			int b2=a[flg].second;
			if((a2>=(a1-2))&&(((b2-2)<=b1)&&((b2+2)>=b1))){
				d[a2-a1+2][b2-b1+2]=1;
			}
			if(b2<b1-2){
				flg=upper_bound(a.begin(),a.end(),P(a2-1,b1+2))-a.begin();
			}
			if(a2<a1-2)break;
		}
		a.push_back(P(a1,b1));
		d[2][2]=1;

//		for(int j1=0;j1<5;++j1){
//			for(int j2=0;j2<5;++j2){
//				cout<<d[j1][j2]<<" ";
//			}
//			cout<<endl;
//		}

		for(int j1=0;j1<3;++j1){
			for(int j2=0;j2<3;++j2){
				int t=0;
				for(int j3=0;j3<3;++j3){
					for(int j4=0;j4<3;++j4){
						t+=d[j1+j3][j2+j4];
					}
				}
				if(t<10){
					dp[t]++;
					dp[t-1]--;
				}
			}
		}
//		cout<<dp[0]<<endl;
	}
	for(int i=0;i<10;++i)cout<<dp[i]<<endl;
	return 0;
}


Measured memory_bytes: 2296
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

char button[10][6] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

void solve()
{
    int n;

    cin >> n;
    cin.ignore();

    rep(i, n) {
        int idx = 0;
        char c;
        string str;
        getline(cin, str);

        while( idx < str.length() ) {
            int cnt = 0;
            c = str[idx];

            while(str[idx] != '0') {
                cnt++;
                idx++;
            }

            if (c != '0') {
                int len = strlen(button[c - '0']);
                cout << button[c - '0'][(cnt - 1) % len];
            }

            cnt = 0;
            while(str[idx] == '0') {
                idx++;
            }

        }

        cout << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

Measured memory_bytes: 3136
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

    var s = input[0];
    //console.log(s);
    var acgt='ACGT';
   // var p = s.substr(1,1);
    var cnt = 0;cnt2 = 0;
    for(i=0;i<s.length;i++){
      　　var q =s.substr(i,1)
         var result = acgt.indexOf(q);
       //  console.log(result);
         if(result >=0){cnt = cnt+1;
                    //   console.log(cnt);
                       }
           else if(cnt>cnt2){var cnt2=cnt;var cnt = 0;
                           // console.log(cnt,cnt2);
                            }
                       else{//console.log(cnt,cnt2);
                            var cnt = 0;}
                   }
        
        if(cnt>cnt2){var cnt2=cnt;};      
        console.log(cnt2) ;
   
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N, A;
  cin >> N >> A;

  int rem = N % 500;
  string res = (A - rem >= 0) ? "Yes" : "No";

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vector<double> x(n),y(n);
	rep(i,n) cin >> x[i] >> y[i];
	double left = -1000, right = 2000;
	double ans = 1010101010;
	rep(p,100){
		double xmid[2], mx[2];
		xmid[0] = (2*left+right)/(double)3.0, mx[0] = 1010101010;
		xmid[1] = (left+2*right)/(double)3.0; mx[1] = 1010101010;
		if(xmid[1]-xmid[0]<1e-7) break;
		rep(i,2){
			double down = -1000, up = 2000;
			rep(q,100){
				double ymid[2], res[2];
				ymid[0] = (down*2+up)/(double)3.0, res[0] = 0.0;
				ymid[1] = (down+up*2)/(double)3.0, res[1] = 0.0;
				if(ymid[1]-ymid[0]<1e-7) break;
				rep(j,2){
					rep(k,n) chmax(res[j],(y[k]-ymid[j])*(y[k]-ymid[j])+(x[k]-xmid[i])*(x[k]-xmid[i]));
				}
				if(res[0]<res[1]) up = ymid[1], chmin(mx[i],res[0]);
				else down = ymid[0], chmin(mx[i],res[1]);
			}
		}
		if(mx[0]<mx[1]) right = xmid[1], chmin(ans,mx[0]);
		else left = xmid[0], chmin(ans,mx[1]);
	}
	printf("%.10f\n",sqrt(ans));
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
conflict = []
for _ in range(m):
    a, b = map(int, input().split())
    conflict.append((a, b))
conflict.sort(key=lambda x: x[1])


ans = 0
X = 0
for L, R in conflict:
    if L <= X:
        continue
    X = R-1
    ans += 1
print(ans)


Measured memory_bytes: 23928
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<"ABC"<<n;
        
    }
    return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    ll ans = 0, sum, now;
    string s;
    cin >> s;
    for (int i = 0; i < (1 << (s.size() - 1)); ++i) {
        sum = 0, now = 0;
        for (int j = 0; j < s.size(); ++j) {
            now = now * 10 + s.at(j) - '0';
            if (i & (1 << j)) {
                sum += now;
                now = 0;
            }
        }
        ans += sum + now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
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 data = 0;
      boolean stop = false;
      int count = 0;

      for (int i = 1;i<=b-a ;i++ ) {
        data +=i;
      }

      for (;;data-- ) {
        if (b==data) {
          System.out.println(count);
          System.exit(0);
        }
        count++;
      }



      }
    }


Measured memory_bytes: 21844
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W = map(int, readline().split())
    A = list(list(map(int, readline().split())) for _ in range(H))
    move = []
    for i in range(H):
        for j in range(W - 1):
            if A[i][j] % 2:
                A[i][j] -= 1
                A[i][j + 1] += 1
                move.append([i + 1, j + 1, i + 1, j + 2])
    for i in range(H - 1):
        if A[i][W - 1] % 2:
            A[i][W - 1] -= 1
            A[i + 1][W - 1] += 1
            move.append([i + 1, W, i + 2, W])
    print(len(move))
    for m in move:
        print(m[0],m[1],m[2],m[3])


if __name__ == '__main__':
    main()


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

struct data {
  long long num, size, next;
};

struct command {
  string c;
  data d;
};

int n;
vector<data> sec;
set<int> st;
vector<command> commands;

void solve();
void secwrite(data now);
void secdelete(data now);
void secread(data now);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    commands.assign(n, {"a", {0, 0, -1}});
    for(int i = 0; i < n; ++i) {
      cin >> commands[i].c >> commands[i].d.num;
      if(commands[i].c == "W") cin >> commands[i].d.size;
    }
    solve();
    cout << endl;
    st.clear();
  }
  return 0;
}

void solve() {
  sec.assign(1, {-1, 0, -1});
  st.insert(-1);
  for(int i = 0; i < n; ++i) switch(commands[i].c[0]) {
      case 'W': secwrite(commands[i].d); break;
      case 'D': secdelete(commands[i].d); break;
      case 'R': secread(commands[i].d); break;
    }
}

void secwrite(data now) {
  auto it = sec.begin();
  st.insert(now.num);
  while(1) {
    if(st.find(it->num) == st.end()) {
      data newdata = {-2, it->size - now.size, it->next};
      it->num = now.num;
      it->size = min(it->size, now.size);
      now.size -= it->size;
      if(newdata.size > 0) {
        it->next = sec.size();
        sec.push_back(newdata);
      }
    }
    if(it->next == -1 || now.size <= 0) break;
    it = sec.begin() + it->next;
  }
  if(now.size > 0) {
    it->next = sec.size();
    sec.push_back(now);
    return;
  }
}

void secdelete(data now) { st.erase(now.num); }

void secread(data now) {
  auto it = sec.begin();

  long long ans = -1;
  while(1) {
    now.size += it->size;
    if(now.num < now.size) {
      if(st.find(it->num) != st.end()) ans = it->num;
      break;
    }
    if(it->next == -1) break;
    it = sec.begin() + it->next;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3928