akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const ll M = 9000000000000000000;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		ll N;
		int A, B, C, D;
		cin >> N >> A >> B >> C >> D;
		/*
		ll hold = N;
		int cnt2 = 0, cnt3 = 0, cnt5 = 0;
		while (hold % 2 == 0) {
			cnt2++;
			hold /= 2;
		}
		while (hold % 3 == 0) {
			cnt3++;
			hold /= 3;
		}
		while (hold % 5 == 0) {
			cnt5++;
			hold /= 5;
		}
		res += hold * D;
		*/
		priority_queue <pair <ll, ll> > pq;
		pq.push({0, N});
		set <ll> vis;
		while (!pq.empty()) {
			ll w = -pq.top().fi, x = pq.top().se;
			pq.pop();
			if (x == 0) {
				cout << w << '\n';
				break;
			}
			//if (t == 0) cout << w << " " << x << endl;
			if (vis.count(x)) continue;
			vis.insert(x);
			ll fst2 = x / 2 * 2;
			ll ww2 = (x - fst2) * D;
			if (w + ww2 >= w && w + ww2 >= ww2) {
				pq.push({-w - ww2, fst2});
			}
			if (fst2 < x) fst2 += 2;
			ll w2 = (fst2 - x) * D;
			ll fst3 = x / 3 * 3;
			ll ww3 = (x - fst3) * D;
			if (w + ww3 >= w && w + ww3 >= ww3) {
				pq.push({-w - ww3, fst3});
			}
			if (fst3 < x) fst3 += 3;
			ll w3 = (fst3 - x) * D;
			ll fst5 = x / 5 * 5;
			ll ww5 = (x - fst5) * D;
			if (w + ww5 >= w && w + ww5 >= ww5) {
				pq.push({-w - ww5, fst5});
			}
			if (fst5 < x) fst5 += 5;
			ll w5 = (fst5 - x) * D;
			ll temp2 = fst2 - fst2 / 2;
			if (M / temp2 >= D) {
				w2 += min((ll)A, (fst2 - fst2 / 2) * D);
			} else {
				w2 += A;
			}
			ll temp3 = fst3 - fst3 / 3;
			if (M / temp3 >= D) {
				w3 += min((ll)B, (fst3 - fst3 / 3) * D);
			} else {
				w3 += B;
			}
			ll temp5 = fst5 - fst5 / 5;
			if (M / temp5 >= D) {
				w5 += min((ll)C, (fst5 - fst5 / 5) * D);
			} else {
				w5 += C;
			}
			if (w + w2 >= w && w + w2 >= w2) {
				pq.push({-w - w2, fst2 / 2});
			}
			if (w + w3 >= w && w + w3 >= w3) {
				pq.push({-w - w3, fst3 / 3});
			}
			if (w + w5 >= w && w + w5 >= w5) {
				pq.push({-w - w5, fst5 / 5});
			}
		}
	}
	return 0;
}


Measured memory_bytes: 5716
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
double dis(double x, double y)
{
	return x*x + y*y;	
}
int main()
{
	int n;
    double d;
    cin >> n >> d;
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        double x,y;
        cin >> x >> y;
        
        if(dis(x,y) <= d * d)
        {
			cnt++;
        }
    }
    cout << cnt << endl;
	return 0;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  bool ans = false;
    
  for(int i = 0; i <= x; i++){
   if(2*(i)+4*(x-i)==y){
     ans = true;
     break;
   }
    else{
      continue;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> G[100010];

void dfs(int v, int p, int dist, vector<int> &d){
	d[v] = dist;
	for(auto u : G[v]){
		if(u == p) continue;
		dfs(u, v, dist + 1, d);
	}
}

signed main(){
	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;
	rep(i, 0, n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> dt(n, INF), da(n, INF);
	dfs(u, -1, 0, dt);
	dfs(v, -1, 0, da);
	int ans = 0;
	rep(i, 0, n){
		if(dt[i] < da[i]){
			ans = max(ans, da[i] - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 12544
#depth first
N=int(input())
V=[]
a=[0]
for i in range(N):
    V.append([int(i) for i in input().split()])
    w=V[i][2:]
    w.sort()
    V[i]=V[i][:2]+w
    a.append(0)
V=sorted(V,key=lambda x:x[0])
c=1
t=1
i=0
r=[1]
a[1]=1
p=[[1,t]]
q=[]
while t<N*2:
    j=2
    while t<N*2 and j-2<V[i][1] and V[i][1]>0 and a[V[i][j]]==1:
        j+=1
    t+=1
    if j-2<V[i][1]:
        a[V[i][j]]=1
        c+=1
        r.append(V[i][j])
        p.append([V[i][j],t])
        i=V[i][j]-1
    else:
        q.append(p[-1]+[t])
        r.pop(-1)
        p.pop(-1)
        if len(r)>0:
            i=r[-1]-1
        else:
            j=1
            while j<N and a[j]==1:
                j+=1
            if j<N:
                t+=1
                i=j-1
                r.append(j)
                p.append([j,t])
q=sorted(q,key=lambda x:x[0])
for i in range(N):
    for j in range(3):
        q[i][j]=str(q[i][j])
    print(" ".join(q[i]))

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int N, K;
vector<int> al[MX_N];

ii dfs(int u, int p) {
    ii ret = ii(0,0);
    for (int v : al[u]) if (v != p) {
        ii x = dfs(v,u);
        if (x.sc+1 == K && u != 1) ++ret.fi;
        else ret.sc = max(ret.sc, x.sc+1);
        ret.fi += x.fi;
    }
    return ret;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> K;
    int add = 0;
    FOR(i,1,N){
        int A; cin >> A;
        if (i > 1) al[A].push_back(i);
        else if (A != 1) ++add;
    }
    cout << dfs(1,-1).fi + add;
}



Measured memory_bytes: 12032
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char field[101][101];
int d[101][101];
int N,M;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
bool f;
int cal(int a,int b,int k){
	if(k==0)
		return a+b;
	else if(k==1)
		return a-b;
	else
		return a*b;
}

void solve(vector<int>v,int i,int j,int k){
	if(!f)return;
	int a=v[0];
	int b=v[1];
	int c=v[2];
	int d=v[3];
	
	if(cal(cal(cal(a,b,i),c,j),d,k)==10){
	cout<<"((("<<a<<" "<<o[i]<<" "<<b<<")"<<o[j]<<" "<<c<<")"<<o[k]<<" "<<d<<")"<<endl;
	f=false;
		return;
	}
	if(cal(cal(a,b,i),cal(c,d,k),j)==10){
		cout<<"(("<<a<<" "<<o[i]<<" "<<b<<")"<<o[j]<<"("<<c<<" "<<o[k]<<" "<<d<<"))"<<endl;
		f=false;
		return;
	}
	if(cal(cal(a,cal(b,c,j),i),d,k)==10){
		cout<<"(("<<a<<" "<<o[i]<<"("<<b<<" "<<o[j]<<" "<<c<<"))"<<o[k]<<" "<<d<<")"<<endl;
		f=false;
		return;
	}
}

int main(){
	
	int a,b,c,d;
	
	while(cin>>a>>b>>c>>d,a!=0||b!=0||c!=0||d!=0){
		vector<int> v(4);
		 f=true;
		v[0]=a;
		v[1]=b;
		v[2]=c;
		v[3]=d;
		
		sort(v.begin(),v.end());
		do{
			for(int i=0;i<3&&f;i++){
				for(int j=0;j<3&&f;j++){
					for(int k=0;k<3&&f;k++){
						solve(v,i,j,k);
					}
				}
			}
		}while(next_permutation(v.begin(),v.end())&&f);
		if(f)
			cout<<0<<endl;
	}
	

	
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, x, c[15], a[15][15];
int cnt[15];
int ans = 10000000000000000;

signed main() {
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++)cin >> a[i][j];
	}
	for (int i = 0; i < (1 << n); i++) {
		fill(cnt, cnt + m, 0);
		int cnt2 = 0;
		for (int j = 0; j < n; j++)if (i&(1 << j)) {
			cnt2 += c[j];
			for (int k = 0; k < m; k++)cnt[k] += a[j][k];
		}
		bool bl = true;
		for (int j = 0; j < m; j++)if (cnt[j] < x)bl = false;
		if (bl)ans = min(ans, cnt2);
	}
	if (ans == 10000000000000000)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, i = Is()
print(n-i+1)

Measured memory_bytes: 68076
import java.util.*;
	import java.io.*;
	public class Main {
		static int n,wi[],W;
		static long dp[][],vi[];
		public static void main(String[] args) throws IOException{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			int t=1;
	//		Integer.parseInt(br.readLine().trim());
			StringBuilder printans=new StringBuilder();
			while(t-->0)
			{
				StringTokenizer tok=new StringTokenizer(br.readLine()," ");
				n=Integer.parseInt(tok.nextToken());
				W=Integer.parseInt(tok.nextToken());
				
				wi=new int[n];
				vi=new long[n];
				int sm=0;
				for(int i=0;i<n;i++) {
					tok=new StringTokenizer(br.readLine()," ");
					wi[i]=Integer.parseInt(tok.nextToken());
					vi[i]=Long.parseLong(tok.nextToken());
				
				}
				dp=new long[n+1][W+1];
				memset();
				printans.append(call(0,0,0));
			    
			}
			System.out.println(printans);
			
		}
		static void memset() {
			for(long a[]:dp) {
				Arrays.fill(a, -1);
			}
		}
static long call(int i,long v,int w) {
			
			if(i==n) {
				
				return 0;
			}
		
			if(dp[i][w]!=-1) {
				return dp[i][w];
			}
			if(wi[i]+w>W) {
				dp[i][w]=call(i+1,v,w);
			}
			else {
				dp[i][w]=Math.max(call(i+1,v,w), vi[i]+call(i+1,v,w+wi[i]));
			}
			
		
			return dp[i][w];
			
		}	
			
	}


Measured memory_bytes: 127060
/*
  AUTHOR:SOURABH
  CREATED:21:08:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 100000000
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,sum;
    string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s;
        sum=0;
        n=s.length();
        fn(i,n)
        sum+=s[i]-'0';
        if(sum%9)
            cout<<"No";
        else
            cout<<"Yes";
    }
    return 0;
}












Measured memory_bytes: 3780
#include<stdio.h>
int main(){
	int N;
	scanf("%d", &N);
	int V[N], C[N], S[N];
	for (int i = 0; i < N; i++){
		scanf("%d", &V[i]);
	}
	for (int j = 0; j < N; j++){
		scanf("%d", &C[j]);
	}
	int a, b, s = 0;
	for (int k = 0; k < N; k++){
		a = V[k] - C[k];
		if (a > 0) s += a;
	}
	printf("%d", s);
}

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

def main():
	H, W, N = map(int, input().split(" "))
	AB = []
	for _ in range(N):
		a, b = map(int, input().split(" "))
		AB.append((a, b))

	ans = {}
	for i, val in enumerate(AB):
		a, b = val
		a, b = a-1, b-1
		for ba in range(max(0, a-2), min(H-2, a+1)):
			for bb in range(max(0, b-2), min(W-2, b+1)):
				if (ba, bb) in ans.keys():
					ans[(ba, bb)] += 1
				else:
					ans[(ba, bb)] = 1

	ans2 = [0] * 10
	total = (H-2) * (W-2)
	t = 0
	for i in ans.values():
		ans2[i] += 1
		t += 1
	ans2[0] = total - t
	for i in range(10):
		print(ans2[i])

if __name__ == "__main__":
	main()


Measured memory_bytes: 165180
h,w = map(int,input().split())
#典型的なBFS
s = ["#"*(w+2) for _ in range(h+2)]
setroad = set([])
#額縁コーティング
for i in range(1, h+1):
	s[i] = "#"+input()+"#"

for i in range(h+2):
	for j in range(w+2):
		if s[i][j]==".":
			setroad.add((i,j))


#
def isroad(n, m):
	if (n, m) in setroad:
		return True
	else:
		return False


# 全探索
ans = 0

for shokix, shokiy in setroad:
	kaisuu = 0
	settansaku = set([])
	listmada = [(shokix, shokiy)]
	setmada = set([(shokix,shokiy)])
	while len(setmada) != 0:
		for i, j in listmada[:]:
			settansaku.add((i,j))
			listmada.remove((i, j))
			setmada.remove((i, j))
			for k,l in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
				if isroad(k,l):
					if not (k,l) in setmada:
						if not (k,l) in settansaku:
							listmada.append((k,l))
							setmada.add((k,l))
		kaisuu += 1
	kaisuu -= 1
	if kaisuu >= ans:
		ans = kaisuu
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,s1=0,s2=0,dif;cin >> n;
  vector<int> number(n);
  rep(i,n){
    cin >> number.at(i);
    s2 += number.at(i);
  }
  dif = abs(s2-s1);
  rep(i,n){
    if(dif > abs(s2-s1)) dif = abs(s2-s1);
    s2 -= number.at(i);
    s1 += number.at(i);
  }
  cout << dif << endl;
}

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

for i in range(n):
    s = [int(x) for x in input().split()]
    s.reverse()

    u, k = s.pop(), s.pop()
    se = set()
    for j in range(k):
        se.add(s.pop())

    ans = []
    for i in range(1, n + 1):
        ans.append(int(i in se))

    print(*ans)



Measured memory_bytes: 5608
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var base = parseInt(line[0]);
    var waru = parseInt(line[1]);
    var amari = parseInt(line[2]);
    var flag = 0;
    var arrAmariall = [];
    for(var i = 0; i<100; i++){
        arrAmariall.push(base*i%waru);
    }
    
    for(var i = 0; i<100; i++){
        if(amari === arrAmariall[i]){
            flag++;
        }
    }
    
    if(flag>=1){
        console.log("YES");
    } else {
        console.log("NO");
    }
//    console.log(line[0].charAt(line[0].length));
//    console.log(line[1].charAt(line[1].length));
//    console.log(line[2].charAt(line[2].length));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, A, B;
bool visited[int(3e5 + 5)];
int ans[int(3e5 + 5)];

int main(){
  cin >> N >> A >> B;
  if (A * B < N || A + B - 1 > N){
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= A; i++){
    ans[i] = N - A + i;
    visited[N - A + i] = true;
  }

  int now = A + 1, num = 0;
  while (now <= N){
    num += B - 1;
    num = min(num, (int)(N - A));

    for (int i = 0; i < B - 1; i++){
      if (num - i <= 0) break;
      if (now > N) break;
      ans[now] = num - i;
      visited[num - i] = true;
      now++;
    }
  }

  cout << ans[1];
  for (int i = 2; i <= N; i++) cout << " " << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 5024
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayDeque;
import java.awt.Point;
 
class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String A = a.toUpperCase();

        if(a.equals(A)){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }
    } 
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n;
	string res = "Christmas";
	REP(i, 25-n)
		res += " Eve";
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int h,w;
string s[10];
vector<pair<int,int>> check;
bool ok = 0;
void dfs(int x, int y, int cnt,vector<vector<int>> dis){
    if(ok == 1) return;
    if(cnt > 100) return ;
    int dx[] = {0, 1}, dy[] = {1, 0};
    rep(i,2){
        vector<vector<int>> copy = dis;
        int nx = x + dx[i], ny = y + dy[i];
        if(nx >= 0 && nx < h && ny >= 0 && ny < w && s[nx][ny] == '#'){
            copy[nx][ny] = 1;
            if(nx == h - 1 && ny == w - 1){
                ok = 1;
                for(auto u : check){
                    if(copy[u.first][u.second] == 0) ok = 0;
                }
                if(ok == 1) return;
                dfs(nx, ny, cnt + 1, copy);
            }else dfs(nx, ny, cnt + 1, copy);
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    cin >> h >> w;
    rep(i,h) cin >> s[i];
    rep(i,h) rep(j,w) if(s[i][j] == '#') check.push_back({i, j});
    if(s[0][0] == '.'){
        cout << "Impossible" << endl;
        return 0;
    } 
    vector<vector<int>> dis(10, vector<int>(10, 0));
    dis[0][0] = 1;
    dfs(0, 0, 0, dis);
    if(ok) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, M;
    cin >> N >> M;

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

    int ans = N;
    for (int i = 0; i < M; i++)
    {
        if (ans - A[i] >= 0)
        {
            ans -= A[i];
        }
        else
        {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	
	int n,x,t;
	cin >> n >> x >> t;
	
	int ans=0;
	while(n>0){
		n -= x;
		ans += t;
	}
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 3592
z = list(map(int, input().split()))
z.append(z[2] + z[1] - z[3])  #z[4](x_3)を生成
z.append(z[3] - z[0] + z[2])  #z[5](y_3)を生成
z.append(z[4] + z[3] - z[5])  #z[6](x_4)を生成
z.append(z[5] - z[2] + z[4])  #z[7](y_4)を生成
print(z[4], z[5], z[6], z[7])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
typedef long long ll;
typedef pair<int, int> P;
 
const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976
 
int dx[2] = {0,1};
int dy[2] = {1,0};
 
int main()
{
    int h,w;
    cin >> h >> w;
    char f[h][w];
    rep(i,h){
        rep(j,w) cin >> f[i][j];
    }
    int dp[h][w];
    rep(i,h) rep(j,w) dp[i][j] = inf;
    if(f[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i,h){
        rep(j,w){
            rep(k,2){
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(ny < h && nx < w){
                    int add = 0;
                    if(f[ny][nx] == '#' && f[i][j] == '.') add++;
                    dp[ny][nx] = min(dp[ny][nx],dp[i][j]+add);
                }
            }
            
        }
    }
    cout << dp[h-1][w-1];
}

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

int main() {
	int year, month, day;

	scanf("%d / %d / %d", &year, &month, &day);

	if(year <= 2019 && month <= 4 && day <= 30){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut a = get!([usize]);
    let mut b = get!([usize]);

    let mut count = 0;
    for i in (0..n).rev() {
        let tmp = min!(b[i], a[i+1]);
        count += tmp;
        a[i+1] -= tmp;
        b[i] -= tmp;
        let tmp = min!(b[i], a[i]);
        count += tmp;
        a[i] -= tmp;
    }
    println!("{}", count);
}


Measured memory_bytes: 14588
#include<iostream>

using namespace std;

int main(){

	for(int i1=0 ; i1<9 ; i1++){
		for(int i2=0 ; i2<9 ; i2++){
			cout << i1+1 << 'x' << i2+1 << '=' << (i1+1)*(i2+1) << endl;
		}
	}
return 0;
}

Measured memory_bytes: 1112
function main(s) {
	s = s.split("\n")[0].split(" ").map(x => Number(x));
	console.log((s.reduce((x, y) => x + y, 0)) - Math.max(s[0], s[1], s[2]));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

int main(void){
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		int h;
		cin >> h;
		if(h>=k) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
 
 ll n,a,b;
 cin>>n>>a>>b;
 ll x=n/(a+b);
 x=x*a;
 ll y=n%(a+b);
 if(y>=a)
 {
   x+=a;
 }
 else
 {
   x+=y;
 }
cout<<x<<endl;

}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  rep(i,n) {
    int k, l;
    cin >> k >> l;
    p.at(i) = make_pair(k, l);
  }
  sort(ALL(p), compare_by_b);

  ll count = 0;
  for(int i=0; i<p.size(); i++) {
    // cout << p[i].first << ' ' << p[i].second << endl;
    if (count+p[i].first <= p[i].second) count += p[i].first;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main() {
 vector<int> c(9);
  for(int &x: c) cin>>x;
  if(c[4]==c[3]+c[1]-c[0]&&c[5]==c[3]+c[2]-c[0]&&
     c[7]==c[6]+c[1]-c[0]&&c[8]==c[6]+c[2]-c[0])
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace V0005{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            while(Console.In.Peek() != -1){
                var A = sr.Next<int>();
                var B = sr.Next<int>();
                Console.WriteLine(Ex.Gcd(A, B) + " " + Ex.Lcm(A, B));
            }
            //---------------------------------
        }
    }

    public class Ex{
        public static long Gcd(long a, long b){
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long Lcm(long a, long b){
            return a * (b / Gcd(a, b));
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }
    }
}

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

int ra[114514], rb[114514];
int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A')ra[i + 1] = ra[i] + 1;
		else ra[i + 1] = ra[i] + 2;
	}
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'A')rb[i + 1] = rb[i] + 1;
		else rb[i + 1] = rb[i] + 2;
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int aq = ra[b] - ra[a - 1], bq = rb[d] - rb[c - 1];
		if (aq % 3 == bq % 3)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1664
N, M = map(int, input().split())
s = [list(map(lambda s: int(s) - 1, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
# print(s)
# print(p)
ret = 0
for i in range(2 ** N):
    on = list(map(int, bin(i)[2:]))
#     print(on)
    on = ([0] * N + on)[-N:]
#     print(on)
    for si, pi in zip(s, p):
        if sum(on[sij] for sij in si) % 2 != pi:
            break
    else:
        ret += 1
print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define sort(p) sort(p.begin(),p.end())
#define rsort(p) sort(p.rbegin(),p.rend())
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 998244353;
const ll N = 1e5 + 7;
const ld pi = 3.14159265358979; 

void solve() {
    ll n,a,b,q;
    cin>>n;
    vector<ll> arr(n);
    map<ll,ll> mp;
    ll sum = 0;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        mp[arr[i]]++;
        sum+=arr[i];
    }
    cin>>q;
    while(q--) {
        cin>>a>>b;
        if(mp.find(a)==mp.end()) {
            cout<<sum<<"\n";
            continue;
        }
        ll cnt = mp[a];
        mp.erase(a);
        mp[b]+=cnt;
        ll ans = sum - cnt*a + cnt*b;
        sum = ans;
        cout<<ans<<"\n";
    }
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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



Measured memory_bytes: 256
#include"stdio.h"
#include"string.h"

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + key % (M-1); }

int find(char str[]){

  /* your task */
  int i=0;
  int j;
  int k=getKey(str);
  while(i<M)
    {
      j=(h1(k)+i*h2(k))%M;
      if(!strcmp(H[j],str))
        {
          return j;
        }
      else if(H[j][0]=='\0')
        {
          return 0;
        }
      else
        {
          i++;
        }
    }
  return 0;
}

int insert(char str[]){
  int i=0;
  int j;
  int k=getKey(str);
  while(i<M)
    {
      j=(h1(k)+i*h2(k))%M;
      if(!strcmp(H[j],str))
        {
          return j;
        }
      else if(H[j][0]=='\0')
        {
          strcpy(H[j],str);
          return j;
        }
      else
        {
          i++;
        }
    }
  return -1;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 15456
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,Q,tot;
ll q[MAX],ans[MAX],s[MAX];
int Binary(int l,int r,ll k)
{
	int ret=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(k>=q[mid])l=mid+1,ret=mid;
		else r=mid-1;
	}
	return ret;
}
int main()
{
	n=read();Q=read();q[tot=1]=n;
	for(int i=1;i<=Q;++i)
	{
		ll x=read();
		while(tot&&q[tot]>=x)--tot;
		q[++tot]=x;
	}
	Q=tot;s[Q]=1;
	for(int i=Q;i;--i)
	{
		ll l=q[i];int p=Binary(1,i-1,l);
		while(p)
		{
			s[p]+=l/q[p]*s[i];
			l%=q[p];
			p=Binary(1,p-1,l);
		}
		ans[l]+=s[i];
	}
	for(int i=n;i;--i)ans[i]+=ans[i+1];
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4096
import numpy as np
n = int(input())
# 1, 6, 6**2, ---, 9, 9**2, -----
lim = 10 ** 18
dp = [lim] * (n + 1)
dp[0] = 0

check = [1]
# for 6
temp = 6
while (temp <= n):
    check.append(temp)
    temp *= 6

# for 9
temp = 9
while (temp <= n):
    check.append(temp)
    temp *= 9

# print(check)

for i in range(1, n + 1):
    for cc in check:
        temp = i - cc
        if (temp >= 0):
            dp[i] = min(dp[i], dp[temp] + 1)
            # i -cc = 0 になるのは、i = 6,9,46,81　のとき
            # > 元の値と前ステップのコスト＋１を比較して、小さい方を選択
            # dp[0] + 1から始まる。
            # print(dp[i])

print(dp[n])


Measured memory_bytes: 13156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

const int NM = 60;
vector<int> vertex[NM];
int sz;
bool seen[NM];

void dfs(int now, P p){
    sz++;
    seen[now] = true;
    for(auto next : vertex[now]) {
        if(seen[next]) continue;
        if((now==p.first && next == p.second) || (now == p.second && next==p.first)) continue;
        dfs(next, p);
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<P> edges;
    rep(i, m){
        int a, b; cin>>a>>b;
        edges.push_back(make_pair(a,b));
        vertex[a].push_back(b);
        vertex[b].push_back(a);
    }
    int ans = 0;
    for(P p : edges){
        rep(i, 60) seen[i] = false;
        sz = 0;
        dfs(1, p);
        if(sz != n) {
            ans++;
        }
    }
    cout<<ans<<endl;
}

// abc075_c

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <random>
#include <cmath>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const int mod = 1e9+7;
const int inf = 1e18;



int32_t main(){
    FAST;

    int a , b;  cin >> a >> b;
    string n = to_string(a) + to_string(b);
    int f = stoll(n);
    int r = sqrt(f);

    cout << (r*r == f ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
# bit全順列列挙
def bitall(n):
    parm = []
    for i in range(1<<n): # 0/1の組み合わせは1<<n(=2**n)通り存在。
        on = [0 for _ in range(n)] # とりあえず全て0にしておく。
        
        for j in range(n):
            if i & (1<<j): # iのj桁目が1となっている場所をonにする。
                on[j] = 1
                
        parm.append(on)
                
    return parm


N, M = map(int, input().split())
K = []
S = []
for m in range(M):
    tmp = list(map(int, input().split()))
    K.append(tmp[0])
    S.append(tmp[1:])
P = list(map(int, input().split()))

swi_parms = bitall(N)
ans =0

for swi_parm in swi_parms:
    flag = 0
    for k in range(len(K)):
        cnt = 0
        
        for s in S[k]:
            # 対応するスイッチのon数をカウント
            if swi_parm[s-1] == 1: cnt += 1
        
        if cnt%2 == P[k]:
            continue
        else:
            flag = 1
            break
    if flag == 0:
        ans += 1

print(ans)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X.at(i);
  }
  
  sort(X.begin(), X.end());
  
  vector<int> distances(M - 1);
  for (int i = 0; i < M - 1; i++) {
    distances.at(i) = X.at(i + 1) - X.at(i);
  }
  
  sort(distances.begin(), distances.end(), greater<int>());
  
  int answer = 0;
  for (int i = 0; i < M - 1; i++) {
    if (i < N - 1) {
      continue;
    }
    answer += distances.at(i);
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll n,ans=0;
string s;
void dfs(ll keta,bool seven,bool five,bool three){
    if (keta==0){
        if (seven and five and three){
            ans++;
        }
        return;
    }
    dfs(keta-1,true,five,three);
    dfs(keta-1,seven,true,three);
    dfs(keta-1,seven,five,true);
}
void dfsm(ll c,ll t,ll keta,bool seven,bool five,bool three){
    if (keta==0){
        if (seven and five and three and c>t){
            ans--;
        }
        return;
    }
    dfsm(c*10+7,t*10+(s[s.size()-keta]-'0'),keta-1,true,five,three);
    dfsm(c*10+5,t*10+(s[s.size()-keta]-'0'),keta-1,seven,true,three);
    dfsm(c*10+3,t*10+(s[s.size()-keta]-'0'),keta-1,seven,five,true);
}

int main(){
    cin >> n;
    s=to_string(n);
    if (s.size()<3){
        cout << 0 << endl;
        return 0;
    }
    for (ll i=3;i<=7;i+=2){
        dfsm(i,s[0]-'0',s.size()-1,(i==7),(i==5),(i==3));
    }
    for (ll i=s.size()-1;i>=0;i--){
        dfs(i,true,false,false);
        dfs(i,false,true,false);
        dfs(i,false,false,true);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3728
import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]

maxA = max(A)
B = sorted(A, reverse = True)
secA = max(B[1:])
for i in range(N) :
    if A[i] == maxA :
        print(secA)
    else :
        print(maxA)


Measured memory_bytes: 14124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,sum=0;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        sum=(n/x)*t;
    }
    else if(n%x!=0)
    {
        sum=((n/x)+1)*t;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3584
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n + 1];

        for(int x = 1; x < 100; x++){
            for(int y = 1; y < 100; y++){
                for(int z = 1; z < 100; z++){
                    int i = x * x + y * y + z * z + x * y + y * z + z * x;
                    if(i <= n){
                        a[i]++;
                    }
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= n; i++){
            sb.append(a[i]).append("\n");
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 36596
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
	FastScanner sc = new FastScanner();
	
	int a1 = sc.nextInt();
	int b1 = sc.nextInt();
	int a2 = sc.nextInt();
	int b2 = sc.nextInt();
	int a3 = sc.nextInt();
	int b3 = sc.nextInt();
	
	boolean can;
	
	int[] dig = new int[4];
	
	dig[a1-1] += 1;
	dig[a2-1] += 1;
	dig[a3-1] += 1;
	dig[b1-1] += 1;
	dig[b2-1] += 1;
	dig[b3-1] += 1;
	
	int odd = 0;
	for(int i=0;i<4;i++){
		if(!(dig[i]%2 == 0)){
			odd += 1;
		}
	}
	
	if(odd==0 || odd==2){
		can = true;
	}
	else{
		can = false;
	}

	if(can){
	    System.out.println("YES");
	}
	else{
	    System.out.println("NO");
	}
	
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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




int main(void) {
  ll N;
  cin >> N;
  ll i;
  ll f=1;
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
    if(a&1) f=0;
  }
  
  if(f==0) pt("first");
  else pt("second");
  
}








Measured memory_bytes: 256