akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    vector<string> M(h);
    for (int i = 0; i < h; ++i) {
        cin >> M[i];
    }

    const int INF = 1 << 28;
    vector<vector<int>> dis(h, vector<int>(w, INF));
    dis[0][0] = 1;
    vector<pair<int,int>> que;
    que.emplace_back(0, 0);

    vector<int> X{-1, 1, 0, 0};
    vector<int> Y{0, 0, -1, 1};
    for (int i = 0; i < que.size(); ++i) {
        int x = que[i].first, y = que[i].second;
        for (int j = 0; j < X.size(); ++j) {
            int nx = x + X[j], ny = y + Y[j];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && M[nx][ny] == '.') {
                if (dis[nx][ny] > dis[x][y] + 1) {
                    dis[nx][ny] = dis[x][y] + 1;
                    que.emplace_back(nx, ny);
                }
            }
        }
    }

    int whites = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (M[i][j] == '.') {
                ++whites;
            }
        }
    }
    if (dis[h - 1][w - 1] >= INF) {
        cout << -1 << '\n';
    } else {
        // cout << whites << " " << dis[h - 1][w - 1] << endl;
        int res = whites - dis[h - 1][w - 1];
        cout << res << '\n';
    }


    return 0;
}

Measured memory_bytes: 384
import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print(lcm(*(a)))



Measured memory_bytes: 6332
import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

def solve(test):
	h1, m1, h2, m2, k = map(int, input().split())
	r1 = h1 * 60 + m1
	r2 = h2 * 60 + m2
	ans = max(0, r2 - r1 - k)
	print(ans)

if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	std::string a, b, ans;

	std::cin >> a >> b;

	
	if (std::stoi(a) > std::stoi(b))
	{
		std::string tmp = a;
		a = b;
		b = tmp;
	}
	
	for (int i = 0; i < std::stoi(b); i++){
		ans += a;
	}

	std::cout << ans << std::endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 100010

using namespace std;

int n, m, indeg[maxn], F[maxn], res;
vector<int> A[maxn];
queue<int> Q;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(indeg, 0, sizeof(indeg));
	cin >> n >> m;
	FOR(i, 1, m) {
        int u, v;
        cin >> u >> v;
        A[u].push_back(v);
        ++indeg[v];
	}
	memset(F, 0, sizeof(F));
    FOR(i, 1, n)
        if (!indeg[i]) Q.push(i);
    res = 0;
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        res = max(res, F[u]);
        if (A[u].empty()) continue;
        FOR(i, 0, A[u].size()-1) {
            F[A[u][i]] = max(F[A[u][i]], F[u]+1);
            if ((--indeg[A[u][i]]) == 0)
                Q.push(A[u][i]);
        }
    }
    cout << res;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main () {

    int n;
    string s;
    string a;

    cin >> s;
    a = s;
    REP(i,s.length()) {
        if(s[i]=='1') {
            a[i] = '9';
        } else
        {
            a[i] = '1';
        }
    } 
    
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  ll ans = 0;
  map<ll, ll> m;
  V a(n);
  rep(i,n) {
    cin >> a[i];
  }
  rep(i,n) {
    m[(i+1)-a[i]]++;
  }
  rep(i,n) {
    ans += m[(i+1)+a[i]];
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 27492
#include<bits/stdc++.h>
using namespace std;
long long a[200005],n;
map <long long, long long> mp;
int main()
{
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i];
		if (mp[a[i]]==1)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		mp[a[i]]++;
	}
	cout<<"YES"<<endl;
	
}
    

Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	int A[3], B[3];
	for (int i = 0; i < 100; i++) {
		bool ok = true;
		A[0] = i;
		for (int j = 0; j < 3; j++) B[j] = c[0][j] - A[0];
		for (int j = 1; j < 3; j++) A[j] = c[j][0] - B[0];
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j] + B[k] != c[j][k]) ok = false;
			}
		}
		if (ok) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
#include<iomanip>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  int tmp = 0;
  int next = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    if (tmp == next) {
      next++;
    } else {
      ans++;
    }
  }
  if (next == 1) {
    cout << -1;
  } else {
    cout << ans;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   string s;
   cin>>s;
   sort(all(s));
   int f=0;
   if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

    return 0;
}


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

int main(){
  int n,m;
  std::cin >> n>>m;
  std::vector<int> ans(n,-1);
  bool flag = true;
  rep(i,m){
    int s,c;
    std::cin >> s>>c;
    s--;
    if(ans[s]==-1 || ans[s]==c)ans[s]=c;
    else flag = false;
  }


  if(ans[0]==0 && ans.size()>1)flag = false;



  if(flag){
    if(n!=1)
    rep(i,n){
      if(ans[i]!=-1)std::cout << ans[i];
      else if(i==0 && ans[i]==-1)std::cout << "1";
      else if(ans[i]==-1)std::cout << "0" ;
    }
    else{
      if(ans[0]!=-1)std::cout << ans[0];
      else std::cout << "0";
    }
  }
  else std::cout << "-1";

  std::cout  << '\n';


  return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int main(){
  int n,m;
  std::cin >> n>>m;
  std::vector<int> ans(n,-1);
  bool flag = true;
  rep(i,m){
    int s,c;
    std::cin >> s>>c;
    s--;
    if(ans[s]==-1 || ans[s]==c)ans[s]=c;
    else flag = false;
  }


  if(ans[0]==0)flag = false;



  if(flag){
    rep(i,n){
      if(i==0 && ans[i]==-1)std::cout << "1";
      else if(ans[i]==-1 )std::cout << "0" ;
      else std::cout << ans[i];
    }
  }
  else std::cout << "-1";

  std::cout  << '\n';


  return 0;
}

*/


Measured memory_bytes: 256
defmodule Main do
  def main do
    [a, b, c] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    k = IO.gets("") |> String.trim |> String.to_integer
    a = String.to_integer(a)
    b = String.to_integer(b)
    c = String.to_integer(c)
    IO.puts(a + b + c - Enum.max([a, b, c]) + Enum.max([a, b, c]) * :math.pow(2,k) |> round)
  end
end

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

using namespace std;

typedef long long ll;

vector <ll> GetDiv(ll x)
{
    vector <ll> Res;

    for(ll y = 1; y * y <= x; y++)
    {
        if(x % y == 0)
        {
            Res.push_back(y);
            if(y * y != x)  Res.push_back(x / y);
        }
    }

    return Res;
}

bool Can(ll n, ll k)
{
    if(k < 2 || k > n)  return false;

    while(n % k == 0)   n /= k;

    return n % k == 1;
}

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

    vector <ll> D1 = GetDiv(n);
    vector <ll> D2 = GetDiv(n - 1);

    set <ll> Ans;

    for(ll k : D1)
        if(Can(n, k))
            Ans.insert(k);

    for(ll k : D2)
        if(Can(n, k))
            Ans.insert(k);

    cout << Ans.size() << endl;
}


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

int a[100];
int result[100][100];

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

  int r = 0, c = 0, d = 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      result[r][c] = i + 1;
      int next = c + d;
      if (next < 0 || next >= W) {
        r++;
        d *= -1;
      } else {
        c = next;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j)
        cout << " ";
      cout << result[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

int main(){
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    for(;;){
        c -= b;
         if(c <= 0){
            cout << "Yes" << endl;
            break;
            }
       
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }

}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(){
    int i,n,s[1000];
    double h,sum;
    
    while(1){

        scanf("%d",&n);
        if(!n) break;
        
        sum = 0;
        h = 0;
        
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum += s[i];
        }
    
        sum /= n;
        
        for(i=0;i<n;i++){
            h += pow(s[i]-sum, 2.0);
        }
            
        h /= n;

        printf("%lf\n",pow(h,1.0/2.0));
    
    }
    
    
}



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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define MOD 998244353

Int R[3 << 10][3 << 10];
int a, b, c, d;

Int f(int x, int y)
{
    if(x < a || y < b) return 0;
    if(x == a && y == b) return 1;
    Int& res = R[x][y];
    if(res != -1) return res;
    if(x == a) return res = f(x, y - 1)*x % MOD;
    if(y == b) return res = f(x - 1, y)*y % MOD;
    res = f(x, y - 1) + f(x - 1, y);
    res += f(x - 1, y)*(y - 1) % MOD;
    res += f(x, y - 1)*(x - 1) % MOD;
    res += MOD - (f(x - 1, y - 1)*(x - 1)*(y - 1) % MOD);
    res %= MOD;
    return res;
}

void solve(int test)
{
    cin >> a >> b >> c >> d;
    CLEAR(R, -1);
    cout << f(c, d) << endl;
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T) solve(t);
    return 0;
}


Measured memory_bytes: 77712
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *right,*left,*parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26764
import java.util.*;

public class Main {
	

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

		Long A = sc.nextLong();
		Long B = sc.nextLong();
		Long N = sc.nextLong();

		if(B>N){
			Long ans = (long) Math.floor((A*N)/B);
			System.out.println(ans);
			return;
		}

		Long divideNB = (long) Math.floor(N/B);
		N = (divideNB*B) - 1;

		Long ans = (long) (Math.floor((A*N)/B) - A*(Math.floor(N/B)));
		System.out.println(ans);
		return;

	}


}


Measured memory_bytes: 35852
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxNM = 100000;

int N, M;
string S, T;
int ans = 0;

int g, l, sn, tn;

int Gcd(int a, int b) {
  if (b == 0) { return a; }
  return Gcd(b, a%b);
}

int Ans() {
  REP(i, g) {
    if (S[sn*i] != T[tn*i]) { return -1; }
  }
  return l;
}

signed main() {
  cin >> N >> M;
  cin >> S;
  cin >> T;

  g = Gcd(N, M);
  l = (N/g) * (M/g) * g;

  sn = N/g;
  tn = M/g;

  ans = Ans();

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


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

int main(){
  string SA, SB, SC;
  cin >> SA >> SB >> SC;
  char Next='a';
  string Ans;
  int L=SA.size()+SB.size()+SC.size();
  for(int i=0; i<L; i++){
    if(Next=='a'){
      if(SA.size()==0){
        Ans="A";
        break;
      }
      else{
        Next=SA.at(0);
        SA.erase(SA.begin());
      }
    }
    if(Next=='b'){
      if(SB.size()==0){
        Ans="B";
        break;
      }
      else{
        Next=SB.at(0);
        SB.erase(SB.begin());
      }
    }
    if(Next=='c'){
      if(SC.size()==0){
        Ans="C";
        break;
      }
      else{
        Next=SC.at(0);
        SC.erase(SC.begin());
      }
    }
  }
  cout << Ans << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX=1000000001, MIN=-1000000001;
int n, q, a[1005], c, st, en;
int mintree[4005], maxtree[4005];
void buildmin(int ind, int s, int e) {
	int mid;
	if (s==e) {
		mintree[ind]=a[s];
	} else {
		mid=(s+e)/2;
		buildmin(2*ind, s, mid);
		buildmin(2*ind+1, mid+1, e);
		mintree[ind]=min(mintree[2*ind], mintree[2*ind+1]);
	}
}

void buildmax(int ind, int s, int e) {
	int mid;
	if (s==e) {
		maxtree[ind]=a[s];
	} else {
		mid=(s+e)/2;
		buildmax(2*ind, s, mid);
		buildmax(2*ind+1, mid+1, e);
		maxtree[ind]=max(maxtree[2*ind], maxtree[2*ind+1]);
	}
}

int query(int c, int ind, int s, int e, int l, int r) { //s,e=target range l,r=range now
	int mid;
	if (c==1) {
		if (l>=s && r<=e) return maxtree[ind];
		else if (r<s || e<l) return MIN;
		else {
			mid=(l+r)/2;
			return max(query(c, 2*ind, s, e, l, mid), query(c, 2*ind+1, s, e, mid+1, r));
		}
	} else {
		if (l>=s && r<=e) return mintree[ind];
		else if (r<s || e<l) return MAX;
		else {
			mid=(l+r)/2;
			return min(query(c, 2*ind, s, e, l, mid), query(c, 2*ind+1, s, e, mid+1, r));
		}
	}
}

int main() {
	cin >> n;
	for (int i=0; i<n; i++) cin >> a[i];
	
	buildmin(1,0,n-1);
	buildmax(1,0,n-1);
	
	cin >> q;
	for (int i=0; i<q; i++) {
		cin >> c >> st >> en;
		cout << query(c, 1, st, en-1, 0, n-1) << "\n";
	}
}


Measured memory_bytes: 3112
import math
import sys
import random

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

input_list = sieve_of_erastosthenes(10**6+1)
prime_list = [i for i, b in enumerate(input_list) if b == True]

def factorization(n):
    arr = []
    temp = n
    for i in prime_list:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)
    if arr==[]:
        arr.append(n)
    return arr
random.shuffle(a)
g = a[0]
arr = factorization(a[0])
used = set()
for i in arr:
    if i == 1: continue
    used.add(i)

# not coprimeか判定
for i in range(n-1):
    g = gcd(g, a[i+1])
if g > 1:
    print('not coprime')
    exit(0)

# pairwise coprimeか判定
used = [0] * (10**6+1)
pair = True
for _a in a:
    if _a == 1:
        continue
    if used[_a]:
        print('setwise coprime')
        exit(0)
    else:
        used[_a] = True

for p in prime_list:
    v = p
    cnt = 0
    while v < 10**6+1:
        if used[v]:
            cnt+=1
        v += p
    if cnt > 1:
        print('setwise coprime')
        exit(0)
print('pairwise coprime')


Measured memory_bytes: 223060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500006;

void solve(){	
	int x,A;
	cin>>x>>A;
	if(x<A)cout<<0;
	else cout<<10;
}
	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}


}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


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

const int maxn=105;
int f[maxn];
int main(){
	f[1]=1;
	for(int i=2;i<maxn;i++){
		f[i]=f[i-1]+i;
	}
	int n;
	cin>>n;
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    int temp = 2 * d + 1;
    int ans = n / temp;
    if (n % temp != 0)
    {
        ans++;
    }

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

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

int main() {
	string s;
	cin >> s;
	bool f = true;
	for (auto c : s) {
		if (f && c == 'L') {
			cout << "No" << endl;
			return 0;
		}
		if (!f && c == 'R') {
			cout << "No" << endl;
			return 0;
		}

		f = !f;
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const double PI=3.14159265358979323846;
int main() {
    int n;
    cin >> n;
    vector <int> s(n);
    for(int i=0;i<n;++i) cin >> s[i];
    vector <int> a(n);
    for(int i=0;i<n;++i) a[s[i]-1]=i+1;
    for(int i=0;i<n;++i) cout << a[i] << endl;
}



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

#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)

const int N = 2e5;
int a[N+5];

signed main() {
	ios_base::sync_with_stdio(0);

	int n, k;
	cin >> n >> k;
	REP(i, 0, n-1) {
		cin >> a[i];
	}
	REP(i, k, n-1) {
		cout << (a[i] > a[i-k] ? "Yes\n" : "No\n");
	}
	return 0;
}

Measured memory_bytes: 4444
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

f = True
for i in a:
  if (i%2 == 0):
    if (i%3 == 0 or i%5 == 0):
      pass
    else:
      print('DENIED')
      f = False
      break;
if f:
  print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int h,w,cnt,k;
  string now,al,b;
  cin>>h>>w;
  getline(cin,now);
  now="";
  for (int i=0;i<h;i++)
  {
    getline(cin,now);
    al=al+"!"+now+"%";
  }
  h+=2;w+=2;
  vector<int> l;
  l={-w,-w+1,1,w+1,w,w-1,-1,-w-1};
  for (int g=0;g<w;g++){b+="!";}
  al=b+al+b;
  for (int c=0;c<h*w;c++)
  {
    if (al.at(c)=='!'){continue;}
    if (al.at(c)=='.')
    {cnt=0;
      for (int t=0;t<8;t++)
      {
        k=c+l.at(t);
        if (al.at(k)=='#')cnt+=1;
      }
      cout<<cnt;
    }
    else
    {
      if (al.at(c)=='#')cout<<'#';
      else
      {
        if (al.at(c)=='%')cout<<"\n";
      }
    }
      }
}

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

using namespace std;

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}

	int l = n-k;
	
	cout << 1 + ceil(double(l)/double(k-1)) << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int i,n,q,a,v,aaa=0,vvv=0,f[1000000],vv[9000];
    scanf("%d %d",&n,&q);
    for(i=n;i>0;i--)f[i-1]=0;
	for(i=1;i<1000;i++)vv[i]=0;
	vv[0]=n;
    for(;q>0;q--){
        scanf("%d %d",&a,&v);
		vv[f[a-1]]--;
        f[a-1]+=v;
		vv[f[a-1]]++;
        if(v>0){if(f[a-1]>vvv || (f[a-1]==vvv && a<aaa)){vvv=f[a-1];aaa=a;}}
        else{
            if(a==aaa){
				for(i=vvv;vv[i]<1;i--);
				vvv=i;
                for(i=0;f[i]!=vvv;i++);
				aaa=i+1;
            }
        }
        printf("%d %d\n",aaa,vvv);
    }
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
vector<int> ue,si,me;
int keta;

vector<string> ve;

vector<int> hal(vector<int> ue,vector<int> si){
	vector<int> e;
	for(int i=0;i<keta;i++)e.pb(ue[i]+si[i]);
	
	for(int i=keta-1;i>=1;i--){
		while(e[i]>=10){
			e[i]-=10;
			e[i-1]++;
		}
	}
	for(int i=0;i<keta;i++){
		if(e[i]%2){
			e[i]--;
			if(i!=keta-1)e[i+1]+=10;
		}
		e[i]/=2;
	}
	return e;
}

int ch(vector<int> V){
	int ans=0;
	//for(auto v:V)cout<<v<<" ";
	//cout<<endl;
	for(int i=0;i<10;i++)for(int j=i+1;j<10;j++){
		bool ok=false;
		
	//	if(j<V[0]) continue;
		//cout<<i<<" "<<j<<endl;
		
		string st="";
		ve.clear();
		for(int d=0;d<keta;d++){
			if(ok){
				st+="1";
			}
			else{
				if(V[d]>j){
					ve.pb(st);
					while(ve.back().size()<keta)ve.back()+="1";
					goto lll;
				}
				else if(V[d]==j){
					ve.pb(st+"0");
					while(ve.back().size()<keta)ve.back()+="1";
					st+="1";
				}
				else if(V[d]>i){
				ve.pb(st+"0");
					while(ve.back().size()<keta)ve.back()+="1";
					goto lll;
				}
				else if(V[d]==i){
					st+="0";
				}
				else goto lll;
			}
		}
		if(st.size()==keta)ve.pb(st);
		lll:;
		if(ve.size()==0) continue;
		sort(ve.begin(),ve.end());
		string s=ve.back();
		
		int ko=0;
		for(int i=0;i<keta;i++)if(s[i]=='1')ko+=1ll<<(keta-1-i);
		if(i!=0){
			if(ko==(1ll<<keta)-1) ko--;
		}
		if(i==0 && s[0]=='0') continue;
		if(i==0){
			if(ko==(1ll<<keta)-1) {
				ko=(1ll<<(keta-1))-1;
			//cout<<"d"<<endl;
			}
			else{
				ko=ko-(1ll<<(keta-1))+1;
			}
			
		}
	//	cout<<i<<" "<<j<<" "<<s<<" "<<ko<<endl;
	ans+=ko;
	}
return ans;
}


void solve(){

	int n;
	cin>>n;
	if(n==0) exit(0);
	for(int i=2;;i++){
		if(n<=(1ll<<(i-1))*81-81){
			keta=i;
			break;
		}
		n-=(1ll<<(i-1))*81-81;
	}
	//cout<<keta<<" "<<n<<endl;
	ue.clear();
	si.clear();
	
	si.pb(0);
	for(int i=1;i<=keta;i++)ue.pb(9),si.pb(9);
	si.pop_back();
	
	for(int i=1;i<=1000;i++){
		me=hal(ue,si);
		
		if(ch(me)>=n) ue=me;
		else si=me;
		
	}
	//ue.back()--;
	for(int i=0;i<keta;i++)cout<<ue[i];
	
	cout<<endl;
	//cout<<ch(ue)<<endl;
}

    signed main(){
    	while(1){
    		solve();
    	//	cout<<d<<endl;
    	}
    	
return 0;
    	
            }


Measured memory_bytes: 3176
#include<iostream>   //AA06( 19/ 04/ 20) If u see my code, Have a Good Day! (^_^)
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int R;

    cin >> R;

    cout << R * 2 * M_PI << endl;

    return 0;
}


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

#define M 100000
#define INFTY 10000000000

typedef struct{
  char mark;
  int s;
} Card;

Card A[M],B[M],D[M];
int C[M],n;

int partition(int p, int r){

  int x,i,j;
  Card k;

  x = A[r].s;
  i = p-1;

  for(j = p;j<r;j++){
    if(A[j].s <= x){
      i = i+1;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }
  k = A[i+1];
  A[i+1] = A[r];
  A[r] = k;

  return i+1;
}

void quicksort(int p,int r){

  int q;
  
  if(p<r){
    q = partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}

void merge(int left,int mid,int right){
  
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  Card L[n1],R[n2];
  
  for(i=0;i<n1;i++) L[i] = D[left + i];
  for(i=0;i<n2;i++) R[i] = D[mid + i];
  L[n1].s = INFTY;
  R[n2].s = INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].s <= R[j].s){
      D[k] = L[i];
      i=i+1;
    }
    else {
      D[k] = R[j];
      j = j+1;
    }
  }
}

void mergesort(int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(left, mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}

int main(){

  int i,j,k,stable = 1;
  char L;


  scanf("%d",&n);
  scanf("%c",&L);

  for(i=0;i<n;i++){
    scanf("%c",&A[i].mark);
    scanf("%d",&A[i].s);
    scanf("%c",&L);
    D[i] = A[i];
  }

  quicksort(0,n-1);

  k = D[0].s;
  for(i=1;i<n;i++){
    if(k<D[i].s) k =D[i].s;
  }

  mergesort(0,n);

  for(i=0;i<n;i++){
    if(A[i].mark != D[i].mark) stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");

  
  for(i=0;i<n;i++){
  printf("%c %d\n",A[i].mark,A[i].s);
}
  

  return 0;
}



Measured memory_bytes: 4076
#include<stdio.h>

int main(){
char s[27]={0};
scanf("%s",s);
int i,j,n=0,f=0;
while(s[n]!=0)n++;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(s[i]==s[j])f=1;
}
}
if(f==0)puts("yes");
else puts("no");
return 0;
}

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

typedef long long int lld;
lld MAX = numeric_limits<lld>::max();

/*
g++ -std=c++11 f-lcs.cpp -o k
*/
int main() {
    string s;
    string t;
    cin >> s >> t;
    int sn = s.size() + 1;
    int tn = t.size() + 1;
    // s by t
    int m[sn][tn];
    for(int i = 0; i < sn; i++)
        m[i][0] = 0;

    for(int j = 1; j < tn; j++)
        m[0][j] = 0;

    for(int i = 1; i < sn; i++) {
        for(int j = 1; j < tn; j++) {
            if(s[i-1] == t[j-1]) {
                m[i][j] = m[i-1][j-1] + 1;
            } else {
                m[i][j] = max(m[i][j-1], m[i-1][j]);
            }
        }
    }

    string o = "";
    int i = s.size();
    int j = t.size();
    while(i > 0 && j > 0) {
        if(m[i][j] == m[i][j-1]) {
            j--;
        } else if(m[i][j] == m[i-1][j]) {
            i--;
        } else {
            o = s[i-1] + o;
            i--;
            j--;
        }
    }
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

const int MAXN = 100005;

// -- Union-Find ----------------------

int par[MAXN];
int rank_[MAXN];
int size_[MAXN];

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rank_[i] = 0;
    size_[i] = 1;
  }
}

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

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rank_[x] < rank_[y]) {
    par[x] = y;
    size_[y] += size_[x];
  }
  else {
    par[y] = x;
    size_[x] += size_[y];
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int size(int x) {
  return size_[find(x)];
}

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

int main () {
  int n, m;
  cin >> n >> m;
  vi a(m), b(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  init(n);

  vll ans(m);
  ans[m-1] = (ll)n*(n-1)/2;
  for (int i = m-1; i >= 1; --i) {
    ans[i-1] = ans[i];
    if (find(a[i]) != find(b[i])) {
      ans[i-1] -= (ll)size(a[i])*size(b[i]);
      unite(a[i], b[i]);
    }
  }
  rep(i,m) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n,k;cin>>n>>k;
	vector<ll> p(n + 1);
	vector<ll> c(n + 1);
	for(int i = 1; i <= n; i++) {
		cin>>p[i];
	}
	for(int i = 1; i <= n; i++) {
		cin>>c[i];
	}
	vector<ll> sum_c(n + 1,0LL);
	vector<ll> sum_cnt(n + 1,0LL);
	for(int i = 1; i <= n; i++) {
		ll index = i;
		ll sum = 0LL;
		ll cnt = 0LL;
		while(1){
			sum += c[p[index]];
			index = p[index];
			cnt++;
			if(index == i){
				break;
			}	
		}
		sum_c[i] = sum;
		sum_cnt[i] = cnt;
		// cout << cnt << endl;
	}

	// cout << amari << endl;
	ll res = -INF;
	for(ll i = 1; i <= n; i++) {
		ll point = 0LL;
		ll index = i;
		ll m = 1LL;
		if (k / sum_cnt[i] != 0){
			res = max(res,k / sum_cnt[i] * sum_c[i]);
		}
		if (sum_c[i] > 0LL){
			while(m <= sum_cnt[i]){
				if(m > k){break;}
				point+= c[p[index]];
				index = p[index];
				if((k - m) / sum_cnt[i] != 0LL || m != 0LL){
					res = max(res,point + (k - m) / sum_cnt[i] * sum_c[i]);
					// cout << res << endl;
				}
				m++;	
			}
		}
		else{
			while(m <= min(k,sum_cnt[i])){
				point+= c[p[index]];
				index = p[index];
				res = max(res,point);
				m++;	
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

const int ALPHABET = 26;
const char A = 'a';
int main() {
	int K, cng, length;
	string s;
	cin >> s >> K;
	length = s.size();
	for (int i = 0;i < length - 1;i ++) {
		cng = (ALPHABET - s[i] + A) % ALPHABET;
		if (K >= cng) {
			K -= cng;
			s[i] = A;
		} else {
			continue;
		}
	}
	K %= ALPHABET;
	s[length - 1] = (s[length - 1] - A + K) % ALPHABET + A;
	cout << s;
	return 0;
}

Measured memory_bytes: 512
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)
# print(uf)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))
print(ans)

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

using namespace std;
int main() {
  int input;
  cin >> input;
  array<int, 4> n;
  tie(n.at(0), n.at(1), n.at(2), n.at(3)) = tuple<int, int, int ,int>(input/1000, (input/100)%10, (input/10)%10, input%10);
  // bit 0 ==> '-'
  // bit 1 ==> '+'
  for (int i = 0; i < (1 << 3); ++i) {
    int result = 0;
    result += n.at(0);
    for (int j = 1; j < 4; ++j) {
      if ((i >> (3-j))%2 == 0)
        result -= n.at(j);
      else
        result += n.at(j);
    }
    if (result == 7) {
      cout << n.at(0) << ((i>>2)%2 ? '+' : '-')
           << n.at(1) << ((i>>1)%2 ? '+' : '-')
           << n.at(2) << (i%2      ? '+' : '-')
           << n.at(3) << "=7" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def min(a,b)
  return a>b ? b : a
end
n,w=get_i
vw=array(n,1)
MAX_V=100*n
n.times do|i|
  vw[i]=get_i
end
INF=Float::INFINITY
vw.sort!{|x,y| x[0]<=>y[0]}
dp=array(MAX_V+1,n+1,INF)
dp[0][0]=0
n.times do|i|
  for j in 0..MAX_V
    dp[i+1][j]=dp[i][j]
    dp[i+1][j]=min(dp[i+1][j],dp[i][j-vw[i][0]]+vw[i][1]) if j-vw[i][0]>=0 and j-vw[i][0]>=0
  end
end
max=0
MAX_V.times do|i|
  if dp[n][i+1]<=w
    max=i+1
  end 
end
puts max


Measured memory_bytes: 14776
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int main()
{ int n;cin>>n;int r=0,b=0,g=0;int r1[n],b1[n],g1[n];
  string h;
  cin>>h;
 for(int i=n-1;i>=0;i--)
  {
      r1[i]=r;
      b1[i]=b;
      g1[i]=g;
      if(h[i]=='R') r++;
      else if(h[i]=='G')g++;
      else b++;
      
      
  }
  ll sum=0;
  FOR(i,n)
  {
      For(j,i,n)
      {
          if(h[i]=='R')
          {
              if(h[j]=='B')
              {
                  sum+=g1[j];
                  if(h[j+(j-i)]=='G') sum+=(-1);
              }
              
              if(h[j]=='G')
              {
                   sum+=b1[j];
                  if(h[j+(j-i)]=='B') sum+=(-1);
              }
          }
          
          if(h[i]=='B')
          {
              if(h[j]=='R')
              {
                  sum+=g1[j];
                  if(h[j+(j-i)]=='G') sum+=(-1);
              }
              
              if(h[j]=='G')
              {
                   sum+=r1[j];
                  if(h[j+(j-i)]=='R') sum+=(-1);
              }
          }
          
          if(h[i]=='G')
          {
              if(h[j]=='B')
              {
                  sum+=r1[j];
                  if(h[j+(j-i)]=='R') sum+=(-1);
              }
              
              if(h[j]=='R')
              {
                   sum+=b1[j];
                  if(h[j+(j-i)]=='B') sum+=(-1);
              }
          }
          
      }
  }

cout<<sum;




return 0;
}











Measured memory_bytes: 3616
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val h = (0 until n).map { sc.next().toInt() }
    println(edpcA(n, h))
}

fun edpcA(n: Int, h: List<Int>): Int {
    val dp = (0 until n).map { Integer.MAX_VALUE }.toMutableList()
    dp[0] = 0
    for (i in 1 until n) {
        dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]))
        if (i != 1) {
            dp[i] = Math.min(dp[i], dp[i - 2] +  Math.abs(h[i] - h[i - 2]))
        }
    }
    return dp[n - 1]
}

Measured memory_bytes: 46860
#include <iostream>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  for(int i = 0; i < 3; i++) {
    if(n[i] == ('1')) n[i] = '9';
    else if(n[i] == ('9')) n[i] = '1';
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    string A[55];
    string B[55];
    for (int i = 0; i < N; i++){
	cin >> A[i];
    }
    for (int i = 0; i < M; i++){
	cin >> B[i];
    }

    bool can = false;
    for (int i = 0; i <= N-M; i++){
	for (int j = 0; j <= N-M; j++){

	    bool can2 = true;
	    for (int k = 0; k < M; k++){
		for (int l = 0; l < M; l++){
		    if (A[i+k][j+l] != B[k][l]){
			can2 = false;
		    }
		}
	    }
	    if (can2) can = true;
	}
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())

sx = [0, w]
sy = [0, h]

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        sx[0] = max(sx[0], x)
    if a == 2:
        sx[1] = min(sx[1], x)
    if a == 3:
        sy[0] = max(sy[0], y)
    if a == 4:
        sy[1] = min(sy[1], y)

print(max(0, max(0, (sx[1] - sx[0])) * max(0, (sy[1] - sy[0]))))


Measured memory_bytes: 9008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int sum = 0;
		int min = 0;
		for (int i = 0; i < N; i++) {
			int input = sc.nextInt();
			sum += input;
			if (i == 0)
				min = input;
			if (min > input)
				min = input;
		}
		int remaining = X - sum;
		System.out.println(remaining / min + N);
		sc.close();
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    ll n, sum=0;
    
    cin>>n;
    
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    
    rep(i, n) cin>>a[i];
    rep(i, n) cin>>b[i];
    rep(i, n-1) cin>>c[i];
    
    sum+= b[a[0]-1];
    Rep(i,1,n){
        sum+= b[a[i]-1];
        
        if(a[i] == a[i-1]+1){
            sum += c[a[i-1]-1];
        }
    }
    
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
# from collections import Counter,defaultdict,deque
import sys
# import bisect
# import math
# import itertools
# import string
# import queue
# import copy
# import numpy as np
# import scipy
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
# mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
    
def main():
    n,m=inpm()
    s=list(input())
    s.reverse()
    s=tuple(s)
    ans = []
    now = 0
    while True:
        key = 0
        for go in range(m,0,-1):
            if now+go>=n:
                x=n-now
                ans.append(str(x))
                ans.reverse()
                print(' '.join(ans))
                return
            elif s[now + go]=='0':
                key = 1
                now+=go
                ans.append(str(go))
                break
        if key == 0:
            print(-1)
            return

if __name__ == "__main__":
    main()

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

int main() {
  ll h,cnt=0,ans=0;
  cin>>h;
  while(h>0){
    h/=2;
    cnt++;
  }
  rep(i,cnt){
    ans+=pow(2,i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int N, M;
int a[1050], b[1050], c[1050][20];

void input(){
    cin >> N >> M;
    for(int i = 1; i <= M; i++){
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++){
            cin >> c[i][j];
        }
    }
}

void solve(){
    input();
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++){
        int now = 0;
        for(int j = 1; j <= b[item]; j++){
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++){
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF){
        dp[(1 << N) - 1] = -1;
    }
    cout << dp[(1 << N) - 1] << endl;
    return;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int E,Y,c;
	scanf("%d %d",&E,&Y);
	if(E==0){
		if(Y>=1868 && Y<=1911){
			c=Y-1868;
			printf("M%d\n",c+1);
		}
		else if(Y>=1912 && Y<1926){
			c=Y-1912;
			printf("T%d\n",c+1);
		}
		else if(Y>=1926 && Y<1989){
			c=Y-1926;
			printf("S%d\n",c+1);
		}
		else if (Y>=1989 && Y<=2016){
			c=Y-1989;
			printf("H%d\n",c+1);
		}
	}
	else if(E==1)printf("%d\n",1868+Y-1);
	else if(E==2)printf("%d\n",1912+Y-1);
	else if(E==3)printf("%d\n",1926+Y-1);
	else if(E==4)printf("%d\n",1989+Y-1);
	return 0;
}


Measured memory_bytes: 2068