akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int D = scanner.nextInt();
		int[][] arr = new int[N+1][D+1];
		int ans = 0;
		for(int i = 1 ; i <= N ; i ++) {
			for(int j = 1 ; j <= D ; j++) {
				arr[i][j] = scanner.nextInt();
			}
		}
		/*for(int i = 1 ; i <= N ; i ++) {
			for(int j = 1 ; j <= D ; j ++) {
				System.out.print(arr[i][j] + " ");
			}
			System.out.println();
		}*/
		for(int i = 1 ; i < N ; i ++) {
			for(int j = i+1 ; j <= N ; j ++) {
				if(judge(arr[i],arr[j])) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scanner.close();
	}
	
	public static boolean judge(int[] i, int[] j) {
		double ans = 0;
		for(int x = 1 ; x < i.length ;  x ++) {
			ans += (Math.pow(i[x] - j[x], 2));
		}
//		System.out.print(ans);
		ans = Math.pow(ans, 0.5);
//		System.out.println("    " + ans);
		if(ans%1 == 0) {
			return true;
		}
		return false;
	}
}


Measured memory_bytes: 21844
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		int l = s.Length;
		int counter = 0;
		for(int i=0;i!=l;i++){
			if(s.Substring(i,1)!=t.Substring(i,1)){
				counter++;
			}
		}
		Console.WriteLine(counter);
		
	}
}

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

void init() {
//#if __GLIBCXX__ == 20160609
#ifdef KEK
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
#else
    ///freopen(TASKNAME".in", "r", stdin);
    ///freopen(TASKNAME".out", "w", stdout);
#endif
}
#define pb push_back
#define fi first
#define se second

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

const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;


void solve() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll ans = n * m / __gcd(n, m);
    ll pt1 = 0, pt2 = 0;
    ll i1 = ans / n, i2 = ans / m;
    while (pt1 < ans && pt2 < ans) {
        //cerr << pt1 << ' ' << pt2 << "\n";
        if (pt1 == pt2 && s[pt1 / i1] != t[pt2 / i2]) {
            cout << -1;
            return;
        }
        if (pt1 < pt2)
            pt1 += i1;
        else
            pt2 += i2;
    }
    cout << ans;
}

int main() {
    init();
    solve();

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

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

} 



Measured memory_bytes: 2596
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){
	
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	rep2(b, 1, N + 1){
		ll cnt = b - K;
		if(cnt > 0){
			ll div = (N + 1) / b;
			ll mod = N + 1 - div * b;
			ans += div * cnt + max(mod - K, (ll)0);
		}
	}
	if(K == 0) ans -= N;
	print(ans);
		
}

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





Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    int ans = 0;
    cin >> n;
    while (n / 10 != 0)
    {
        if (n % 10 == 2)
        {
            ans++;
        }
        n /= 10;
    }
    if (n % 10 == 2)
    {
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int maxofall = 0, minofall = mod;
	int maxindex = 0, minindex = 0;
	vector<pair<long long int, long long int> > v;
	for(int i = 0; i < n; i++){
		long long int x, y;
		cin >> x >> y;
		if(x > y) swap(x, y);
		v.push_back(make_pair(x, y));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < n; i++){
		long long int x = v[i].first;
		long long int y = v[i].second;
		if(y > maxofall){
			maxindex = i;
			maxofall = y;
		}
		if(x < minofall){
			minindex = i;
			minofall = x;
		}
	}
	long long int amax = maxofall, amin = v[minindex].second;
	long long int bmax = v[maxindex].first, bmin = minofall;
	for(int i = 0; i < n; i++){
		long long int x = v[i].first;
		long long int y = v[i].second;
		if(i == maxindex || i == minindex) continue;
		amin = min(amin, y);
		bmax = max(bmax, x);
	}
	long long int ans = (amax - amin) * (bmax - bmin);
	if(maxindex == minindex){
		cout << ans << endl;
		return 0;
	}
	amax = maxofall;
	amin = minofall;
	bmax = max(v[n - 1].first, v[0].second);
	bmin = min(v[1].first, v[0].second);
	long long int miny = v[0].second;
	long long int maxy = v[0].second;
	ans = min(ans, (amax - amin) * (bmax - bmin));
	for(int i = 1; i < n; i++){
		long long int x = v[i].first;
		long long int y = v[i].second;
		miny = min(miny, y);
		maxy = max(maxy, y);
		if(i == n - 1) ans = min(ans, (amax - amin) * (max(bmax , maxy) - miny));
		else ans = min(ans, (amax - amin) * (max(bmax, maxy) - min(v[i + 1].first, miny)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k, t = map(int, input().split())
    A = list(map(int, input().split()))
    etc = sum(A) - max(A)
    res = max(0, max(A) - 1 - etc)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
require 'prime'
include Math
def max(a,b);                    a > b ? a : b                            end
def min(a,b);                    a < b ?  a : b                           end
def swap(a,b);                   a, b = b, a                              end
def gif;                         gets.to_i                                end
def gsf;                         gets.chomp                               end
def gi;                          gets.split.map(&:to_i)                   end
def gs;                          gets.chomp.split.map(&:to_s)             end
def gc;                          gets.chomp.split('')                     end
def pr(num);                     num.prime_division                       end
def putall(obj);                 obj.each{|o| puts(o)}                    end
def array(size,init=nil);        Array.new(size){init}                    end
def darray(size1,size2,init=nil);Array.new(size1){Array.new(size2){init}} end
def rep(num);                    num.times {|i|yield(i)}                  end
def repl(st,en);                 st.upto(en) {|i|yield(i)}                end


n = gif
s = []
rep n do
s << gc.sort	
end
sum = []
repl "a", "z" do |al|
	num = Float::INFINITY
	rep n do |i|
		dd = s[i].count al
		num = dd if dd < num
	end

	sum << al * num if num > 0
end

puts sum.join


Measured memory_bytes: 2172
//???1:WA
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_to,double arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	double cost;
};

vector<Info> G[100001];
double table[100001],P,E = 0.0;

void recursive(int node_id,int parent){

	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].to == parent)continue;

		table[G[node_id][i].to] = table[node_id]*P;
		E += table[G[node_id][i].to]*G[node_id][i].cost;
		recursive(G[node_id][i].to,node_id);
	}
}

int main(){

	scanf("%lf",&P);

	int N;
	int from,to;

	scanf("%d",&N);

	double cost;

	for(int i = 0; i < N-1; i++){
		scanf("%d %d %lf",&from,&to,&cost);
		from--;
		to--;
		G[from].push_back(Info(to,cost));
		G[to].push_back(Info(from,cost));
	}

	table[0] = 1.0;
	recursive(0,-1);

	double ANS = E;
	for(int i = 0; i < N; i++)ANS += table[i]*E;

	printf("%.10lf\n",ANS);

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  if ( n&1 ) {
    puts("No");
    return 0;
  }
  for ( int i=0; i<n; i+=2 ) {
    if ( s[i]!='h'||s[i+1]!='i' ) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 3560
import Data.List (sort)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine :: IO [Integer]
  abs <- sequence . replicate (fromInteger n) $ unsafeListToTuple . map read . words <$> getLine :: IO [(Integer, Integer)]
  let
    abs' = sort abs
    a = fst . foldl step (0, 0) $ abs'
    step (s, t) (u, v) = if t + v < m then (s + u * v, t + v) else let v' = m - t in (s + u * v', m)
  print a

unsafeListToTuple :: [a] -> (a, a)
unsafeListToTuple (x : y : _) = (x, y)
unsafeListToTuple _ = undefined


Measured memory_bytes: 116092
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
ll a,b;
int main(){
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


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

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

    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    vector<int> dp(n, INT_MAX);
    for(int i = 0; i < n; ++i){
        *lower_bound(begin(dp), end(dp), a[i]) = a[i];
    }

    cout << lower_bound(begin(dp), end(dp), INT_MAX)-begin(dp) << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll>
#define INF 1123456789012
using namespace std;
 
 
 
int main(){
	ll a, b, c; cin >> a >> b >> c;
	if (c >= a && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }
    int x=0,y=0;
    for(auto&p:mp){
        if(p.second>=2){
            y=x;
            x=p.first;
        }
        if(p.second>=4){
            x=p.first;
            y=p.first;
        }
    }
    cout<<(ll)x*y<<endl;
}

Measured memory_bytes: 4992
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    n = input()
    a = tuple(map(int, readlines()))
    ac = Counter(a)
    ac2 = [c % 2 for c in ac.values()]
    r = sum(ac2)
    print(r)
if __name__ == '__main__':
    main()


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A+B)>(C+D))
    cout << "Left" << endl;
  else if ((A+B)<(C+D))
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

public class Program
{
    public static void Main(string[] args)
    {
        int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = line[0];
        int[] request = new int[3];
        for (int i = 0; i < request.Length; i++) request[i] = line[1 + i];

        int[] L = new int[N];
        for (int i = 0; i < L.Length; i++)
        {
            L[i] = int.Parse(Console.ReadLine());
        }

        int maxBit = 1 << N;
        int[] take = new int[maxBit];
        for (int bit = 0; bit < maxBit; bit++)
        {
            int sum = 0;
            for (int i = 0; i < N; i++)
            {
                int mask = 1 << i;
                if((bit & mask) == mask)
                {
                    sum += L[i];
                }
            }

            take[bit] = sum;
        }
        take[0] = 1 << 19;

        //  [どこまで, 使ったbit] = コスト
        int[,] dp = new int[4, maxBit];

        int big = 1 << 19;
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < maxBit; j++)
            {
                dp[i, j] = big;
            }
        }
        dp[0, 0] = 0;

        int[] bitC = new int[maxBit];
        for (int i = 0; i < bitC.Length; i++)
        {
            bitC[i] = bitCount(i);
        }

        for (int i = 0; i < 3; i++)
        {
            //  すでに使った竹
            for (int j = 0; j < maxBit; j++)
            {
                //  これに対して使う竹
                for (int k = 0; k < maxBit; k++)
                {
                    //  重なりが無い = まだ使える
                    if((j & k) == 0)
                    {
                        int p = Math.Max(0, (bitC[k] - 1) * 10);
                        dp[i + 1, j | k] = Math.Min(dp[i + 1, j | k], dp[i, j] + Math.Abs(request[i] - take[k]) + p);
                    }
                }
            }
        }

        int mostMin = int.MaxValue;
        for (int i = 0; i < maxBit; i++)
        {
            mostMin = Math.Min(dp[3, i], mostMin);
        }

        Console.WriteLine(mostMin);
        Console.ReadLine();
    }

    static int bitCount(int bit)
    {
        int c = 0;
        for (int i = 0; i < 31; i++)
        {
            int mask = 1 << i;
            if((bit & mask) == mask)
            {
                c++;
            }
        }
        return c;
    }
}

Measured memory_bytes: 11348
#include <stdio.h>

#define N 200001
#define INF 2000000000

int max(int, int);
int min(int, int);

int main() {
    int i, n, minv, maxv, R[N];
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &R[i]);
    }

    minv = R[0];
    maxv = -INF;

    for (i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

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

    return 0;
}


int max(int a, int b) {
    if (b > a) {
        return b;
    }
    return a;
}


int min(int a, int b) {
    if (b > a) {
        return a;
    }
    return b;
}



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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int>vec;
  for(int i = 0 ; i < n ; i++){
    int t; cin >> t;
    vec.push_back(t);
  }
  sort(vec.begin(), vec.end());
  int res = 0;
  for(int i = 0 ; i < k ; i++){
    res += vec[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3632
if __name__ == "__main__":
    n = int(input())
    robot = list()
    for i in range(n):
        x, l = map(int, input().split())
        robot.append([x - l, x + l])

    robot.sort(key=lambda x: x[1])

    ans = 0
    arm_pos = -10 ** 9 - 1
    for r in robot:
        if r[0] >= arm_pos:
            ans += 1
            arm_pos = r[1]

    print(ans)


Measured memory_bytes: 21308
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  string s,t; cin >>s >>t;
  int x=s.size(),y=t.size(),ans=x;
  for(int i=0; i<=x-y; i++){
    int tem=0;
    for(int j=0; j<y; j++) if(s[i+j]!=t[j]) tem++;
    ans=min(ans,tem);
  }
  cout <<ans;
return 0;}

Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int a[212345];
int main()
{
//	freopen("B.in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read();ll t=0;
	For(i,n) a[i]=read();
	if(a[1]) puts("-1"),exit(0);
	For(i,n-1) {
		if(a[i+1]-a[i]>1) puts("-1"),exit(0);
	}
	For(i,n) t+=a[i]>0;
	Fork(i,2,n) if (a[i] && a[i-1]!=a[i]-1)
		t+=a[i]-1;
	cout<<t<<endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    ll mod = 1000000007;
    vector<ll> x(n), y(m);
    rep(i, n)cin >> x[i];
    rep(i, m)cin >> y[i];
    ll a = 0;
    rep(i, n)a = (a + (2 * (i + 1) - 1 - n) * x[i] % mod) % mod;
    ll b = 0;
    rep(i, m)b = (b + (2 * (i + 1) - 1 - m) * y[i] % mod) % mod;
    cout << a * b % mod << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=5010,mo=1e9+7;
int w[N*2],ne[N*2],la[N],t,size[N],n;
ll f[N][N],g[N],v[N];
void link(int x,int y){
	w[++t]=y;
	ne[t]=la[x];
	la[x]=t;
}
void move(ll &a,ll b){
	a=(a+b)%mo;
}
void dfs(int x,int fa){
	f[x][1]=size[x]=1;
	for (int y=la[x];y;y=ne[y]){
		int z=w[y];
		if (z==fa)continue;
		dfs(z,x);
		memset(g,0,sizeof g);
		for (int i=0;i<=size[x];i++)
			for (int j=0;j<=size[z];j++)
				move(g[i+j],f[x][i]*f[z][j]);
		memcpy(f[x],g,sizeof g);
		size[x]+=size[z];
	}
	for (int j=2;j<=size[x];j+=2)
		move(f[x][0],-f[x][j]*v[j]);
}
int main(){
	cin>>n;
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y);
		link(y,x);
	}
	v[0]=1;
	for (int i=2;i<=n;i+=2)v[i]=v[i-2]*(i-1)%mo;
	dfs(1,0);
	cout<<(-f[1][0]+mo)%mo<<endl;
} 

Measured memory_bytes: 196608
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val v = listOfInt()
    val c = listOfInt()

    var count = 0
    var value = 0
    var cost = 0
    c.forEach {
        if (v[count] > c[count]){
            value += v[count]
            cost += c[count]
        }
        count++
    }
    pw.println(value-cost)
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }

Measured memory_bytes: 37920
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static inline constexpr int digitsum(int x) {
  return (x < 10) ? x : (x % 10) + digitsum(x / 10);
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int answer = 0;
  REP1(i, N) {
    const int x = digitsum(i);
    if (x >= A && x <= B) {
      answer += i;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

int ans = 0;


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

	int N, T;
	cin >> N >> T;

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

	int ans = 0;
	for (int i = 1; i < N; i++)
	{
		ans += min(t[i] - t[i - 1], T);
	}
	ans += T;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    ll add = min(B,C);
    ll ans = add*2;
    C -= add;
    B -= add;

    if(C > 0){
        ll add2 = min(A,C);
        C -= add2;
        A -= add2;
        ans += add2;
    }
    else{
        ans += B;
    }

    if(C > 0){
        ans++;
    }

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


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

ll n, m;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = read();
	if (n > m) puts("safe");
	else puts("unsafe");
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int B[200010];

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        B[A]++;
    }
    sort(B,B+N,greater<int>());
    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += B[i];
    }
    cout << N - sum << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1024
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int k, x;
    cin >> k >> x;
    if (500 * k >= x)
        print("Yes");
    else
        print("No");

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(3 , "Ofast" , "inline")

#include <bits/stdc++.h>

#define rep(i , a , b) for(register int i=(a);i<=(b);i++)
#define per(i , a , b) for(register int i=(a);i>=(b);i--)


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int> pi;

template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}

const int maxn = 2e5 + 10;
const int inf = int (1e9);
const ll INF = ll (1e18);
const double PI = acos (- 1);
const int mod = 1e9+7;
const double eps = 1e-8;

ll dp[111][10];


int main () {
    int h,w,m;
    read (h);read (w);read (m);
    if(w==1) {
        puts ("1");
        return 0;
    }
    dp[0][0]=1;
    rep (i,1,h) {
        rep (j,0,(1<<w-1)-1) {
            bool ok=1;
            rep (k,0,w-3) {
                if((j&(1<<k))&&(j&(1<<k+1))) {
                    ok=0;
                    break;
                }
            }
            if(!ok) continue;
            rep (k,0,w-1) {
                if(k>=1&&(j&(1<<(k-1)))) {
                    dp[i][k]=(dp[i][k]+dp[i-1][k-1])%mod;
                }
                else if(k<w-1&&(j&(1<<k))) {
                    dp[i][k]=(dp[i][k]+dp[i-1][k+1])%mod;
                }
                else dp[i][k]=(dp[i][k]+dp[i-1][k])%mod;
            }
        }
    }
    cout<<dp[h][m-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
    char c;
    scanf("%c", &c);

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        printf("vowel\n");
    } else {
        printf("consonant\n");
    }
}

Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

bl = bisect.bisect_left
br = bisect.bisect_right

def solve():
    n = I()
    p = LIR(n)
    fx = {x for (x, _, _, _) in p} | {x for (_, _, x, _) in p}
    fx = list(fx)
    fx.sort()
    fy = {y for (_, y, _, _) in p} | {y for (_, _, _, y) in p}
    fy = list(fy)
    fy.sort()
    h,w = len(fy),len(fx)
    a = [[0]*w for i in range(h)]
    for x1,y1,x2,y2 in p:
        l,u,r,d = bl(fx,x1),bl(fy,y1),bl(fx,x2),bl(fy,y2)
        a[u][l] += 1
        a[u][r] -= 1
        a[d][l] -= 1
        a[d][r] += 1
    s = [list(accumulate(i)) for i in a]
    for j in range(w):
        for i in range(h-1):
            s[i+1][j] += s[i][j]
    ans = 0
    for i in range(h-1):
        y = fy[i+1]-fy[i]
        for j in range(w-1):
            if s[i][j]:
                x = fx[j+1]-fx[j]
                ans += x*y
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 468944
#include "bits/stdc++.h"
using namespace std;
int n;
int h[100010];
vector<int> result(100010, 0);

int move(int x) {
	if (h[x + 1] > h[x] || x == n - 1) {
		return 0;
	}
	
	return move(x + 1) + 1;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		//cout << move(i) << endl;
		if (i != 0) {
			if (h[i - 1] < h[i]) {
				result.at(i) = move(i);
			}
		}
		else {
			result.at(i) = move(i);
		}
		
	}
	sort(result.begin(), result.end());
	cout << result.at(100009) << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define heapmax 2000000

int heap[heapmax],heapsize=0;

void heapincreasekey(int [],int,int);

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxheapify(int A[],int i){
  int largest,leftN,rightN,tmp;
  leftN=left(i);
  rightN=right(i);
  if(leftN<=heapsize && A[leftN]>A[i]){
    largest=leftN;
  }
  else {
    largest=i;
  }
  if(rightN<=heapsize && A[rightN]>A[largest]){
    largest=rightN;
  }
  if(largest!=i){
    tmp=A[largest];
    A[largest]=A[i];
    A[i]=tmp;
    maxheapify(A,largest);
  }
}

void Buildmaxheap(int A[]){
  int i;
  for(i=heapsize/2;i>=1;i--){
    maxheapify(A,i);
  }
}

void heapincreasekey(int A[], int i,int key){
  int tmp;
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    tmp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=tmp;
    i=parent(i);
  }
}

void maxheapinsert(int A[], int key){
  heapsize=heapsize+1;
  A[heapsize]=INT_MIN;
  heapincreasekey(A,heapsize,key);
}

int heapextractmax(int A[]){
  int max;
  max=A[1];
  A[1]=A[heapsize];
  heapsize=heapsize-1;
  maxheapify(A,1);
  return max;
}

int main(){
  int i=0,key;
  char M[2000000];
  
  while(1){
    scanf("%s",M);
    if(M[0]=='e'&&M[1]=='n'){
      break;
    }
    if(M[0]=='i'){
      scanf("%d",&key);
      maxheapinsert(heap,key);
    }
    if(M[0]=='e'&& M[1]=='x'){
      printf("%d\n",heapextractmax(heap));
    }
  }

  return 0;
}

Measured memory_bytes: 4704
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    float money[n];
    string lang[n];
    for (int i = 0; i < n; i++) {
        cin >> money[i] >> lang[i];
        if (lang[i] == "BTC") {
            money[i] *= 380000.;
        }
    }
    cout << accumulate(money, money + n, 0.) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    
    int wa1 = 0,wa2 = 0,ans = 0;
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<to_string(N).length();j++){
        wa1= i / pow(10,j);
        wa2 =wa2 + (wa1 % 10);
            
        }
            if(A <= wa2 && wa2 <= B){
                ans += i;
            }
            wa2= 0;
    
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
ll n, k;
vector<ll> dis;
ll sum = 0;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> k >> n;
    dis.resize(n);
    ll lst, now;
    cin >> lst;
    int one = lst;
    bool flag = false;
    if(lst == 0){
        flag = true;
    }
    for(int i = 1; i < n; i++){
        cin >> now;
        dis[i-1] = now - lst;
        lst = now;
    }
    if(flag){
        dis[n-1] = k - now;
    } else {
        dis[n-1] = k - now + one;
    }
    sort(dis.begin(),dis.end());
    /*for(auto e:dis){
        cout << e << " ";
    }
    cout << endl;*/
    for(int i = 0; i <= n - 2; i++){
        sum += dis[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

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

int main() {
    COME_LET_THE_GAMES_BEGIN();
    ll N;
    cin >> N;
    ll A;
    cin >> A;
    ll x = A;
    rep(i, N - 1) {
        cin >> A;
        x = gcd(x, A);
    }
    cout << x << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]
L = [0]
for i in range(1, N+1):
    M = []
    for a in A:
        if i - a >= 0:
            M.append(L[i-a]+1)
    L.append(min(M))
print(L[-1])

Measured memory_bytes: 3860
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n, 0);

	for (int i = 1; i < n; i++) {
		int tmp;
		cin >> tmp;
		a[tmp-1]++;
	}

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


	return 0;
}

Measured memory_bytes: 3964
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class soundhound2018_a {
public:
    void solve(istream& in, ostream& out) {
        int a, b;
        in >> a >> b;
        if (a + b == 15) {
            out << '+';
        } else if (a * b == 15) {
            out << '*';
        } else {
            out << 'x';
        }
        out << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	soundhound2018_a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
ll mod = INF;

int main(){
    int n;
    cin >> n;
    int streak=0;
    int tmp=0;
    rep(i,n){
        int a,b;
        cin >> a>>b;
        if(a==b){
            tmp++;
        }else{
            tmp=0;
        }
        streak=max(streak,tmp);
    }

    if(streak>=3){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3672
while True:
  n, a, b, c, x = list(map(int, input().split()))
  if n==0:
    break

  y = list(map(int, input().split()))
  cnt = 0
  cur = 0
  while cnt<=10000:
    if x==y[cur]:
      cur += 1
    if cur==n:
      break
    x = (a*x+b)%c
    cnt += 1
  if cnt==10001:
    print(-1)
  else:
    print(cnt)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> V(N);
  vector<double> C(N);
  vector<double> W(N);
  for(int i = 0; i < N; i++)
    cin >> V.at(i);
  for(int i = 0; i < N; i++)
  	cin >> C.at(i);
  for(int i = 0; i < N; i++)
    W.at(i) = (V.at(i)-C.at(i));
  std::sort(W.rbegin(), W.rend());
  cout << endl;
  int w = 0;
  int p_w = 0;
  for(int i = 0; i < N; i++){
    w += W.at(i);
    if(w - p_w > 0){
      p_w = w;
    }
    else
      break;
  }
  cout << p_w << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {
    
    ll n;
    cin >> n;
    int d[11];
    ll k=n;
    for(int i=10;i>=0;i--){
        d[i] = k/pow(10,i);
        k = k-pow(10,i)*d[i];
    }
    
    int sum=0;
    FOR(i, 0, 10){
        sum+=d[i];
    }
    
    if((n/sum)*sum == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
struct Edge
{
    int to_;
    int id;
};
vector<ll> ans; //答えを格納する配列。
vector<Edge> to[200005];

void dfs(int v, int c = -1, int p = -1)
{
    int g = 1;
    for (Edge x : to[v]) //
    {
        int u = x.to_;
        int ei = x.id; //これはxが何番目に出てくるものであるかをカウントしている。
        if (u == p)
        {
            continue;
        }
        if (c == g)
        {
            g++;
        }
        ans[ei] = g;
        dfs(u, g, v);
        g++; //これで一つのノードの子ノードまでを補えた。
    }
}
ll dp2(int v)
{
    int res = 0;
    for (Edge x : to[v]) //
    {
        res++;
    }
    return res;
}

int main()
{
    ll n;
    cin >> n;
    ans.resize(n - 1);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back((Edge){b, i});
        to[b].push_back((Edge){a, i});
    }
    ll max1 = 0;
    rep(i, n)
    {
        max1 = max(max1, dp2(i));
    }
    cout << max1 << endl;
    dfs(0);
    for (int x : ans)
    {
        cout << x << endl;
    }
}

Measured memory_bytes: 11904
#include<iostream>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a*b / gcd(a, b);
}
int main()
{
	ll a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, g;
  cin >> N >> A >> g;
  if  (A * N > g ) {
    cout << g << endl;
  }
  else if ( N * A < g){
    cout << N * A << endl;
  }
    else if ( N * A == g){
    cout << N * A << endl;
  }
}

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

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n) {
        for(int i=0; i<n; i++) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    for(int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }
    int cnt = 0;
    for(int i=0; i<n; i++) {
        if(!tree.same(0, i)) {
            tree.unite(0, i);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3732
def hi?(s)
	l = s.length
	if l%2 == 1 then return "No" end
	l /= 2
	0.upto(l-1) do |i|
		if s[2*i]!="h" || s[2*i+1]!="i" then
			return "No"
		end
	end
	return "Yes"
end

#n, prime = gets.chomp.split(" ").map{|e|e.to_i}
s = gets.chomp

print(hi?(s))




Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

uint64_t attack(uint64_t h)
{
    if (h == 1) return 1;
    return 2 * attack(h/2) + 1;
}

int main()
{
    uint64_t H;
    cin >> H;

    cout << attack(H) << endl;
}


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

int main()
{ int a,b,c,d,x,y;
  while(~scanf("%d %d %d %d",&a,&b,&c,&d))
  {
      x=a*b;
      y=c*d;
      if(x<y)
        printf("%d\n",y);
      else
        printf("%d\n",x);
  }

    return 0;
}


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

int main() {
    string s,t,u;
    int n, h[100];
    while (1) {
        cin >> s >> n;
        if (s == "-") break;
        for (int i = 0; i < n;i++) {
            cin >> h[i];
            t = s.substr(0, h[i]);
            s.erase(0, h[i]);
            u=s+t;
            s = u;
        }
        cout << s << endl;
    }

}


Measured memory_bytes: 3172
function main(input) {
  const x = parseInt(input);
  // この下の行から
  if(x==0){console.log("1");}else if(x==1){
    console.log("0");}
 
  // この上の行まででプログラムを書く
};
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 29568
from fractions import gcd

def main():
    n, X = map(int, input().split())
    x = list(map(lambda x: abs(int(x) - X), input().split()))

    M = x[0]

    for i in x[1:]:
        M = gcd(M, i)

    print(M)

if __name__ == "__main__":
    main()

Measured memory_bytes: 16276
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<vector<int>>> A(4, vector<vector<int>>(3, vector<int>(10)));
    
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b-1][f-1][r-1] += v;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << A[i][j][k];
            }
            cout << endl;
        }
        if(i == 3) break;
        else{
            for(int l = 0; l < 20; l++) cout << "#";
            cout << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3156
#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 f(int n){
  if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(){
  int s, t; cin >> s;

  set<int> st;
  st.insert(s);
  for(int i=2; ; i++){
    t = f(s);
    s = t;
    if(st.find(t) != st.end()){
      cout << i << endl;
      return 0;
    }

    st.insert(t);
  }
  return 0;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = 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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

	int n;cin>>n;
	vec c(n);
	rep1(i,n) c[i-1]=i;

	vec p,q;
	p = q = vec(n);
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	int num=1;
	int a=0,b=0;

	do{
		num++;
		int cnt=0,cnt2=0;		
		rep(i,n){
			if(p[i]==c[i]) cnt++;
			if(q[i]==c[i]) cnt2++;
		} 
		if(cnt==n)  a=num;
		if(cnt2==n) b=num;
		if(a!=0 and b!=0) break;
	}while(next_permutation(c.begin(),c.end()));

	cout<<abs(a-b)<<endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)



int main(){
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    rep(i, n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [0]+[int(x) for x in input().split()]+[0]
cost1 = [abs(x-y) for x, y in zip(a, a[1:])]
s = sum(cost1)
cost2 = [abs(x-y) for x, y in zip(a, a[2:])]
for i in range(n):
    print(s-cost1[i]-cost1[i+1]+cost2[i])


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

vector<int> x[22], y[22];
int c[1 << 16];
int main() {
    int n, r = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        x[i].resize(a);
        y[i].resize(a);
        for(int j = 0; j < a; j++)
            cin >> x[i][j] >> y[i][j];
    }
    for(int i = 1; i < 1 << n; i++) {
        c[i] = c[i & i - 1] + 1;
        int m = 0;
        for(int j = 0; j < n; j++)
            if(i & 1 << j) {
                for(int k = 0; k < x[j].size(); k++)
                    if(y[j][k] == !(i & 1 << x[j][k] - 1))
                        m = 1;
            }
        if(!m)
            r = max(r, c[i]);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 384