akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

for i in range(1000):
        x = str(i)
        if len(x)!=n: continue
        can = 1
        for s,c in sc:
                if int(x[s-1])!=c: can = 0
        if can:
                print(i)
                break
else: print(-1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
    return(0);
}

Measured memory_bytes: 580
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int N;
  int A,B;
  cin >> N >> A >> B;
  int P[N];
  int cnt[3];
  memset(cnt,0,sizeof(cnt));
  for(int i = 0 ; i <N; i++) cin >> P[i];
  for(int i=0; i<N; i++){
     if( P[i] <= A ) cnt[0]++;
     else if(P[i] <= B) cnt[1]++;
     else cnt[2]++;
  }
  cout << min(cnt[0],min(cnt[1],cnt[2]))<<endl;

  return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int coins = 0;
  
  for ( int i = 0; i < 2; i++){
    if (A > B){
      coins += A;
      A--;
    }
    else{
      coins += B;
      B--;
    }
  }
  
  cout << coins;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,s=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;++i)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<k;++i)
  {
    s+=a[i];
  }
  cout<<s<<endl;
  return 0;
    
}

Measured memory_bytes: 3616
N = int(input())
A, B = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)

aa = 0
bb = 0
cc = 0
for i in range(N):
    if p[i] <= A:
        aa += 1
    elif p[i] <= B:
        bb += 1
    else:
        cc += 1

print(min(aa, bb, cc))


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

char c[2020][2020];
ll cnt[4][2020][2020];
int main(){
	ll h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>c[i][j];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(c[i][j]=='#')cnt[0][i][j]=0;
			else cnt[0][i][j]=cnt[0][i][j-1]+1;
			if(c[i][w+1-j]=='#')cnt[1][i][w+1-j]=0;
			else cnt[1][i][w+1-j]=cnt[1][i][w+2-j]+1;
		}
	}
	for(int i=1;i<=w;i++){
		for(int j=1;j<=h;j++){
			if(c[j][i]=='#')cnt[2][j][i]=0;
			else cnt[2][j][i]=cnt[2][j-1][i]+1;
			if(c[h+1-j][i]=='#')cnt[3][h+1-j][i]=0;
			else cnt[3][h+1-j][i]=cnt[3][h+2-j][i]+1;
		}
	}
	// for(int k=0;k<4;k++){
	// 	for(int i=1;i<=h;i++){
	// 		for(int j=1;j<=w;j++)cout<<cnt[k][i][j]<<' ';
	// 		cout<<endl;
	// 	}
	// 	cout<<endl;
	// }
	ll ans=0;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
		ll sum=-3;
		for(int k=0;k<4;k++)sum+=cnt[k][i][j];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int N, X[110], sum = 0, P = 0, ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        sum += X[i];
    }
    P = (int) (1.0 * sum / N + 0.5);
    for (int i = 0; i < N; i++) {
        ans += (X[i] - P) * (X[i] - P);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
// 整数の入力
fscanf(STDIN, "%d", $n);
// スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $t, $a);

$format = "%d";
for ($i = 1; $i < $n; $i++) {
  $format .= " %d";
}
  //n個を配列に格納
$data = fscanf(STDIN, $format);

$min_dif = 1000;
$min_index = -1;

foreach ($data as $i => $d) {
  $temp = $t - $d * 0.006;
  if ($min_dif > abs($temp - $a)) {
    $min_index = $i;
    $min_dif = abs($temp - $a);
  }
}

echo $min_index + 1;

?>


Measured memory_bytes: 3956
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    ma_ = 0
    # 2 乗リスト作っておくか？
    LIST = []
    for i in range(7):
        LIST.append(2**i)
    for i in range(6,-1,-1):
        if LIST[i] <= n:
            print(LIST[i])
            exit()
    print(0)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll last,a,b,c,i,j,k,m,n,str[100005],sum=1;
int main()
{
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&str[i]);
    }
        if(str[0]!=0)
        {
            printf("0\n");
            return 0;
        }
    sort(str,str+n);
    j=0;
    for(i=0;i<n;i++){
        if(str[i]==j)
            j++;
        else if(str[i]>j)
            break;
    }
    if(i!=n)
        {printf("0\n");return 0;}

    j=0;
    while(str[j]==0)
    {
        j++;
    }
    if(j>1)
        printf("0\n");
    else
    {
        j=1;
        last=j;
        b=0;
        for(i=1;i<n;i++){
            if(str[i]==j)
            {
                sum=sum%998244353*last%998244353;
                b++;
            }
            else
            {
                j=str[i];
                last=b;
                sum=sum%998244353*last%998244353;
                b=1;
            }
        }
            printf("%lld\n",sum);
    }
    return 0;
}


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

int main() {
  int s;
  cin >>  s;
  //cout << s % 1000 << endl;
  //cout << s % 100 << endl;
  //cout << s % 10 << endl;
  int sum = (s % 1000)/100 + (s % 100)/10 + (s % 10);
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String args[]){
        int a,b;
        a=sc.nextInt();
        b=sc.nextInt();
        if(a%2==0||b%2==0){
            System.out.println("No");    
        }else
            System.out.println("Yes");
    }
}

Measured memory_bytes: 25172
X =int(input())
if X > 10100:
    print(1)
    quit()
lst = []
for i in range(20):
    lst.append([i*105+1, i*100+99])
for item in lst:
    if X >= item[0] and X<=item[1]:
        print(0)
        quit()
print(1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1=scan.nextLine();
		StringBuilder s= new StringBuilder(s1);
		s.reverse();
		if(s1.contains(s)) System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 26880
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int main()
{
	char s[100010]={0};
	int n=0;
	while(cin>>s[n++]);n--;
	int l=0,r=n-1,cnt=0;
	for(;l<=r;)
	{
		if(s[l]==s[r])
		{
			l++;r--;
		}
		else if(s[l]=='x')
		{
			cnt++;l++;
		}
		else if(s[r]=='x')
		{
			cnt++;r--;
		}
		else
		{
			cout<<(-1)<<endl;
			return 0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		for(int i = 1;i <= n;i++){
			double num = Math.floor(i*1.08);
			if(n == num){
				System.out.println(i);
				return;
			}
		}
		System.out.println(":(");
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
  string a, b, c, winner;
  bool a_turn = true, b_turn = false, c_turn = false;
  cin >> a >> b >> c;

  auto next_flag_setter = [&a_turn, &b_turn, &c_turn](char w) {
    if (w == 'a')
    {
      a_turn = true;
    }
    else if (w == 'b')
    {
      b_turn = true;
    }
    else if (w == 'c')
    {
      c_turn = true;
    }
  };

  while (true)
  {
    if (a_turn == true)
    {
      if (a.empty())
      {
        winner = 'A';
        break;
      }
      a_turn = false;
      next_flag_setter(a[0]);
      a.erase(0, 1);
      continue;
    } else if (b_turn == true) {
      if (b.empty())
      {
        winner = 'B';
        break;
      }
      b_turn = false;
      next_flag_setter(b[0]);
      b.erase(0, 1);
    } else if (c_turn == true) {
      if (c.empty())
      {
        winner = 'C';
        break;
      }
      c_turn = false;
      next_flag_setter(c[0]);
      c.erase(0, 1);
    }
  }

  cout << winner << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
  int a,b;
  cin >> a >> b;
  for(int i = 13; i <= 1000; i++){
    if((int)(i*0.08) == a && (int)(i*0.1) == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;


signed main() {
  int n; cin >> n;
  map<string,int> mp;
  for(int i = 0; i < n;i++) {
    string s; cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for(auto x: mp) {
    mx = max(x.second, mx);
  }
  for(auto x: mp) {
    if(x.second == mx) {
      cout << x.first << endl;
    }
  }

}


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

int main() {
  //Nを代入
  int N;
  cin >> N;
  
  //配列を代入，今回は数列になります
  vector<int> numbers(N);
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }
  
  //小さい順に並べる
  sort(numbers.begin(), numbers.end());
  
  //絶対値の最大値を出力
  cout << numbers.at(N-1)-numbers.at(0) << endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int M=int.Parse(str[1]);
      int C=int.Parse(str[2]);
      int ans=0;
      string[] str2=Console.ReadLine().Split(' ');
      int[] B=str2.Select(int.Parse).ToArray();
      for(int i=1;i<=N;i++){
        string[] str3=Console.ReadLine().Split(' ');
        int[] A=str3.Select(int.Parse).ToArray();
         int sum=0;
        for(int j=0;j<M;j++){
         
          sum+=A[j]*B[j];
      }
        if((sum+C)>0){
          ans++;
        }
      }
      Console.WriteLine(ans);
    }
    
  }

}


Measured memory_bytes: 28260
#include <stdio.h>
#include <queue>
#include <math.h>
#include <utility>
#define delta 1e-7
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, l, m;
  scanf("%lld", &n);
  ll x[n], y[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &x[i], &y[i]);
  double he = 0.5, ta = 1420.0, r;
  for(m = 0; m < 50; ++m) {
    r = (he + ta) / 2.0;
    queue< pair<double, double> > q;
    for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) 
      if((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= 4 * r * r + delta) {
      double a = x[j] - x[i], b = y[j] - y[i];
      if(y[j] != y[i]) {
        double t = -a / b, s = (a * a + b * b) / (2 * b);
        double d = sqrt(t * t * s * s - (1 + t * t) * (s * s - r * r)), xt = (-t * s + d) / (1 + t * t);
        q.push(make_pair(xt + x[i], t * xt + s + y[i]));
        xt = (-t * s - d) / (1 + t * t);
        q.push(make_pair(xt + x[i], t * xt + s + y[i]));
      } else {
        double xt = a / 2;
        double yt = sqrt(r * r - xt * xt);
        q.push(make_pair(xt + x[i], yt + y[i])), q.push(make_pair(xt + x[i], -yt + y[i]));
      }
    }
    while(q.size()) {
      ll cnt = 0;
      for(i = 0; i < n; ++i) {
        if((x[i] - q.front().first) * (x[i] - q.front().first) + (y[i] - q.front().second) * (y[i] - q.front().second) <= r * r + delta) cnt++;
      }
      if(cnt == n) {
        ta = r;
        break;
      }
      q.pop();
    }
    if(!q.size()) he = r;
  }
  printf("%lf", r);
  return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int MOD = 1e9+7;
const ll INF = 1001001001;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
  ll n,m,l;
  cin>>n>>m>>l;
  vector<vll> d(n, vll(n, INF));
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--;b--;
    d[a][b]=d[b][a]=c;
  }
  
  ll q;
  cin>>q;
  vll S(q), T(q);
  rep(i,q){
    ll s,t;
    cin>>s>>t;
    S[i]=s-1;
    T[i]=t-1;
  }
  
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
  
  vector<vll> d2(n, vll(n, INF));
  for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j){
        if(d[i][j] <= l) d2[i][j] = 1;
      }
      
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
          d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
        }
        
  rep(i,q){
    int ans = d2[S[i]][T[i]];
    if(ans==INF){
      cout<<-1<<endl;
    }else{
      cout<<ans-1<<endl;
    }
  }
  
}

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

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

bool isPrimeNumber(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}


int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    vector<ll> d = divisor(g);
    int ans = 0;
    for (ll i : d) {
        if (isPrimeNumber(i)) ans++;
    }
    cout << ans + 1 << endl;
}


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

int main() {
	int h,w;

	cin >> h >> w;

	vector<string> s;

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

	for (int i = 0; i < h; i++) {
		string str;
		cin >> str;
		s.push_back(str);
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int num = 0;
			if (s[i][j] == '.') {
				for (int k = 0; k < 8; k++) {
					int x = i + dx[k];
					int y = j + dy[k];

					if (x < 0 || h <= x || y < 0 || w <= y) {
						continue;
					}
					if (s[x][y] == '#') {
						num++;
					}
				}
				s[i][j] = char(num + '0');
			}
		}
	}

	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e8
template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    map<pair<int, int>, int> mp;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            mp[{a, b}] = es.size() / 2;
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                mp[{b, a}] = es.size() / 2;
                es.push_back((Edge){b, a, c});
            }
        }
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }
    bool dfs(int u, int v, bitset<50> &bs, int from = -1) {
        if (u == v) {
            return true;
        }
        for (auto e : edge[u]) {
            if (from == e.to) continue;
            if (dfs(e.to, v, bs, u)) {
                bs.set(mp[{u, e.to}]);
                return true;
            }
        }
        return false;
    }
};

template <typename T, typename U>
T Pow(T x, U n) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}

ll PIE(vector<pair<int, int>> &a, Graph<int> &g) {
    int m = a.size();
    ll res = 0;
    map<pair<int, int>, bitset<50>> bitmp;
    for (int i = 0; i < m; i++) {
        g.dfs(a[i].first, a[i].second, bitmp[{a[i].first, a[i].second}]);
    }
    // {0, 1, ..., m-1} の部分集合の全探索
    for (int bit = 0; bit < (1 << m); ++bit) {
        bitset<50> bs(0);
        int cnt = 0;
        for (int i = 0; i < m; i++) {
            if ((1 << i) & bit) {
                bitset<50> bs1(0);
                bs |= bitmp[{a[i].first, a[i].second}];
                cnt++;
            }
        }
        ll c = bs.count();
        if (cnt) res += Pow(2ll, g.E - c) * (cnt % 2 ? 1 : -1);
    }
    return Pow(2ll, g.E) - res;
}

int main() {
    int n;
    cin >> n;
    Graph<int> g(n, n - 1);
    g.input(false);
    int m;
    cin >> m;
    vector<pair<int, int>> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i].first >> p[i].second;
        p[i].first--;
        p[i].second--;
    }
    cout << PIE(p, g) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {


       string s;
       cin>>s;

       char a=s[s.length()-1];
       if(a=='2' || a=='4' || a=='5'||a=='7'||a=='9'){
        cout<<"hon";
       }
       else if(a=='3'){
        cout<<"bon";
       }
       else cout<<"pon";







    }



    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String strInput = input.nextLine();
        String str[] = new String[2];
        str = strInput.split(" ");
        if(Integer.parseInt(str[0])<Integer.parseInt(str[1])){
            System.out.println("a < b");
        }else if(Integer.parseInt(str[0])>Integer.parseInt(str[1])){
            System.out.println("a > b");
        }else if(Integer.parseInt(str[0])==Integer.parseInt(str[1])){
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26176
import sys

a, b, c = map(int, input().split())
sum_abc = a + b + c
    
flag = True
cnt = 0
while flag:
    if sum_abc//3 >= max(a, b, c):
        break
    else:
        sum_abc += 2
        cnt += 1


if (abs(3*max(a,b,c) - sum_abc)%2 == 1):
    cnt += 1

print("{}".format(cnt))

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

long long r, c, k, a, b, w, g[3005][3005], dp[3005][3005][5];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> r >> c >> k;
    for (int i = 0; i < k; i++){
        cin >> a >> b >> w;
        g[a][b] = w;
    }
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            dp[i][j][0] = max(dp[i][j-1][0], dp[i-1][j][4]);
            dp[i][j][1] = max(dp[i][j-1][1], dp[i-1][j][4]+g[i][j]);
            dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1]+g[i][j]);
            dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2]+g[i][j]);
            dp[i][j][4] = max(max(dp[i][j][0], dp[i][j][1]), max(dp[i][j][2], dp[i][j][3]));
        }
    }
    cout << dp[r][c][4] << "\n";
}


Measured memory_bytes: 425952
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
const [N, K] = lines[0].split(' ').map(Number)
const k = []

for (let i = 1; i <= K; i++) {
    const [L, R] = lines[i].split(' ').map(Number)
    k.push([L, R])
}
const ksum = Array(K).fill(0)

const mod = 998244353
const map = Array(N).fill(0)
map[0] = 1

for (let i = 1; i < map.length; i++) {
    let c = 0
    for (let j = 0; j < k.length; j++) {
        ksum[j] = ksum[j] + (map[i - k[j][0]] || 0) - (map[i - k[j][1] -1 ] || 0)
    }
    map[i] = ksum.reduce((a, b) => a + b) % mod
}

console.log(map.pop())


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    ll ans = -1*N;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        ans += A.at(i);
    }
    cout << ans << endl;


    return 0;
}

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

int main(){
  int N,M; cin>>N>>M;
  vector<int> X(M);
  for(int i=0;i<M;i++) cin>>X[i];
  sort(X.begin(),X.end());
  vector<int> dif(M-1);
  for(int i=1;i<M;i++) dif[i-1] = X[i] - X[i-1];
  sort(dif.begin(),dif.end());
  int ans = 0;
  for(int i=0;i<M-N;i++)
    ans += dif[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
	while(cin >> a >> b) {
		int g = min(a, b);
		while(true) {
			if(a % g == 0 && b % g == 0) break;
			g--;
		}
		cout << g << ' ' << a / g * b << endl;
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<double> a(n);
  double sum = 0;

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  double cut = sum / (4 * m);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (cut <= a.at(i)) count++;
  }

  if (count >= m) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


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

int main()
{
	int a[5], min=10, store;
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(a[i]%10<min && a[i]%10!=0){
			store = i;
			min=a[i]%10;
		}
	}
	int sum=0;
	for(int i=0;i<5;i++){
		if(i==store)continue;
		
		sum+=(ceil(a[i]/10.0))*10;
	}
	sum += a[store];
	cout << sum << endl;
}

Measured memory_bytes: 256
//問題URL
    //

    //解き方メモ
    //
    
    #include<iostream>
    #include<algorithm>
    using namespace std;

    #define MAX_N 100

    int main(){
        int n;
        int t[MAX_N];
        int v[MAX_N];

        //0.5s単位の速度。ve[1]で0.5秒時点の速度
        double ve[MAX_N*200*2+1];

        double result;
        
        //入力
        cin >> n;
        for(int i=0;i<n;i++){
            cin >> t[i];
        }
        for(int i=0;i<n;i++){
            cin >> v[i];
        }

        //計算
        //veを制限速度vで埋める。ただし、0sと終了時点は速度0
        ve[0] = 0;
        int total_half_s = 1;
        for(int i=0;i<n;i++){ //i:ti,vi
            if(i>0)
                ve[total_half_s-1] = min(v[i],v[i-1]);
            for(int j=0;j<t[i];j++){ //tの秒数だけ埋める。0.5s単位なので、veは要素数が倍。
                ve[total_half_s]   = v[i];
                ve[total_half_s+1] = v[i];
                total_half_s += 2;
            }
        }
        int ve_n = total_half_s-1;
        ve[ve_n] = 0;

        //veを開始から0.5s単位で加速した速度で埋める。ただし、制限速度vを上回るなら制限速度vとする。
        int i;
        for(i=1;i<ve_n;i++){
            ve[i] = min(ve[i],ve[i-1]+0.5);
        }
        //veを終着に向けて0.5s単位で減速した速度（0.5s未来から見て0.5速い速度：ve[i+1]+0.5）で埋める。
        //ただし、先のfor文の速度（ありえる速度の上限：ve[i]）を上回る速度は設定しない。
        for(i=ve_n-1;i>0;i--){
            ve[i] = min(ve[i],ve[i+1]+0.5);
        }

        //0.5s単位で移動距離を足し合わせる
        result = 0;
        for(int i=0;i<ve_n;i++){
            //台形の公式：（上辺（現在速度）＋底辺（0.5s後の速度））×高さ（0.5s）／２
            result += (ve[i]+ve[i+1])*0.5/2;
        }

        printf("%lf",result);
        cout << endl;

        return 0;
    }

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

int N, M, K;
vector<int> C;
vector<bool> visited;
vector<int> cnt;  // cnt[i] := 色が i の人数
vector<pair<int, int>> F, B;
vector<vector<int>> G;
vector<int> ans;

void dfs(int cur, int color) {
  visited.at(cur) = true;
  C.at(cur) = color;
  cnt.at(color)++;
  for (auto nx : G.at(cur)) {
    if (visited.at(nx)) continue;
    dfs(nx, color);
  }
}

int main() {
  cin >> N >> M >> K;
  C.resize(N);
  cnt.assign(N, 0);
  visited.resize(N);
  G.resize(N);
  F.resize(M);
  B.resize(K);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  int color = 0;
  for (int i = 0; i < N; i++) {
    if (!visited.at(i)) {
      dfs(i, color);
      color++;
    }
  }
  ans.resize(N);
  for (int i = 0; i < N; i++) {
    ans.at(i) = cnt.at(C.at(i)) - 1;
    int tmp = G.at(i).size();
    ans.at(i) -= tmp;
  }

  for (int i = 0; i < K; i++) {
    int a, b; cin >> a >> b; a--; b--;
    if (C.at(a) == C.at(b)) {
      ans.at(a)--;
      ans.at(b)--;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << max(0, ans.at(i));
  }
  cout << endl;


}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

bool isp(long n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (int i = 3; i * i <= n; i+=2) {
        if (n % i == 0) return false;
    }
    return true;
}

int cnts[100001];

int main() {
    int q;
    cin >> q;
    for (int i = 1; i < 100001; i++) {
        if (isp(i) && isp((i + 1) / 2)) {
            cnts[i] = cnts[i-1] + 1;
        } else {
            cnts[i] = cnts[i-1];
        }
    }
    
    REP(i,q) {
        int l, r;
        cin >> l >> r;
        cout << cnts[r] - cnts[l - 1] << endl;
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define x first
#define y second

namespace QAQ
{
	typedef std::pair<int,int> pii;

	const int N=303;

	int type[N*2][N*2];
	int n,d0,d1;

	bool vis[N*2][N*2];
	std::vector<pii> mv;

	void dfs(int nx,int ny,int val,int cur=0)
	{
		if(nx<0 || ny<0 || nx>=n*2 || ny>=n*2 || vis[nx][ny])return;

		vis[nx][ny]=1,type[nx][ny]^=cur,cur^=val;

		for(int i=0;i<(int)mv.size();i++)
			dfs(nx+mv[i].x,ny+mv[i].y,val,cur);
	}

	void work(int dis,int val)
	{
		mv.resize(0);
		for(int i=0;i*i<=dis;i++)
			for(int j=0;i*i+j*j<=dis;j++)
				if(i*i+j*j==dis)
				{
					mv.push_back(pii(i,j));
					mv.push_back(pii(-i,j));
					mv.push_back(pii(i,-j));
					mv.push_back(pii(-i,-j));
				}

		memset(vis,0,sizeof(vis));
		for(int i=0;i<n*2;i++)
			for(int j=0;j<n*2;j++)
				if(!vis[i][j])dfs(i,j,val);
	}
	std::vector<pii> ans[4];
	void solve()
	{
		scanf("%d%d%d",&n,&d0,&d1);
		work(d0,1),work(d1,2);

		for(int i=0;i<n*2;i++)
			for(int j=0;j<n*2;j++)
				ans[type[i][j]].push_back(pii(i,j));
		int ind=0;
		for(int i=1;i<4;i++)
			if(ans[i].size()>ans[ind].size())ind=i;

		if((int)ans[ind].size()<n*n)printf("O_O\n");

		for(int i=0;i<n*n;i++)
			printf("%d %d\n",ans[ind][i].x,ans[ind][i].y);
	}
}

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


Measured memory_bytes: 22516
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, K;
	cin >> N >> K;
	if (N%K == 0) cout << 0 << "\n";
	else cout << 1 << "\n";
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll a,b,q;
    cin >> a >> b >> q;
    vector<ll>d1(a);
    vector<ll>d2(b);
    set<ll>s1;set<ll>s2;
    for(int i = 0;i<a;i++)
    {
        cin >> d1[i];
        s1.insert(d1[i]);
    }
    for(int i = 0;i<b;i++)
    {
        cin >> d2[i];
        s2.insert(d2[i]);
    }
    while(q--){
        ll x;cin >> x;
        vector<ll>p;vector<ll>j;
        auto it = s1.lower_bound(x);
        if(it!=s1.end())p.push_back(*it);
        if(it!=s1.begin()) p.push_back(*prev(it));
        it = s2.lower_bound(x);
        if(it!=s2.end())j.push_back(*it);
        if(it!=s2.begin()) j.push_back(*prev(it));
        ll ans = LLONG_MAX;
        for(int i = 0;i<p.size();i++){
            for(int k = 0;k<j.size();k++){
                ans = min(ans,abs(x-p[i])+abs(p[i]-j[k]));
                ans = min(ans,abs(x-j[k])+abs(j[k]-p[i]));
            }
        }
        cout << ans <<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

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

  if (s.back() != 's') cout << s << 's';
  else cout << s << "es";
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  cout << nl;
  // }

  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int x[51], y [51], n = 0, res = 0;

    scanf("%d", &n);

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

    for (int q = 0; q < n; q++) {
        if (x[q] > y[q]) {
            res += (x[q]-y[q]);
        }
    }

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

    return 0;
}


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

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ma = max({a,b,c});
    for(int i = 1; i <= k; i++){
        ma *= 2;
    }
    cout << a+b+c+ma-max({a,b,c}) << endl;
}

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

int main(){
  char N[300000];
  int S=0;
  scanf("%s",N);
  int l=strlen(N);
  for(int i=0;i<l;i++){
   S+=(int)(N[i]-'0'); 
  }
  if(S%9==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

int main(){
    string S,T;
    cin >> S;
    int cnt=0;
    for(int i=0;i<S.size()/2;i++){
        if(S[i] != S[S.size()-1-i]) cnt++;
    }
    cout << cnt << endl;
}

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

int c[3][3];
int row[3][3];
int col[3][3];
bool f = true;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	for(int i=0; i<3; ++i)
		for(int j=0; j<3; ++j)
			cin >> c[i][j];
	for(int i=0; i<3; ++i)
		for(int j=0; j<3; ++j)
			row[i][j] = c[i][j] - c[i][(j+1)%3];
	for(int i=0; i<3; ++i)
		for(int j=0; j<3; ++j)
			col[i][j] = c[i][j] - c[(i+1)%3][j];
	for(int i=0; i<3; ++i)
		for(int j=0; j<2; ++j)
			if(row[j][i] != row[j+1][i] || col[i][j] != col[i][j+1])
				f = false;
	cout << (f ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans1 = a * x + b * y  #そのまま
ans2 = 0
if x > y:  #少ない方をABで補う
    ans2 = c * min(x, y) * 2 + a * (x - y)
else:
    ans2 = c * min(x, y) * 2 + b * (y - x)
ans3 = c * max(x, y) * 2  #すべてABで
print(min(ans1, ans2, ans3))

Measured memory_bytes: 3064
n,m=map(int,input().split())
s_p=[list(map(int,input().split()))for i in range(n)]
c_p=[list(map(int,input().split()))for i in range(m)]
for s in s_p:
    d=abs(c_p[0][0]-s[0])+abs(c_p[0][1]-s[1])
    a=1
    for i in range(1,m):
        if d>abs(c_p[i][0]-s[0])+abs(c_p[i][1]-s[1]):
            a=i+1
            d=abs(c_p[i][0]-s[0])+abs(c_p[i][1]-s[1])
    print(a)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
//int ar[100001];

int main() {
	io;
	int n;
	cin>>n;
	ll ans = 0;
	for(int i = 1; i<=n; i++)
	for(int j = 1; j<=n; j++)
	for(int k = 1; k<=n; k++)
	ans += __gcd(__gcd(i, j), k);
	cout<<ans;
	
}
	


Measured memory_bytes: 3648
#include<stdio.h>
int main(){
int i,j,n,s,t,u,g[100][100];
scanf("%d",&n);
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
  g[i][j]=0;
}
}
for(i=0;i<n;i++){
  scanf("%d%d",&s,&t);
  for(j=0;j<t;j++){
    scanf("%d",&u);
    g[s-1][u-1]=1;
  }
}
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)printf(" ");
    printf("%d",g[i][j]);
  }
  printf("\n");
}
}



Measured memory_bytes: 2720
#include <stdio.h>
int main(void){
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int n;
    scanf("%d", &n);
    int test[3][3] = {0};
    for (int i = 0; i < n; i++) {
        int b;
        scanf("%d", &b);
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) {
                    test[j][k] = 1;
                }
            }
        }
    }
    if (test[0][0] && test[0][1] && test[0][2]) {
        puts("Yes");
    } else if (test[1][0] && test[1][1] && test[1][2]) {
        puts("Yes");
    } else if (test[2][0] && test[2][1] && test[2][2]) {
        puts("Yes");
    } else if (test[0][0] && test[1][0] && test[2][0]) {
        puts("Yes");
    } else if (test[0][1] && test[1][1] && test[2][1]) {
        puts("Yes");
    } else if (test[0][2] && test[1][2] && test[2][2]) {
        puts("Yes");
    } else if (test[0][0] && test[1][1] && test[2][2]) {
        puts("Yes");
    } else if (test[2][0] && test[1][1] && test[0][2]) {
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 128
import java.util.*;

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

        //入力
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }

        boolean judge = true;
        int count = 0;
        //条件に合っているときに繰り返す
        while(judge){
            //奇数があるなら止める
            for(int j=0; j<n; j++){
                if(a[j] % 2 == 1){
                    judge = false;
                }
            }
            //割れるなら2で割る
            if(judge){
                //2で割る
                for(int k=0; k<n; k++){
                    a[k] /= 2;
                }
                //割った回数カウントする
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 36204
#include <stdio.h>
#define N 20000001
 
int A[N];
int B[N];
int C[N];
int  n;

int main(){
 
  int i;
  int m = 0;
  scanf("%d", &n);
 
  for( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
    if(m < A[i]){
      m = A[i];
    }
  }
 
  CountingSort( m );
   
  for( i = 1; i <= n; i++ ){
    if(i > 1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

return 0;
} 

void CountingSort( int k ){
  int i;
  int j;
  
for( i = 0; i <= k; i++ ){
    C[i] = 0;
  }
  for( j = 1; j <= n; j++ ){
     C[A[j]]++;
  }
  for( i = 1; i <= k; i++ ){
    C[i] = C[i] + C[i-1];
  }
  for( j = n; j > 0; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}
 

Measured memory_bytes: 21076
#include <stdio.h>
#include <stdlib.h>
   
int pz[4][4];
int tmp[4][4];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
   
void empty(int *,int *);
int dfs(int,int,int,int,int);
int cal();
void swap(int *,int *);
   
int main() {
  int i,j,k,a,x,y;
    for(i = 0; i < 4; i++)
      {
        for(j = 0; j < 4; j++)
      scanf("%d",&pz[i][j]);
      }
   
    empty(&x,&y);
    for(k = 0; k < 100; k++) {
        for(i = 0; i < 4; i++) {
            for(j = 0; j < 4; j++) tmp[i][j] = pz[i][j];
        }
   
        a = dfs(x,y,-1,0,k);
        if(a!=-1) {
            printf("%d\n",a);
            break;
        }
   
        for(i = 0 ; i < 4; i++) {
            for(j = 0 ; j < 4; j++) pz[i][j] = tmp[i][j];
        }
        a = -1;
        if(k == 99) printf("%d\n",a);
    } 
    return 0;
}
   
void empty(int *x,int *y)
{
    int p,q;
    for(p = 0;p < 4; p++)
      {
        for(q = 0; q < 4; q++)
      {
            if(!pz[p][q])
          {
                *x = q;
                *y = p;
                return;
          }
      }
      }
}
 
void swap(int *m,int *n)
{
    int sw;
    sw = *m;
    *m = *n;
    *n = sw;
}
   
   
int cal()
{
    int i,s,sum=0;
    for(i = 0; i < 16; i++)
      {
        s = pz[i/4][i%4];
        if(s)
      {
            s--;
            sum += abs(i/4 - s/4) + abs(i%4 - s%4);
      }
      }
    return sum;
}
   
   
int dfs(int x,int y,int p,int dep,int lim)
{
    int i,h,fx,fy,res;
   
    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;
   
    for(i=0; i<4; i++)
      {
        fx = x+dx[i];
        fy = y+dy[i];
   
        if((~p && i == (p+2) % 4) || (!(0 <= fx && fx < 4 && 0 <= fy && fy < 4))) continue;
   
        swap(&pz[y][x],&pz[fy][fx]);
        res = dfs(fx,fy,i,dep+1,lim);
        if(~res) return res;
   
        swap(&pz[y][x],&pz[fy][fx]);
      }
   
    return -1;
}


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

beaten = 0
B = B + [0, 0]
for i in range(N):
    if B[i] >= A[i]:
        beaten += A[i]
        beaten += min(A[i+1], B[i] - A[i])
        A[i+1] = max(0, A[i+1] - (B[i] - A[i]))
    else:
        beaten += B[i]
print(beaten)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int check(ll a){
    vector<int> flag(3, 0);
    string s = to_string(a);
    REP(i, 0, s.size()){
        if(s[i] == '3'){
            flag[0]++;
        }else if(s[i] == '5'){
            flag[1]++;
        }else if(s[i] == '7'){
            flag[2]++;
        }
    }
    REP(i, 0, 3){
        if(flag[i] == 0){
            return 0;
        }
    }
    return 1;
}

int main(){
    ll x; cin >> x;
    priority_queue<ll, vector<ll>, greater<ll> > pq;
    ll h[3] = {3, 5, 7};
    REP(i, 0, 3){
        pq.push(h[i]);
    }
    int ans = 0;
    while(1){
        ll mid = pq.top();
        if(mid > x){break;}
        pq.pop();
        REP(i, 0, 3){
            pq.push(mid*10 + h[i]);
        }
        if(x >= mid && check(mid) == 1){
            ans++;  
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
n, d = map(int, input().split())
T = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        tmp = 0

        for k in range(d):
            tmp = tmp + (T[i][k] - T[j][k]) ** 2

        tmp = tmp ** 0.5

        if tmp == int(tmp):
            ans = ans + 1

print(ans)

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

using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007

vector<pair<ll,ll> > adj[100005];
ll c[100005];

void dfs(ll x)
{
	for(ll i = 0 ; i < adj[x].size() ; i++)
	{
		ll adjver = adj[x][i].first;
		ll w1 = adj[x][i].second;

		//cout<<adjver<<" "<<x<<" "<<w1<<""<<c[adjver]<<endl;

		if(c[adjver] == -1)
		{
			if(w1 % 2 == 0)
			{
				c[adjver] = c[x];
			}
			else
			{
				c[adjver] = c[x] ^ 1;
			}

			dfs(adjver);

		}

	}
}

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

	for(ll i = 0 ; i < n - 1; i++)
	{
		ll u,v,w;
		cin>>u>>v>>w;

		u--;
		v--;

		adj[u].push_back({v,w});
		adj[v].push_back({u,w});

	}


	for(ll i = 0 ; i < n ; i++)
	{
		c[i] = -1;
	}

	for(ll i = 0 ; i < n ; i++)
	{
		if(c[i] == -1)
		{
			c[i] = 0;
			dfs(i);
		}
	}

	for(ll i = 0 ; i < n ; i++)
	{
		cout<<c[i]<<endl;
	}

}	

Measured memory_bytes: 10240
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, y = map(int, read().split())
for xx in range(n + 1):
    for yy in range(n + 1):
        v = 9 * xx + 4 * yy
        if v == y // 1000 - n:
            if n - xx - yy >= 0:
                print(xx, yy, n - xx - yy)
                exit()
print(-1, -1, -1)


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


int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;++i){
    cin >> b[i];
    --b[i];
  }
  vector<int> ans;
  for(int i=0;i<n;++i){
    int p=-1;
    for(int j=b.size()-1;j>=0;--j){
      if(b[j]==j){
        p=j;
        break;
      }
    }
    if(p==-1){
      cout << p << endl;
      return 0;
    }
    ans.push_back(p+1);
    b.erase(b.begin()+p);
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<n;++i){
    cout << ans[i] << endl;
  }

  return 0;


}


Measured memory_bytes: 256