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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n, k; cin >> n >> k;

    int res = 0;
    while (n > 0) {
    	res++;
    	n = n/k;
    }
    cout << res << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,sum,i,cnt;
	sum=0;
	cnt=0;
	while(1){
		if(cnt==0)	scanf("%d",&n);
		if(n==0)	break;
		scanf("%d",&a);
		sum+=a;
		cnt++;
		if(cnt==9){
			printf("%d\n",n-sum);
			cnt=0;
			sum=0;
		}
	}
	return 0;
}



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

    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String S = sc.next();
    String ans[] = new String[N];
    int passC =0;
    int passB =0;
    String tmp="";
    for(int i=0;i<N;i++){
      tmp=S.substring(i,i+1);
      if(tmp.equals("a")){
        if(passC<A+B){
          ans[i]="Yes";
          passC++;
        }else{
          ans[i]="No";
        }
      }else if(tmp.equals("b")){
        if(passC<A+B&&passB<B){
          ans[i]="Yes";
          passC++;
          passB++;
        }else{
          ans[i]="No";
        }
      }else{
        ans[i]="No";
      }
    }
    for(int i=0;i<N;i++){
      System.out.println(ans[i]);
    }
  }
  

  
}


Measured memory_bytes: 47200
import bisect
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
zero = bisect.bisect_left(x, 0)

if zero == 0:
    print(x[K-1])
    exit(0)

if zero+K <= N:
    ans = min(ans, x[zero+K-1])
if zero >= K:
    ans = min(ans, -x[zero-K])

if zero != N:
    for k in range(K-1):
        if 0 <= K+zero-k-2 < N and 0 <= zero-k-1 < N: 
            ans = min(ans,2*x[K+zero-k-2]-x[zero-k-1],x[K+zero-k-2]-2*x[zero-k-1])

print(ans)


Measured memory_bytes: 14480
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>

#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
const ll mod = 1e9+7;
ll f(ll x){
    ll count0 = 0;
    while(x != 0){
        count0 ++;
        x /= 10;
    }
    return count0;
}
int main() {
    //pld(C)
    ll n,m;
    sld(n)
    //pld(sqrt(n)) pn
    for(ll i = (sqrt(n)+2); i >= 1; i --){
        if(n % i == 0){
            pld(max(f(i),f(n/i)));
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 100;
    rep(i, n){
        int cnt = 0;
        while(a[i] % 2 == 0){
            cnt++;
            a[i] /= 2;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	string ans;
	if (a < b) {
		ans = "Bob";
	} else if (b < a) {
		ans = "Alice";
	} else {
		ans = "Draw";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int k,x;
    cin >> k >> x;
    if(k * 500 >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void) {
    int n, A, B, C;
    cin >> n >> A >> B >> C;

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

    vector<char> ans;
    vector<int> rem = {A, B, C};

    auto dfs = [&](auto f, int idx) -> void {
        if (idx == n) {
            cout << "Yes" << endl;
            for (char c : ans) {
                cout << c << endl;
            }
            exit(0);
        }
        int x = s[idx][0] - 'A';
        int y = s[idx][1] - 'A';
        for (int i = 0; i < 2; i++) {
            if (rem[x] > 0) {
                ans.push_back('A' + y);
                rem[x]--;
                rem[y]++;
                f(f, idx + 1);
                rem[x]++;
                rem[y]--;
                ans.pop_back();
            }
            swap(x, y);
        }
    };
    dfs(dfs, 0);
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 19444
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H==0 || W==0){
                break;
            }
            for(int y=0;y<H;y++){
                for(int x=0;x<W;x++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34572
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
vvb visited;
int main(void)
{
	int h, w;

	cin>>h>>w;

	vvi a(h, vi(w));

	vi y1, x1, y2, x2;

	visited=vvb(h, vb(w));

	rep(i, h){
		rep(j, w) cin>>a[i][j];
	}

	rep(i, h){
		rep(j, w){
			if(a[i][j]%2){
				bool flag=true;
				if(j!=w-1){
					if(a[i][j+1]%2){
						a[i][j]--; a[i][j+1]++; flag=false;
						y1.push_back(i+1); x1.push_back(j+1); y2.push_back(i+1); x2.push_back(j+2);
						//cout<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+2<<endl;
					}
				}
				if(i!=h-1){
					if(a[i+1][j]%2&&flag){
						a[i][j]--; a[i+1][j]++; flag=false;
						y1.push_back(i+1); x1.push_back(j+1); y2.push_back(i+2); x2.push_back(j+1);
						//cout<<i+1<<" "<<j+1<<" "<<i+2<<" "<<j+1<<endl;
					}
				}
				if(flag){
					if(j!=w-1){
						a[i][j]--; a[i][j+1]++;
						y1.push_back(i+1); x1.push_back(j+1); y2.push_back(i+1); x2.push_back(j+2);
						//cout<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+2<<endl;
					}else if(i!=h-1){
						a[i][j]--; a[i+1][j]++;
						y1.push_back(i+1); x1.push_back(j+1); y2.push_back(i+2); x2.push_back(j+1);
						//cout<<i+1<<" "<<j+1<<" "<<i+2<<" "<<j+1<<endl;
					}
				}
			}
		}
	}

	cout<<y1.size()<<endl;
	rep(i, y1.size()){
		cout<<y1[i]<<" "<<x1[i]<<" "<<y2[i]<<" "<<x2[i]<<endl;
	}

	/*int ans=0;
	rep(i, h){
		rep(j, w){
			if(a[i][j]%2==0) ans++;
		}
	}
	cout<<ans<<endl;*/
}


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

using namespace std;

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define debug(x) std::cout << #x << ": " << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

int T, n;
const int maxn = 50+5;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    string s[maxn];
    int t[maxn];
    string X;
    rep(i, 0, n)
    {
      cin >> s[i];
      cin >> t[i];
    }
    cin >> X;
    bool flag = 0;
    int ans = 0;
    rep(i, 0, n)
    {
      if(flag) ans += t[i];
      if(s[i] == X) flag = 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string p;
    cin>>p;
    int l=p.size();
    if(p[l-1]=='s')
    {
        cout<<p<<"es"<<endl;
    }
    else
    {
        cout<<p<<"s"<<endl;
    }
}


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

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

	int intHour = input / 3600;
	input = input % 3600;
	int intMin = input / 60;
	int intSec = input % 60;

	ostringstream hour;
	hour << intHour;
	ostringstream min;
	min << intMin;
	ostringstream sec;
	sec << intSec;

	cout << hour.str() + ":" + min.str() + ":" + sec.str() << endl;
}



Measured memory_bytes: 3236
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-27 14:18:07
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int n , a[maxn];
int main()
{
    cin >> n ;
    int ans = INF;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = -100; i <= 100; i++){
        int kp = 0;
        for(int j = 0; j < n; j++){
            kp += (a[j] - i) * (a[j] - i);
        }ans = min(ans , kp);
    }
    cout << ans << endl;
    
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 504
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut v = vec![0; 9];
    for i in a {
        if i < 400 {
            v[0] += 1;
        } else if i < 800 {
            v[1] += 1;
        } else if i < 1200 {
            v[2] += 1;
        } else if i < 1600 {
            v[3] += 1;
        } else if i < 2000 {
            v[4] += 1;
        } else if i < 2400 {
            v[5] += 1;
        } else if i < 2800 {
            v[6] += 1;
        } else if i < 3200 {
            v[7] += 1;
        } else {
            v[8] += 1;
        }
    }

    let c = v[..8].iter().filter(|&i| *i > 0).count();
    let (c1, c2) = if c > 0 { (c, c + v[8]) } else { (1, v[8]) };
    println!("{} {}", c1, c2);
}


Measured memory_bytes: 4352
import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		int a = 0, b = 0;
		for(int i = 0;i<n;i++){
			String str[] = br.readLine().split(" ");
			if(str[0].compareTo(str[1])>0) a+=3;
			else if(str[0].compareTo(str[1])<0) b+=3;
			else if(str[0].compareTo(str[1])==0){
			a++;
			b++;
			}
		}
		System.out.println(a+" "+b);
	}
}

Measured memory_bytes: 24996
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define MOD 1000000007
#define fi first
#define se second
#define ld double

using namespace std;

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

char a, b, c, d;
int A[4];

int main(){
    // ifstream cin("date.in");
    // ofstream cout("date.out");

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> a >> b >> c >> d;
    A[0] = a - '0';
    A[1] = b - '0';
    A[2] = c - '0';
    A[3] = d - '0';

    int n = 8;
    for (int i = 0; i < n; i++) {
        int rs = A[0];
        for (int j = 0; j < 3; j++) {
            if ((1 << j) & i) {
                rs += A[j + 1];
            } else {
                rs -= A[j + 1];
            }
        }

        if (rs == 7) {
            cout << A[0];
            for (int j = 0; j < 3; j++) {
                if ((1 << j) & i) {
                    cout << "+" << A[j + 1];
                } else {
                    cout << "-" << A[j + 1];
                }
            }

            cout << "=7";

            return 0;
        }
    }
    
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  double x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
    y = (f - (d * c) / a) / ((d * -1 * b) / a + e);
    x = (c - b * y) / a;
    printf("%.3f %.3f\n",x,y);
  }
  return(0);
}

Measured memory_bytes: 1080
import java.util.*

fun main(args: Array<String>){

    var (N, H) = readLine()!!.split(" ").map{it.toLong()}
    var a = LongArray(N.toInt())
    var b = LongArray(N.toInt())
    var maxa = 0L

    for(i in a.indices){
        var (tmpa,tmpb) = readLine()!!.split(" ").map{it.toLong()}
        a[i] = tmpa
        b[i] = tmpb
        maxa = Math.max(a[i],maxa)
    }
    Arrays.sort(b)

    var ans = (H + maxa -1) / maxa
    var sumb= 0L
    for(i in N-1 downTo 0){
        sumb += b[i.toInt()]
        ans = Math.min(Math.max((H - sumb + maxa -1) / maxa,0) + N-i,ans)
    }

    if(ans < 1) ans = 1
    println(ans)




}

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

// dp[i][j][k][m] :=  i: 上位 i 桁目まで決定
//                    j: started(数字を書き込んだ)か
//                    k: small(数字を自由に選べる)か
//                    m: {3,5,7} を選んだかのflag
//                    としたときの753数の数
int dp[11][2][2][8];

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

  string n;
  cin >> n;

  int len = n.size();
  dp[0][0][0][0] = 1;
  for (int i = 0; i < len; ++i)
  {
    for (int j = 0; j < 2; ++j)
    {
      for (int k = 0; k < 2; ++k)
      {
        for (int m = 0; m < 8; ++m)
        {
          if (!dp[i][j][k][m]) continue;

          if (k == 1)                  // small ([0, 9] から数字を選べる)か
          {
            if (j == 0 && m == 0)      // not started (数字を書き込んでいない)か
              dp[i + 1][0][1][0] += dp[i][0][1][0];                // nothing

            dp[i + 1][1][1][m | 1] += dp[i][j][1][m];              // +3
            dp[i + 1][1][1][m | 2] += dp[i][j][1][m];              // +5
            dp[i + 1][1][1][m | 4] += dp[i][j][1][m];              // +7
          }
          else                         // not small ([0, d] から数字を選べる)か
          {
            int d = n[i] - '0';

            if (j == 0 && m == 0)      // not started (数字を書き込んでいない)か
              dp[i + 1][0][1][0] += dp[i][0][0][0];                // nothing

            if (d == 3) dp[i + 1][1][0][m | 1] += dp[i][j][0][m];  // +3
            if (3 < d)  dp[i + 1][1][1][m | 1] += dp[i][j][0][m];  // +3
            if (d == 5) dp[i + 1][1][0][m | 2] += dp[i][j][0][m];  // +5
            if (5 < d)  dp[i + 1][1][1][m | 2] += dp[i][j][0][m];  // +5
            if (d == 7) dp[i + 1][1][0][m | 4] += dp[i][j][0][m];  // +7
            if (7 < d)  dp[i + 1][1][1][m | 4] += dp[i][j][0][m];  // +7
          }
        }
      }
    }
  }

  int ans = dp[len][1][0][7] + dp[len][1][1][7];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    OUT(min(b/a,c));
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#define ll long long
using namespace std;
ll a[200100];
map<ll, ll> mp;
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	ll sum = 0;
	ll dap = 0;
	mp[0] = 1;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		dap += mp[sum];
		mp[sum]++;
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 14336
import Control.Applicative( (<$>))
import Data.IntMap.Strict
import qualified Data.IntMap.Strict as M
import Control.Monad( replicateM)

main = do
    let
	readPair = do
	    [a,b] <- Prelude.map read . words <$> getLine
	    return (a,b)

    [n_, k_] <- Prelude.map read . words <$> getLine
    abs_ <- replicateM n_ readPair
    let
	dataMap = fromListWith (+) abs_

	search c [] = c
	search c ((v,amount):pairs) = let
					c' = c+amount
				    in
					if k_<=c'
					  then v
					  else search c' pairs
    
    print $ search 0 (toList dataMap)

Measured memory_bytes: 79612
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#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>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string a, b;
    cin >> a >> b;
    int n = atoi((a+b).c_str());
    if((int)sqrt(n)*(int)sqrt(n) == n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<tuple<int, int, int>> input;
	vector<tuple<int, int, int>> donot;
	REP(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		if (c == 0) {
			donot.push_back(make_tuple(a, b, c));
			continue;
		}
		input.push_back(make_tuple(a, b, c));
	}
	for (int i = 0; i <= 100; ++i) {
		for (int q = 0; q <= 100; ++q) {
			int ng = 0;
			for (int j = 1; j < input.size(); ++j) {
				int as = abs(i - get<0>(input[0])) + abs(q - get<1>(input[0])) + get<2>(input[0]);
				int bs = abs(i - get<0>(input[j])) + abs(q - get<1>(input[j])) + get<2>(input[j]);
				if (as != bs) {
					ng = 1;
					break;
				}
			}
			long long hoge = abs(i - get<0>(input[0])) + abs(q - get<1>(input[0])) + get<2>(input[0]);
			for (int j = 0; j < donot.size(); ++j) {
				long long geko = abs(i - get<0>(donot[j])) + abs(q - get<1>(donot[j]));
				if (hoge - geko > 0) {
					ng = 1;
					break;
				}
			}
			if (ng == 0) {
				cout << i << " " << q << " " << hoge << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 888
from operator import itemgetter
n = int(input())

ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))

abs=sorted(ab, key=itemgetter(1))

sum=0
check=0
for i in range(n):
    sum+=abs[i][0]
    if sum <= abs[i][1]:
        continue
    else:
        check=1
        break

if check == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 55256
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect
def main():
    h, w, m = map(int,input().split()) 
    h_lis = [0] * (h+1)
    w_lis = [0] * (w+1)
    bombs = set([tuple(map(int,input().split())) for i in range(m)])
    for hh, ww in bombs:
        h_lis[hh] += 1
        w_lis[ww] += 1
    max_h = max(h_lis)
    max_w = max(w_lis)
    h_max_index = [i for i, h in enumerate(h_lis) if h == max_h]
    w_max_index = [i for i, w in enumerate(w_lis) if w == max_w]
    for h_i in h_max_index:
        for w_i in w_max_index:
            if not (h_i, w_i) in bombs:
                print(h_lis[h_i] + w_lis[w_i])
                sys.exit()
    else:
        print(h_lis[h_i] + w_lis[w_i] - 1)

if __name__=='__main__':
    main()

Measured memory_bytes: 83528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  if(M==0){
    if(N==1)cout<<"0"<<endl;
    if(N==2)cout<<"10"<<endl;
    if(N==3)cout<<"100"<<endl;
  }
  else{
    vector<pair<int,int>>a(M);
    for(int i=0;i<M;i++)cin>>a.at(i).first>>a.at(i).second;
    sort(a.begin(),a.end());
    if(N!=1&&a.at(0)==make_pair(1,0))cout<<"-1"<<endl;
    else{
      bool x=false;
      for(int i=0;i<M;i++)for(int j=0;j<M;j++){
        if(a.at(i).first==a.at(j).first&&a.at(i).second!=a.at(j).second)x=true;
      }
      if(x)cout<<"-1"<<endl;
      else{
        vector<int>m(N,0);
        for(int i=0;i<M;i++){
          m.at(a.at(i).first-1)=a.at(i).second;
        }
        if(N!=1&&m.at(0)==0)m.at(0)=1;
        for(int i=0;i<N;i++)cout<<m.at(i);
        cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

bool chmin(ll &a, ll b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  Yes(s < t);
  return 0;
}


Measured memory_bytes: 256
# code like professional " write main function "

import sys
def main():
	n = int(input())
	S1 =input()
	S2 =input()
	ans  = 1
	mod = 10**9+7
	i = 0
	if S1[0]==S2[0]:
		ans = 3
		i=1
	else:
		ans = 6
		i = 2
	while i<n:
		if S1[i]==S2[i]:
			if S1[i-1]==S2[i-1]:
				ans = (ans*2)%mod
			i = i+1
		else:
			if S1[i-1]==S2[i-1]:
				ans = (ans*2)%mod
			else:
				ans = (ans*3)%mod
			i = i+2
	print(ans)

if __name__ == "__main__":
	main()

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

using namespace std;

#define endl '\n'

const int MOD = 1e9 + 7;
char grid[1002][1002];
int dist[1002][1002];

int paths(int i, int j, int h, int w) {
  if (i < 1 || i > h || j < 1 || j > w || grid[i][j] == '#') return 0;
  if (dist[i][j] != -1) return dist[i][j];
  return dist[i][j] = (paths(i - 1, j, h, w) + paths(i, j - 1, h, w)) % MOD;
}

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

  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> grid[i][j];
      dist[i][j] = -1;
    }
  }
  dist[1][1] = 1;
  cout << paths(h, w, h, w) << endl;

	return 0;
}


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

int main() {
	
	//vector<int> a(n);  (a.begin(),a.end())
	//cout << "test" << endl;

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";


	int n;
	cin >> n;
	
	
	int sum1=0,sum2=0;
	
	
	vector<int> a(n);
	
	
	
	rep(i,n) {
		cin >> a[i];
		sum1+=a[i];
	}
	
	int ans=1000000;
	
	rep(i,n){
		sum1-=a[i];
		sum2+=a[i];
		int diff=sum1-sum2;
		if(diff<0) diff*=-1;
		if(diff<ans) ans=diff;
		else break;
		
		
	}
	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if (s<t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
using mint=modint998244353;
mint ans,beki[200005],one[200005];
int n,q;
struct S{
    mint sum;
    int size;
};
struct F{
    int d;
};
S op(S l,S r){
    return S{beki[r.size]*l.sum+r.sum,l.size+r.size};
}
S e(){
    return S{0,0};
}
S mapping(F f,S x){
    if(f.d==-1) return x;
    return S{one[x.size]*mint(f.d),x.size};
}
F composition(F f,F g){
    if(f.d==-1) return g;
    return f;
}
F id(){
    return F{-1};
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>q;
    beki[0]=1; one[0]=0;
    for(int i=1;i<=n;i++){
        beki[i]=beki[i-1]*mint(10);
        one[i]=one[i-1]*mint(10)+mint(1);
    }
    lazy_segtree<S,op,e,F,mapping,composition,id> seg(n);
    for(int i=0;i<n;i++){
        seg.set(i,S{1,1});
    }
    while(q--){
        int l,r,d;
        cin>>l>>r>>d;
        seg.apply(l-1,r,F{d});
        cout<<seg.all_prod().sum.val()<<endl;
    }
    
}


Measured memory_bytes: 11420
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y ;
  cin >> n >> x >> y ;
  vector<int> cnt(n-1,0) ;
  
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0 ; ;
      if(i<=x && j<=x){
        dis = j - i ;
      }
      else if(y<=i && y<=j){
        dis = j - i ;
      }
      else if(i<=x && x<=j && j<=y){
        dis = x-i + min(j-x,y-j+1) ;
      }
      else if(x<=i && i<=y && y<=j){
        dis = j-y + min(y-i,i-x+1) ;
      }
      else if(x<=i && j<=y){
        dis = min(j-i,i-x+y-j+1) ;
      }
      else if(i<=x && y<=j){
        dis = j-y + x-i +1 ;
      }
      cnt[dis-1]++ ;
    }
  }
  
  REP(i,n-1){
    cout << cnt[i] << endl ;
  }
  
  
  
  return 0 ;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_127
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            long[] array = ReadLongs();
            Array.Sort(array);
            long[][] bcs = new long[m][];
            for(int i = 0; i < m; i++)
            {
                bcs[i] = ReadLongs();
            }
            bcs = bcs.OrderBy(a => -a[1]).ToArray();

            int now = 0;
            bool interrupt = false;
            for(int i = 0; i < m; i++)
            {
                for(int j = 0; j < bcs[i][0]; j++)
                {
                    if (array[now] >= bcs[i][1])
                    {
                        interrupt = true;
                        break;
                    }

                    array[now] = bcs[i][1];
                    now++;
                    if (now >= n)
                    {
                        interrupt = true;
                        break;
                    }
                }
                if (interrupt) break;
            }

            long sum = 0;
            for (int i = 0; i < n; i++) sum += array[i];

            WriteLine(sum);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 33604
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007


int main()
{
  string S;
  cin >>S;
  int o=0,l=0;
  rep(i,S.size()){
  if(S[i]=='0')
    o++;
    else
      l++;
  }
  cout << o+l-abs(o-l) << endl;
}

Measured memory_bytes: 512
package main

import (
  "fmt"
)

func main() {
  a := [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
  var k int
  fmt.Scanf("%d", &k)
  
  fmt.Printf("%d\n", a[k-1])
}

Measured memory_bytes: 1836
import java.util.*;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        Integer[] Az = new Integer[N];
        Integer[] Bz = new Integer[N];
        for (int n = 0; n < N; n++){
            Az[n] = sc.nextInt();
            Bz[n] = sc.nextInt();
        }
        Arrays.sort(Az, Comparator.reverseOrder());
        Arrays.sort(Bz, Comparator.reverseOrder());

        int max = 0;
        for (int n = 0; n < N; n++){
            if (max < Az[n]) max = Az[n];
        }

        int throwNum = N;
//        System.out.println("========\n");
        for (int n = 0; n < N; n++){
//            System.out.println(Az[n]+" "+Bz[n]);
            if (max > Bz[n]){
                throwNum = n;
                break;
            }
        }
//        System.out.println("thrownum>>"+ throwNum);
        int ans = 0;
        for (int n = 0; n < throwNum; n++){
            H -= Bz[n];
            ans = n + 1;
            if (H <= 0) {
                System.out.println(ans);
                System.exit(0);
            }
        }
//        System.out.println("H>>"+H+" ans>> "+ans);
        while(H > 0){
            H -= max;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 93764
#include<bits/stdc++.h>
using namespace std;
int h,n,a[100009],tot;
int main() {
	scanf("%d%d",&h,&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) tot+=a[i];
	if(tot<h) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" ( fun n -> n)

let lst = Str.split (Str.regexp " ") (read_line ())
          |> List.map int_of_string 

let rec log2 n =
        if n = 0 then
                0
        else
                1 + (log2 (n lsr 1))

let rec f lst ac =
        if ac > (Int.pow 10 18) then
                -1
        else
                match lst with
                          [] -> ac
                        | first :: rest -> 
                                let bac = (log2 ac) - 1 in
                                let bfst = log2 first in
                                        if (bac + bfst) > 60 then
                                                -1
                                        else
                                                f rest (ac * first)

let () =
        (
                if List.exists (fun elmnt -> elmnt = 0) lst then
                        0
                else
                        f lst 1
        ) |> Printf.printf "%d\n"


Measured memory_bytes: 20220
#include <stdio.h>
#include <string.h>
#define MN 200000

int tot=0;
char s[MN+5];

int main(){
	scanf("%s",&s[1]);
	for(int i=1,len=strlen(&s[1]);i<=len;i++){
		tot += s[i]-'0';
	}
	puts(tot%9?"No":"Yes");
}


Measured memory_bytes: 3360
n=int(input())
h=list(map(int, input().split()))
a=[0]*n
ans=0
roop=max(h)
for i in range(roop):
    flag=False
    for j in range(n):
        if h[j]==a[j]:
            flag=False
        elif flag:
            a[j]+=1
        else:
            ans+=1
            a[j]+=1
            flag=True
print(ans)

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > L(N);
    for(int i=0; i<N; i++){
        std::cin >> L[i];
    }
    
    std::sort(L.begin(), L.end());
    
    int cnt = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            if(L[i] == L[j]){
                continue;
            }
            for(int k=j+1; k<N; k++){
                if(L[i] == L[k]){
                    continue;
                }
                if(L[j] == L[k]){
                    continue;
                }
                if(L[i] + L[j] > L[k]){
                    cnt++;
                }
            }
        }
    }
    
    std::cout << cnt << std::endl;
    
    
    return 0;
    
}


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

const int N = 100005, L = 50, K1 = 70, K2 = 70, K = 20;

template <class T>
void read(T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' && ch < '9'); ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write(T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, cnt[K1][K2];
char str[L];
long long ans = 0ll;

void update() {
	int len = strlen(str), pos = len;
	long long num = 0ll;
	for (int i = 0; i < len; i++) {
		if (str[i] == '.') pos = i;
		else num = num * 10ll + str[i] - '0';
	}
	int times2 = 0, times5 = 0;
	if (pos < len) times2 = times5 = pos + 1 - len;
	while (num % 2 == 0) times2++, num /= 2;
	while (num % 5 == 0) times5++, num /= 5;
	cnt[times2 + K][times5 + K]++;
}

int main() {
	read(n);
	for (int i = 0; i < K1; i++) {
		for (int j = 0; j < K2; j++) cnt[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		scanf("%s", str);
		update();
	}
	for (int i1 = 0; i1 < K1; i1++) {
		for (int j1 = 0; j1 < K2; j1++) {
			for (int i2 = 0; i2 < K1; i2++) {
				for (int j2 = 0; j2 < K2; j2++) {
					if (i1 == i2 && j1 == j2) {
						if (i1 >= K && j1 >= K) ans += 1ll * cnt[i1][j1] * (cnt[i1][j1] - 1);
					}
					else {
						if (i1 + i2 >= (K << 1) && j1 + j2 >= (K << 1)) ans += 1ll * cnt[i1][j1] * cnt[i2][j2];
					}
				}
			}
		}
	}
	write(ans >> 1), putchar('\n'); 
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
 
int main()
{
    bool inverted = false;
    std::string result;
 
    std::cin >> result;
 
    int queryCount = 0;
    std::cin >> queryCount;
 
    //result.reserve(result.size() + queryCount);
 
    for (auto count = 0; count < queryCount; ++count)
    {
        int instruction = 0;
        std::cin >> instruction;
        if (instruction == 1)
        {
            inverted = !inverted;
        }
        else
        {
            int option = 0;
            std::cin >> option;
            bool optionInvert = inverted;
            if (option == 1)
            {
                optionInvert = !optionInvert;
            }
 
            char append = '\0';
            std::cin >> append;
 
            if (optionInvert)
            {
                result.insert(result.begin(), append);
            }
            else
            {
                result.push_back(append);
            }
        }
    }
 
    if (inverted)
    {
        std::string work;
        std::copy(result.rbegin(), result.rend(), std::back_inserter(work));
        std::cout << work;
    }
    else
    {
        std::cout << result;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
const int maxn=5003;
const int mo=1e9+7;

int dp[maxn][maxn][2],fac[maxn],siz[maxn],res,n;
vector<int> g[maxn];

void dfs(int u,int pre=0){
	dp[u][1][0]=1;siz[u]=1;
	for(int i=0;i<g[u].size();++i){
		int to=g[u][i];
		if(to==pre) continue;
		dfs(to,u);
		for(int j=siz[u];j>0;--j){
			int cur[2]={dp[u][j][0],dp[u][j][1]};
			dp[u][j][0]=dp[u][j][1]=0;
			for(int k=0;k<2;++k){
				if(cur[k]){
					for(int z=1;z<=siz[to];++z){
						for(int c=0;c<2;++c)if(dp[to][z][c]){
							int nj=j+z,nk=(k+c)%2;
							dp[u][nj][nk]=(dp[u][nj][nk]+1ll*cur[k]*dp[to][z][c])%mo;
							if(z%2==0){
								int nw=1ll*cur[k]*fac[z]%mo;
								int nk=(k+c+1)%2;
								dp[u][j][nk]=(dp[u][j][nk]+1ll*nw*dp[to][z][c])%mo;
							}
						}
					}
				}
			}
		}
		siz[u]+=siz[to];
	}
}


int main(){
	fac[0]=1;
	for(int i=2;i<maxn;i+=2)fac[i]=(1ll*(i-1)*fac[i-2])%mo;
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		static int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	for(int j=2;j<=n;j+=2){
		int w=fac[j];
		res=(res+1ll*w*dp[1][j][0])%mo;
		res=(res-1ll*w*dp[1][j][1]%mo+mo)%mo;
	}
	printf("%d\n",res);
	return 0;
}



Measured memory_bytes: 195200
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string s;
	cin >> s;
	FOR(i, 0, s.length()) {
		if (s[i] == ',')
			cout << " ";
		else
			cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from collections import deque
from itertools import chain

dire = [(0,1),(1,0),(0,-1),(-1,0)]

H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S_initial = deepcopy(S)

    
def bfs():
    S[0][0] = "#"
    dq = deque() ## (y, x, dist from start)
    dq.append((0,0,0))
    while dq:
        y,x,d = dq.popleft()
        if d > H*W:
          break
        for dy,dx in dire:
            ny = y + dy; nx = x + dx
            if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
                continue
            if (ny,nx) == (H-1,W-1):
                return d+1
            if S[ny][nx] == ".":
                dq.append((ny,nx,d+1))
                S[ny][nx] = "#"
    return -1

dist = bfs()
if dist == -1:
  print(-1)
else:
  S_flatten = list(chain.from_iterable(S_initial))
  cnt_dot = S_flatten.count('.') - (dist+1)
  print(cnt_dot)



Measured memory_bytes: 3572
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=[v]
  next2=set()
  visited=[-1]*n
  visitct=0
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            distance[connection[next[i]][j]]=ct
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

import sys
input = sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
 
f=bfs(0);s=bfs(n-1)
ctf=0;cts=0
for i in range(n):
  if f[i]<=s[i]:
    ctf+=1
  else:
    cts+=1
 
if ctf>cts:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 78168
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int memo[150];
int main(){
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF){
        memset(memo,0,sizeof(memo));
        memo[a] = 1;
        memo[b] = 1;
        memo[c] = 1;
        int ans = 0;
        for(int i = 1;i <= 100;++i) if(memo[i] == 1) ans ++;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
class Unionfind():

    def __init__(self, n):
        self.par = [-1]*n

    def find(self, x):
        if(self.par[x] < 0):
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.par[x]>self.par[y]:
            x,y = y,x
        self.par[x]+=self.par[y]
        self.par[y] = x
        return True

    def size(self,x):
        return -self.par[self.find(x)]

    def count_group():
        c = 0
        for i in range(len(self.par)):
            if self.par[i]<0:
                c+=1
        return c

n,q = map(int, input().split())
uf = Unionfind(n)
for _ in range(q):
    com,x,y = map(int, input().split())
    if com==0:
        uf.union(x,y)
    else:
        print(int(uf.same(x,y)))


Measured memory_bytes: 5716
import sys
fin = sys.stdin.readline

N, Z, W = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]
assert len(a_list) == N

if N == 1:
    print(abs(a_list[-1] - W))
else:
    print(max(abs(a_list[-1] - W), abs(a_list[-2] - a_list[-1])))


Measured memory_bytes: 3188
a,b,m=map(int,input().split())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
l=[]
for i in range(m):
    x,y,c=map(int,input().split())
    l+=[la[x-1]+lb[y-1]-c]
print(min(min(l),min(la)+min(lb)))

Measured memory_bytes: 71356