akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
input:
5
1 2 3 4 5
3 2 4 1 5

output:
3 4 2 5 1
"""

import sys


# recursively defines a binary tree
# node.left or node.right may also be a binary tree
class TreeNode:
    __slots__ = ('val', 'left', 'right')

    def __init__(self, val):
        self.val = val
        self.left, self.right = None, None


def rec(pre_order, in_order, post_order):
    if not pre_order:
        return None, list()
    else:
        rt = TreeNode(pre_order[0])
        rt_pos = in_order.index(pre_order[0])
        rt.left = rec(pre_order[1:1 + rt_pos], in_order[:rt_pos], post_order)
        rt.right = rec(pre_order[rt_pos + 1:], in_order[rt_pos + 1:], post_order)

        # append rt.val at last to implement post_order node scan
        post_order.append(rt.val)
        return rt, post_order


def solve():
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    pre_order = list(map(int, _input[1].split()))
    in_order = list(map(int, _input[2].split()))
    # assert len(pre_order) == len(in_order) == array_length
    
    post_order = list()
    ans = rec(pre_order=pre_order, in_order=in_order, post_order=post_order)
    print(*ans[1])
    return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 7716
from itertools import accumulate
H, W, K = map(int, input().split())
squares = [list(input()) for _ in range(H)]
# black_squares = []
# for i in range(H):
#     accumrated_list = []
#     for j, color in enumerate(list(input())):
#         if color == '#':
#             accumrated_list.append(1)
#         else:
#             accumrated_list.append(0)
#     accumrated_list = list(accumulate(accumrated_list))
#     black_squares.append(accumrated_list)
# print(black_squares)
# black_count = 0
# for i in range(H):
#     black_count += black_squares[i][W - 1]

# print(black_count)
# 2,3のエリアで、
# 消すところが0,0の場合、1,1から
ans = 0
for hs in range(1 << H):
    for ws in range(1 << W):
        # ここまででどの行と列を使うかが決まる。
        # 使用する行と列に含まれる黒の数をカウントする
        count = 0
        for i in range(H):
            for k in range(W):
                if hs >> i & 1 and ws >> k & 1:
                    # そこは使うのでカウントする
                    # print(hs >> i, ws >> k)
                    if squares[i][k] == '#':
                        count += 1
        if count == K:
            ans += 1
print(ans)


Measured memory_bytes: 68588
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    int n = a % 100;
    if (n >= 10) n = n % 10;
    string result;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        result = "hon";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        result = "pon";
    } else {
        result = "bon";
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> A(n), B(n);
  ll biga = 0, bigb = 0;
  rep(i, n) cin >> A[i];
  rep(i,n)  cin >> B[i];
  rep(i,n){
    if(A[i] > B[i]) biga += A[i] - B[i];
    if(B[i] > A[i]) bigb += (B[i] - A[i])/2;
  }
  if(bigb >= biga) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;
  int mx = 0;
  int s = 0;
  rep(i,k){
    s += p[i];
  }
  mx = s;
  int j=0;
  repi(i,k,n){
    s+=p[i];
    s-=p[j];
    mx = max(mx,s);
    j++;
  }
  double ans = mx;
  ans/=2;
  printf("%.10f\n",ans);
  return 0;
  
}

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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);
    int N; cin >> N;
    int ans = 2; 
    if (N%2 == 0) ans = N;
    else ans = N*2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  input = input.trim().split('\n')
  const [N, M, K] = input[0].split(' ').map(BigInt)
  const booksA = input[1].split(' ').map(BigInt)
  const booksB = input[2].split(' ').map(BigInt)

  let currentSum = 0n
  const maxB = []
  for (let i = 0; i < booksB.length; i++) {
    currentSum += booksB[i]
    maxB.push(booksB[i])

    if (currentSum > K) {
      currentSum -= maxB.pop()
      break
    }
  }

  let ans = maxB.length

  let A_sum = 0n
  const Alist = []
  for (let i = 0; i < booksA.length; i++) {
    A_sum += booksA[i]
    Alist.push(booksA[i])

    while (A_sum + currentSum > K && maxB.length) currentSum -= maxB.pop()
    if (A_sum + currentSum > K) break

    ans = Math.max(ans, Alist.length + maxB.length)
  }

  return console.log(ans)
}


process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 96592
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<set>
#include<vector>

using namespace std;
vector <string> S;

int main()
{
    int i,j;
    string::size_type lens,lent;
    string s,t;
    cin>>s;
    cin>>t;
    lens=s.size();
    lent=t.size();
    for(i=0;i<lens;++i)
    {
        if(s[i]=='?'||s[i]==t[0])
        {
           string temp=s;
            for(j=0;j<i;++j)
            {
                if(temp[j]=='?')
                    temp[j]='a';
            }
             bool flag=false;
        for(j=0;j<lent;++j)
        {
            if((temp[i+j]!='?'&&temp[i+j]!=t[j]))break;
            temp[i+j]=t[j];
            if(j==lent-1)
            {
                flag=true;
            }
        }
        if(flag)
        {
            for(j=i+lent;j<lens;++j)
            {
                if(temp[j]=='?')temp[j]='a';
            }
            S.push_back(temp);
        }
        }
    }
    sort(S.begin(),S.end());
    if(S.size()==0)cout<<"UNRESTORABLE"<<endl;
    else cout<<*S.begin()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x,a,b,c,ans;
	scanf("%d",&x);
	getchar();
	scanf("%d",&a);
	getchar();
	scanf("%d",&b);
	c = x - a;
	ans = c % b;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	char x=toupper(a[0]),y=toupper(b[0]),z=toupper(c[0]);
	cout<<x<<y<<z<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(b >= a)
	{
		printf("%d\n",a);
	}
	else
	{
		printf("%d\n",a - 1);
	}
	return 0;
}

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

int main() {
	string W, S;
	int count = 0;
	cin >> W;
	for (int i = 0; i < W.size(); i++) {
        if (65 <= W[i] && W[i] <= 90) W[i] += 32;
	}
	while (1) {
		cin >> S;
		if (S == "END_OF_TEXT") break;
		for (int i = 0; i < S.size(); i++) {
		    if (65 <= S[i] && S[i] <= 90) S[i] += 32;
		}
		if (S == W) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3176
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<bool> mp(1000005, 0);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (mp[a[i]]) continue;
		for (int j = a[i]; j < 1000005; j += a[i]) {
			mp[j] = true;
		}
		if (i > 1) {
			if (a[i] == a[i - 1]) continue;
		}
		if (i < n - 1) {
			if (a[i] == a[i + 1]) continue;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4320
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll N;
    cin>>N;
    v A(N);
    rep(i,0,N)cin>>A[i];
    ll n4 = 0, n2 = 0;
    rep(i,0,N){
        if(A[i] % 4 == 0)n4++;
        else if(A[i] % 2 == 0) n2++; 
    }
    N-=n4*2;
    YN(N <= n2 || (N <= 1 && n4 >= 1));
    return 0;
}

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

int main(){

 int n, x, c;

 while(1) {
  cin >> n >> x;
  if (n == 0 && x == 0) break;

  c = 0;

  for (int i = 1; i < n - 1; i++) {
   for (int j = i + 1; j < n; j++) {
    for (int k = j + 1; k <= n; k++) {
     if (x == i + j + k) c++;
    }
   }
  }

  cout << c << endl;
 }
 
 return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int main(){
    string s;
    cin>>s;
    long long k;
    cin>>k;
    if(s[0]!='1'){
      cout<<s[0]<<endl;
      return 0;
    }
    if(s[0]=='1'){
      if(k==1){
        cout<<1<<endl;
        return 0;
      }
      for(long long i=1;i<s.size();i++){
      if(s[i]!='1'){
        cout<<s[i]<<endl;
        return 0;
      }
      else if(s[i]=='1'){
        if(k-1==i){
          cout<<1<<endl;
          return 0;
        }
      }
      }
    }
    return 0;
}


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

using namespace std;

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

    int f=0;

    for(int i=0; c[i]; i++)
    {

        if((i+1)%2==0)
        {
            if(c[i]=='L' || c[i]=='U' ||c[i]=='D')
                f=0;
            else
            {
                f=1;
                break;
            }

        }
        else
        {
            if(c[i]=='R' || c[i]=='U' ||c[i]=='D')
                f=0;
            else
            {
                f=1;
                break;
            }

        }

    }
    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




}


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


int main(){
    cout << fixed << setprecision(20);
    long long N;
    cin >> N;

    vector<long long> L(87);

    for(int i=0; i<N+1;i++){
    	if (i==0){
    		L[0]=2;
  		}else if (i==1){
    		L[1]=1;
  		}else{
    		L[i]=L[i-1]+L[i-2];
  		}
    }

    cout << L[N] << endl;
    
    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())

ans = round(n * 100 / 108)
# print(ans)

if n == math.floor(ans * 1.08):
  print(ans)
elif n == math.floor((ans-1) * 1.08):
  print(ans-1)
elif n == math.floor((ans+1) * 1.08):
  print(ans+1)
else:
  print(':(')

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

string S;

int atgc(string s) {
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') {
      return 0;
    }
  }
  return n;
}

void abc132b() {
  int n = S.size();
  int res = 0;
  string str;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) {
      str = S.substr(i, j);
      res = (res < atgc(str)) ? atgc(str) : res;
    }
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> S;
  abc132b();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <set>
using namespace std;

long long l(long long n, long long m){
    if(n < m) swap(n, m);
    if(n % m == 0) return m;
    else return l(m, n%m); 
}

long long g(long long n, long long m){
    long long ll = l(n, m);
    return n * m / ll;
}

int main(){
	long long n, m;
    string s, t;
    long long ll, gg, n_, m_;
    cin >> n >> m >> s >> t;
    
	ll = l(n, m);
    gg = g(n, m);
    n_ = n / ll;
    m_ = m / ll;

    for(long long i=0;i<ll;i++){
        if(s[i*n_] != t[i*m_]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << gg << endl;
	
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int main () {
	make3(a, b, c);
	int ans = min(a+b+1, c);
	printf("%d\n", ans + b);
}


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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int MOD = 1000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const ll INF = MOD;
const int N = 105, V = 100005;
int n, ww;
ll dp[V], v[N], w[N];

int main()
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);
	cout.precision(10);

	cin >> n >> ww;

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

	for(int i = 0; i < V; i++)
		dp[i] = INF;

	dp[0] = 0;

	for(int i = 0; i < n; i++)
	{
		for(int j = V - 1; j >= v[i]; j--)
			dp[j] = min(dp[j - v[i]] + w[i], dp[j]);
	}

	int ans = 0;
	for(int i = 0; i < V; i++)
		if(dp[i] <= ww) ans = i;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main(){
    int n;
    int h[110];
    map < int,int > mp;
    while (~scanf("%d", &n)) {
        if (!n) break;
        REP(i, n + 1) {
            scanf("%d", &h[i]);
        }

        REP(i, n + 1) {
            mp.clear();
            REP(j, n + 1) {
                if (!j || j == i) continue;
                if (j == i + 1) {
                    if (j == 1) continue;
                    if (mp.find(h[j] - h[j - 2]) == mp.end()) mp[h[j] - h[j - 2]] = 1;
                    else mp[h[j] - h[j - 2]]++;
                } else {
                    if (mp.find(h[j] - h[j - 1]) == mp.end()) mp[h[j] - h[j - 1]] = 1;
                    else mp[h[j] - h[j - 1]]++;
                }
            }
            if (mp.size() == 1) {
                printf("%d\n", h[i]);
                break;
            }
        }
    }

    return 0;
}




Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin>>a>> b >> c;
	if (a <= b && b <= c) {
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c && c <= b) {
		cout << a << " " << c << " " << b << endl;
	}
	else if (b <= c && c <= a) {
		cout << b << " " << c << " " << a << endl;
	}
	else if (b <= a && a <= c) {
		cout << b << " " << a << " " << c << endl;
	}
	else if (c <= b && b <= a) {
		cout << c << " " << b << " " << a << endl;
	}
	else {
		cout << c << " " << a << " " << b << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
"use strict";

const Main = args => {
  const input = args.trim().split("");
  let counter = {};
  input.forEach(e => {
    if (!counter.hasOwnProperty(e)) {
      counter[e] = 1;
    } else {
      counter[e] += 1;
    }
  });

  let result = true;
  Object.keys(counter).forEach(key => {
    if ((counter[key] % 2) !== 0) result = false
  });

  if (result) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main() {
    int n, m;
    while (cin >> n >> m && !(n == 0 && m == 0)) {
        set<int> friends, guests;

        int a[m]; int b[m];
        for (int i=0; i<m; ++i) {
            cin >> a[i] >> b[i];
            if (a[i] == 1) {
                friends.insert(b[i]);
                guests.insert(b[i]);
            }
        }

        for (int i=0; i<m; ++i) {
            if (friends.find(a[i]) != friends.end()) {
                if (b[i] != 1) {
                    guests.insert(b[i]);
                }
            }
            if (friends.find(b[i]) != friends.end()) {
                if (a[i] != 1) {
                    guests.insert(a[i]);
                }
            }
        }
        
        cout << guests.size() << endl;
    }
    return 0;
}

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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
int n, a[N];
int k;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	int g = 0;
	fo(i, n)
		cin >> a[i], g = __gcd(a[i], g);
	fo(i, n)
	{
		ll dif = a[i] - k;
		if(dif % g == 0 && dif >= 0)
			return cout <<  "POSSIBLE", 0;
	}
	cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants
#define INF 1e9

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin


// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  string S;
  cin >> S;
  string year = S.substr(0,4);
  string mon = S.substr(5,2);
  string date = S.substr(8,2);
  dump(year,mon,date);
  int yyyy = atoi(year.c_str());
  int mm = atoi(mon.c_str());
  int dd = atoi(date.c_str());
  if(yyyy<2019) cout << "Heisei" << endl;
  else if (yyyy>2019){
    cout << "TBD" << endl;
  } else {
    if(mm<5) cout << "Heisei" << endl;
    else {
      cout << "TBD" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double a, b;
	cin >> a >> b;
	double c = 0, d = a;
	while (d >= b) {
		d = d - b;
		c++;
	}
	printf("%.10f %.10f %.10f\n", c, d, a / b);
}


Measured memory_bytes: 3192
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections

N=int(input())
A = list(map(int, input().split()))

for i in range(N):
    A[i] = A[i]-i-1

median = statistics.median(A)

ans = 0
for i in range(N):
    ans += abs(A[i]-median)

print(int(ans))

Measured memory_bytes: 35356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int AB = sc.nextInt();
		int BC = sc.nextInt();
		int CA = sc.nextInt();

		int area = AB * BC / 2;

		System.out.println(area);

	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  int i,n,a[100];

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

  for(i = n - 1;i >= 0;--i){
    printf("%d",a[i]);
    if(i != 0){
      printf(" ");
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

//Triangle of Blocks
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean[] tri = new boolean[1000001];
		for(int i=1;i*(i+1)>>1<=1000000;i++){
			tri[i*(i+1)>>1] = true;
		}
		int[] a = new int[1000001];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Arrays.fill(a, -1);
			int sum = 0;
			for(int i=1;i<=n;i++){
				a[i] = sc.nextInt();
				sum+=a[i];
			}
			if(tri[sum]){
				int res = 0;
				int R = n;
				boolean f = false;
				while(res <= 10000){
					f = true;
					for(int i=1;i<=R&&f;i++)f&=i==a[i];
					if(f)break;
					int L = 1;
					for(int i=1;i<=R;i++){
						if(a[i]==1)continue;
						a[L++] = a[i]-1;
					}
					a[L] = R;
					R = L;
					res++;
				}
				if(f){
					System.out.println(res); continue;
				}
			}
			System.out.println(-1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 27848
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	string s;
	cin >> s;
 
	for(int i=0; i<s.length(); i+=2) cout << s.at(i);
	cout << endl;
 
	return 0;
}

Measured memory_bytes: 512
n, a, b = map(int, input().split())
d = b - a
if d % 2 == 0:
  print(d // 2)
else:
  m1 = a - 1 + 1
  m2 = n - b + 1
  if m1 < m2:
    print((b - m1 - 1) // 2 + m1)
  else:
    print((n - a - m2) // 2 + m2)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
#define PI 3.1415926535897932384626433832795028
#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int x_1, y_1, x_2, y_2;
Int n;
Int x[216000], y[216000];
vector<P> nums;
int main(){
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  if(x_1 > x_2){
    swap(x_1, x_2);
    swap(y_1, y_2);
  }
  cin >> n;
  for(int i = 0;i < n;i++)cin >> x[i] >> y[i];

  if(y_1 > y_2){
    y_1 = -y_1;
    y_2 = -y_2;
    for(int i = 0;i < n;i++)y[i] *= -1;
  }

  for(int i = 0;i < n;i++){
    if(x[i] < x_1 || x_2 < x[i])continue;
    if(y[i] < y_1 || y_2 < y[i])continue;
    nums.push_back(P(x[i], y[i]));
  }
  sort(nums.begin(), nums.end());
  vector<int> dp(n, INF);
  for(int i = 0;i < nums.size();i++){
    int val = nums[i].second;
    *upper_bound(dp.begin(), dp.end(), val) = val;
  }
  int cnt = 0;
  while(cnt < n && dp[cnt] != INF)cnt++;
  double ans;
  ans = (x_2 - x_1 + y_2 - y_1) * 100 + cnt * (5 * PI - 20);
  
  if(min(x_2 - x_1,y_2- y_1) + 1 == cnt){
    ans -= 5 * PI - 20;
    ans += 10 * PI - 20;
  }

  printf("%.10lf\n", ans);
  
  return 0;
}

Measured memory_bytes: 9584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[1005], f[1005];
int n;

int main()
{
	while (scanf("%d", &n) == 1) {
		int t, cnt = 0;
		memset(a, 0, sizeof(a));
		memset(f, -1, sizeof(f));
		for (int i = 0; i<n; i++) {
			scanf("%d", &t);
			if (a[t] == 0) {
				a[t] = 1;
				f[cnt++] = t;
			}
		}
		sort(f, f + cnt);
		int ans = 0;
		for (int i = 1; i<cnt; i++) {
			ans += f[i] - f[i - 1];
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
raw_1 = list(map(int, input().split()))
raw_2 = list(map(int, input().split()))
raw_3 = list(map(int, input().split()))
a = [0, 0, 0]
b = [0, 0, 0]

flg = False

while(a[0] <= raw_1[0]):
  for raw in range(len(raw_1)):
    b[raw] = raw_1[raw] - a[0]
  
  a[1] = raw_2[0] - b[0]
  a[2] = raw_3[0] - b[0]  
  # a,b全て求めた

  
  row_list = [raw_1, raw_2, raw_3]
  
  tmp_flg = True
  for num_a in range(3):
    for num_b in range(3):
      if row_list[num_a][num_b] != a[num_a] + b[num_b]:
          tmp_flg = False
          break
  
  if(tmp_flg):
    flg = True
    break
 
  a[0] += 1

  
if(flg):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
N, A, B = list(map(int, input().split()))
ans = 0

def sumCount(n):
    total = 0
    while n > 0:
        total += n % 10
        n //= 10
    return total

for i in range(1, N + 1):
    sum = sumCount(i)
    if sum >= A and sum <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<P,int> PP;
struct edge { int to; int to2; int cost; };
int x[15][15];

signed main() {
	int n, d; cin >> n >> d;
	rep(i, n)rep(j, d)cin >> x[i][j];
	int cnt = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			rep(k, d) {
				sum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			int x = sqrt(sum);
			x *= x;
			if (sum == x)cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::max;

#[fastout]
fn main() {
    input! {
    n: usize,
    f: [[usize; 10]; n],
    p: [[i64; 11]; n],
    }
    let mut ans = std::i64::MIN;
    for i in 1..1 << 10 {
        let mut counts = vec![0; n];
        for j in 0..10 {
                if i & 1 << j > 0 {
                for k in 0..n {
                    if f[k][j] == 1 {
                        counts[k] += 1;
                    }
                }
            }
        }

        ans = max(ans, (0..n).map(|x| p[x][counts[x]]).sum::<i64>());
    }
    println!("{}", ans);
}


Measured memory_bytes: 2112
// AtCoder Beginner Contest 143b
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {

        // Input
        Scanner sc = new Scanner(System.in);

        int kosuu = sc.nextInt();
        int[] arrayOishi = new int[kosuu];
        for ( int i = 0; i < arrayOishi.length; i++ ) {
            arrayOishi[i] = sc.nextInt();
        }

        // Calc
        int result = 0;
        for ( int j = 0; j < kosuu; j++ ) {
           int curTY = arrayOishi[j];
           for ( int k = j + 1; k < kosuu; k++ ) {
              int nextTY = arrayOishi[k];
              result += curTY * nextTY;
           }
        }

        // Output
        System.out.println(result);

        sc.close();
    }
}

Measured memory_bytes: 35648
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    if(A % B === 0) {
        console.log(-1);
        return;
    }
    
    console.log(A);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

A = [0] * N
A[0] = 1
result = []


def dfs(d, n, A):
    # 深さがNを超えるか、数字がMを超えたらreturn
    if d > N or n > M:
        return
    # 深さdの数字にnを入力
    A[d - 1] = n

    # 最深まで値が入ったら総和を計算
    if d == N:
        total = 0
        for i in range(Q):
            ai = abcd[i][0]
            bi = abcd[i][1]
            ci = abcd[i][2]
            di = abcd[i][3]
            if A[bi - 1] - A[ai - 1] == ci:
                total += di
        result.append(total)

    dfs(d + 1, n, A)
    dfs(d, n + 1, A)


dfs(2, 1, A)

print(max(result))

Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    string abc="ABC";
    int cnt=0;
    rep(i,n){
        if(s.substr(i,3)==abc){
            cnt++;
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
/* author ::  ubc_123 */
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
// using namespace boost::multiprecision; //cpp_int a;

#define find_bug(x) cout <<'>' << #x << " : " << x << endl;
#define ff first
#define ss second
#define pf push_front
#define pb push_back
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define pu push
#define in insert
typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD = 1e9+7;
const ll SMOD = 998244353;
const ll N_MAX = 100100;
const ll INF = 1e18;
const ld PI = ld(3.1415926535897932384626433832795);
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rfr(i,n) for(ll i=(n-1);i>=0;i--)
#define frs(i,s,n) for(ll i=s;i<(n);++i)
#define frb(i,s,e) for(ll i=s;i<=(e);++i)
#define frbr(i,e,s) for(ll i=e;i>=(s);i--)
#define mset(m,v) memset(m,v,sizeof(m))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
//-------------------------------------------------------------------------------
ld distance(ld* x ,ld* y ,ll i , ll j)
{
  ld d;
  d = sqrtl((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
  return d;
}

void solve()
{
  ll n;
  cin>>n;
  ld arr[n][2];
  ld xx[n],yy[n];
  fr(i,n)
  {
    ld t1,t2;
    cin>>t1>>t2;
    arr[i][0] = t1;
    arr[i][1] = t2;
    xx[i] = t1;
    yy[i] = t2;
  }
  ld sum = 0;
  frb(i,0,n-2)
  {
    frb(j,i+1,n-1)
    {
      sum = sum + distance(xx,yy,i,j);
    }
  }
  cout<< fixed << setprecision(10) << ld(2)*sum/ld(n) <<endl;
}

signed main()
{  
    // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    ll test = 1;
    // cin>>test;
    fr(i,test)
    {
      // cout << "Case #" << i + 1 << ": ";
      // cout << '>' << "Case #" << i+1 << endl;
      solve();
    }
    return 0;
}           



Measured memory_bytes: 256
#include <stdio.h>

int binarySearch(int);
int s[100000],n;

main(){
  int t[100000];
  int i,j,c=0,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  for(i=0;i<q;i++){
    c+=binarySearch(t[i]);
  }

  printf("%d\n",c);
  return 0;
}

int binarySearch(int key){
  int left,right,mid;

  left=0;
  right=n;
  while(left < right){
    mid=(left + right)/2;
  if(s[mid]==key) return 1;
  else if( key < s[mid]) right=mid;
  else left = mid + 1;  
  }
  return 0;
}
  

Measured memory_bytes: 1188
s = input()
n = len(s)
p1 = [0 for _ in range(n)]
p2 = p1.copy()
for i in range(n):
    if i % 2 == 1: p1[i] = 1
    else: p2[i] = 1
ans1, ans2 = 0, 0
for i in range(n):
    if int(s[i]) != p1[i]: ans1 += 1
    else: ans2 += 1
print(ans1) if ans1 < ans2 else print(ans2)


Measured memory_bytes: 4724
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

typedef long long ll;
typedef std::tuple<int,int> T;

const int INF = 1001001001, MAX_N = 200000;

class SegmentTree{
public:
    SegmentTree(){}
    void init(const std::vector<T>& v, const int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        
        REP(i, size*2-1){
            seg1[i] = INF;
            seg2[i] = -INF;
        }
        REP(i, v.size()){
            update(i, std::get<1>(v[i]));
        }
    }
    void update(int k, int v){
        k += size - 1;
        seg1[k] = v;
        seg2[k] = v;
        
        while(k > 0){
            k = (k-1) / 2;
            seg1[k] = std::min(seg1[k*2+1], seg1[k*2+2]);
            seg2[k] = std::max(seg2[k*2+1], seg2[k*2+2]);
        }
    }
    int queryMin(int l, int r){
        return _queryMin(l, r, 0, 0, size);
    }
    int queryMax(int l, int r){
        return _queryMax(l, r, 0, 0, size);
    }
private:
    int _queryMax(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return -INF;}
        if(a <= l && r <= b){return seg2[k];}
        return std::max(_queryMax(a, b, 2*k+1, l, (l+r)/2),
                        _queryMax(a, b, 2*k+2, (l+r)/2, r));
    }
    int _queryMin(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return INF;}
        if(a <= l && r <= b){return seg1[k];}
        return std::min(_queryMin(a, b, 2*k+1, l, (l+r)/2),
                        _queryMin(a, b, 2*k+2, (l+r)/2, r));
    }
    int seg1[MAX_N*4], seg2[MAX_N*4], size;
};

int N, d;
std::vector<T> xs, ys;
SegmentTree xt, yt;

ll f(const int b, const std::vector<T>& v, SegmentTree& t){
    int lb = std::lower_bound(v.begin(), v.end(), std::make_tuple(b, -1)) - v.begin(),
        ub = std::upper_bound(v.begin(), v.end(), std::make_tuple(b+d, INF)) - v.begin();
    return t.queryMax(lb, ub) - t.queryMin(lb, ub);
}

int main(){
    scanf("%d %d", &N, &d);

    for(int i=0;i<N;i++){
        int x, y, b;
        scanf("%d %d %d", &x, &y, &b);

        xs.push_back(std::make_tuple(b, x));
        ys.push_back(std::make_tuple(b, y));
    }

    std::sort(xs.begin(), xs.end());
    std::sort(ys.begin(), ys.end());

    // for(const T& t : xs){
    //     printf("%d, %d\n", std::get<0>(t), std::get<1>(t));
    // }
    // puts(std::string(45, '-').c_str());
    // for(const T& t : ys){
    //     printf("%d, %d\n", std::get<0>(t), std::get<1>(t));
    // }
    // puts(std::string(45, '-').c_str());
    
    xt.init(xs, N);
    yt.init(ys, N);

    ll res = 0ll;
    for(int i=0,j=0;i<N;){
        // printf("%d: %lld, %lld\n", std::get<0>(xs[i]), f(std::get<0>(xs[i]), xs, xt), f(std::get<0>(xs[i]), ys, yt));
        res = std::max(res, f(std::get<0>(xs[i]), xs, xt) * f(std::get<0>(xs[i]), ys, yt));

        while(j < N && std::get<0>(xs[j]) == std::get<0>(xs[i])){
            j++;
        }
        i = j;
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 16376
#include<stdio.h>
int main(void) {
	int n, i, a[101], b[101];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if(a[i] % b[i] == 0) printf("%d\n", b[i]);
		else printf("%d\n", a[i] % b[i]);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  for(int i=0; i<vec.size()-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(vec.size()-1) << endl;
}

int main(){
  string S; cin >> S;
  vector<string> vec{"Sunny","Cloudy","Rainy"};
  for(int i=0; i<3; i++){
    if(vec.at(i)==S) cout << vec.at((i+1)%3) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a;
    cin >> a;
    int p[a];
    for(int i = 0; i < a; i++){
        cin >> p[i];
    }
    int min = p[0];
    int cnt = 1;
    for(int i = 1; i < a; i++){
        if(min >= p[i]){
            cnt++;
            min = p[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << n/(a+b)*a + min(n%(a+b),a) << endl;
  return 0;
}

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

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

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 1000)
	sc.Buffer(buf, 100000000)

	sc.Scan()
	sc.Scan()
	listA := strings.Split(sc.Text(), " ")

	sc.Scan()
	sc.Scan()
	listB := strings.Split(sc.Text(), " ")

	i := 0
	j := 0
	for {
		a, _ := strconv.Atoi(listA[i])
		b, _ := strconv.Atoi(listB[j])
		if a == b {
			fmt.Println(listA[i])
			i++
			j++
		} else if a < b {
			fmt.Println(listA[i])
			i++
		} else {
			fmt.Println(listB[j])
			j++
		}

		if i == len(listA) {
			for k := j; k < len(listB); k++ {
				fmt.Println(listB[k])
			}
			break
		} else if j == len(listB) {
			for k := i; k < len(listA); k++ {
				fmt.Println(listA[k])
			}
			break
		}
	}

}



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

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

  vector<int> a(n);
  for (int i=0; i < n; ++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A = 0,B = 0;
  for (int i=0; i < n; i++){
    if (i % 2 == 0){
      A += a[i];
    }
    else{
      B += a[i];
    }
  }
  cout << A - B << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}
}


class Solve{


	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int a = sc.nextInt();
		 int b = sc.nextInt();
		 int res = 0;
		 if(a>=13) {
			 res = b;
		 }else if(a>=6) {
			 res=b/2;
		 }

		 System.out.println(res);




		 }
}

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

void fnInput(int& rnNumA, int& rnNumB)
{
  cin >> rnNumA >> rnNumB;
}

int64_t fnLCMGet(int nNumA, int nNumB)
{
  int nDividend = max(nNumA, nNumB);
  int nDivisor  = min(nNumA, nNumB);

  while (nDividend % nDivisor != 0)
  {
    int nRemain = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemain;
  }

  int nGCM = nDivisor;
  int nQuotA = nNumA / nGCM;
  int nQuotB = nNumB / nGCM;
  return ((int64_t)nGCM * nQuotA * nQuotB);
}

int main()
{
  int nNumA, nNumB;

  fnInput(nNumA, nNumB);
  cout << fnLCMGet(nNumA, nNumB) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList().toMutableList()
    var ans = MInt2(0)
    var base = MInt2(1)
    for (d in 1..60) {
        var one = 0L
        var zero = 0L
        for (i in A.indices) {
            if (A[i] and 1 == 0L) {
                zero++
            } else {
                one++
            }
            A[i] = A[i] shr 1
        }
        ans += base * (MInt2(one) * zero)
        base *= 2
    }
    println(ans)
}

class MInt2 {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt2): MInt2 {
        val a = MInt2(v)
        a.v += b.v
        if (a.v >= MOD) a.v -= MOD
        return a
    }

    operator fun plus(b: Int) = plus(MInt2(b))
    operator fun plus(b: Long) = plus(MInt2(b))

    operator fun minus(b: MInt2): MInt2 {
        val a = MInt2(v)
        a.v -= b.v
        if (a.v < 0) a.v += MOD
        return a
    }

    operator fun minus(b: Int) = minus(MInt2(b))
    operator fun minus(b: Long) = minus(MInt2(b))

    operator fun times(b: Long) = times(MInt2(b))
    operator fun times(b: MInt2): MInt2 {
        val a = MInt2(v)
        a.v *= b.v
        a.v %= MOD
        return a
    }

    fun pow(N: Int) = pow(N.toLong())

    fun pow(N: Long): MInt2 {
        var ans = MInt2(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans *= a
            }
            a *= a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 102432
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N,L;
	cin>>N>>L;
	vector<string>S(N);
	for(int i=0;i<N;i++)cin>>S[i];
	sort(S.begin(),S.end());
	for(int i=0;i<N;i++)cout<<S[i];
}

Measured memory_bytes: 256
url = "https://atcoder.jp/contests/abc084/tasks/abc084_b"

import re


def main():
    n, m = list(map(int, input().split()))
    s = list(input())
    if s[n] != '-':
        print('No')
        exit()
    else:
        s.pop(n)

    s = ''.join(s)
    pat = '^[0-9]+$'
    rep = re.compile(pat)
    result = rep.match(s)
    if result is not None:
        if result.group() == s:
            print('Yes')
            exit()
    print('No')



if __name__ == '__main__':
    main()




Measured memory_bytes: 3188
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0: break
    for j in range(h):
        for i in range(w):
            if (i + j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

using namespace std;

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

    long int n,ac=0,wa=0,tle=0,re=0;
    cin>>n;

    string s;

    for(long int i=0;i<n;i++){
        cin>>s;

        if(s=="AC"){
            ac++;
        }
        else if(s=="WA"){
            wa++;
        }
        else if(s=="TLE"){
            tle++;
        }
        else{
            re++;
        }


    }

    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";


    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  int ans = (n - h + 1) * (n - w + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256