akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc074.contest.atcoder.jp/tasks/arc074_a>
問題文============================================================
 縦 H ブロック、横 W ブロックの板チョコがあります。
 すぬけ君は、この板チョコをちょうど 3 つのピースに分割しようとしています。
 ただし、各ピースはブロックの境目に沿った長方形でなければなりません。
 
 すぬけ君は、3 つのピースの面積 (ブロック数) をできるだけ均等にしようとしています。
 具体的には、3 つのピースの面積の最大値を Smax、最小値を Smin としたとき、
 Smax−Smin を最小化しようとしています。 Smax−Smin の最小値を求めてください。

=================================================================

解説=============================================================
この問題は調べなければならない長方形の領域の取り方は４パターンしかない、
 それは、
     入力例１のような領域の取り方
     入力例１を90度回転させたような領域の取り方
     入力例２のような領域の取り方
     入力例３のような領域の取り方
 
 それぞれ、ある一つの領域を決めたら、残りの領域は、その領域を二分するようにすればいいので一意にもとまる。
 
 よって、４パターンそれぞれにおいてパターンを全探索して
 O(2*H + 2*W)
 でもとまる
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll H,W; cin >> H >> W;
    ll ans = LINF;
    /*
     パターン１
         サンプル１のようなパターン
     */
    for(int i = 1; i <= H - 2;i++){
        ll S1 = i*W;
        ll S2 = ((H - i)/2) * W;
        ll S3 = ((H - i) - (H - i)/2)*W;
        ans = min(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    /*
     パターン２
         パターン１を90度回転させたパターン
     */
    for(int i = 1; i <= W - 2;i++){
        ll S1 = i*H;
        ll S2 = ((W - i)/2) * H;
        ll S3 = ((W - i) - (W - i)/2)*H;
        ans = min(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    /*
     パターン3
         サンプル2のようなパターン
     */
    for(int i = 1; i <= W;i++){
        ll S1 = H*i;
        ll S2 = (H/2)*(W-i);
        ll S3 = (H - H/2)*(W-i);
        ans = min(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    /*
     パターン４
         パターン３を90度回転させたパターン（サンプル３のようなパターン）
     */
    for(int i = 1; i <= H; i++){
        ll S1 = W*i;
        ll S2 = (W/2)*(H-i);
        ll S3 = (W - W/2)*(H-i);
        ans = min(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{

  int n;
  cin >> n;

  int a[n];

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

  ll min = LONG_MAX;
  ll tmp = 0;

  for (int i = -100; i <= 100; i++)
  {
    tmp = 0;

    for (int j = 0; j < n; j++)
      tmp += (a[j] - i) * (a[j] - i);

    if (min > tmp)
      min = tmp;
  }

  ll ans = min;

  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int a[200100],cnt[2001000];
bool vis[1000100];


int main()
{
    int n;
    cin >> n;
    for(int i = 0; i<n; i++)  cin >> a[i], vis[a[i]] = true, cnt[a[i]]++;
    int Ans = 0;
    for(int i = 0; i<n; i++)
    {
        if(cnt[a[i]] > 1)  continue;
        bool flag = false;
        for(int j = 2; j*j<=a[i]; j++)
        {
            if(a[i] % j == 0)
            {
                flag|=vis[j];
                flag|=vis[a[i]/j];
            }
        }
        if(a[i] != 1 && vis[1])  continue;
        Ans+=!flag;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 9244
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    vector<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    double ans = 0.0;

    for(int i = 0; i < n ;i++){
        ans += 1.0/v[i];
    }

    cerr << ans << endl;

    cout << setprecision(17) << fixed;
    cout << (1.0/ans) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(str, input()))

def solve(k):
  k1, k2, k3 = list(k)
  ans = 0
  flag = 0
  for i1 in range(n):
    if s[i1] == k1:
      for i2 in range(i1+1, n):
        if s[i2] == k2:
          for i3 in range(i2+1, n):
            if s[i3] == k3:
              flag = 1
              break
          break
      break
  if flag:
    return 1
  else:
    return 0

ans = 0
for k in range(1000):
  k = '{:0=3}'.format(k)
  ans += solve(k)

print(ans)


Measured memory_bytes: 41712
import java.lang.Math;
import java.util.Scanner;
import java.util.Arrays;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[][] rewrites = new int[M][2];  // [num, target]

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        for (int i = 0; i < M; i++) {
            rewrites[i][0] = sc.nextInt();
            rewrites[i][1] = sc.nextInt();
        }

        // reverse
        Arrays.sort(A);
        Arrays.sort(rewrites, (a, b) -> -Integer.compare(a[1], b[1]));

        // System.out.println(Arrays.deepToString(rewrites));

        long answer = 0;
        int pos = 0;
        for (int i = 0; i < M; i++) {
            boolean breakOuter = false;
            for (int j = 0; j < rewrites[i][0]; j++) {
                if (pos >= A.length) {
                    breakOuter = true;
                    break;
                }

                if (rewrites[i][1] > A[pos]) {
                    answer += rewrites[i][1];
                    pos++;
                }
                else {
                    breakOuter = true;
                    break;
                }
            }
            if (breakOuter) { break; }
        }

        for (int i = pos; i < A.length; i++) {
            answer += A[i];
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 98912
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		int x, y, w, j, i = 0;
		ArrayList<Integer> X = new ArrayList<Integer>();
		ArrayList<Integer> Y = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(i < 10000){
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0)
				break;
			else if(x > y){
				w = x;
				x = y;
				y = w;
			}
			X.add(new Integer(x));
			Y.add(new Integer(y));
			i++;
		}
		j = i;
		for(i = 0; i != j; i++){
			System.out.println(X.get(new Integer(i)) + " " + Y.get(new Integer(i)));
		}
	
	}
}

Measured memory_bytes: 35872
import java.util.Scanner;

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

    int l = sc.nextInt();
    int r = sc.nextInt();
    int d = sc.nextInt();

    int ret = 0;
    int multiply = d;
    while (true) {
      if (multiply > r) {
        break;
      } else if (multiply >= l && multiply <= r) {
        ret++;
      }
      multiply += d;
    }
    System.out.println(ret);
  }
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 2e5 + 100;
char S[MAXN], T[MAXN];

int main() {
  int H, W, N;
  int sx, sy;
  scanf("%d%d%d", &H, &W, &N);
  scanf("%d%d", &sx, &sy);
  scanf("%s%s", S, T);

  int min_x = 1, max_x = H;
  int min_y = 1, max_y = W;
  bool fail = false;
  for (int i = N - 1; i >= 0; i--) {
    switch (T[i]) {
      case 'L':
        max_y = min(W, max_y + 1);
      break;
      case 'R':
        min_y = max(1, min_y - 1);
      break;
      case 'U':
        max_x = min(H, max_x + 1);
      break;
      case 'D':
        min_x = max(1, min_x - 1);
      break;
    }
    switch (S[i]) {
      case 'L':
        min_y++;
      break;
      case 'R':
        max_y--;
      break;
      case 'U':
        min_x++;
      break;
      case 'D':
        max_x--;
      break;
    }
    if (min_x > max_x || min_y > max_y) {
      fail = true;
      break;
    }
  }

  if (sx < min_x || sx > max_x || sy < min_y || sy > max_y)
    fail = true;

  if (fail)
    puts("NO");
  else
    puts("YES");

  return 0;
}


Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

counter = 0
S= input()
T= input()

for i in range(3):
    if S[i] == T[i]:
        counter +=1

print(counter)


Measured memory_bytes: 3060
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = []
for i in range(m - 1):
    d.append(x[i + 1] - x[i])
d.sort(reverse=True)
print(x[-1] - x[0] - sum(d[:n - 1]))

Measured memory_bytes: 13960
n = int(input())

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0

for i in range(0, n):
  s = input()
  if s == 'AC':
    ac_count += 1
  elif s == 'WA':
    wa_count += 1
  elif s == 'TLE':
    tle_count += 1
  else:
    re_count += 1

print('AC x ' + str(ac_count))
print('WA x ' + str(wa_count))
print('TLE x ' + str(tle_count))
print('RE x ' + str(re_count))

Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
   int n=0,i=0;
   char s[4];

   scanf("%s",s);

   while(s[i]!='\0'){
      if(s[i]=='+')      n++;
      else if(s[i]=='-') n--;
      i++;
   }
   printf("%d",n);

   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,m,h[100005],a,b,ans=0;
    bool c[100005]={};
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        if(h[a]>h[b]){
            c[b]=true;
        }
        else if(h[a]<h[b]){
            c[a]=true;
        }
        else{
            c[a]=true;
            c[b]=true;
        }
    }
    for(int i=0;i<n;i++){
        if(!c[i])
            ans++;
    }
    cout<<ans<<endl;
    return(0); 
}


Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

int m = 0;

rrep(i,N) {
    int cnt = 0;
    int A = i;
    while(A%2 == 0) {
        A/= 2;
        cnt++;
    }
    m = max(m,cnt);
}

cout << pow(2,m) << endl;

return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

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



Measured memory_bytes: 26568
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 r, d;
  i64 x;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi64, &r, &d, &x);
  for (i32 i = 1; i <= 10; ++i) {
    x = r * x - d;
    printf ("%" PRIi64 "\n", x);
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 128
package main
import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  
  b := false
  for a:=1; a<10; a++ {
    if n % a == 0 {
      k := n / a
    	for i:=1; i<10; i++ {
          if k == i {
        		b = true
     	 }
   	 }
  	}
  }
  switch b{
    case true:
    fmt.Println("Yes")
    default:
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}

ll get(string &s){
    return (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
}

void __sol(){
    string b; ll a;
    cin >> a >> b;
    cout << (a*get(b))/100;
    
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define NMAX (100000)
int prime[NMAX + 1];
int ans[NMAX];

int main()
{
	int Q, l, r;

	rep(i, NMAX + 1) prime[i] = 1;
	prime[0] = 0;
	prime[1] = 0;

	repc(i, 2, NMAX) {
		if (prime[i] == 0) continue;

		for (int j = i * 2; j <= NMAX; j += i) {
			prime[j] = 0;
		}
	}

	rrepc(i, NMAX, 3) {
		if (prime[i] == 1 && prime[(i + 1) / 2] != 1) prime[i] = 0;
	}

	prime[2] = 0;

	repc(i, 2, NMAX - 1) prime[i + 1] += prime[i];

	cin >> Q;

	rep(i, Q) {
		cin >> l >> r;
		ans[i] = prime[r] - prime[l - 1];
	}

	rep(i, Q) cout << ans[i] << '\n';

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(1005, vector<char>(1005, ' '));
    queue<pii> q;
    vvi dist(1005, vi(1005, -1));

    rep(i, H) {
        rep(j, W) {
            cin >> s[i + 1][j + 1];
            if (s[i + 1][j + 1] == '#') {
                dist[i + 1][j + 1] = 0;
                q.push(mp(i + 1, j + 1));
            }
        }
    }
    int ans = 0;

    while (!q.empty()) {
        pii P = q.front(); q.pop();
        int x, y; tie(x, y) = P;
        ans = max(ans, dist[x][y]);

        rep(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx <= 0 || nx > H || ny <= 0 ||
                    ny > W || s[nx][ny] != '.' || dist[nx][ny] != -1) {
                continue;
            }
            else {
                dist[nx][ny] = dist[x][y] + 1;
                q.push(mp(nx, ny));
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 13456
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

// Int dp[1<<20], dp2[1<<20];

int main() {
  Int N = lin();
  Int A = lin();
  const Int LIM = 1<<20;

  // dp[1] = 0;
  // for (int x = 1; x < LIM; ++x) {
  //   for (int xx = x + x, k = 2; xx < LIM; ++k, xx += x) {
  //     chmin(dp[xx], dp[x] + k + A);
  //   }
  // }

  // Int res = INFLL;
  // for (int x = 1; x < LIM; ++x) {
  //   chmin(res, dp[x] + (N + x - 1) / x);
  // }

  Int res = N;
  for (int x = 2; x < LIM; ++x) {
    chmin(res, x + A + (N + x - 1) / x);
  }
  for (int x = LIM; x >= 1; --x) {
    Int v = (N + x - 1) / x;
    chmin(res, v + A + (N + v - 1) / v);
  }

  for (int as = 2; as <= 40; ++as) {
    Int v = (1LL << as);
    Int ksum = 2 * as;
    vector<int> ks;
    for (int i = 0; i < as; ++i) {
      ks.push_back(2);
    }
    while (true) {
      chmin(res, (N + v - 1) / v + A * as + ksum);
      if (v >= N) {
        break;
      }
      sort(ks.begin(), ks.end());
      v = v / ks[0] * (ks[0] + 1);
      ++ks[0];
      ++ksum;
    }
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

// BinaryTreeNode for alds1_7_B
type BinaryTreeNode struct {
	left   int
	right  int
	parent int
}

func preorder(nodes []BinaryTreeNode, iNode int) {
	if iNode == -1 {
		return
	}
	node := nodes[iNode]
	fmt.Printf(" %v", iNode)
	preorder(nodes, node.left)
	preorder(nodes, node.right)
}

func inorder(nodes []BinaryTreeNode, iNode int) {
	if iNode == -1 {
		return
	}
	node := nodes[iNode]
	inorder(nodes, node.left)
	fmt.Printf(" %v", iNode)
	inorder(nodes, node.right)
}

func postorder(nodes []BinaryTreeNode, iNode int) {
	if iNode == -1 {
		return
	}
	node := nodes[iNode]
	postorder(nodes, node.left)
	postorder(nodes, node.right)
	fmt.Printf(" %v", iNode)
}

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

	nNodes := nextInt()
	nodes := make([]BinaryTreeNode, nNodes)
	for iNode := 0; iNode < nNodes; iNode++ {
		nodes[iNode] = BinaryTreeNode{
			left:   -1,
			right:  -1,
			parent: -1,
		}
	}

	for iNode := 0; iNode < nNodes; iNode++ {
		key := nextInt()
		leftID := nextInt()
		rightID := nextInt()

		nodes[key].left = leftID
		nodes[key].right = rightID
		if leftID != -1 {
			nodes[leftID].parent = key
		}
		if rightID != -1 {
			nodes[rightID].parent = key
		}
	}
	root := 0
	for nodes[root].parent != -1 {
		root = nodes[root].parent
	}
	fmt.Print("Preorder\n")
	preorder(nodes, root)
	fmt.Print("\n")
	fmt.Print("Inorder\n")
	inorder(nodes, root)
	fmt.Print("\n")
	fmt.Print("Postorder\n")
	postorder(nodes, root)
	fmt.Print("\n")
}



Measured memory_bytes: 1140
a=[]
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
N=int(input())
b=[int(input()) for _ in range(N)]

bingo = [[0]*3, [0]*3, [0]*3]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            bingo[i][j]=1

f=False
for i in range(3):
    if sum(bingo[i])==3:
        f=True
    if bingo[0][i]+bingo[1][i]+bingo[2][i] == 3:
        f=True
if bingo[0][0]+bingo[1][1]+bingo[2][2] == 3:
    f=True
if bingo[0][2]+bingo[1][1]+bingo[2][0]==3:
    f=True
if f:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1<<29)
using namespace std;
const int N=505;
char s[N];
int n,cnt[N];
ll ans;
int a[N][N],sum[N][N];
int l[N][N],r[N][N];
int tl[N][N],tr[N][N];
void recalc(int i){
	For(j,1,n) sum[i][j]=sum[i][j-1]+a[i][j];
}
int S(int i,int l,int r){
	return sum[i][r]-(l?sum[i][l-1]:0);
}
int main(){
	scanf("%d",&n);
	For(i,1,n){
		scanf("%s",s+1);
		For(j,1,n) a[i][j]=(s[j]=='#'?0:s[j]-48);
		recalc(i);
	}
	For(i,1,n) For(j,1,n)
		l[i][j]=n+1,r[i][j]=0;
	Rep(x,n,1){
		For(i,1,n) For(j,1,n)
			tl[i][j]=n+1,tr[i][j]=0;
		For(y,x,n)
			if (y==x){
				Rep(j,n,1) if(a[y][j]){
					tl[y][j]=j;
					tr[y][j]=max(j,j==n?0:tr[y][j+1]);
					ans+=1ll*a[y][j]*S(y,tl[y][j]+1,tr[y][j]);
				}
			}
			else{
				Rep(j,n,1) if (a[x][j]){
					tl[y][j]=min(l[y][j],j==n?n+1:tl[y][j+1]);
					tr[y][j]=max(r[y][j],j==n?0:tr[y][j+1]);
				}
				For(j,1,n) cnt[j]=0;
				For(j,1,n) if (tl[y][j]<=tr[y][j]){
					++cnt[tl[y][j]];
					--cnt[tr[y][j]+1];
				}
				bool flag=0;
				For(j,1,n){
					cnt[j]+=cnt[j-1];
					if (!cnt[j]&&a[y][j])
						a[y][j]=0,flag=1;
				}
				if (flag) recalc(y);
				For(j,1,n)
					if (tl[y][j]<=tr[y][j])
						ans+=1ll*a[x][j]*S(y,tl[y][j],tr[y][j]);
			}
		For(i,1,n) For(j,1,n)
			l[i][j]=tl[i][j],r[i][j]=tr[i][j];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6144
#include <stdio.h>
#define SIZE 2001
 
char resultTable[SIZE];
int n,q,elems[20];
 
void calc(int sum,int index){
    if(index == n){
        if(sum >= 1 && sum <= 2000){
            resultTable[sum] = 'y';
        }
    }else{
        calc(sum+elems[index],index+1);
        calc(sum,index+1);
    }
}
 
int main(){
 
    for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';
 
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
    calc(0,0);
 
    scanf("%d",&q);
 
    int tmp;
    for(int i = 0; i < q; i++){
        scanf("%d",&tmp);
        if(resultTable[tmp] == 'y'){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}


Measured memory_bytes: 2676
def main():
  n,k,*t=map(int,open(0).read().split())
  e=tuple(set()for _ in[0]*n)
  for a,b in zip(t[::2],t[1::2]):
    e[a-1].add(b-1)
    e[b-1].add(a-1)
  c,q=k,[0]
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w].discard(v)
      q+=w,
      i+=1
  print(c)
main()

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double X = 0;
  P ans = P(100*a, 0);
  for(int i = 0; i*100*a <= f; ++i) {
    for(int j = 0; i*100*a + j*100*b <= f; ++j) {
      for(int x = 0; x*c <= (i*a+j*b)*e; ++x) {
        for(int y = 0; x*c + y*d <= (i*a+j*b)*e; ++y) {
          if(i*100*a + j*100*b + x*c + y*d > f) break;
          int fir = i*100*a + j*100*b, sec = x*c + y*d;
          if((fir+sec)*ans.second < sec*(ans.first+ans.second)) ans = P(fir, sec);
        }
      }
    }
  }
  cout << ans.first+ans.second<< " " << ans.second << endl;
}


Measured memory_bytes: 3592
n,w = map(int,input().split())
dp = [[0 for x in range(w+1)] for x in range(n+1)]
array = [[int(x) for x in input().split()] for x in range(n)]
for i in range(1,w+1):
    for j in range(1,n+1):
        if(array[j-1][0] > i):
            dp[j][i] = dp[j-1][i]
        else:
            if(dp[j-1][i] < dp[j-1][i-array[j-1][0]] + array[j-1][1]):
                dp[j][i] = dp[j-1][i-array[j-1][0]] + array[j-1][1]
            else:
                dp[j][i] = dp[j-1][i]
print(dp[-1][-1])


Measured memory_bytes: 171656
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
kaidan=[1]*(n+3)
gyaku=[1]*(n+3)
for i in range(n+2):
    kaidan[i+1]=(i+1)*kaidan[i]%mod
for i in range(n+2):
    gyaku[i+1]=pow(kaidan[i+1], mod-2,mod)
def comb(n,r):
    if r>=0 and n-r>=0:
        return kaidan[n]*gyaku[n-r]*gyaku[r]%mod
    else:
        return 0
A.sort()
R=list(reversed(A))
ans=0
for i in range(n-k+1):
    ans-=A[i]*comb(n-1-i,k-1)
    ans+=R[i]*comb(n-1-i,k-1)
print(ans%mod)

Measured memory_bytes: 15736
#include <iostream>

using namespace std;

int main()
{
    int a;
    int sum = 0;
    cin >> a;
    for (int i = 1 ; i <= a ; i++){
        for (int j = 1 ; j <= i ; j++){
            if (i % 2 == 1){
                if (j % 2 == 0){
                    sum++;
                }
            }else if (j % 2 == 1){
                sum++;
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3552
def solve():
    P.sort(reverse = True)
    M.sort()
    P.append(-1)
    M.append(1) # add endpoint
    p, m = [], []
    while len(p) + len(m) < k:
        if P[len(p)] < -M[len(m)]:
            m.append(M[len(m)])
        else:
            p.append(P[len(p)])
    if len(m)%2 == 0: return p + m

    exist_p = len(p) > 0
    exist_m = len(m) > 0
    remain_P = len(P) - 1 > len(p)
    remain_M = len(M) - 1 > len(m)
    if exist_p & remain_M & exist_m & remain_P:
        if abs(p[-1] * P[len(p)]) < abs(m[-1] * M[len(m)]):
            p.pop()
            m.append(M[len(m)])
        else:
            m.pop()
            p.append(P[len(p)])
    elif exist_p & remain_M:
        p.pop()
        m.append(M[len(m)])
    elif exist_m & remain_P:
        m.pop()
        p.append(P[len(p)])
    else:
        M.pop() # del endpoint
        m = sorted(M, reverse = True)[:k]
    return p + m

n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


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

typedef long double ld;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

ld n, d, x, ans;

int main() {
	n = read();
	d = read();
	x = read();
	while(n) {
		ans += d+(n*2-1)*x*0.5;
		d = (d*(n+1)+2.5*x)/n;
		x = x*(n+2)/n;
		n--;
	}
	printf("%.15LF\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        cout << 180 * (n - 2) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
// Problem : C - Multiple Gift
// Contest : AtCoder - AtCoder Beginner Contest 083
// URL : https://atcoder.jp/contests/abc083/tasks/arc088_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int x,y;cin>>x>>y;
	int cnt=0;
	while(x<=y)
	{
		cnt++;
		x*=2;
	}
	cout<<cnt;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3688
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        PriorityQueue queue = new PriorityQueue(Collections.reverseOrder());

        for (int i = 0; i < n; i++) {
            queue.add(sc.nextInt());
        }

        for (int i = 0; i < m; i++) {
            queue.add((int) queue.poll() / 2);
        }

        long answer = 0;
        for (int i = 0; i < n; i++) {
            answer += (int) queue.poll();
        }

        System.out.println(answer);

    }
}


Measured memory_bytes: 58440
n = int(input())

def mod_k_n(k,n,default):
    r = []
    j = k
    while n > 1:
        if n % 2 == 1:
            r.append(j)
            n -= 1
        j = (j ** 2) % (10 ** 9 + 7)
        n = n // 2
    else:
        r.append(j)
        for s in r:
            default = (default * s) % (10 ** 9 + 7)
    return default
if n == 1:
  print(0)
else:
  ans = mod_k_n(10,n,1) - mod_k_n(9,n,2) + mod_k_n(8,n,1) + (10 ** 9 + 7)
  print(ans%(10 ** 9 + 7))


Measured memory_bytes: 9088
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <random>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main () {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b;
    
    cout << (a%2==0 || b%2==0 ?"No":"Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
typedef pair<int,int> P;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool start_flag,color_flag;
char table[50][50];
char color;
bool flag_table[50][50];
int w,h;
queue<char> tmp;
queue<P> que;
void dfs(int y, int x){
    que.push(P(y,x));    
    flag_table[y][x] = true;
    if(start_flag == true) color = tmp.front();
    rep(i,4){
        int ny = y+dy[i];
        int nx = x+dx[i];
        if(ny < 0 || nx < 0 || ny >= h || nx >= w || flag_table[ny][nx] == true) continue;
        if(start_flag == false && table[ny][nx] != '.'){
            start_flag = true;
            color = table[ny][nx];
            tmp.push(color);
        }
        else if(start_flag == true && table[ny][nx] != color && table[ny][nx] != '.'){
            color_flag = true;
        }
        if(table[ny][nx] == '.')  dfs(ny,nx);
    }
}
int main(){
    while(cin >> w >> h){
        if(h == 0 && w == 0) break;
        rep(i,h) rep(j,w) cin >> table[i][j];
        int cnt_black = 0;
        int cnt_white = 0;
        rep(i,h) rep(j,w) flag_table[i][j] = false;
        while(!que.empty()) que.pop();
        while(!tmp.empty()) tmp.pop();
        rep(i,h){
            rep(j,w){
                start_flag = false;
                color_flag = false;
                color = '.';
                if(table[i][j] != '.' || flag_table[i][j] == true) continue;
                dfs(i,j);
                if(color_flag == false){
                    while(!que.empty()){
                        pair<int,int> pi = que.front();
                        que.pop();
                        table[pi.first][pi.second] = color;
                        if(color == 'B') cnt_black++;
                        if(color == 'W') cnt_white++;
                    }
                }
                while(!que.empty()) que.pop();
                while(!tmp.empty()) tmp.pop();
            }
        }
        cout << cnt_black << " " << cnt_white << endl;
    }
    return 0;
}


Measured memory_bytes: 3368
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int change(string s){
    int x = 0;
    int ten = 1;
    rep(i,8){
        x+= ten * (s[7-i] - '0');
        ten *= 10;
    }
    return x;
}

int main(){
    int n;
    string s;

    cin >> n;
    rep(i,n){
        cin >> s;
        sort(s.begin(), s.end(), greater<char>());
        int big = change(s);
        sort(s.begin(), s.end());
        int small = change(s);
        cout << big - small << endl;
    }
}

Measured memory_bytes: 1224
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()
a = [0]*n
b = [0]*n
c = [0]*n

for i in range(n-1):
        if s[i] == 'W':
                a[i+1] += 1

for i in range(n-1,0,-1):
        if s[i] == 'E':
                b[i-1] += 1

for i in range(1, n):
        a[i] += a[i-1]

for i in range(n-2,-1,-1):
        b[i] += b[i+1]

ans = min(a[i]+b[i] for i in range(n))
print(ans)

Measured memory_bytes: 36160
#include <iostream>
#include <math.h>
#include <float.h>
using namespace std;
int main() {
  int A,B;
  cin>>A>>B;
  float minA,minB,maxA,maxB,ans;
  minA=A*12.5;
  maxA=(A+1)*12.5;
  minB=B*10;
  maxB=(B+1)*10;
  if(maxA<=minB|minA>=maxB){
    cout<<-1;
 }else{
  ans=ceil(max(minA,minB));
  cout<<ans;
  
  }
}

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

int main(int argc, char **argv)
{
	int N;
	scanf("%d", &N);
	uint64_t *a = malloc(sizeof(uint64_t) * N);
	for (int i = 0; i < N; i++)
		scanf("%ld", &a[i]);
	uint64_t sum = 0;
	int sz[60] = {0};
	int so[60] = {0};
	for (int b = 0; b < 60; b++) {
		uint64_t c = (uint64_t)1 << b;
		for (int i = 0; i < N; i++) {
			if (a[i] & c)
				++so[b];
			else
				++sz[b];
		}
		fprintf(stderr, "%d: %d %d\n", b, sz[b], so[b]);
		if (sz[b] && so[b]) {
			sum += ((((c % 1000000007) * sz[b]) % 1000000007) * so[b]) % 1000000007;
		}
	}
	printf("%ld\n", sum % 1000000007);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a=1,b=1,c=1;
	for(register int i=0;i<=2;i++)
		if(s[i]=='a')  a--;
		else if(s[i]=='b')  b--;
		else if(s[i]=='c')  c--;
	if(a==0 && b==0 && c==0)  cout<<"Yes";
	else  cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
int main(){
    int n,m;
    std::cin>>n>>m;
    std::vector<int> g[n+1];
    std::queue<int> bfs;
    int b[n+1];
    int store[n+1];
    for(int i=0;i<=n;++i){
        b[i]=0;
    }
    for(int i=0;i<m;++i){
        int t1,t2;
        std::cin>>t1>>t2;
        g[t1].push_back(t2);
        g[t2].push_back(t1);
    }
    bfs.push(1);
    while(!bfs.empty()){
        int temp=bfs.front();
        for(int i=0;i<g[temp].size();++i){
            int hello=g[temp][i];
            if(!b[hello]){
                b[hello]=1;
                bfs.push(hello);
                store[hello]=temp;
            }
        }
        bfs.pop();
    }
    for(int i=2;i<=n;++i){
        if(!b[i]){
            std::cout<<"No"<<std::endl;
            return 0;
        }
    }
    std::cout<<"Yes"<<std::endl;
    for(int i=2;i<=n;++i){
        std::cout<<store[i]<<std::endl;
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    
    vector<ll> p(A);
    vector<ll> q(B);
    vector<ll> r(C);

    REP(i, A){
        cin >> p[i];
    }
    REP(i, B){
        cin >> q[i];
    }
    REP(i, C){
        cin >> r[i];
    }

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    vector<ll> S(X+Y);
    for(ll i=0; i<X; i++){
        S[i] = p[i];
    }
    for(ll i=0; i<Y; i++){
        S[X+i] = q[i];
    }
    sort(S.begin(), S.end());

    // REP(i, X+Y){
    //     cout << S[i] << endl;
    // }

    for(ll i=0; i<min(X+Y,C); i++){
        if(S[i] < r[i]){
            S[i] = r[i];
        }
    }
    ll ans = 0;
    for(ll i=0; i<X+Y; i++){
        ans += S[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Perform BFS from 2...N then use those values to print
	//Things learned: Strings = SLOW; Only time spent for such questions is printing 
	//(maybe use print writer) CASH MONEY BABY!!!

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = input.nextInt();
		int M = input.nextInt();
		ArrayList<Integer>[] graph = new ArrayList[N+1];
		for (int i = 1; i<=N; i++) {
			graph[i]=new ArrayList<Integer>();
		}
		for (int i = 0; i < M; i++) {
			int A = input.nextInt();
			int B = input.nextInt();
			graph[A].add(B);
			graph[B].add(A);
		}
		int[] ans = BFS(graph);
		boolean bad = false;
		for (int i = 2; i <= N; i++) {
			if (ans[i]==0) {
				bad=true;
				break;
			}
		}
		if (bad) {
			out.println("No");
			out.flush();
		}
		else {
			out.println("Yes");
			out.flush();
			for (int i = 2; i <= N; i++) {
				out.println(ans[i]);
				out.flush();
			}
		}
	}	
	public static int[] BFS(ArrayList<Integer>[] graph) {
		int[] ans = new int[graph.length];
		boolean[] vis = new boolean[graph.length];
		Queue<Integer> cur = new LinkedList<Integer>();
		cur.add(1);
		while (!cur.isEmpty()) {
			int size = cur.size();
			for (int i = 0; i < size; i++) {
				int curSTART = cur.poll();
				for (int j = 0; j < graph[curSTART].size(); j++) {
					if (!vis[graph[curSTART].get(j)]) {
						ans[graph[curSTART].get(j)]=curSTART;
						vis[graph[curSTART].get(j)]=true;
						cur.add(graph[curSTART].get(j));
					}
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 66780
N = int(input())
t,a = map(int,input().split())
high = list(map(int,input().split()))
def temp(h):
    return t - h*0.006

ans = 0
min = 10**10
for i in range(N):
    if min > abs(a-temp(high[i])):
        ans = i
        min = abs(a-temp(high[i]))
print(ans+1)

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys

def solve(a, b):
    return str(a) * b if a < b else str(b) * a

def main():
    a, b = [int(s) for s in sys.stdin.readline().split()]

    ans = solve(a, b)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
  int k, n, a[200000], max;

  scanf("%d%d", &k, &n);
  for(int i=0;i<n;i++)
    scanf("%d", &a[i]);
  max=k-a[n-1]+a[0];
  for(int i=0;i<n-1;i++){
    if(max<a[i+1]-a[i])
      max=a[i+1]-a[i];
  }
  printf("%d", k-max);

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

#define MAX_H 70
#define MAX_W 70

int h, w;
string field[MAX_H];
string cache[MAX_H][MAX_W];

bool non_zero(char c) {
    return (isdigit(c) && c != '0');
}

bool non_zero(string s) {
    if (s.empty() || s[0] == '0') return false;
    for (string::iterator si = s.begin(); si != s.end(); si++) {
        if (! isdigit(*si) ) {
            return false;
        }
    }
    return true;
}

bool bigger(string a, string b) {
    if (a.size() > b.size()) return true;
    if (a.size() < b.size()) return false;
    else return (a>b);
}

int main() {
    while (cin >> w >> h) {
        if (w == 0 && h == 0) break;
        for (int i = 0; i < h; i++) {
            cin >> field[i];
            for (int j = 0; j < w; j++) {
                if (non_zero(field[i][j])) {
                    cache[i][j] = field[i][j];
                } else {
                    cache[i][j] = "";
                }
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (isdigit(field[i][j])) {
                    string u, l;
                    if (1 <= i && i < h && non_zero(cache[i-1][j])) {
                        u = cache[i-1][j] + field[i][j];
                        if (!bigger(cache[i][j], u)) {
                            cache[i][j] = u;
                        }
                    }
                    if (1 <= j && j < w && non_zero(cache[i][j-1])) {
                        l = cache[i][j-1] + field[i][j];
                        if (!bigger(cache[i][j], l)) {
                            cache[i][j] = l;
                        }
                    }
                }
            }
        }

        string biggest = "";
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
//                if (cache[i][j] == "") {
//                    cout << 0 << ' ';
//                } else {
//                    cout << cache[i][j] << ' ';
//                }
                if (bigger(cache[i][j], biggest)) {
                    biggest = cache[i][j];
                }
            }
//            cout << endl;
        }

//        for (int i = 0; i < h; i++) {
//            for (int j = 0; j < w; j++) {
//                cout << field[i][j] << ' ';
//            }
//            cout << endl;
//        }

        cout << biggest << endl;
    }
    return 0;
}

    

Measured memory_bytes: 1056
import scala.io.Source

object Main extends App {
  val lines: List[List[Int]] = Source.stdin.getLines.toList.init.map(_.split(" ").toList.map(_.toInt))

  val tupList: List[(Int, String)] = lines.map { line => (line(0), "#"*line(1)) }

  def print = {
    for {
      tup <- tupList
      i <- (0 to tup._1).toList.reverse
    } yield { if (i == 0) println()
             else println(tup._2) }
  }

  print

}

Measured memory_bytes: 44364
S = input()

# 逆順にする
S = S[::-1]

# 黒石より右にある白石の数だけ操作可能
ans = 0
white = 0
for i in range(len(S)):
    if S[i]=="B":
        ans += white
    else:
        white += 1

print(ans)

Measured memory_bytes: 3500