akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("");
    let vec: Vec<&str> = input.split_whitespace().collect();
    let mut h: i32 = vec[0].parse().unwrap_or(0);
    let a: i32 = vec[1].parse().unwrap_or(0);
    let mut counter = 0;

    loop {
        h -= a;
        counter += 1;
        if h <= 0 {
            break;
        }
    }

    println!("{}", counter);
}

Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    ss=[int(input()) for _ in range(n)]
    ans=sum(ss)
    if ans%10==0:
        ss.sort()
        for s in ss:
            if s%10:
                ans-=s
                break
        else:
            ans=0
    print(ans)

main()

Measured memory_bytes: 3064
#include <stdio.h>
long long gcd(long long x, long long y) {
	long long r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
long long lcm(long long x, long long y) { return (x / gcd(x, y) * y); }
int main() {
	int n;
	long long t[100], ans = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &t[i]);
	}
	for (int i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstdlib>
#include<map>
#include<numeric>
#include<cmath>

using namespace std;

int A,B,C;
int X,Y;

 int main(){
   scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
   if(X>Y){
     int cand1 = A*X + B*Y;
     int cand2 = 2*C*X;
     int cand3 = 2*C*Y + (X-Y)*A;
     int ans = min(min(cand1,cand2),cand3);
     cout << ans << endl;

   }
   else{
     int cand1 = A*X + B*Y;
     int cand2 = 2*C*Y;
     int cand3 = 2*C*X + (Y-X)*B;
     int ans = min(min(cand1,cand2),cand3);
     cout << ans << endl;
   }


   return 0;
 }


Measured memory_bytes: 256
import sys
import collections


def main():
    S = sys.stdin.readline().strip()
    d = collections.defaultdict(int)
    for c in S:
        d[c] += 1
    for key in d:
        if d[key] != 2:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        string s; cin >> s;
        map<char, int> mp;
        FOR(i, 0, s.size()) mp[s[i]]++;
        int ans = 1;
        for(auto x: mp) if(x.ss % 2 == 1) ans = 0;
        puts(ans == 1 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 3608
c = [list(map(int,input().split())) for _ in range(3)]
a1 = []
a2 = []
b1 = []
b2 = []
for i in range(3):
  a1.append(c[1][i] - c[0][i])
  a2.append(c[2][i] - c[1][i])
  b1.append(c[i][1] - c[i][0])
  b2.append(c[i][2] - c[i][1])
def l(x):
  return len(list(set(x)))
if (l(a1) == 1) and (l(a2) == 1) and (l(b1) == 1) and (l(b2) == 1):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double c=abs(5.0*h+m/12.0-m);
	c=sqrt(a*a+b*b-2*a*b*cos(c*PI/30.0));
	cout.setf( ios::fixed );
    cout<<setprecision(20)<<c<<endl;
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<numeric>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> v(N);
    for(auto &x:v){
        cin>>x;
    }

    long sum=accumulate(v.begin(),v.end(),0);
    long ma=*max_element(v.begin(),v.end());

    if(sum-ma>ma){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int answer;
    for (int i=1; i<=n; i++) {
        if (i >= 1 && i <=9) answer++;
        if (i >= 100 && i <=999) answer++;
        if (i >= 10000 && i <=99999) answer++;
    }
    
    cout << answer;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     String str = scanner.nextLine();
     int q = scanner.nextInt();
     for(int i=0;i<q;i++){
       String ope = scanner.next();
       if(ope.equals("print")){
         int a = scanner.nextInt();
         int b = scanner.nextInt();
         System.out.println(str.substring(a,b+1));
       }
       if(ope.equals("reverse")){
         int a = scanner.nextInt();
         int b = scanner.nextInt();
         StringBuffer rstr = new StringBuffer(str);
         StringBuffer sb = new StringBuffer(str.substring(a,b+1));
         String revstr = sb.reverse().toString();
         str = rstr.replace(a,b+1,revstr).toString();
       }
       if(ope.equals("replace")){
         int a = scanner.nextInt();
         int b = scanner.nextInt();
         String pstr = scanner.next();
         StringBuffer rstr = new StringBuffer(str);
         str = rstr.replace(a,b+1,pstr).toString();
       }
     }
  }
}



Measured memory_bytes: 29644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    int n,a,b; cin>>n>>a>>b;
    vector<int> x(n);
    rep(i,n) cin>>x.at(i);
    int ans=0;
    rep(i,n-1){
        if((x.at(i+1)-x.at(i))*a>=b) ans+=b;
        else ans+=(x.at(i+1)-x.at(i))*a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)


void solve(){
	//write here
    int n;
    cin>>n;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    int mxval = arr[0];
    ll sm = 0;
    for (int i = 0 ; i<n ; i++){
        sm += max(mxval-arr[i],0);
        mxval = max(mxval,arr[i]);
    }
    cout<<sm<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
		solve();
	return 0;
}

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

int main()
{


	int A, B;
	cin >> A >> B;
	int k;
	k = (A + B)%3;
	
	if (k == 0||A%3==0||B%3==0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;
	
	system("pause");
	return 0;

}

Measured memory_bytes: 504
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = B[N-1]
for i in range(N-1):
    D += B[i]
    if A[i] + 1 == A[i+1]:
        D += C[A[i]-1]
print(D)

Measured memory_bytes: 3188
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	static int D;
	static int[] Ci;
	static int[][] Sdi;
	//last[d,i]
	static int[,] Ldi;

	static int tests = 26;

	//満足度の変化を求める
	static int CalcS(int d, int i){
		int plus = Sdi[d][i];
		int minus = Ci[i] * (d - Ldi[d,i]);

		return (plus - minus);
	}

	//Solve
	static int Solve(int d){
		//満足度の変化が最大になるiを求める
		int max = -100000000;
		int maxIdx = 0;
		for(int i=0; i<tests; i++){
			int satis = CalcS(d, i);
			if(satis > max){
				max = satis;
				maxIdx = i;
			}
		}

		return maxIdx;
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		D = int.Parse(Console.ReadLine());

		//初期化
		Ci = new int[tests];
		Sdi = new int[D][];
		Ldi = new int[D,tests];

		//読み込む
		Ci = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		for(int i=0; i<D; i++){
			Sdi[i] = new int[tests];
			Sdi[i] = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
		}

		//出力準備（AutoFlushを切る）
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);

		for(int i=0; i<D; i++){
			int t = Solve(i);
			//出力
			Console.WriteLine(t+1);
			//データを更新
			Ldi[i,t] = i;
		}

		//出力終了
		Console.Out.Flush();
	}
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll cm(ll i, ll x) {
    if (i==-1) return -1;
    return i/x;
}

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = cm(b, x) - cm(a-1, x);
    if (ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
}



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

int main() {
  string N;
  cin >> N;
  int result = 0;
  for (int i = 0; i < N.size(); i++) {
    int iN = N.at(i) - '0';
    
    result += iN;
  }
  if (result % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();
		Caracal caracal = new Caracal();

		System.out.println(caracal.attack(h));

		scan.close();
	}
}

class Caracal {
	long attack(long h) {
		if (h > 1) return attack(h / 2) * 2 + 1;
		if (h == 1) return 1;
		return 0;
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


signed main(){
    cin >> n;
    UnionFind uf(n);
    int q;
    cin >> q;
    REP(i,q){
        int a,b,c;
        cin >> a >> b >> c;
        if(a==0){
            uf.unite(b,c);
        }
        else{
            if(uf.same(b,c)){
                print(1)
            }
            else{
                print(0)
            }
        }
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3236
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int a, b;

int jeb(int x) {
  if (x%4 == 0)
    return x;
  else if (x%4 == 1)
    return 1;
  else if (x%4 == 2)
    return x+1;
  else
    return 0;
}

signed main() {
  init_ios();
  cin >> a >> b;
  if (a == 0) {
    cout<<jeb(b)<<"\n";
    return 0;
  }
  cout<<(jeb(a-1)^jeb(b))<<"\n";
}

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

dish = []
for i in range(N):
    a,b = map(int, input().split())
    dish.append((a+b, a, b))

takahashi = 0
aoki = 0
dish.sort(reverse=True)

for i, (diff, a, b) in enumerate(dish):
    if i % 2 == 0:
        takahashi += a
    else:
        aoki += b

print(takahashi - aoki)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> b(n);REP(i, n)cin >> b[i];

	priority_queue<P> pq;
	REP(i, n)if(b[i] > a[i])pq.push(MP(b[i], i));
	ll ans = 0;

	while(!pq.empty()){
		auto now = pq.top();pq.pop();
		ll id = now.SE;
		ll num = now.FI - a[id];
		ll mai = b[(id+1)%n] + b[(id+n-1)%n];
		ans += num / mai;
		num %= mai;
		if(b[id] == a[id] + num){
			cout << -1 << endl;
			return 0;
		}
		b[id] = a[id] + num;
		if(num != 0){
			pq.push(MP(a[id]+num, id));
		}
	}

	REP(i, n){
		if(a[i] != b[i]){
			cout << -1 << endl;
			return 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9328
// Problem : 
// 			D - Grid Coloring
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 069
// URL : https://atcoder.jp/contests/abc069/tasks/arc080_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int r,c; cin >> r >> c;
    int n; cin >> n;
    vi v(n+1);
    int ans[r][c];
    rep(i,1,n+1) cin >> v[i];
    
    int r1 = 0 ,c1 = 0 , dirn = 1 , num;
    
    rep(i,1,n+1){
        num = v[i];
        deb(num);
        while(num--){
            
            if(r1==r){
                c1++ , r1=r-1;
                deb(r1);
                dirn++;
            } else if(r1==-1){
                c1++ , r1=0;
                dirn++;
            }
            
            ans[r1][c1] = i;
            
            if(dirn%2) r1++;
            else r1--;
        }
    }
    
    rep(i,0,r){
        rep(j,0,c) cout << ans[i][j] << " ";
        cout << "\n";
    }
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3740
#include<stdio.h>
int main()
{
  int a,b,s;
  while (1) {
    scanf("%d %d", &a,&b);
    if (a == 0 && b == 0){
    break;
    }
    if(a > b){
      s=b;
      b=a;
      a=s;
    }
    printf("%d %d\n", a,b);
  }
  return 0;
}

Measured memory_bytes: 2564
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
 
int main(void) {
  int n;
  cin >> n;
  string s[n];
  int t[n];
  int ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
    ans += t[i];
  }
  string x;
  cin >> x;
  for(int i = 0; i < n; i++) {
    ans -= t[i];
    if(s[i] == x)
      break;
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vec<ll> mem(n,0);
    rep(i,k){
        ll d;
        cin>>d;
        rep(j,d){
            ll a;
            cin>>a;
            mem[a-1]++;
        }
    }
    ll sum=0;
    rep(i,n){
        if(mem[i]==0) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        cout << (char)(((S[i] - 'A' + N) % 26) + 'A');
    }
    cout << endl;
}

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

/*int main ()
{
  int n;
   cin>>n;
   int a[n];
   unordered_map<int,int> m;
   for(int i=0;i<n;i++)
   {
       m[cin>>a[i],a[i]]++;
   }
   int ans=0;
   sort(a,a+n);
   if(m[1]>0)
   {
       if(m[1]==1)
       cout<<1<<endl;
       else
        cout<<0<<endl;
   }
   else
    {
        for(int i=0;i<n;i++)
       {
            int f=0;
            if(m[a[i]]>1)
            {
                f=1;
                continue;
            }
            else
            {
                for(int k=2;k<=sqrt(a[i]);k++)
                {
                    if(a[i]%k==0)
                    {
                        if((m[a[i]/k])||m[k])
                        {
                            f=1;
                            break;
                        }
                    }
                }
            }
            if(!f)
                ans++;
       }
       cout<<ans<<endl;
   }
}*/
int main ()
{
    int n;
  cin>>n;
  int64_t a[n+10],ans=1;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  if(a[0]==0)
  {
      cout<<0<<endl;
      return 0;
  }
  for(int i=0;i<n;i++)
{
  if(a[i]<=bada/ans)
  {
      ans*=a[i];
  }
  else
  {
      cout<<-1<<endl;
      return 0;
  }
}
  cout<<ans;
}
/*int main()
{
    double a,b;
    cin>>a>>b;
    int64_t res=floor(a*b);
    cout<<res<<endl;
}*/



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

int n, ans=0;
vector<int> a(500000);

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

    for (int i = 0; i < n; ++i)
    {
        if (a.at(a.at(i)-1)-1 == i)
        {
            ans++;
        }
    }

    cout << ans/2 << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        char c0 = str.charAt(0);
        char c1 = str.charAt(1);
        char c2 = str.charAt(2);
        char c3 = str.charAt(3);

        if ((c0 == c1 && c2 == c3 & c0 != c2)
            || (c0 == c2 && c1 == c3 & c0 != c1)
                || (c0 == c3 && c1 == c2 & c0 != c1)) {

            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MAXN 99999
int a[2*MAXN+5],N;
int Query(int ans)
{
	char ret[20]={};
	printf("%d\n",ans);
	fflush(stdout);
	scanf("%s",ret);
	if(ret[0]=='V')	exit(0);
	return ret[0]=='M'?1:0;
}
int main()
{
	memset(a,-1,sizeof(a));
	scanf("%d",&N);
	int L=0,R=N-1;
	int lnum=Query(0),rnum=Query(N-1);
	a[0]=a[N]=lnum;
	a[N-1]=a[2*N-1]=rnum;
	while(1)
	{
		int mid=(L+R)/2;
		int ret=Query(mid);
		bool Find=false;
		a[mid]=a[mid+N]=ret;
		for(int i=L+N;i>mid;i--)
		{
			if(a[i]!=-1&&(mid+N-i+1)%2==ret!=a[i])
			{
				R=mid;
				rnum=ret;
				Find=true;
				break;
			}
		}
		if(Find==false)
		{
			lnum=ret;
			L=mid;
		}
//		for(int i=R;i<2*N;i++)
//		{
//			if(a[i]!=-1&&(i-mid+1)%2==ret!=a[i])
//			{
//				L=mid;
//				lnum=ret;
//				continue;
//			}
//		}
	}
	return 0;
}

Measured memory_bytes: 1620
N,M = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

MOD = 10**9+7

dxs = [b-a for a,b in zip(X,X[1:])]
dys = [b-a for a,b in zip(Y,Y[1:])]

xsum = 0
k = d = len(dxs)
for dx in dxs:
    xsum += k*dx
    xsum %= MOD
    d -= 2
    k += d

ysum = 0
k = d = len(dys)
for dy in dys:
    ysum += k*dy
    ysum %= MOD
    d -= 2
    k += d

print((xsum * ysum) % MOD)

Measured memory_bytes: 20604
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
Scanner sc=new Scanner(System.in);
long dd[]=new long[10000];
int x=9;
long r = 0;
long su;
for(int i=0;x==9;i++){
su=sc.nextInt();
if(su!=0){
	dd[i]=su;
}
if(su==0){
	r=i;
	break;
}
}
for(int y=0;y<r;y++){
	int l=y+1;
	System.out.println("Case "+ l +": "+dd[y]);
}


	}

}

Measured memory_bytes: 43676
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n, m)-2)
elif n == 2 or m == 2:
    print(0)
else:
    print((n-2)*(m-2))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int solve(string s, string t){
    int ans = 0;
    for(int i=0 ; i < s.size() ; i++ ){
        string s_ = s.substr(i);
        int len = min( s_.size() , t.size() );
        int a[4001] = {0};
         
        for(int j=0 ; j < len ; j++ ){
            if( s_[j] == t[j] ) a[j] = 1;
        }
         
        int sum=0;
        for(int j=1 ; j < len ; j++ ){
            if( a[j-1] > 0 && a[j] > 0 ){
                a[j] = a[j-1] + 1;
                sum = max( sum , a[j-1] + 1 );
            }
        }
        ans = max( ans , sum );
    }
    return ans;
}
 
int main(){
    string s, t;
    while( cin >> s >> t ){
        int ans = max( solve(s,t) , solve(t,s) );
        cout << ans << endl;
    }
}

Measured memory_bytes: 1244
H, W = [int(x) for x in input().split()]
cell = [list(input()) for i in range(H)]

painted = []
for h in range(H):
    for w in range(W):
        if cell[h][w] == '#':
            painted.append([h, w])

ans = 0
while len(painted) > 0:
    to_be_painted = []
    for blackcell in painted:
        h = blackcell[0]
        w = blackcell[1]
        for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
            nh = h + dy
            nw = w + dx
            if 0 <= nh and nh < H and 0 <= nw and nw < W and cell[nh][nw] == '.':
                cell[nh][nw] = '#'
                to_be_painted.append([nh, nw])
    painted = to_be_painted
    if len(painted) > 0: ans += 1

print(ans)


Measured memory_bytes: 178560
n = int(input())
name = {}
for i in range(n):
    st = str(input())
    if st in name:
        tmp = name[st] + 1
        name[st] = tmp
    else:
        name[st] = 1

max_val = max(name.values())
max_name = [k for k, v in name.items() if v==max_val]
max_name = sorted(max_name)

for n in max_name:
    print(n)

Measured memory_bytes: 32988
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0

for rem in range(k):
    dp = [[0]*3 for _ in range(n//k + int(n%k > rem))]
    ind = 0
    for i in range(rem,n,k):
        dp[ind][0] = max(dp[ind-1][1], dp[ind-1][2]) + int(t[i] == 's') * r
        dp[ind][1] = max(dp[ind-1][2], dp[ind-1][0]) + int(t[i] == 'p') * s
        dp[ind][2] = max(dp[ind-1][0], dp[ind-1][1]) + int(t[i] == 'r') * p

        ind += 1
    ind -= 1
    ans += max(dp[ind][0], dp[ind][1], dp[ind][2])
print(ans)

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

int main() {
   int N;
   cin >> N;
   vector<long long> a(N,0);
   for(int i = 0; i < N; ++i){
     cin >> a.at(i);
   }
   int SUM = 0;
   for(int i = 0; i < N; ++i){
     SUM = SUM ^ a.at(i);
   }
   for(int i = 0; i < N; ++i){
     cout << (SUM ^ a.at(i)) << " ";
   }

   return 0;
}


Measured memory_bytes: 4648
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll num[205][205];
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int i,j,k;
	memset(num,-1,sizeof(num));
	for(i=1;i<=200;i++)
	{
		for(j=1;j<=i;j++)
		{
			ll s=gcd(i,j);
			num[i][j]=s;
			num[j][i]=s;
		}
	}
	ll ans=0;
	int t;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		for(j=1;j<=t;j++)
		{
			for(k=1;k<=t;k++)
			{
				ans+=num[num[i][j]][k];
			}
		}
	}
	cout<<ans;
	return 0;
 } 

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

int main(){
    int a,b;
    cin >> a >> b;

    int ans =-1;
    rep(i, 10010){
        int ax = floor(i*0.08);
        int bx = floor(i*0.10);
        if(ax==a and bx==b){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
	int n,i,j,c;
	ll k,a[100000],x,sub_k=0,s=0,tmp=0;
	cin >> n >> k; ++k;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(j=0; j<40; ++j){
		c = 0;
		for(i=0; i<n; ++i){
			if(a[i]&(1ll<<j)){
				++c;
			}
		}
		if(c*2<n){
			s += (1ll<<j);
		}
	}
	for(j=0; j<40; ++j){
		tmp = 0ll;
		if(!(k&(1ll<<j))){
			continue;
		}
		x = (k/(1ll<<(j+1)))*(1ll<<(j+1))+s%(1ll<<j);
		for(i=0; i<n; ++i){
			tmp += (a[i]^x);
		}
		sub_k = max(sub_k,tmp);
	}
	cout << sub_k << endl;
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};
vector<vector<int>> v;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    n = n % 10;
    if(n==3){
        cout << "bon";
    }
    else if(n==0||n==1||n==6||n==8){
        cout << "pon";
    }
    else{
        cout << "hon";
    }
}
    

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a = 0;
  cin >> n;
  for(int i=0; i<10; i++) {
    for(int j=0; j<10; j++) {
      if(n == i*j) {
        a = 1;
      }
    }
  }
  if (a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define int long long
#define INF 1e18

signed main() {
    vector<int> v(5); for(int i = 0; i < 5; i++) cin >> v[i];
    int k; cin >> k;

    for(int i = 0; i < 5; i++) {
        for(int j = 0; j < 5; j++) {
            if(abs(v[i] - v[j]) > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
A = list(map(int, input().split()))

def func(A, ind):
    return abs(A[ind[2]] - A[ind[1]]) + abs(A[ind[1]] - A[ind[0]])


indices = [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]

m = float("inf")
for ind in indices:
    tmp = func(A, ind)
    if tmp <= m:
        m = tmp

print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    ll ans=0;
    
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    
    ll a[N];
    for(ll i=0; i<N; i++){
        cin >> a[i];
    }
    
    ll sum[N];
    sum[0]=a[0];
    for(ll i=1; i<N; i++){
        sum[i]=sum[i-1]+a[i];
    }
    
    ll num=N*(N+1)/2;
    ll beauty[num];
    
    ll cnt=0;
    for(ll l=0; l<N; l++){
        for(ll r=l; r<N; r++){
            if(l==0){
                beauty[cnt]=sum[r];
            }else{
                beauty[cnt]=sum[r]-sum[l-1];
            }
            cnt++;
        }
    }
    
    
    ll divisor=1;
    for(int i=0; i<48; i++){
        divisor*=2;
    }
    
    int yes[num];
    for(ll i=0; i<num; i++){
        yes[i]=1;
    }

    
    for(; divisor>=1; divisor/=2){
        ll n=0;
        for(ll i=0; i<num; i++){
            if(((beauty[i]/divisor)%2==1)&&yes[i]==1){
                n++;
            }
        }
        
        if(n>=K){
            for(ll i=0; i<num; i++){
                if(((beauty[i]/divisor)%2==1)&&yes[i]==1){
                    yes[i]=1;
                }else{
                    yes[i]=0;
                }
            }
            
            ans+=divisor;
        }else{
            
        }
    }
    

    
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6144
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

const int mx=8e3+5;
int X[2];
char str[mx];
vector <int> ara[2];
int8_t DP[2*mx][mx][2];

int8_t solve (int x,int pos,int i)
{
    if (pos==ara[i].size()) {///cout<<pos<<endl;
        if (x==X[i]) return DP[x+mx][pos][i]=1;
        else return DP[x+mx][pos][i]=-1;
    }
    if (DP[x+mx][pos][i]!=0) return DP[x+mx][pos][i];
    return DP[x+mx][pos][i]=max(solve(x+ara[i][pos],pos+1,i),solve(x-ara[i][pos],pos+1,i));
}

int main ()
{
    int i,n;

    scanf ("%s",str);
    scanf ("%d %d",&X[0],&X[1]);
    n=strlen(str);
    int j=0,cnt=0;
    for (i=0;i<n;i++) {
        if (str[i]=='T') {
            ara[j].push_back(cnt);
            cnt=0;
            j^=1;
        }
        else cnt++;
    }
    ara[j].push_back(cnt);
    int rx=solve(ara[0][0],1,0);
    int ry=solve(0,0,1);///cout<<rx<<' '<<ry<<endl;
    if (rx==1 && ry==1) printf ("Yes\n");
    else printf ("No\n");

    return 0;
}


Measured memory_bytes: 137472
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }

    int ans = 0;
    queue<pair<int, int>> que;
    queue<int> rec;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (grid[i][j] == '#')
            {
                que.push(make_pair(j, i));
                rec.push(0);
            }
        }
    }

    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        ans = rec.front();
        rec.pop();
        for (int i = 0; i < 4; i++)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (nx < 0 || nx >= w || ny < 0 || ny >= h || grid[ny][nx] == '#')
            {
                continue;
            }
            grid[ny][nx] = '#';
            que.push(make_pair(nx, ny));
            rec.push(ans + 1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13584
R, G, B, N = map(int, input().split())

ans = 0
for r in range(-(-N // R) + 1):
    for g in range(-(-N // G) + 1):
        bB = N - r * R - g * G
        if bB % B > 0: continue
        b = bB // B
        if b < 0: continue
        ans += 1

print(ans)

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0)
			ans += v[i] - c[i];
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {

	long long W, a, b;

	cin >> W >> a >> b;

	if(b > (W + a)){
		cout << b - (W + a) << endl;
	}else if(a > (W + b)){
        cout << a - (W + b) << endl;
	}else{
        cout << 0 << endl;
    }

	return 0;
}

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

#define ln '\n'
#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 FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a + b - 3) / (a - 1) << ln;
    return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    int a, b;
    cin >> a >> b;

    if (a * b % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,i,k=100000;
scanf("%d",&n);
for(i=0;i<n;i++){
k*=1.05;
if(k%1000!=0){
k=k/1000;
k=k*1000+1000;
}
}
printf("%d\n",k);
return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    string m,n;
    cin >> m >> n;
    ll ans=0;
    for (ll i=0;i<3;i++){
        if (m[i]==n[i])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(N-1));
    rep(i,N){
        rep(j,N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vector<queue<ll>> que(N);
    rep(i,N){
        rep(j,N-1){
            que[i].push(A[i][j]);
        }
    }
    ll ans = 0;
    ll cnt = 0;
    rep(j,N*(N-1)/2){
        ans++;
        vector<ll> mp(N,0);
        bool flag = false;
        rep(i,N){
            if(mp[i] > 0) continue;
            if(que[i].empty()) continue;
            ll t = que[i].front();
            if(mp[t] > 0) continue;
            if(que[t].front() == i){
                flag = true;
                que[i].pop();
                que[t].pop();
                mp[i]++;
                mp[t]++;
                cnt++;
            }else{
                continue;
            }
        }
        //cout << ans << " " << cnt << endl;
        if(!flag){
            bool flag2 = false;
            rep(i,N){
                if(!que[i].empty())flag2 = true;
            }
            if(flag2){
                cout << -1 << endl;
                return 0;
            }else{
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19904
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
         
        int W,H,x,y,r;
         
        W=scan.nextInt();
        H=scan.nextInt();
        x=scan.nextInt();
        y=scan.nextInt();
        r=scan.nextInt();
         
        if(r<=x&&r<=y&&x<=W-r&&y<=H-r){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
         
        scan.close();
    }
}



Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, ans;
multiset<ll> st;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		ll x; scanf("%lld", &x);
		st.insert(x);
	}
	while (!st.empty()) {
		ll v = *--st.end();
		st.erase(--st.end());
		for (int i = 0; i <= 32; ++i) {
			ll t = (1ll << i) - v;
			if (st.find(t) != st.end()) {
				++ans; st.erase(st.find(t)); break;
			}
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 9600
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

vector<ll> fact, invfact;

ll modpow(ll x, ll a){
    ll ans=1;
    while(a){
        if(a&1) ans=ans*x%MOD;
        a>>=1;
        x=x*x%MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x,MOD-2);
}


void buildFact(int n){
    fact=vector<ll>(n+1,1);
    invfact=vector<ll>(n+1,1);
    for(int i=1;i<=n;i++){
        fact[i]=fact[i-1]*i%MOD;
    }
    invfact[n] = inv(fact[n]);
    for(int i=n-1;i>=1;i--){
        invfact[i] = invfact[i+1]*(i+1)%MOD;
    }
}

ll bcomb(int n, int k){
    return fact[n]*invfact[k]%MOD*invfact[n-k]%MOD;
}

int main(){
    // CFS;
    int x, y;
    cin >> x >> y;
    ll l, r;
    if(-x + 2 * y >= 0 && (-x + 2 * y) % 3 == 0 && -y + 2 * x >= 0 && (-y + 2 * x) % 3 == 0){
        l = (-x + 2 * y) / 3;
        r = (-y + 2 * x) / 3;
        buildFact(l+r+1);
        cout << bcomb(l+r, l) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; i++)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; i--)
#define vi vector<int>
#define vs vector<string>
#define all(x) (x).begin(),(x).end()
int main() {
    int n;
    cin>>n;
    vi d(n);
    repp(i,0,n){
        cin>>d[i];
    }
    sort(all(d), greater<int>());
    int cnt=1;
    repp(i,1,n){
        if(d[i]!=d[i-1]){
            cnt++;
        }
    }
    cout<< cnt <<endl;
}

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

int main(){
  long long  n,k;
  cin>>n>>k;
  long long sum=(n/k)*(n/k)*(n/k);
  if(k%2==0){
    long long t=n/(k/2)-n/k;
    sum+=t*t*t;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int a,b;
	while(cin>>a>>b,a||b){
		int hit=0,blow=0;
		for(int i=0,c=1;i<4;++i){
			for(int j=0,d=1;j<4;++j){
				if(i==j) hit+=(a/c%10==b/d%10)?1:0;
				else blow+=(a/c%10==b/d%10)?1:0;
				d*=10;
			}
			c*=10;
		}
		cout<<hit<<" "<<blow<<endl;
	}
}

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

// RMQ<int> rmq(114514);
template<typename V> struct RMQ {
	private:
	int n;
	vector<V> node;
	public:
	RMQ(int sz) {
		n=1;while(n<sz)n*=2;
		node.resize(2*n-1,(1<<31)-1);
	}
	void update(int x, V val) {
		x+=n-1,node[x]=val;
		while(x>0) x=(x-1)/2,node[x]=min(node[2*x+1],node[2*x+2]);
	}
	V q(int a, int b, int k=0, int l=0, int r=-1) {
		if(r<0) r=n;
		if(r<=a||b<=l) return INT_MAX;
		if(a<=l&&r<=b) return node[k];
		return min(q(a,b,2*k+1,l,(l+r)/2),q(a,b,2*k+2,(l+r)/2,r));
	}
};

int n, q, a, b, c;
RMQ<int> rmq(114514);

int main() {
	cin >> n >> q;
	while (q--) {
		cin >> a >> b >> c;
		if (a==0) rmq.update(b,c);
		else cout << rmq.q(b,c+1) << endl;
	}
}


Measured memory_bytes: 3712