akhauriyash/Code-Regression huggingface dataset:
n,m = map(int, input().split())

a = [0]*n
b = [False]*n
for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == 'AC':
        b[p] = True
    elif b[p] == False:
        a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
    if b[i] == True:
        wa += a[i]
print(ac,wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
    int a;
    double b, c;
    while(~scanf("%d,%lf,%lf",&a,&b,&c)) {
        if(b / c / c >= 25) cout << a << endl;
    }
return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n==0)
    {
        printf("0\n");
    }
    else if(n==1)
    {
        printf("1\n");
    }
    else if(n%2==0)
    {
        printf("%d\n",n/2);
    }
    else if(n%2==1)
    {
        printf("%d\n",n/2+1);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int data[] = new int[N];

      int a = 0;
      int total=0;

      while(a<N){
        data[a] = sc.nextInt();
        a++;
      }

      Arrays.sort(data);

      for(int i = 0;i<N-2;i++){
        for(int j = i+1;j<N-1;j++){
          int low = 0;
          int high = N;
          int middle = 0;

          while(high-low>1){

              middle =(high+low)/2;

             
            if(data[middle]<data[i]+data[j]){
              low = middle;
              
            }else{
              high = middle;
          }
        }
        total=total+high-1-j;
      }


    }
    System.out.println(total);
  }
}


Measured memory_bytes: 26172
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
using namespace std;

void trace(string a[], int n)
{
    for (int i = 0; i < n - 1; i++)
        cout << a[i] << " ";
    cout << a[n - 1] << "\n";
}

void swap(string *x, string *y)
{
    string tmp = *x;
    *x = *y;
    *y = tmp;
}

void bubbleSort(string a[], int n)
{
    for(int i = 0; i < n; i++)
        for(int j = n-1; j >= i+1; j--)
        {
            if(a[j][1] < a[j-1][1])
                swap(&a[j], &a[j-1]);
        }
    trace(a, n);
    cout << "Stable\n";
}

void SelectionSort(string a[], int n)
{
    bool flag = true;
    int count = 0;
    int minj;
    int same;
    for (int i = 0; i < n; i++)
    {
        same = -1;
        minj = i;
        for (int j = i+1; j < n; j++)
        {
            if (a[j][1] < a[minj][1])
                minj = j;
            else if(a[j][1] == a[i][1])
                same = j;
        }
        if (i != minj)
        {
            swap(&a[i], &a[minj]);
            if(same > 0 && minj > same)
                flag = false;
        }
        //trace(a, n);
    }
    trace(a, n);
    if(flag)
        cout << "Stable\n";
    else
        cout << "Not stable\n";
}

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

    string a[n];
    string b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }

    bubbleSort(a, n);
    SelectionSort(b, n);

    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    ll X,Y;
    cin >> X >> Y;
    ll ans = 0;
    ll tmp = X;
    while(tmp<=Y) {
        tmp*=2;
        ans++;
    }    
    cout << ans << endl;
}

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

int main(){
  long long int n, m;
  cin >> n >> m;
  priority_queue<long long int> que;
  rep(i,n,0){
    long long int a;
    cin >> a;
    que.push(a);
  }
  rep(i,m,0){
    long long int b = que.top() / 2;
    que.pop();
    que.push(b);
  }
  long long int ans = 0;
  rep(i,n,0){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 998244353;

int main() {
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if (x == 1 && y == 1) ans = 400000;
	if (x <= 3)ans += 400000 - x * 100000;
	if (y <= 3)ans += 400000 - y * 100000;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Q,H,S,D,N;
int main()
{
	cin>>Q>>H>>S>>D>>N;
	S=min(S,min(Q*4,H*2));
	long long ans=0;
	if (S*2>D) ans+=1ll*D*(N/2),N%=2;
	ans+=1ll*S*N;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N, M = map(int, input().split())
E = [[False]*N for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    E[a][b] = E[b][a] = True
ans = 0
for t in permutations(range(1, N)):
    pv = 0
    for v in t:
        if not E[pv][v]:
            break
        pv = v
    else:
        ans += 1
print(ans)


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

int n, p;
int cnt;
vector<int> v;

int solve() {
  while (true) {
    for (int i = 0; i < n; ++i) {
      if (cnt) {
        --cnt;
        ++v[i];
      } else {
        if (!v[i]) continue;
        cnt += v[i];
        v[i] = 0;
      }
      if (v[i] == p) return i;
    }
  }
}

int main() {
  while (cin >> n >> p, n) {
    cnt = p;
    v = vector<int>(n, 0);
    cout << solve() << endl;
  }
  return 0;
}



Measured memory_bytes: 3068
s = list(map(int, input().split()))
if ((s[0]-s[1])%2 == 0):
    if  (s[0]-s[1] > 0):
        k = int(s[0] - (s[0]-s[1])/2)
        print(k)
    else:
        k = int(s[1] - (s[1]-s[0])/2)
        print(k)
else:
    print("IMPOSSIBLE")
    

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N); 
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  int a = 0;
  for(int i = 0; i < N-1; i++) {
    if(S.at(i) == S.at(i+1)) {
      a++;
    }
  }
  cout << N-a << endl;
}


Measured memory_bytes: 9604
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

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

int n, x;

int main() {
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;

        int ans = 0;

        for (int i = 1; i <= n - 2; i++) {
            for (int j = 2; j <= n - 1; ++j) {
                for (int k = 3; k <= n; ++k) {
                    if (i + j + k == x &&
                        i != j && i != k && k != j &&
                        i < j && j < k) {
                        ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a,b;cin>>a>>b;

	cout<<min(n*a,b)<<endl;





























	
}

Measured memory_bytes: 256
# 参考
# https://atcoder.jp/contests/keyence2020/submissions/9575705
#------------------------------------------

n = int(input())
robots = []

for i in range(n):
    x, l = map(int, input().split())
    robots.append([x + l, x - l])
    
#robotsという配列には
#・[0]に右側の手で届く範囲
#・[1]に左側の手で届く範囲
#が格納されている。
    
robots.sort()

r = - 10 ** 9 - 1
cnt = 0
for i in range(n):
    if r <= robots[i][1]:#この式で、左側に腕を伸ばした時にぶつからないことを指している
        cnt += 1
        r = robots[i][0]#最小値には右側に腕を伸ばした場合を代入
print(cnt)


Measured memory_bytes: 20104
package main

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

type PS struct {
	p int
	s string
}

type AP struct {
	acknowledged int
	penalty      int
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()
	ps := make([]PS, m)
	for k, _ := range ps {
		ps[k].p = scanInt()
		ps[k].s = scanString()
	}

	ap := make([]AP, n)

	for _, v := range ps {
		if ap[v.p-1].acknowledged == 0 {
			switch v.s {
			case "AC":
				ap[v.p-1].acknowledged = 1
			case "WA":
				ap[v.p-1].penalty++
			}
		}
	}

	correctAnswers, penalties := 0, 0
	for _, v := range ap {
		correctAnswers += v.acknowledged
		if v.acknowledged == 1 {
			penalties += v.penalty
		}
	}
	fmt.Printf("%d %d", correctAnswers, penalties)
}


Measured memory_bytes: 5504
#include <cstdio>
#include <vector>
#include <cstring>

using namespace std;

const int N = 1e5 + 500;

int dp[N][2],n;
vector < int > v[N];


int f(int i,int x,int lst){
  if(x == 0 && v[i].size() == 1 && i != 1) return 0;
  if(v[i].size() == 1 && i != 1) return 1;
  if(dp[i][x] != -1) return dp[i][x];
  vector < int > v1,v0;
  int s0 = 0,s1 = 0;
  for(int j = 0;j<v[i].size();j++){
    if(v[i][j] == lst) continue;
    v0.push_back(f(v[i][j],0,i));
    v1.push_back(f(v[i][j],1,i));
    s0 += v0[v0.size() - 1];
    s1 += v1[v1.size() - 1];
  }
  if(x == 1 && s0 != v0.size()) return dp[i][x] = 0;
  if(x == 1) return dp[i][x] = 1;
  int tk = 0;
  for(int j = 0;j<v0.size();j++){
    if(v1[j] + s0 - v0[j] == v0.size()) return dp[i][x] = 1;
  }
  return dp[i][x] = 0;
}

int main(){
  memset(dp,-1,sizeof(dp));
  scanf("%d",&n);
  for(int i = 0;i<n-1;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  if(f(1,0,1)) printf("Second\n");
  else printf("First\n");
}


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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
char c[] = {'R', 'Y', 'G', 'B'};
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int H = gi<int>(), W = gi<int>(), k = gi<int>();
	for (int i = 1; i <= H; i++, puts(""))
		for (int j = 1; j <= W; j++) {
			int x = i + j + 1000, y = i - j + 1000;
			printf("%c", c[((x / k) & 1) << 1 | ((y / k) & 1)]);
		}
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    string T,Ans;
    cin >> T;
    Ans = "";
    for (int i=0; i < T.size(); i++){
      if (T.at(i) == '?'){
      Ans += "D";
      }
      else{
      Ans += T.at(i);
      }
    }
    cout << Ans << endl;
    }

Measured memory_bytes: 3912
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int left = 1, right = N;
    for (int i = 0; i < M; ++i)
    {
        int Li, Ri;
        cin >> Li >> Ri;
        if (left < Li) left = Li;
        if (Ri < right) right = Ri;
    }
    cout << std::max(right - left + 1, 0);
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
li = []
for i in range(M):
    li.append(input().split())


r = ['WA']*(N+1)
wa_li = [0]*(N+1)
o = []
c = 0
ac_c = 0

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            wa_li[index]+=1

    else: # AC
        if r[index] == 'WA':
            r[index] = 'AC'
            ac_c += 1
        else:
            pass

p_c =0
for i,v in enumerate(r):
    if v == 'AC':
        p_c+=wa_li[i]

print(ac_c, p_c)


Measured memory_bytes: 33696
//  Author : Amit Kumar 

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

int main(void){
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 
    int n; cin >> n; 
    if(n%1000){
        cout << 1000 - n%1000 << '\n';
    }else{
        cout << 0 << '\n'; 
    }

#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>

using namespace std;

const int kInf = 1e9+19;

void Solve() {
	string s;
	cin >> s;

	int n = s.length();

	unordered_map<int, vector<int>> edges;
	vector<int> pref(n + 1);
	queue<int> Q;
	vector<int> d(n + 1, kInf);

	pref[0] = 0;

	for (int i = 0; i < s.length(); ++i) {
		pref[i+1] = pref[i] ^ (1<< (s[i] - 'a'));
		edges[pref[i+1]].push_back(i + 1);
	}
	
	Q.push(0);
	d[0] = 0;
	while(!Q.empty()) {
		int x = Q.front();
		// cerr << x << "\n";
		Q.pop();
		
		for (int j = 0; j < 27; ++j) {
			int new_pref;
			if (j == 26)
				new_pref = pref[x];
			else new_pref = pref[x] ^ (1 << j);
			auto& e = edges[new_pref];
			while (!e.empty() && x < e.back()) {
				int y = e.back();
				Q.push(y);
				d[y] = d[x] + 1;
				e.pop_back();
			}
		}
	}

	cout << d[n] << "\n";
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 245724
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    string S, T;
    cin >> S;
    cin >> T;

    ll count = 0;
    for (ll i = 0; i < S.size(); i++)
    {
        if (S[i] == T[i])
        {
            count++;
        }
    }

    cout << count << endl;
}

int main()
{
    solve();
    return 0;
}


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


int main()
{
	
	int n ; 
	 cin>>n;
	 int k ;
	  cin>>k;
	 vector<int> h ;
	 for(int i  =0;i<n;i++)
	 {
	 	int a;
	 	cin>>a;
	 	
	 	h.push_back(a);
	 	
	 }
	 
	 
	 vector<int>dp(n+1,INF);
	dp[0]=0;

	for(int i =0;i<n;i++)
	{
		for (int j  = i+1;j<=i+k;j++)
		{
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	
	cout<<dp[n-1];
	 return 0 ;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n+1];for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=n;i>=1;i-=2)cout<<a[i]<<" ";
    for(ll i=1+n%2;i<=n;i+=2)cout<<a[i]<<" ";
}

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

int main()
{
	int N;
	int answer;

	cin >> N;
   
    if      ( N == 1 )           { answer=1; }
    else if ( 2 <= N && N <  4 ) { answer=2; }
    else if ( 4 <= N && N <  8 ) { answer=4; }
    else if ( 8 <= N && N < 16 ) { answer=8; }
    else if (16 <= N && N < 32 ) { answer=16; }
  	else if (32 <= N && N < 64 ) { answer=32; }
  	else if (64 <= N )           { answer=64; }
  
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int n,q;

struct fenwicktree
{
    vector<int> tree;
    fenwicktree(int n):tree(n+1) {}

    int sum(int pos)
    {
        int ret=0;
        while(pos>0)
        {
            ret += tree[pos];
            pos &= (pos-1);
        }
        return ret;
    }

    void add(int pos,int value)
    {
        while(pos < tree.size())
        {
            tree[pos] += value;
            pos += (pos & -pos);
        }
    }
};

int main()
{
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    scanf("%d%d",&n,&q);
    fenwicktree ft(n);
    for(int i=1;i<=q;++i)
    {
        int command,x,y;
        scanf("%d%d%d",&command,&x,&y);
        if(command == 0) ft.add(x,y);
        if(command == 1) printf("%d\n",ft.sum(y)-ft.sum(x-1));
    }
    return 0;
}

Measured memory_bytes: 3352
a, b = map(int, input().split())
count = 0
for i in range(a, b+1):
    s = str(i)
    if(len(s) == 1):
        count += 1
        break
    for j in range(len(s) // 2):
        if(s[j] != s[len(s)-1-j]):
            break
    else:
        count += 1
print(count)    

Measured memory_bytes: 3064
n=int(input())
l=[input().split() for i in range(n)]
l2=[x for x in range(n)]
base=list(zip(l2,l))
ans=sorted(base, key=lambda x: int(x[1][1]),reverse=True)
ans=sorted(ans,key=lambda x: x[1][0])

for i in range(n):
    print(1+ans[i][0])

Measured memory_bytes: 9096
# coding:utf-8
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0

for i in range(n):
    candy = sum(a1[:i + 1]) + sum(a2[i:])
    ans = max(ans, candy)
print(ans)


Measured memory_bytes: 9068
//dhruv
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
const int inf = 1e18 + 5;
 
template<typename T>
T binpow(T a,T b,T modi){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a)%modi;
		}
		b /= 2;
		(a *= a) %= modi;
	}
	return res;
}
 
 
template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a);
		}
		b /= 2;
		a *= a;
	}
	return res;
}
 
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}

int make_int(string s){
	int x = 0;
	reverse(s.begin(),s.end());
	string tmp = s;
	for(int i = 0;i < s.length(); ++i){
		x *= 10;
		x += (int)(tmp.back() - '0');
		tmp.pop_back();
	}
	return x;
}
 
string make_string(int s){
	string x;
	while(s){
		x.push_back(char(s%10 + '0'));
		s /= 10;
	}
	reverse(x.begin(),x.end());
	return x;
}

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



const int N = 100;
int lp[N + 1];
vector<int> pr;
void ls(){
	for(int i = 2;i <= N; ++i){
		// means prime
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(int j = 0;j < pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; j++){
			lp[i*pr[j]] = pr[j];
		}
	}
}


// getting the prime factorisation

vector<int> getfc(int n){
	vi fact;
	while(n != 1){
		int x = lp[n];
		fact.push_back(x);
		while(n%x == 0){
			n /= x;
		}
	}
	return fact;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int x;
	cin >> x;
	string s = "";
	while(x > 0){
		int rem = x%26;
		if(rem == 0){
			s.push_back('z');
			x/=26;
			x--;
		}else{
			s.push_back(char(rem - 1 + 'a'));
			x/=26;
		}
	}
	reverse(s.begin(),s.end());
	cout << s;
	return 0;
}

Measured memory_bytes: 3648
N,M,K=[int(s) for s in input().split()]
A=[int(s) for s in input().split()]
B=[int(s) for s in input().split()]
Asum=[0 for i in range(N+1)]
Bsum=[0 for i in range(M+1)]
for i in range(N):
  Asum[i+1]=Asum[i]+A[i]
for i in range(M):
  Bsum[i+1]=Bsum[i]+B[i]

def nibu(x):
  time=set()
  for i in range(0,N+1):
    if i>x:
      break
    if x-i>M:
      continue
    time.add(Asum[i]+Bsum[x-i])
  if min(time)<=K:
    return True
  else:
    return False
  
nibu_l=0
nibu_r=N+M
while nibu_r-nibu_l>1:
  c=(nibu_l+nibu_r)//2
  if nibu(c)==True:
    nibu_l=c
  else:
    nibu_r=c
if nibu(nibu_r)==True:
  print(nibu_r)
else:
  print(nibu_l)

Measured memory_bytes: 61228
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    int ans = 0;

    while(N)
    {
        if( N % 10 == 7)
            ans = 1;
        N /= 10;
    }

    if( ans)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int num=0,m=0;
	vector<int> broken;
	cin>>num>>m;
	int old=-1;
	broken.push_back(-1);
	for(int i=0;i<m;i++){
		int tmp;
		cin>>tmp;
		broken.push_back(tmp);
		if(tmp==old+1){
			cout<<0;
			return 0;
		}else{
			old=tmp;
		}
	}
	broken.push_back(num+1);
	long data[100002]={0,1};
	for(int i=2;i<100002;i++){
		data[i]=(data[i-1]+data[i-2])%1000000007;
	}
	long ans=1;
	for(int i=1;i<broken.size();i++){
		ans*=data[broken[i]-broken[i-1]-1];
		ans%=1000000007;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1404
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(grid):  # fix inputs here
    console("----- solving ------")

    # return a string (i.e. not a list or matrix)
    return max(max([(x+y) for x,y in grid]) - min([(x+y) for x,y in grid]), 
               max([(x-y) for x,y in grid]) - min([(x-y) for x,y in grid]))


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
inp = sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    nrows = int(inp[0])
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for row in range(1,nrows+1):
        grid.append(list(map(int,inp[row].split())))

    res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


Measured memory_bytes: 149408
#include <iostream>

using namespace std;

int main()
{
    long n, input, i=1, max, min, sum=0;
    
    cin >> n >> input;
    max = input;
    min = input;
    for (i=1;i<=n;i++)
    {
        sum = sum + input;
        if (input < min)
        {
        min = input;
        }
        if (input > max)
        {
            max = input;
        }
        cin >> input;
    }
     cout << min << " " << max  << " " << sum<< endl;
   return 0;
}



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

int main(void) {
    int a, b, c, d;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = [0]*110000
X = [0]*110000
Y = [0]*110000
for n in range(N):
    T[n+1], X[n+1], Y[n+1] = map(int, input().split())
res = True
for n in range(N):
    dt = T[n+1] - T[n]
    dist = abs(X[n+1] - X[n]) + abs(Y[n+1] - Y[n])
    if dt < dist:
        res = False
    if dt % 2 != dist % 2:
        res = False
if res:
    print('Yes')
else:
    print('No')

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


int main(){
  string sa,sb,sc;
  cin >> sa;
  cin >> sb;
  cin >> sc;
  int aid,bid,cid;
  aid=0;
  bid=0;
  cid=0;
  char an=sa[0];
  aid++;
  while(aid<=sa.size() || bid<=sb.size() || cid<=sc.size()){
    if(an=='a'){
      if(aid==sa.size()){
        cout << 'A' << endl;
        return 0;
      }
      an=sa[aid];
      aid++;
    }else if(an=='b'){
      if(bid==sb.size()){
        cout << 'B' << endl;
        return 0;
      }
      an=sb[bid];
      bid++;
    }else{
      if(cid==sc.size()){
        cout << 'C' << endl;
        return 0;
      }
      an=sc[cid];
      cid++;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-8;
	const double PI = 3.1415926536;
	
	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
		/*
		StreamReader sr = new StreamReader(@"D:\Download\2017-pr-t1-in5.txt");
		StreamWriter sw = new StreamWriter(@"D:\prog\joi\1-5.txt");
		string[] line = sr.ReadLine().Split(' ');
		sr.Close();
		sw.Close();
		*/
		int a = cin.nextInt();
		int b = cin.nextInt();
		Console.WriteLine(1/(1/(double)a+1/(double)b));
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int min = 200005;
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
		if(a[i] < min){
			min = a[i];
			ans++;
		}
	}
	cout << ans;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    long long s;
    s = M/N;
    for(long long i = s;i>0;i--){
        if(M % i == 0){
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 380
#include<iostream>
#include<cstdio>
using namespace std;
char a[110],k,ans;
int main(){
	do{
		k++;
		scanf("%c",&a[k]);
		if(a[k]=='C')ans=1;
		else if(ans==1&&a[k]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}while(a[k]!='\n');
	cout<<"No"<<endl;
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define TARO 0
#define HANAKO 1

int main() {
	int n;
	
	while (cin >> n, n) {
		set< int > card[2];
		
		for_(i,0,2*n) card[HANAKO].insert(i + 1);
		
		for_(i,0,n) {
			int c;
			cin >> c;
			card[TARO].insert(c);
		}
		
		for (int t : card[TARO]) card[HANAKO].erase(t);
		
		int cur = -1, turn = 0;
		
		while (card[TARO].size() > 0 && card[HANAKO].size() > 0) {
			if (cur == -1) {
				cur = *card[turn % 2].begin();
				card[turn % 2].erase(cur);
			} else {
				set< int >::iterator it = card[turn % 2].upper_bound(cur);
				
				if (it == card[turn % 2].end()) {
					cur = -1;
				} else {
					cur = *it;
					card[turn % 2].erase(cur);
				}
			}
			
			++turn;
		}
		
		cout << card[HANAKO].size() << endl << card[TARO].size() << endl;
	}
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<string.h>

int main(){
  int N;
  int point[100],point2=-1,enflag[100]={0},num;
  char cname[100][101],name[101]="{";
  scanf("%d\n",&N);
  for(int i = 0;i < N;i++){
    scanf("%s %d\n",cname[i],&point[i]);
  }
  for(int i = 0;i < N;i++){
    name[0]='{';name[1]='\0';point2 = -1;
    for(int j= 0;j < N;j++){
      if(enflag[j]==0&&(strcmp(name,cname[j])>0||(strcmp(name,cname[j])==0&&point2 < point[j]))){
        num = j;point2 = point[j];strcpy(name,cname[j]);
      }
    }enflag[num] = i+1;
  }
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
    	if(enflag[j]==i+1){printf("%d\n",j+1);}
    }
  }return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<int>> graph;
vector<vector<bool>> reached;

//解法はあってるからあと自力で実装する
int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N;i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    ll ans = 0;
    for(int i=0;i<N;i++){
        ll cnt_a = lower_bound(A.begin(),A.end(),B[i])-A.begin();
        ll cnt_c = C.end()-upper_bound(C.begin(),C.end(),B[i]);
        ans += cnt_a*cnt_c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import scala.io.StdIn._
object Main {
  def main(args: Array[String]): Unit = {
    val input1 = readLine.split(" ")
    val N = input1(0).toInt
    val T = input1(1).toInt
    val ctls = for(i <- 1 to N) yield readLine
    val ctls2 = ctls map {
      ele =>
        val seq = ele.split(" ") map {_.toInt}
        (seq(0),seq(1))
    } filter {
      ele => ele._2 <= T
    } sortBy {
      ele => ele._1
    }
    if(ctls2.isEmpty) println("TLE")
    else println(ctls2(0)._1)
  }
}


Measured memory_bytes: 27200
import java.util.Scanner;

public class Main{


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

		int n = scan.nextInt();
		scan.nextLine();

		int[] array = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
			if (array[i] > max) {
				max = array[i];
			}
		}
		int[] result = new int[max + 3];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			result[array[i]+1]++;
			result[array[i]]++;
			result[array[i] + 2]++;

		}
		int newMax = 0;
		for (int i = 0; i < max + 3; i++) {
			if (result[i] > newMax) {
				newMax = result[i];
			}
		}
		System.out.println(newMax);

	}

}


Measured memory_bytes: 50392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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

  string ans = "AC";

  if(s[0] != 'A') ans = "WA";
  int c = 0;
  for(int i = 2; i < s.size()-1; i++){
    if(s[i] == 'C') c++;
  }
  if(c != 1) ans = "WA";
  c = 0;
  for(int i = 0; i < s.size(); i++){
    if('A' <= s[i] && s[i] <= 'Z') c++;
  }
  if(c != 2) ans = "WA";

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

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

    if(H % 3 == 0 or W % 3 == 0) {cout << 0 << endl; return 0;}

    ll ans = INF;
    rep1(h,H) {
        ll temp = INF;
        ll a = h * W;
        ll b = (H-h) * (W/2);
        ll c = (H-h) * (W - (W/2));
        ll max3 = max(a, max(b,c));
        ll min3 = min(a, min(b,c));
        temp = max3 - min3;
        ans = min(ans, temp);
    }
    rep1(w,W) {
        ll temp = INF;
        ll a = w * H;
        ll b = (W-w) * (H/2);
        ll c = (W-w) * (H - (H/2));
        ll max3 = max(a, max(b,c));
        ll min3 = min(a, min(b,c));
        temp = max3 - min3;
        ans = min(ans, temp);
    }
    ans = min(ans, H);
    ans = min(ans, W);
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        for(int i = 0;i < s.length();i++){
            if(i % 2 == 0){
                System.out.print(str[i]);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 33488
import java.util.Scanner;

public class Main {
	static int toInt(int h , int w , int d , int H , int W){
		return d * H * W + w * H + h;
	}
	static int solve(int H, int W , int[][] R , int[][] B){
//		Stack<State> q = new Stack<State>();
		int q[] = new int[H * W * (H + W) * 80];
		int head = 0;
		int tail = 0;
		q[tail++] = 0;
		int ret = 10000;
		boolean vis[] = new boolean[H * W * (H + W) * 80];
		while(head < tail){
			int cur = q[head++];
			int h = cur % H;
			int w = (cur / H) % W;
			int r = (cur / H / W) ;
			int diff = Math.abs(B[h][w] - R[h][w]);
//			System.out.println(h+" "+w+" "+r+" "+diff);
			int d1 = r + diff;
			int d2 = Math.max(r - diff , diff - r);
			if(h == H - 1 && w == W - 1){
				int d = Math.min(Math.abs(d1), Math.abs(d2));
				ret = Math.min(ret, d);
			}
			if(h < H - 1){				
				int nh = h + 1;
				int nw = w;
				int ns = toInt(nh , nw , d1 , H , W);
				if(!vis[ns]){
					vis[ns] = true;
					q[tail++] = ns;
				}
				ns = toInt(nh , nw , d2 , H , W);
				if(!vis[ns]){
					vis[ns] = true;
					q[tail++] = ns;
				}
			}
			if(w < W - 1){
				int nh = h;
				int nw = w + 1;				
				int ns = toInt(nh , nw , d1 , H , W);
				if(!vis[ns]){
					vis[ns] = true;
					q[tail++] = ns;
				}
				ns = toInt(nh , nw , d2 , H , W);
				if(!vis[ns]){
					vis[ns] = true;
					q[tail++] = ns;
				}
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A[][] = new int[H][W];
		int B[][] = new int[H][W];
		loadMatrix(sc, H, W, A);
		loadMatrix(sc, H, W, B);
		int ret = solve(H , W , A , B);
		System.out.println(ret);
	}
	private static void loadMatrix(Scanner sc, int H, int W, int[][] A) {
		for(int i = 0 ; i < H ; ++i){
			for(int j = 0 ; j < W ; ++j){
				A[i][j] = sc.nextInt();
			}
		}
	}
}


Measured memory_bytes: 437264
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
int arr[10010], brr[10010];
vector<pi> v;
int m;
// vector<pair<int, int>> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }

void solve()
{
    int n;
    cin >> n;
    int x = n % 10;
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9)
    {
        cout << "hon" << lin;
        return;
    }
    else if (x == 0 || x == 1 || x == 6 || x == 8)
    {
        cout << "pon" << lin;
    }
    else
    {
        cout << "bon" << lin;
    }
}

int main()
{
    auto start = clock();
    fast_io;
    //freopen("test.txt", "r", stdin);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  vector<int> d(n, -1);
  vector<int> prev(n);
  d[0] = 0;
  while(!q.empty()) {
    int v = q.front(); q.pop();
    for(int nv : g[v]) {
      if(d[nv] != -1) continue;
      prev[nv] = v;
      d[nv] = d[v] + 1;
      q.push(nv);
    }
  }
  bool ok = true;
  rep(i, n) {
    if(d[i] == -1) ok = false;
  }
  if(ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  rep(i, n) {
    if(i == 0) continue;
    cout << prev[i]+1 << endl;
  }
  return 0;
}

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n.at(i) == n.at(i + 1)) {
      cout << "Bad" << endl;
      break;
    }
    else if (i == 2) {
      cout << "Good" << endl;
    }
  }
}


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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 char c[ N ];
 int num;
 void Fakemain( )
 {
  IOS;
  cin >> c + 1;
  int len = strlen( c + 1 );
  For( i, 1, len )
   num += c[ i ] - '0';
  cout << ( num % 9 ? "No" : "Yes" );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, cnt;
void check(int x) {
    int b = 0;
    while (x) {
        b++;
        x/=10;
    }
    cnt += b&1;

}
int main() {
    IOS
    cin >>n;
    for (int i = 1; i <= n; ++i) {
        check(i);
    }
    cout << cnt << endl;

    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;
 
int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int a; string s; cin >> a; cin >> s;
        cout << (a >= 3200 ? s : "red") << endl;
		return 0;    
}

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

#input
N, D, A = map(int, input().split())
X = [0]*N
H = [0]*N
for i in range(N):
    X[i], H[i] = map(int, input().split())
 
#output
import numpy as np
import bisect as bi
 
X = np.array(X)
H = np.array(H)
idx = np.argsort(X)
X = X[idx]
H = H[idx]
 
damage = np.zeros(N+1, int)
answer = 0
power = 0
for i in range(N):
    power -= damage[i]
    J = (H[i]-1+A)//A
    if J <= power:
        continue
    else:
        a = bi.bisect_right(X, X[i]+2*D)
        damage[a] += J - power
        answer += J-power
        power = J
 
print(answer)

Measured memory_bytes: 29668
# -*- coding: utf-8 -*-
import math

#入力
#n, m = map(int, input().split())
N = str(input())

N2 = ""

for i in range(len(N)) :
  N2 += N[len(N) - 1 - i]

if N == N2 :
  print ("Yes")
else :
  print ("No")


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		for ( ; ; ) {
			// 人数
			int personNum = Integer.parseInt(scanner.nextLine());
			
			if (personNum == 0) {
				break;
			}

			// 所得配列
			int[] incomeArray = new int [personNum];
			// 合計所得
			int totalIncome = 0;
			for (int i=0; i<personNum; i++) {
				incomeArray[i] = scanner.nextInt();
				totalIncome += incomeArray[i];
			}
			// 平均所得
			int averageIncome = totalIncome / personNum;
			// 平均以下人数
			int under = 0;
			// 平均以下判定
			for (int i=0; i<personNum; i++) {
				if (incomeArray[i] <= averageIncome) {
					under ++;
				}
			}
			System.out.println(under);
			// 次の行へ
			scanner.nextLine();
		}

	}

}



Measured memory_bytes: 67700
using System;

class Program
{
    static void Main()
    {
        // Input
        string[] str = Console.ReadLine().Split(' ');

        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);

        int d = a / b;
        int r = a % b;
        double f = (double)a / b;

        // Output
        Console.WriteLine("{0} {1} {2:f5}", d, r, f);
    }
}

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<int> v[200000];
double dp1[200000];
double dp2[200000];

double dfs1(int u,int prev){
    double ret = 0.0;
    int cnt;
    if(u==prev) cnt = v[u].size();
    else cnt = v[u].size()-1;
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        ret += (dfs1(v[u][i],u)+1.0)/cnt;
    }
    return dp1[u] = ret;
}

void dfs2(int u,int prev,double w){
    double ret = 0.0;
    int cnt = v[u].size();
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev){
            ret += (w+1.0)/cnt;
        }
        else ret += (dp1[v[u][i]]+1.0)/cnt;
    }
    dp2[u] = ret;
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        dfs2(v[u][i],u,(ret*cnt-(dp1[v[u][i]]+1.0))/max(1,cnt-1));
    }
}


int main(){
    int N;cin >> N;
    for (int i = 0; i < N-1; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs1(0,0);
    dfs2(0,0,0);
    for (int i = 0; i < N; i++) {
        cout << setprecision(10) << fixed << dp2[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 21248