akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int s = sc.nextInt();
		int count = 1;
		while (s != 4 && s != 2 && s != 1) {
			count++;
			if (s % 2 == 0)
				s = s / 2;
			else
				s = 3 * s + 1;
		}
		System.out.println(count + 3);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

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

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

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

using namespace std;

const int IINF = INT_MAX;
int N,M,D[1002],C[1002],dp[1002][1002];

int main(){
  cin >> N >> M;
  rep(i,N) cin >> D[i];
  rep(i,M) cin >> C[i];
  rep(i,M+1) rep(j,N+1) dp[i][j] = IINF;
  dp[0][0] = 0;
  rep(day,M){
    rep(city,N){
      if( dp[day][city] == IINF ) continue;
      dp[day+1][city] = min(dp[day+1][city],dp[day][city]);
      dp[day+1][city+1] = min(dp[day+1][city+1],dp[day][city]+D[city]*C[day]);
    }
  }
  int mini = IINF;
  rep(i,M+1) mini = min(mini,dp[i][N]);
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 5088
// ABC113B - Palace

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

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}

	int ans = 0;
	double minT = abs((T - H[0] * 0.006) - A);

	for (int i = 1; i < N; i++) {
		double temp;
		temp = abs((T - H[i] * 0.006) - A);
		if (temp < minT) {
			minT = temp;
			ans = i;
		}
	}

	cout << ans + 1 << endl;

	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int left = 1;
    int right = N;
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        if (L > left) {
            left = L;
        }
        if (R < right) {
            right = R;
        }
    }
    if (right + 1 > left) {
        cout << right - left + 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int q;
  vector<int> p;
  int order;
  int x;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> order;
    switch (order)
    {
    case (0):
      cin >> x;
      p.push_back(x);
      break;
    case (1):
      cin >> x;
      cout << p.at(x) << endl;
      break;
    case (2):
      p.pop_back();
      break;
    }
  }
}


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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int n,m,k;
char gr[7][7];
vector<pair<int,int>> vec;
int ans=0;

void solve(int i,vector<pair<int,int>> temp){
    if(i == vec.size()){
        char gr1[n][m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                gr1[i][j] =gr[i][j];
            }
        }
        for(auto it:temp){
            if(it.second == 0){
                for(int j=0;j<m;j++){
                    gr[it.first][j] = 'X';
                }
            }
            else{
                for(int j=0;j<n;j++){
                    gr[j][it.first] = 'X';
                }
            }
        }
        int c = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(gr[i][j] == '#'){
                    c++;
                }
            }
        }
        if(c == k)
            ans++;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                gr[i][j] = gr1[i][j];
            }
        }
    } else {
        solve(i+1,temp);
        temp.push_back(vec[i]);
        solve(i+1,temp);
        temp.pop_back();
    }
}

signed main(){
	cin >> n >> m >> k;
	for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>gr[i][j];
    for(int i=0;i<n;i++){
        vec.push_back({i,0});
    }
    for(int j=0;j<m;j++){
        vec.push_back({j,1});
    }
	vector<pair<int,int>> temp;
	solve(0,temp);
	cout << ans << endl;
    return 0;

}


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

using namespace std;

typedef unsigned long long ull;

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

    ull monsters[n + 1];
    ull heroes[n];
    for (int i = 0; i < n + 1; i ++)
        cin >> monsters[i];
    
    for (int i = 0; i < n ; i ++)
        cin >> heroes[i];
    ull sum = 0;
    sum = accumulate(heroes, heroes + n, sum);
    for (int i = 0; i < n; i ++) {
        if (monsters[i] >= heroes[i]) {
            monsters[i] -= heroes[i];
            heroes[i] = 0;
        }else {
            heroes[i] -= monsters[i];
            monsters[i] = 0;
            if (monsters[i + 1] >= heroes[i]) {
                monsters[i + 1] -= heroes[i];
                heroes[i] = 0;
            }else {
                heroes[i] -= monsters[i + 1];
                monsters[i + 1] = 0;
            }
        }
    }
    ull sum2 = 0;
    sum2 = accumulate(heroes, heroes + n, sum2);

    cout << sum - sum2;


    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    
    ll n,m;
    cin >> n >> m;
    vvll LR(m,vll (2));
    rep(i,m){
        rep(j,2){
            cin >> LR[i][j];
        }
    }

    ll L = 1,R = n;
    rep(i,m){
        assign_max(L,LR[i][0]);
        assign_min(R,LR[i][1]);
    }

    cout << (R-L+1 > 0 ? R-L+1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 8428
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    i64 n,c;
    cin >> n >> c;
    vector<i64> x(n);
    vector<i64> v(n);
    rep(i,n) cin >> x[i] >> v[i];

    vector<pair<int,i64>> r_oneway(n+1, {0,0});
    vector<pair<int,i64>> l_oneway(n+1, {0,0});
    vector<pair<int,i64>> r_round(n+1, {0,0});
    vector<pair<int,i64>> l_round(n+1, {0,0});

    i64 tmp_cal = 0;
    i64 tmp_dis = 0;
    rep(i,n)
    {
        i64 d = i==0 ? x[i] : x[i] - x[i-1];
        tmp_cal += v[i] - d;
        tmp_dis += d;

        if(tmp_cal>r_oneway[i].second)
        {
            r_oneway[i+1].first = i;
            r_oneway[i+1].second = tmp_cal;
        }
        else
        {
            r_oneway[i+1] = r_oneway[i];
        }

        if(tmp_cal-tmp_dis>r_round[i].second)
        {
            r_round[i+1].first = i;
            r_round[i+1].second = tmp_cal-tmp_dis;
        }
        else
        {
            r_round[i+1] = r_round[i];
        }
    }

    tmp_cal = 0;
    tmp_dis = 0;
    rep(i,n)
    {
        i64 d = i==0 ? c-x[n-1] : x[n-i] - x[n-i-1];
        tmp_cal += v[n-1-i] - d;
        tmp_dis += d;

        if(tmp_cal>l_oneway[i].second)
        {
            l_oneway[i+1].first = i;
            l_oneway[i+1].second = tmp_cal;
        }
        else
        {
            l_oneway[i+1] = l_oneway[i];
        }

        if(tmp_cal-tmp_dis>l_round[i].second)
        {
            l_round[i+1].first = i;
            l_round[i+1].second = tmp_cal-tmp_dis;
        }
        else
        {
            l_round[i+1] = l_round[i];
        }
    }

    i64 max_cal = 0;
    rep2(i,1,n+1)
    {
        // r
        int max_idx_oneway = r_oneway[i].first;
        i64 max_cal_oneway = r_oneway[i].second;

        int max_idx_round = n - (max_idx_oneway + 1);
        i64 max_cal_round = l_round[max_idx_round].second;

        max_cal = max(max_cal, max_cal_oneway+max_cal_round);

        // l
        max_idx_oneway = l_oneway[i].first;
        max_cal_oneway = l_oneway[i].second;

        max_idx_round = n - (max_idx_oneway + 1);
        max_cal_round = r_round[max_idx_round].second;

        max_cal = max(max_cal, max_cal_oneway+max_cal_round);
    }
    cout << max_cal << endl;
    return 0;
}

Measured memory_bytes: 8064
# -*- coding: utf-8 -*-
N = int(input())

if N < 105:
    ans = 0
else:
    ans = 1
    for i in range(107, N+2, 2):
        cnt = 0
        for j in range(1, N+1):
            if i % j == 0:
                cnt += 1

        if cnt == 8:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int H, W; cin >> H >> W;
    char c[H][W]; 
    rep(i,H) {
        rep(j,W) cin >> c[i][j];
    }
    
    rep(i,H) {

        rep(j,W) {
            cout << c[i][j];
        }
        cout << endl;

        rep(j,W) {
            cout << c[i][j];
        }
        cout << endl;
    }


    
    return 0;
}






Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (str != null) {
			int weight = Integer.parseInt(str);
			int n = 0;
			while (weight != 1) {
				if (weight % 2 == 1)
					System.out.print((int) Math.pow(2, n) + " ");
				n++;
				weight /= 2;
			}

			System.out.println((int) Math.pow(2, n));
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24216
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var data=Console.ReadLine();
        string[] st=data.Split(' ');
        for (int i=0;i<n;i++){
            Console.Write(st[0][i]);
            Console.Write(st[1][i]);
        }
    }
}


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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

vector<int> adj[MAX_N];
int colour[MAX_N];
int val[MAX_N];

void c(int v,int col){
  colour[v] = col;
  for(auto x : adj[v])
    if(colour[x] == 0)
      c(x,3-col);
}

pair<int,int> A[MAX_N];

pair<int,int> f(int v,int p){
  pair<int,int> R(INT_MIN/2,INT_MAX/2);
  if(val[v] != -1)
    R = make_pair(val[v],val[v]);
  
  for(auto u : adj[v])
    if(u != p){
      pair<int,int> tmp = f(u,v);
      R.first  = max(tmp.first-1,  R.first);
      R.second = min(tmp.second+1,R.second);
    }
  
  if(R.second < R.first){
    cout << "No" << endl;
    exit(0);
  }
  
  return A[v] = R;
}

void g(int v,int p,int X){
  if(p == -1)
    A[v].second = A[v].first;
  else {
    if(A[v].first <= X-1 && X-1 <= A[v].second){
      A[v] = make_pair(X-1,X-1);
    } else {
      A[v] = make_pair(X+1,X+1);
    }
  }
  
  for(auto u : adj[v])
    if(u != p)
      g(u,v,A[v].first);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  for(int i=0;i<n-1;i++){
    int u,v; cin >> u >> v; u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  
  c(0,1);
  
  for(int i=0;i<n;i++)
    val[i] = -1;
  
  int K; cin >> K;
  for(int i=0;i<K;i++){
    int v,p;
    cin >> v >> p;
    val[v-1] = p;
  }
  
  set<int> check[2];
  // Parity?
  for(int i=0;i<n;i++)
    if(val[i] != -1)
      check[colour[i]-1].insert(val[i]%2);
  
  if(check[0].size() == 2 || check[1].size() == 2){
    cout << "No" << endl;
    return 0;
  }
  
  f(0,-1);
  
  g(0,-1,-1);
  
  cout << "Yes" << endl;
  for(int i=0;i<n;i++)
    cout << A[i].first << endl;
  
  return 0;
}


Measured memory_bytes: 15872
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n, d;
    scan(n, d);
    auto c = 2*d + 1;
    auto ans = (n + c - 1) / c;
    writeln(ans);
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)


Measured memory_bytes: 172928
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define pb push_back
#define mp map<ll,ll>
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int32_t main(){
    fast;
    ll n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<b[i];
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque

s = input()
q = int(input())

s = deque(s)

rev = 0
for _ in range(q):
    que = input()
    if que[0] == "1":
        rev ^= 1

    else:
        t, f, c = que.split()
        if rev:
            if f == "1":
                s.append(c)
            else:
                s.appendleft(c)

        else:
            if f == "1":
                s.appendleft(c)
            else:
                s.append(c)

s = list(s)
if rev:
    print(*s[::-1], sep="")
else:
    print(*s, sep="")


Measured memory_bytes: 12144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    set<string>st;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        st.insert(s);

    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 19196
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007


#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int A,B;
  cin>>A>>B;
  cout<<A*B<<endl;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	n%=10; 
	if(n==2 || n==4 || n==5 || n==7 || n==9)
		cout<<"hon";
	else if(n==0 || n==1 || n==6 || n==8)
		cout<<"pon";
	else if(n==3)
		cout<<"bon";
	return 0;
}


Measured memory_bytes: 3592
/*input
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    

 vector<vector<int>> graph;
 vector<bool> visited;
vector<int>dp;
void dfs(int s,int val){
	visited[s] = true;
	int total = 0;
	for(auto i:graph[s]){
		if(!visited[i]) dfs(i,val+1);
		total= max(total,1+(dp[i]));
	}
	dp[s] = max(dp[s],total);
	
}
int32_t main() {
    IOS;
	int h,w;cin>>h>>w;
	vector<string> s(h);
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	vector<vector<int>> dp(h,vector<int>(w,0));
	dp[0][0] = 1;
	for(int i=1;i<w;i++){
		if(s[0][i]=='#')dp[0][i] = 0;
		else
			dp[0][i]=dp[0][i-1];
	}
	for(int i=1;i<h;i++){
		if(s[i][0]=='#')dp[i][0] = 0;
		else
			dp[i][0]=dp[i-1][0];
	}

	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(s[i][j]=='#'){
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}






Measured memory_bytes: 9216
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 9128
#include <cstdio>
#include <cmath>
using namespace std;

int main(void){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%0lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));

    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> a(H);

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

    for (int j = 0; j < W + 2; j++) {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < a.size(); i++) {
        cout << "#" << a.at(i) << "#" << endl;
    }

    for (int j = 0; j < W + 2; j++) {
        cout << "#";
    }
    cout << endl;
}

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

int main(){
    string S;
    int st0=100,ln0=0,st=100,ln=0;
    bool flg=false;
    cin >>S;

    for (int i=0;i<S.size();i++){
        if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
            if(! flg){
                flg=true;
                st0=i;
                ln0=1;
            }else{
                ln0++;
            }
        }else{
            if(flg){
                if (ln0>ln){
                    st=st0;
                    ln=ln0;
                }
                flg=false;

            }

        } 
    }
        if (ln0>ln){
                    st=st0;
                    ln=ln0;
        }
        cout << ln <<endl;

}

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

using namespace std;
#define int long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second

signed main() {
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    int min2 = min(q * 8, h * 4);
    min2 = min(min2, s * 2);
    min2 = min(min2, d);
    int min1 = min(q * 4, h * 2);
    min1 = min(min1, s);
    int n;
    cin >> n;
    cout << n / 2 * min2 + n % 2 * min1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

vector<long> pp;

void preparePrime( long maxp )
{
    long i;
    vector<long> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        long k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void decompositPrime( ll a, vector<pair<ll,ll> >& vv )
{
    preparePrime( (long)sqrt((double)a) );

    long i;
    for(i=0; i<(long)pp.size(); i++) {
        long count = 0;
        while(a % pp[i] == 0 ) {
            a /= pp[i];
            count ++;
        }
        if(count>0) vv.push_back( make_pair( pp[i], count ) );
        if (a==1) break;
    }
    if(a>1) {
        vv.push_back( make_pair( a, 1 ) );
    }

    return;
}

int main(int argc, char* argv[])
{
    ll n;
    scanf("%lld", &n);

    vector<pair<ll,ll> > vv;
    decompositPrime( n, vv );

    ll num = vv.size();
    ll ans = 1;
    long i;
    for(i=0; i<num; i++) {
        ans *= (vv[i].second+1);
    }

    printf("%lld %lld\n", num, ans-1 );

    return 0;
}




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

typedef long long ll;

int N;
ll A[100010];

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)cin >> A[i];

    ll ans = A[0] - 1;
    int mem = 2;
    for(int i = 1; i < N; i++)
    {
        if(A[i] < mem)continue;
        if(A[i] == mem)mem++;
        else ans += (A[i] - 1) / mem;
    }

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


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

#define ll long long int
int main()
{
    int n;
    cin>>n;
    string s[n];
    map<string ,int>mp;
    int mx=-1;
    for(int i=0;i<n;i++) cin>>s[i],mp[s[i]]++,mx=max(mx,mp[s[i]]);
    vector<string>v;
    for(auto x:mp){
      if(x.second==mx) v.push_back(x.first);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++) cout<<v[i]<<endl;


}


Measured memory_bytes: 33476
#include <bits/stdc++.h>
using namespace std;
int n,size[100010],fa[100010],tmp=0,cnt=0,s[100010],Un_f=0,head[100010],o=0,hd,dis[100010],si[100010];
long long d[100010],g[100010];
map<long long,int>ma;
struct node{
	long long w;
	int id;
	bool operator <(const node &b)const{
		return w<b.w;
	}
};
struct edge{
	int to,link;
}e[400010];
void add_edge(int u,int v){
	e[++o].to=v,e[o].link=head[u],head[u]=o;
	e[++o].to=u,e[o].link=head[v],head[v]=o;
}
priority_queue<node>q;
void dfs(int u,int pre){
	si[u]=1;
	for(int i=head[u];i;i=e[i].link){
		if(e[i].to==pre) continue;
		dis[e[i].to]=dis[u]+1;
		dfs(e[i].to,u);
		si[e[i].to]+=si[u];
	}
}
void work(int u,int pre){
	if(g[u]!=d[u]){
		printf("-1\n");
		exit(0);
	}
	for(int i=head[u];i;i=e[i].link){
		if(e[i].to==pre) continue;
		g[e[i].to]=g[u]+n-si[e[i].to]*2;
		dfs(e[i].to,u);
	}
}
int main(){
	ma.clear();
	while(q.size()) q.pop();
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&d[i]);
		ma[d[i]]=i,size[i]=1;
		q.push((node){d[i],i});
	}
	while(q.size()){
		node now=q.top();q.pop();
		if(q.size()){
			fa[now.id]=ma[d[now.id]+size[now.id]*2-n];
			size[fa[now.id]]+=size[now.id];
			add_edge(fa[now.id],now.id);
		}
		if(!q.size()) hd=now.id;
	}
	dfs(hd,0);
	for(int i=1;i<=n;i++) g[hd]+=dis[i];
	work(hd,0);
	for(int i=1;i<=n;i++){
		if(!fa[i]) continue;
		printf("%d %d\n",i,fa[i]);
	}
}

Measured memory_bytes: 18800
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  long total = 0;
  for(int i=0;i<n;i++){
    if((i+1)%3==0||(i+1)%5==0){
      continue;
    }else{
      total += i+1;
    }
  }
  cout << total;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
    int w, h, n; cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> a[i];
    }

    vector<vector<bool>> grid(h, vector<bool> (w));
    rep(i, h) {
        rep(j, w) {
            grid[i][j] = false;
        }
    }

    int ans = 0;

    rep(i, n) {
        if(a[i] == 1) {
            rep(j, h) {
                rep(k, x[i]) {
                    grid[j][k] = true;
                }
            }
        } else if(a[i] == 2) {
            rep(j, h)
            {
                for(int k = x[i]; k < w; k++) {
                    grid[j][k] = true;
                }
            }
        } else if(a[i] == 3) {

            rep(j, y[i])
            {
                rep(k, w)
                {
                    grid[j][k] = true;
                }
            }

            
        } else {
            for (int j = y[i]; j < h; j++)
            {
                rep(k, w)
                {
                    grid[j][k] = true;
                }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if(!grid[i][j]) {
                ans ++;
            }
        }
    }

    cout << ans << endl;

}

int main()
{
    solve1();
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define ll long long
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
inline int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
inline ll gl(){
	ll sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
vector<int >A[5000010];
int main(){
	int i,j,n,m,k,ans=0;
	n=gi();
	for(i=1;;i++){
		ans+=i;
		if(ans>n)return puts("No"),0;
		if(ans==n){ans=i;break;}
	}
	puts("Yes");int qq=1,qqq=1;printf("%d\n",ans+1);
	for(i=1;i<=n;i++){
		qq++;
		if(qq>ans+1){qqq++;qq=qqq+1;}
		A[qq].push_back(i);
		A[qqq].push_back(i);
	}
	for(i=1;i<=ans+1;i++){
		printf("%d ",A[i].size());
		for(j=0;j<A[i].size();j++)
			printf("%d%c",A[i][j],j==A[i].size()-1?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 119552
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

#define INF (1<<29)
#define EPS (1e-10)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		//cin >> x >> y;
		scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		//cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		while( 1 ){
			if( it == treasure.end() || *it > mp(x2,y2) ) break;
			if( (*it).first > x2 ) it = upper_bound(treasure.begin(), treasure.end(),mp(-INF,(*it).second+1));
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1336
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0252/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aojxxxx/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int R = sc.nextInt();
			int C = sc.nextInt();
			if (R == 0 && C == 0)
				break;
			int a[][] = new int[R][C];
			for (int r = 0; r < R; r++)
				for (int c = 0; c < C; c++)
					a[r][c] = sc.nextInt();

			int best = 0;
			for (int set = 0; set < (1 << R); set++) {
				int temp = 0;
				for (int c = 0; c < C; c++) {
					int b = 0;
					for (int r = 0; r < R; r++) {
						int flip = (set >> r) & 1;
						b += (a[r][c] == flip ? 0 : 1);
					}
					temp += max(b, R - b);
				}
				best = max(best, temp);
			}
			System.out.println(best);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
using namespace std;
int a,b;
int main(){
while(1){
	cin>>a>>b;
	if(a==0 && b==0){
		break;
	}
	int dp[25][25]={},n=0,xi=0,yi=0,k[50][50]={};
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>yi>>xi;
		k[yi][xi]=-1;
	}
	if(k[1][1]!=-1){
		dp[1][1]=1;
	}
	for(int y=1;y<=a;y++){
		for(int x=1;x<=b;x++){
			if(k[y][x]!=-1 && (x!=1 || y!=1)){
				dp[y][x]=dp[y-1][x]+dp[y][x-1];
			}
		}
	}
	cout<<dp[a][b]<<endl;
	}
}

Measured memory_bytes: 1176
def main():
    n, y = map(int, input().split())
    ans = '-1 -1 -1'
    if (10000*n < y):
        print(ans)
        return
    for i in range(n+1):
        for j in range(n-i+1):
            k = n-i-j
            if (1000*i+5000*j+10000*k==y):
                ans = '{0} {1} {2}'.format(k,j,i)
                break
        else:
            continue
        break
    print(ans)
main()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#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=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int a[100005], b[100005], c[100005],n;
int db[100005], dc[100005];


int main(){

	scanf("%d ", &n);
	
	rep(i, n) {
		scanf("%d ", &a[i]);
	}
	rep(i, n) {
		scanf("%d ", &b[i]);
	}
	rep(i, n) {
		scanf("%d ", &c[i]);
	}
	sort(a, a + n);//
	sort(b, b + n);
	sort(c, c + n);
	ll ans = 0LL;
	for (auto t : b) {//
		ll l = lower_bound(a, a + n, t)-a;
		ll r = n - (upper_bound(c, c + n, t)-c);
		ans += l*r;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
def read_input():
    a, b = map(int, input().split())
    return a, b


def judge(a, b):
    if a == 1:
        return 'Alice'

    if b == 1:
        return 'Bob'

    if a > b:
        return 'Alice'
    else:
        return 'Bob'


def submit():
    a, b = read_input()

    if a == b:
        print('Draw')
    else:
        print(judge(a, b))

if __name__ == '__main__':
    submit()


Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	S, T   string
	a, b   [200000]int
	m1, m2 map[byte]int = make(map[byte]int), make(map[byte]int)
	N      int
)

func readVariables() {
	S, T = nextStr(), nextStr()
	N = len(S)
}

func main() {
	readVariables()
	for i := 0; i < N; i++ {
		m1[S[i]]++
		m2[T[i]]++
	}
	for _, v := range m1 {
		a[v]++
	}
	for _, v := range m2 {
		b[v]++
	}
	var answer string
	if a == b {
		answer = "Yes"
	} else {
		answer = "No"
	}
	fmt.Println(answer)
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 3584
d,g= map(int,input().split())
p_c = [input() for i in range(d)]
pc =[]
for j in range(d):
  p,c = map(int,p_c[j].split())
  pc.append([p,c])
ans = []
for x in range(2**d):
  count = 0
  total = 0
  tokanai = []
  for y in range(d):
    if (x >> y) & 1 == 1:
      count += pc[y][0]
      total += pc[y][0] * (y+1)*100 + pc[y][1]
    else:
      tokanai.append([pc[y][0],(y+1)*100])
  if total < g and g-total <= (max(tokanai)[0]-1)*max(tokanai)[1]:
    di = g-total
    for k in range(max(tokanai)[0]):
      if di - ((k+1) * max(tokanai)[1]) <= 0:
        count += k+1
        ans.append(count)
  elif total >= g:
    ans.append(count)
print(min(ans))

Measured memory_bytes: 42972
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;

using namespace std;


signed main() {
  string s;
  cin >> s;

  int N = s.size();
  int ans = 0;
  REP(i, (1<<N)/2){
    int res = 0;
    REP(j, N-1){
      res *= 10;
      res += s[j]-48;
      if((i >> j)%2 == 0){
        ans += res;
        res = 0;
      }
    }
    res *= 10;
    res += s[N-1]-48;
    ans += res;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long fibo(int n){
    long long fibodp[200];
    fibodp[0] = 1;
    fibodp[1] = 1;
    for(int i = 2; i <= n; i++){
            fibodp[i] = fibodp[i-1] + fibodp[i-2];
    }
    return fibodp[n];
}
int main(void){
    int n;
    
    scanf("%d", &n);
    printf("%d\n",fibo(n));
    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int f(int n, int a[], int k){
	int right=n;
	int left=0;
	//if(k>a[n-1])
		//return n;
	while(left<right){
		int m=(left+right)/2;
		if(a[m]>=k){
			if(a[m-1]<k || m==0)
				return m;
			else
				right=m;
		}
		else{
			if(a[m+1]>k)
				return m+1;
			else
				left=m+1;
		}
	}
	return n;
}
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	int q;
	cin>>q;
	while(q--){
		int k;
		cin>>k;
		cout<<f(n,a,k)<<endl;
	}
	return 0;
}


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

int main() {

  string T;

  cin >> T;
  int PD, D;
  int DPDindex;

  rep(i, T.size()) {
    if (T.at(i) == '?') {
      T.at(i) = 'D';
    }
  }
  cout << T << endl;
}


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

const ll MOD = 1e9+7;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

int main(){
    string L ; cin >> L;
    int n = L.size();
    vector<vector<mint> > dp(n+1,vector<mint>(2,0));
    dp[0][0] = 1;
    rep(i,n){
        rep(j,2){
            
            if(L[i]=='1'){
                dp[i+1][1] += dp[i][j];
            }else dp[i+1][j] += dp[i][j];

            if(!(L[i]=='0' and !j)) dp[i+1][j] += dp[i][j]*2;
        }
    }

    cout << dp[n][0] + dp[n][1] << endl;
}

Measured memory_bytes: 8780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define MP make_pair
#define PII pair<int, int>
typedef long long LL;
const LL MOD = 998244353;
const int INF = 0x3fffffff;
const int N = 100010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,x;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	map<int,int>cnt;
	rep(i,1,n)cin>>x,cnt[x]++;
	if(cnt.size()<=3){
		int a[4],b[4],m=0;
		for(auto x:cnt){
			a[++m]=x.first;
			b[m]=x.second;
		}
		//rep(i,1,m)cout<<a[i]<<" "<<b[i]<<endl;
		bool flag = false;
		if(m==1&&a[1]==0)flag=true;
		if(m==2&&b[1]==b[2]*2&&(a[1]^a[1]^a[2])==0)flag=true;
		if(m==2&&b[1]*2==b[2]&&(a[1]^a[2]^a[2])==0)flag=true;
		if(m==3&&b[1]==b[2]&&b[1]==b[3]&&(a[1]^a[2]^a[3])==0)flag=true;
		if(flag){
			cout<<"Yes\n";
			return 0;
		} 
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3840
#!/usr/bin/env python3
#ABC137 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
lst = []
for _ in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    lst.append(s)
lst = list(Counter(lst).items())
ans = 0
for i,j in lst:
    if j == 1:
        continue
    ans += ((j-1)*j)//2
print(ans)


Measured memory_bytes: 74712