akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}


const int mx = 1e5 + 10;

vector<int> a, b;
int n, dep[18][1 << 18];

int dp(int tadi, int mask){
    int now = __builtin_popcount(mask);
    if(now == n) return 0;
    int &ret = dep[tadi][mask];
    if(ret != -1) return ret;
    ret = 1e9;
    int bil = -1e9;
    if(mask > 0){
        if((now - 1) % 2 == tadi % 2) bil = a[tadi];
        else bil = b[tadi];
    }
    vector<int> count(n, 0);
    for(int i = 0; i < n; i++){
        if(mask & (1 << i)) count[i] = 1;
    }
    for(int i = n - 2; i >= 0; i--) count[i] += count[i + 1];
    for(int i = 0; i < n; i++){
        if(mask & (1 << i)) continue;
        int cost = 0;
        if(i < n - 1) cost = count[i + 1];
        int apa = b[i];
        if(i % 2 == now % 2) apa = a[i];
        if(bil <= apa) ret = min(ret, dp(i, mask | (1 << i)) + cost);
    }
    return ret;
}

void solve(){
    cin >> n;
    a.resize(n);
    b.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    reset(dep, -1);
    int ans = dp(0, 0);
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 18688
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    ll ans=0,id;
    int N,M;
    ll A,B,C,W;
    int a[100010];
    bool f=false;
    ll sum=0;
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    A=1;
    while(A*2<=N){
        A*=2;
    }
    cout<<A;
    return 0;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
  int a,b,c,d;scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b == c+d){
    printf("Balanced\n");
  }else if(a+b < c+d){
    printf("Right\n");
  }else{
    printf("Left\n");
  }
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
 
        double a = x1 - x2;
        double b = y1 - y2;
        System.out.println(Math.sqrt(a*a + b*b));
    }
}


Measured memory_bytes: 27752
#include <iostream>
using namespace std;
int main(void){
    int a,b,c, c_Kane,x,kumachan_COUNT=0;
    cin>>a>>b>>c>>x;
    for(int i=0; i<=a; i++)
        for(int j=0; j<=b; j++){
        c_Kane=x-500*i-100*j;
        int c_Maisu = c_Kane / 50;
        if(c_Maisu>=0 && c_Maisu <= c){
        kumachan_COUNT++;
        }
    }
    cout<<kumachan_COUNT<<endl;
}

Measured memory_bytes: 256
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:  
		break
	for h in range(H):
		str = ''
		for w in range(W):
			if (h % 2) == 0:
				if (w % 2) == 0:
					str += '#'
				else:
					str += '.'
			else:
				if (w % 2) == 0:
					str += '.'
				else:
					str += '#'				
		print(str)
	print()


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

long long GCD(long long x, long long y) {
	if (y == 0)return x;
	return GCD(y, x % y);
}

long long LCM(long long x, long long y) {
	return (x * y) / GCD(x, y);
}

long long f(int x, int y, long long a) {
	long long res = a;
	res-= a / x;
	res -= a / y;
	res += a / LCM(x, y);
	return res;
}

int main() {
	long long A, B;
	int C, D;
	cin >> A >> B >> C >> D;
	long long ans = f(C, D, B) - f(C, D, A - 1);
	cout << ans << endl;
	return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

int initial['Z'+1];
signed main() {
    int n; cin >> n;
    rep(i,n){
        string s; cin >> s;
        initial[s[0]]++;
    }
    
    int ans = 0;
    string m = "MARCH";
    reps(i,0,2)reps(j,i+1,3)reps(k,j+1,4){
        ans += initial[m[i]] * initial[m[j]] * initial[m[k]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
inputs = [list(map(int, input().split())) for _ in range(int(input()))]
ans = []

def niwari(x, y, _b, _p):
  b = 5 if _b < 5 else _b
  p = 2 if _p < 2 else _p
  return int(0.8*(x*b+y*p))

for inpt in inputs:
  x, y, b, p = inpt
  if b >= 5 and p >= 2:
    # まとめ買いで2割引
    ans.append(str(int((x*b+y*p)*0.8)))
  else:
    ans.append(str(min(int(x*b+y*p), niwari(x, y, b, p))))

print('\n'.join(ans))


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

int main() {
  int N;
  cin >> N;
  if(N%10==3){
    cout << "bon" << endl;
  } else if(N%10 == 0|| N%10 == 1||N%10 == 6||N%10 == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	const int MAX = 162;
	const int M = MAX * 82;
	int H, W, ans = INF;
	vector<vector<int>> A, B;
	vector<vector<vector<bool>>> sum;
	
	cin>>H>>W;
	
	A.resize(H, vector<int>(W));
	B.resize(H, vector<int>(W));
	// sum.resize(MAX * 2 * 82);
	// sum.resize(MAX, vector<int>(MAX));
	sum.resize(H+1, vector<vector<bool>>(W+1, vector<bool>(MAX * 2 * 83)));
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>A[i][j];
		}
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>B[i][j];
		}
	}
	
	sum[0][0][M] = true;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			for(int k = M - (i + j + 1) * 80; k <= M + (i + j + 1) * 80; k++){
				if(sum[i][j][k]) { 
				// cout<<"i = "<<i<<" j = "<<j<<" k = "<<k-M<<endl;
					sum[i+1][j][k+(A[i][j] - B[i][j])] = true;
				
					sum[i+1][j][k+(B[i][j] - A[i][j])] = true;
					
					sum[i][j+1][k+(A[i][j] - B[i][j])] = true;
					sum[i][j+1][k+(B[i][j] - A[i][j])] = true;
				}
			}
		}
	}
	
	for(int i = 0; i < MAX * 2 * 83; i++){
		if(sum[H-1][W][i]){
			ans = min(ans, abs(i-M));
			// cout<<"i = "<<i-M<<endl;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 24648
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int cur=0;
		for(int j=i;j<n;j++)
		{	
			cur=cur*10 + (s[j]-'0');
			int ahead=n-1-j;
			int behind=i;
			ahead=max(0LL, ahead-1);
			behind=max(0LL, behind-1);
			ans+=cur*(1LL<<(ahead))*(1LL<<(behind));
		}
	}
	cout<<ans;
	return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    vector<int>a2;
    vector<int>b(m);
    vector<int>b2;
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<m;i++){
        if(a[i]==1){
            a2.push_back(b[i]);
        }
        if(b[i]==n){
            b2.push_back(a[i]);
        }
    }
    if(a2.empty()==1||b2.empty()==1){
        cout<<"IMPOSSIBLE";
        return 0;
    }
    sort(a2.begin(),a2.end());
    unique(a2.begin(),a2.end());
    sort(b2.begin(),b2.end());
    unique(b2.begin(),b2.end());
    
    for(int i=0;i<a2.size();i++){
        if(binary_search(b2.begin(),b2.end(),a2[i])==1){
            cout<<"POSSIBLE";
            return 0;
        }
    }
    
    cout <<"IMPOSSIBLE";
}

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

int main(){
  int n;
  cin >> n;
  set<char> st;
  char a;
  for(int i=0;i<n;i++){
    cin >> a;
    st.insert(a);
  }
  if(st.size()==3)cout << "Three" << endl;
  else cout << "Four" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int x = sc.nextInt();
		for (int i = 0; i <= x; i++) {
			if(i*(i+1)/2 >= x) {
				System.out.print(i);
				break;
			}
		}
		

	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

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

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

    vector<long long> ret;
    ret = divisor(n);

    long long count = 0;

    for(long long i = 0; i < ret.size(); i++){
        if(ret[i] >= 3){
            long long another;
            another = n/ret[i];
            if(another < ret[i]-1){
                count += ret[i]-1;
            }
        }
    }

    cout << count << endl;
    return 0;
}

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

int main() {
  int a,b; cin >> a >> b;
  cout << ((a*3)+b)/2 << endl;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args) {
		C();
	}
	
	// R+X = 2G
	public static void A() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		System.out.println(2*g-r);
	}
	
	//シミュレート
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ret = 1;
		for(int i=0;i<N;i++) {
			if(ret<K) ret += ret;
			else ret += K;
		}
		System.out.println(ret);
	}
	
	//Tをもっとも後ろに当てはめる
	//残りの?をaで埋める
	
	//Tがマッチするかどうか　マッチするならもっとも後ろの位置を返す else -1
	public static int match(String S, String T) {
		for(int i=S.length()-1;i>=T.length()-1;i--) {
			if((S.charAt(i)==T.charAt(T.length()-1) || S.charAt(i)=='?')  && checksame(S,T,i)) return i-T.length()+1;
		}
		return -1;
	}
	// i-T.length()+1 ~ iが一致するか調べる　？はワイルドカード
	public static boolean checksame(String S, String T, int i) {
		for(int j = 0;j<T.length();j++) {
			if(S.charAt(i-T.length()+1+j)!=T.charAt(j) && S.charAt(i-T.length()+1+j)!='?') return false;
		}
		return true;
	}
	
	public static void C() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int matchidx = match(S,T);
		if(matchidx == -1) {
			System.out.println("UNRESTORABLE");
			return;
		}
		StringBuilder ns = new StringBuilder();
		int i=0;
		for(;i<matchidx;i++) {
			if(S.charAt(i)=='?') ns.append('a');
			else ns.append(S.charAt(i));
		}
		ns.append(T.toCharArray());
		i += T.length();
		for(;i<S.length();i++) {
			if(S.charAt(i)=='?') ns.append('a');
			else ns.append(S.charAt(i));
		}
		ns.toString();
		System.out.println(ns);
	}
}

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

int main() {
	
	int n; cin >> n;
	vector<string> s(n);
	vector<int>	t(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i];
	}
	string x; cin >> x;
	bool sum = false;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (sum) ans += t[i];
		if (x == s[i]) {
			sum = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
n = int(input())
w = []
for _ in range(n):
    w += [str(input())]

ans = 1
s = w[0][-1]
for x in w[1:]:
    if x[0] == s:
        s = x[-1]
    else:
        ans = 0
        break

import collections
c = collections.Counter(w)
if c.most_common()[0][1] > 1:
    ans = 0

if ans:
    print('Yes')
else:
    print('No')


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

int main(){
  int N;

  cin >> N;
  
  vector<int> W(N);
  
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  
  int sum1 = 0, sum2 = 0;
  
  for (int i = 0; i < N; i++) {
    sum2 += W.at(i);
  }
  
  int dif = sum2;
  
  for (int i = 0; i < N; i++) {
    sum1 += W.at(i);
    sum2 -= W.at(i);
    if (abs(sum2 - sum1) < dif) {
      dif = abs(sum2 - sum1);
    }
  }
  
  cout << dif << endl;
  
  return 0;
}

Measured memory_bytes: 256
// ABC078
// A -HEX
#include<bits/stdc++.h>

using namespace std;

int main(){
    char a,b;
    cin >> a >> b;
    if(a<b) cout << "<" << endl;
    else if (a>b) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}


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

int main()
{
    int n,card[4][20]={},x;
    char c;
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>c>>x;

        if(c=='S'){
            card[0][x]=1;
        }else if(c=='H'){
            card[1][x]=1;
        }else if(c=='C'){
            card[2][x]=1;
        }else{
            card[3][x]=1;
        }
    }

    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(card[i][j]==0){
                if(i==0){c='S';}
                else if(i==1){c='H';}
                else if(i==2){c='C';}
                else{c='D';}

                cout<<c<<" "<<j<<endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<set>
using namespace std;

int main(){
  int n;
  int X;
  set<int>st;
  vector<int>dist;
  vector<int>divide;
  
  cin>>n>>X;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    st.insert(abs(x-X));
  }

  for(set<int>::iterator itr=st.begin();itr!=st.end();itr++){
    dist.push_back(*itr);
  }
  
  for(int i=1;i*i<=dist[0];i++){
    if(dist[0]%i==0){
      divide.push_back(i);
      if(i*i!=dist[0]){
	divide.push_back(dist[0]/i);
      }
    }
  }

  sort(divide.begin(),divide.end());
  int maxIndex=divide.size()-1;

  for(int i=0;i<dist.size();i++){
    while(dist[i]%divide[maxIndex]!=0){
      maxIndex--;
    }
  }
  
  cout<<divide[maxIndex]<<endl;
  return(0);
}


Measured memory_bytes: 5500
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    string x;
    cin >> x;
    vector<char> vt;
    char x1, x2;
    for(int i = 0; i < x.size() ; i ++ ){
        vt.push_back(x[i]);
        if(vt.size() >= 2){
            x1 = vt[(int)vt.size() - 2];
            x2 = vt[(int)vt.size() - 1];
            if(x1 == 'S' && x2 == 'T'){
                vt.pop_back();
                vt.pop_back();
            }
        }
    }
    cout << vt.size() << "\n";
    return 0;
}


Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b,c;
string s,t;
int main(){
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) b++;

    }
    cout << b;

}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int N = 1e6 + 7;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
}

int C(int n, int k) {
	return divv(f[n], mul(f[k], f[n - k]));
}

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

	init();

	int x, y;
	cin >> x >> y;
	if ((x + y) % 3) {
		cout << 0 << endl;
		exit(0);
	}
	int all = (x + y) / 3;
	int ans = 0;
	for (int a = 0; a <= x; a++) {
		int b = all - a;
		if (a + 2 * b == x && 2 * a + b == y) {
			ans = add(ans, C(all, a));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  string S; map<string, int> m; while (N--) cin >> S, ++m[S];
  for (auto s : {"AC", "WA", "TLE", "RE"}) printf("%s x %d\n", s, m[s]);}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    string s;
    cin>>s;
    int res=0;
    int n=s.length();
    for(ri int i=0;i<n;i++) res+=(s[i]=='1');
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3684
use std::vec::Vec;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn tp_sort(l: &Vec<Vec<i64>>, h:  &mut Vec<i64>, v: i64) -> Vec<i64> {
  // l: 出力があるノードをリストに持っているベクター
  // h: 各頂点の入力字数を表したベクター
  // v: ノードの数, e: エッジの数
  let mut res: Vec<i64> = Vec::new(); //トポロジカルソートした結果を蓄積するベクター
  let mut s: Vec<i64> = Vec::new(); //入力エッジを持たないノードの集合

  // 入力される辺がない頂点をsに追加
  for i in 0..v as usize {
    if h[i] == 0 {
      s.push(i as i64);
    }
  }

  while !s.is_empty() {
    let n = match s.pop() {
      Some(n) => n,
      None => 0,
    };

    res.push(n);

    for i in &l[n as usize] {
      h[*i as usize] -= 1;

      if h[*i as usize] == 0 {
        s.push(*i);
      }
    }

  }

  return res;
}

fn main() {
    let (n, m) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    let mut l: Vec<Vec<i64>> = vec![Vec::new(); n];
    let mut h: Vec<i64> = vec![0; n];
    for _ in 0..m {
        let x: Vec<usize> = read_vec();
        l[x[0]-1].push(x[1] as i64 - 1); //x[0]からx[1]にエッジが出力されている
        h[x[1]-1] += 1;
    }

    // トポロジカルソートされた結果のベクター
    let nodes: Vec<i64> = tp_sort(&l, &mut h, n as i64);
    // 各頂点の最大有向パス長を保存する配列
    let mut list: Vec<i64> = vec![0; n];
    // 答えの最大有向パス長を保存する変数
    let mut res: i64 = 0;

    for n in nodes {
      for en in &l[n as usize] {
        list[*en as usize] = cmp::max(list[*en as usize], list[n as usize] + 1);
        res = cmp::max(res, list[*en as usize]);
      }
    }

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


Measured memory_bytes: 14588
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int result = 100000;
        while (n-- > 0) {
            result *= 1.05;
            if (result % 1000 > 0) {
                result = (result / 1000 + 1) * 1000;
            }
        }
        System.out.println(result);
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ul unsigned long
#define ll long long


int main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  
  vector<ll> a(X),b(Y),c(Z);
  for(int i=0;i<X;i++){
    cin>>a[i];
  }
  for(int i=0;i<Y;i++){
    cin>>b[i];
  }
  for(int i=0;i<Z;i++){
    cin>>c[i];
  }
  
  sort(a.begin(), a.end(),greater<ll>() );
  sort(b.begin(), b.end(),greater<ll>() );
  sort(c.begin(), c.end(),greater<ll>() );
  
  //3方向からみた立体平面を考える
  // int vvi[N][M];
  vector<vector<ll>> vvz = vector<vector<ll>>(X, vector<ll>(Y, 0));
  vector<vector<ll>> vvx = vector<vector<ll>>(Y, vector<ll>(Z, 0));
  vector<vector<ll>> vvy = vector<vector<ll>>(Z, vector<ll>(X, 0));
  vector<vector<int>> ctz = vector<vector<int>>(X, vector<int>(Y, 0));
  vector<vector<int>> ctx = vector<vector<int>>(Y, vector<int>(Z, 0));
  vector<vector<int>> cty = vector<vector<int>>(Z, vector<int>(X, 0));
  ll maxx=0;
  int idx=0,idy=0,idz=0;
  
  //最初の1こをやる
  vvz[0][0]=a[0]+b[0]+c[1];
  ctz[0][0]=1;
  vvx[0][0]=b[0]+c[0]+a[1];
  ctx[0][0]=1;
  vvy[0][0]=a[0]+c[0]+b[1];
  cty[0][0]=1;
  
  maxx=a[0]+c[0]+b[0];
  cout<<maxx<<endl;
  maxx=0;
  
  for(int loop=0;loop<K-1;loop++){
    for(int i=0;i<X;i++){
      for(int j=0;j<Y;j++){
        if (vvz[i][j]==0){break;}
        if (maxx<vvz[i][j]){
          maxx=vvz[i][j];
          idx=i;
          idy=j;
          idz=ctz[i][j];
        }
      }
    }

    for(int j=0;j<Y;j++){
      for(int k=0;k<Z;k++){
        if (vvx[j][k]==0){break;}
        if (maxx<vvx[j][k]){
          maxx=vvx[j][k];
          idx=ctx[j][k];
          idy=j;
          idz=k;
        }
      }
    }

    for(int k=0;k<Z;k++){
      for(int i=0;i<X;i++){
        if (vvy[k][i]==0){break;}
        if (maxx<vvy[k][i]){
          maxx=vvy[k][i];
          idx=i;
          idy=cty[k][i];
          idz=k;
        }
      }
    }
    
    //ここで次のx,y,zがきまったので
    
    cout<<maxx<<endl;
    maxx=0;
    
    if (idz+1!=Z){
      vvz[idx][idy]=a[idx]+b[idy]+c[idz+1];
    }else{
      vvz[idx][idy]=-1;
    }
    ctz[idx][idy]++;
    
    if (idx+1!=X){
      vvx[idy][idz]=b[idy]+c[idz]+a[idx+1];
    }else{
      vvx[idy][idz]=-1;
    }
    ctx[idy][idz]++;
    
    if (idy+1!=Y){
      vvy[idz][idx]=a[idx]+c[idz]+b[idy+1];
    }else{
      vvy[idz][idx]=-1;
    }
    cty[idz][idx]++;
  }
  
  
  
  return 0;
}

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

int main(){
  int a, b, c;
  int count = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++){
    if (c % i == 0){
      count += 1;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3116
import java.util.*;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int tomo = scan.nextInt();
        int ktomo = scan.nextInt();
        int keki = 0;
        for (int i = 0; i < ktomo; i++) {
            int keki2 = scan.nextInt();
            keki = keki + keki2;
        }
        if (keki % (tomo + 1) == 0) {
            System.out.println(keki/(tomo + 1));
        } else { System.out.println((keki / (tomo + 1))+1);
            {
            }
        }
    }
}



Measured memory_bytes: 26496
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;
using ll = long long;

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

  vector<int> a(n);
  for (auto i = 0; i != n; ++i) {
    cin >> a[i];
  }
  a.push_back(a[0] + k);

  adjacent_difference(a.begin(),a.end(),a.begin());
  cout << k - *max_element(a.begin(),a.end()) << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  rep(i,1,3501)if(!flag)rep(j,1,3501)if(4*i*j-N*(i+j)>0&&(N*i*j)%(4*i*j-N*(i+j))==0){
    cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*(i+j)) << endl;
    flag=1;
    break;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    ll H;
    cin >> H;
    ll enemy = 1;
    ll attack = 0;
    while(H > 0){
        attack += enemy;
        H/=2;
        enemy *= 2;
    }
    cout << attack << endl;
}

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

int main(void){
    ll a, b, q;
    cin >> a >> b >> q;

    pair<ll, ll> sq[a + q], tq[b + q];
    pair<ll, ll> x[q];
    rep(i, a){
        cin >> sq[i].first;
        sq[i].second = 0;
    }
    rep(i, b){
        cin >> tq[i].first;
        tq[i].second = 1;
    }
    rep(i, q){
        ll tmp;
        cin >> tmp;
        sq[a + i].first = tmp;
        sq[a + i].second = 2;
        tq[b + i].first = tmp;
        tq[b + i].second = 2;
        x[i].first = tmp;
        x[i].second = i;
    }

    sort(x, x + q);
    sort(sq, sq + a + q);
    sort(tq, tq + b + q);

    ll sr[q], sl[q], tr[q], tl[q];
    ll count = 0;
    ll l = -100000000000;
    rep(i, a + q){
        if(sq[i].second == 0){
            l = sq[i].first;
        }else if(sq[i].second == 2){
            sl[count] = l;
            count++;
        }
    }
    ll r = -100000000000;
    count = q - 1;
    rep(i, a + q){
        if(sq[a + q - i - 1].second == 0){
            r = sq[a + q - i - 1].first;
        }else if(sq[a + q - i - 1].second == 2){
            sr[count] = r;
            count--;
        }
    }
    l = -100000000000;
    count = 0;
    rep(i, b + q){
        if(tq[i].second == 1){
            l = tq[i].first;
        }else if(tq[i].second == 2){
            tl[count] = l;
            count++;
        }
    }
    r = -100000000000;
    count = q - 1;
    rep(i, b + q){
        if(tq[b + q - i - 1].second == 1){
            r = tq[b + q - i - 1].first;
        }else if(tq[b + q - i - 1].second == 2){
            tr[count] = r;
            count--;
        }
    }

    pair<ll, ll> ans[q];
    rep(i, q){
        ans[i].second = 100000000000;
        if(sr[i] != -100000000000 && tl[i] != -100000000000){
            ans[i].second = sr[i] - tl[i] + min(x[i].first - tl[i], sr[i] - x[i].first);
        }
        if(tr[i] != -100000000000 && sl[i] != -100000000000){
            ans[i].second = min(ans[i].second, tr[i] - sl[i] + min(x[i].first - sl[i], tr[i] - x[i].first));
        }
        if(tl[i] != -100000000000 && sl[i] != -100000000000){
            ans[i].second = min(ans[i].second, max(x[i].first - tl[i], x[i].first - sl[i]));
        }
        if(tr[i] != -100000000000 && sr[i] != -100000000000){
            ans[i].second = min(ans[i].second, max(tr[i] - x[i].first, sr[i] - x[i].first));
        }
        ans[i].first = x[i].second;
    }

    sort(ans, ans + q);

    rep(i, q){
        cout << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 13824
#include <stdio.h>
#include <math.h>
 
int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
 
    printf("%d", (int)(fmax(fmin(b, d)-fmax(a, c), 0)));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;

    int max = std::max(a, std::max(b, c));
    int min = std::min(a, std::min(b, c));
    int mid = a + b + c - max - min;

    std::cout << max * 10 + mid + min << std::endl;
}


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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	
	string s,t;
	cin>>s>>t;
	int c=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
			c++;
	}
	cout<<c<<endl;
	return 0;
}

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

int main(){
    bool flag=true;
    long long ans=0,sum=0;
    int day=0;
    int n;
    cin >>n;

    vector<queue<int>> match(n);

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n-1; j++){
            int a;
            cin >>a;
            match[i].push(a-1);
        }
    }
    
    int numOfmatch = n*(n-1)/2;

    while(true){
        int today[n]={};
        bool matchdone=false;

        for (int i = 0; i < n; i++){
            if(match[i].empty())continue;

            int p=match[i].front();
            int q=match[p].front();

            if(i == q && (today[i]==0 && today[p]==0)){

                //cout <<i+1<<" vs "<<p+1<<"(rest :)"<<numOfmatch<<endl;

                match[i].pop();
                match[p].pop();
                today[i]=1;
                today[p]=1;
                numOfmatch--;
                matchdone=true;

            }
        }

        day++;

        if(matchdone==false){
            cout << -1 <<endl;
            return 0;
        }
        if(numOfmatch==0){
            break;
        }
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << day << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a;
  long long int b;
  long long int c;
  long long int d;
  long long int ans=0;
  cin>>a>>b>>c>>d;
  ans=max(b*d,max(b*c,max(a*c,a*d)));
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}





int main() {

	ll P, Q, R;
	
	cin >> P >> Q >> R;
	vector<ll> v;
	v.push_back(P);
	v.push_back(Q);
	v.push_back(R);
	sort(v.begin(), v.end());
	cout << v[0] + v[1] << endl;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = long long int;
using uli = unsigned long long int;
using namespace std;

class Player {
  public:
    int hp_, attack_;
    Player(int hp, int attack) : hp_{hp}, attack_{attack} {}
    int damage() { return attack_; }
    bool alive() { return hp_ > 0; }

    void operator-=(Player p) { hp_ -= p.damage(); }
};

int main() {
    fastIO;
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    Player monster1(a, b);
    Player monster2(c, d);
    while (true) {
        monster2 -= monster1;
        if (!monster2.alive()) {
            cout << "Yes";
            break;
        }

        monster1 -= monster2;
        if (!monster1.alive()) {
            cout << "No";
            break;
        }
    }
}

Measured memory_bytes: 3528
# include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void init() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }
    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }
}

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;

    while (1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }

        if (u == -1)
            break;

        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }

        
    }

    for (int i = 0; i < n; i++) {
            cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

void solve() {
    init();
    dijkstra();
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 3116
import sys
input = sys.stdin.readline
def main():
    X = int(input())
    M = 100
    flag = True
    CNT = 0
    while flag == True:
        CNT += 1
        M += int(M*0.01)
        if M >= X:
            flag = False
    print(CNT)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63404
using System;

public class ABC_102_C
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        
        // Array.ConvertAll<TInput, TOutput>  配列の型をintに変更
        var a = Array.ConvertAll(line, int.Parse);
        var b = new int[n];
        
        // 配列a[i]からiを引いたものを配列bとする
        for (int i = 0; i < n; i++) b[i] = a[i] - (i + 1);
        
        //bを昇順ソート
        Array.Sort(b);
        
        // bの中央値を求める（mdファイル参照）
        var med = b[n / 2];
        Console.WriteLine(getSum(a, med));
    }

        /// <summary>
        /// bを中央値として絶対値の合計を求める
        /// </summary>
        /// <param name="a">元の配列</param>
        /// <param name="b">中央値</param>
        /// <returns></returns>
        public static long getSum(int[] a, int b)
        {
        	// 配列の大きさ
            var n = a.Length;
            // 結果用の変数。long型の0
            var ret = 0L;
            
            // 元の配列に対し、中央値と(i+1)を引いたものを合計していく
            for (int i = 0; i < n; i++)
                ret += Math.Abs(a[i] - b - i - 1);
            return ret;
        }

}


Measured memory_bytes: 30684
n=int(input())
al=list(map(int,input().split()))
s=[0]
for i in range(n):
    s.append(s[i]+al[i])
s=sorted(s)
c=1
ans=0
t=10**10
for i in s:
    if i==t:
        c+=1
    else:
        ans+=c*(c-1)//2
        t=i
        c=1
ans+=c*(c-1)//2
print(ans)

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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for(int i = 0; i < M; i++){
        int A;
        cin >> A;
        N -= A;
    }
    cout << ((0<=N) ? N : -1) << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[100005];
int cnt[100005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		cnt[ar[i]]++;
		cnt[ar[i]+1]++;
		cnt[ar[i]-1]++;
	}
	cout<<*max_element(cnt,cnt+100005);
}


Measured memory_bytes: 1792
var
	n,a:int64;
	i,k:Longint;
function S(n:int64):real;
var x,m:int64;
begin
	m:=n;
	x:=0;
	while n>0 do begin
		x:=x+n mod 10;
		n:=n div 10;
	end;
	S:=m/x;
end;
begin
	n:=1;
	a:=1;
	read(k);
	writeln(1);
	for i:=2 to k do begin
		if S(n+a)>S(n+a*10)then a:=a*10;
		n:=n+a;
		writeln(n);
	end;
end.


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

int main() {
    
    int n;
    cin >> n;
    if(n>=400 && n<=599) cout << "8" << endl;
    else if(n>=600 && n<=799) cout << "7" << endl;
    else if(n>=800 && n<=999) cout << "6" << endl;
    else if(n>=1000 && n<=1199) cout << "5" << endl;
    else if(n>=1200 && n<=1399) cout << "4" << endl;
    else if(n>=1400 && n<=1599) cout << "3" << endl;
    else if(n>=1600 && n<=1799) cout << "2" << endl;
    else if(n>=1800 && n<=1999) cout << "1" << endl;
    
    
    
	return 0;
}

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;

  if(e-a>k || e-b>k || e-c>k || e-d>k)cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int a, b, q; cin >> a >> b >> q;
  vector<ll> s(a), t(b), x(q);
  REP(i, a) cin >> s[i];
  REP(i, b) cin >> t[i];
  REP(i, q) cin >> x[i];
  
  function<ll(ll, ll, ll x)> calc = [](ll s, ll t, ll x) {
    if(s >= x && t >= x) return max(s - x, t - x);
    if(s >= x && t < x) return (s - t) + min(s - x, x - t);
    if(s < x && t >= x) return (t - s) + min(x - s, t - x);
    else return max(x - s, x - t);
  }; 

  function<ll(ll)> solve = [&](ll xx) {
    auto si = lower_bound(s.begin(), s.end(), xx);
    auto ti = lower_bound(t.begin(), t.end(), xx);

    ll ans = numeric_limits<ll>::max();
    if(si != s.end() && ti != t.end()) ans = min(ans, calc(*si, *ti, xx));
    if(si != s.end() && ti != t.begin()) ans = min(ans, calc(*si, *prev(ti), xx));
    if(si != s.begin() && ti != t.end()) ans = min(ans, calc(*prev(si), *ti, xx));
    if(si != s.begin() && ti != t.begin()) ans = min(ans, calc(*prev(si), *prev(ti), xx)); 
    return ans;
  };

  REP(i, q) cout << solve(x[i]) << endl;

  return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;


long long gcd(long long a, long long b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main() {
  long long A, B;

  cin >> A >> B;

  std::cout << (A*B) /  gcd(A, B) << endl;
 
  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 1009; i++)
	{
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << NIL << endl;
	return 0;
}

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





int main(){
	int N;
	cin>>N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	int ans = 0;
	for(int i=1;i<N;i++){
		if(a[i-1]!=0&&a[i]==a[i-1]){
			a[i]=0;
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = []
b = []
1.upto(m) do |i|
  x, y = gets.split.map(&:to_i)
  a.push(y) if x == 1
  b.push(x) if y == n
end
c = a & b
if c.size > 0
  puts "POSSIBLE"
else
  puts "IMPOSSIBLE"
end

Measured memory_bytes: 11912
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt();
    int arr[] = new int[N+1];
    for(int i = 1; i<=M; i++){
      int n = sc.nextInt();
      arr[n] = 1;
    }
    int opt1 = 0; 
    int opt2 = 0; 
    for(int i = X; i>=0; i--){
      opt1 += arr[i]; 
    }
    for(int i = X; i<=N; i++){
      opt2 += arr[i]; 
    }
    System.out.println(Math.min(opt1, opt2));
  }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
    }
    int S,T;
    cin >> S >> T;
    --S,--T;

    vector<vector<int>> d(N, vector<int>(3, -1));
    d[S][0] = 0;
    queue<pair<int, int>> q;
    q.push({S, 0});

    while (!q.empty()) {
        int u = q.front().first;
        int c = q.front().second;
        q.pop();

        for (auto e : G[u]) {
            if(d[e][(c+1)%3] != -1) continue;
            q.push({e,(c+1)%3});
            d[e][(c+1)%3] = d[u][c] + 1;
        }
    }
    if(d[T][0] == -1) {
        cout << -1 << endl;
        return 0;
    }
    cout << d[T][0]/3 << endl;
}

Measured memory_bytes: 11136
n, m = map(int, input().split())
dp = [10**9] * (2**n)
dp[0] = 0
for i in range(m):
    a, _ = map(int, input().split())
    # [1, 2], [1, 3]などが入る
    c = list(map(int, input().split()))
    t = 0
    # リストに何が入っているかを2進数で表す
    # c = [1, 2] なら t = 3(011)
    # c = [1, 3] なら t = 5(101)
    for x in c:
        t |= 1 << (x-1)
    for b in range(2**n):
        # これまでに確定したdb[b]とdb[t]の論理和で変える鍵の価格より、
        # これまでのdb[b]と今回の価格を足したものの方が安ければ今回の価格で上書きする
        dp[b|t] = min(dp[b|t], dp[b]+a)
if dp[-1] > 10**8:
    print(-1)
else:
    print(dp[-1])


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

int main() {
	int N;
  	string S,T;
	cin >> N >> S >> T;

  	string ans;
	rep(i, N){
      ans.push_back(S.at(i));
      ans.push_back(T.at(i));
    }
  	cout << ans << endl;
}


Measured memory_bytes: 3640
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n , k ;
	scanf("%d%d",&n,&k);
	
	vector<int> v(n);
	for(int& x: v){
		scanf("%d",&x);
	}
	bool dp[k+1];
	memset(dp,0,sizeof dp);

	for(int i = 1 ; i <= k ; i++){
		for(int x : v){
			if(i >= x and !dp[i-x] ){
				dp[i] = true ;
			}
		}
	}
	
	puts(dp[k]?"First":"Second");
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*
ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}
*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	fast;
	string a;
	cin>>a;
	ll n=a.size();
	ll k=(n-1)/2;
	ll h=(n+3)/2;
	for(ll i=0;i<k;i++)
	{
		if(a[i]!=a[k-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	for(ll i=h-1;i<n;i++)
	{
		if(a[i]!=a[n-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IM

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> f >>= putStrLn
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> String
solve n is = g $ foldl' f (16, 16, 16, 100.0) ls
  where
    ls = do
      s <- [0 .. 15]
      a <- [0 .. 15]
      c <- [0 .. 15]
      return (s, a, c)
    f (xs, xa, xc, xh) (s, a, c) = let m = 256
                                       eps = 1e-9
                                       h = entropy n (outstr s a c m is)
                                   in if xh - h > eps then (s, a, c, h) else (xs, xa, xc, xh)
    g (s, a, c, _) = unwords $ map show [s, a, c]

prand :: Int -> Int -> Int -> Int -> [Int]
prand s a c m = unfoldr (\r -> let r' = (a * r + c) `mod` m in Just(r', r')) s

outstr :: Int -> Int -> Int -> Int -> [Int] -> [Int]
outstr s a c m is = let prs = prand s a c m
                    in zipWith (\x y -> (x + y) `mod` m) is prs

entropy :: Int -> [Int] -> Double
entropy n os = let mp = foldl' (\m x -> IM.insertWith (+) x 1 m) IM.empty os
                   f h x = let xn = (fromIntegral x) / (fromIntegral n) in h + xn * log xn
               in (-1.0) * IM.foldl' f 0 mp



Measured memory_bytes: 5836
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[j-1]=i+1;
    }
    for(int i=0;i<n;i++){
        cout << a[i] << " ";
    }
    cout << '\n';
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;
int tanka[5] = {5, 7, 5, 7, 7};

int main()
{
    while (cin >> N)
    {
        if (N == 0)
            return 0;
        vector<string> s(N);
        for (int i = 0; i < N; i++)
        {
            cin >> s[i];
        }
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            int j = i, len = 0, index = 0;
            while (index < 5 && j < N)
            {
                len += s[j].size();
                if (len == tanka[index])
                    index++, len = 0;
                else if (len > tanka[index])
                    break;
                j++;
            }
            if (index == 5)
            {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3192