akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 2010;
const int MOD = 1000000007;

int n, k;
int f[MAXN][MAXN];
int fac[MAXN * MAXN], inv[MAXN * MAXN];

int power(int x, int y)
{
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1ll * ret * x % MOD;
		x = 1ll * x * x % MOD;
		y >>= 1;
	}
	return ret;
}

int C(int x, int y)
{
	assert(x >= y);
	return 1ll * fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

int main()
{
	in(n); in(k);

	if (k == 1) {
		printf("1\n"); return 0;
	}
	
	f[0][0] = 1;

	fac[0] = 1;
	FOR(i, 1, n * k) fac[i] = 1ll * fac[i - 1] * i % MOD;

	inv[n * k] = power(fac[n * k], MOD - 2);
	DNF(i, n * k - 1, 0) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;

	FOR(i, 0, n) FOR(j, i, n) {
		if (!i && !j) continue;
		if (n - i < n - j) continue;
		int emp = n * k - (n - i) - (k - 1) * (n - j);
		f[i][j] = 0;
		if (i) f[i][j] = f[i - 1][j];
		if (n - i < n - j + 1) continue;
		if (j) f[i][j] = (f[i][j] + 1ll * f[i][j - 1] * C(emp - 1, k - 2) % MOD * j) % MOD;
	}

	printf("%d\n", f[n][n]);
	
	return 0;
}


Measured memory_bytes: 47488
/*
    Author: Anthony Ngene
    Created: 26/09/2020 - 13:32
*/

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        StringBuilder rs = new StringBuilder();
        for (int i = 0; i < n; i++) rs.append("ACL");
        System.out.println(rs);
    }
}


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

int main(){

    int N;
    cin >> N;
    // cout << N << endl;

    vector<long> A(N+1), B(N);
    for(int i = 0; i < N+1; i++){
       cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    
    long ans = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < B[i]){
            ans += A[i];
            B[i] -= A[i];
            if(A[i+1] > B[i]){
                A[i+1] -= B[i];
                ans+= B[i];
            }else{ // A[i+1]<B[i]
                ans+= A[i+1];
                A[i+1] = 0;
            }
        }else{
            ans += B[i];
            B[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int maxn=1e5+7;
int n,t,a;
int dist[maxn],disa[maxn],ans;
vector<int> to[maxn];

void dfs(int x,int f,int* dis)
{
	dis[x]=dis[f]+1;
	for(int i=0;i<to[x].size();++i) {
		int t=to[x][i];
		if(t==f) continue;
		dfs(t,x,dis);
	}
}

int main()
{
	scanf("%d %d %d",&n,&t,&a);
	for(int i=1;i<n;++i) {
		int u,v;
		scanf("%d %d",&u,&v);
		to[u].push_back(v);
		to[v].push_back(u);
	}
	dfs(t,0,dist);
	dfs(a,0,disa);
	for(int i=1;i<=n;++i) {
		if(dist[i]<disa[i]) {
			ans=max(ans,disa[i]-1);
		}
	}
	printf("%d",ans-1);
}

Measured memory_bytes: 11648
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const menu = stdin.split('\n').map(Number)

const lastEl = getBiggest(menu)

const index = menu.indexOf(lastEl)

menu.splice(index, 1)

const res = menu.map(el => {
  if (el % 10 === 0) return el
  return el + 10 - (el % 10)
})
.reduce((acc, curr) => {
  return acc + curr
})

console.log(res+lastEl)

function getBiggest(nums) {
  let el = 0
  const biggest = nums.reduce((acc, c) => {
    const remain = 10 - (c % 10)
    if (remain === 10) return acc
    if (remain > acc) {
      el = c
      return remain
    }
    return acc
  }, 0)
  return el
}

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

typedef long long ll;
const int N = 100005;
const int M = 1000000007;

int n;
pair<int, int> a[N];

int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i].first); a[i].second = i;
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = 1; i < n; i++) {
      ans += abs(i - a[i].second) % 2;
    }
    printf("%d\n", ans / 2 + ans % 2);
  }
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,i;
    long long int sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3==0 && i%5==0)
        {
        }
        else if(i%3==0)
        {
        }
        else if(i%5==0)
        {
        }
        else{
            sum+=i;
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double s;
  cin >> s;
  double w, l, h;
  l = s/3;
  s -= l;
  w = s/2;
  h = s-w;
  cout << fixed << setprecision(10);
  cout << l * w * h << '\n';
  return 0;
}



Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-24 12:05:01
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 3e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 924844033; // 998244353; // 1e9 + 9;

ll n , k , dp[MAXN][MAXN] , dp2[MAXN] , fact[MAXN];
vector<int> vec;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	fact[0] = 1;
	for(int i = 1 ; i < MAXN ; i++)	fact[i] = fact[i - 1] * i % MOD;
	for(int i = 0 ; i < MAXN ; i++){
		dp[i][0] = 1;
		dp[i][1] = i;
		for(int j = 2 ; j <= i ; j++){
			dp[i][j] = dp[i - 1][j] + dp[i - 2][j - 1];
			if(dp[i][j] >= MOD)	dp[i][j] -= MOD;
		}
	}
	cin >> n >> k;
	for(int i = 0 ; i < k ; i++){
		vec.push_back((n - i - 1) / k);
		vec.push_back((n - i - 1) / k);
	}
	dp2[0] = 1;
	for(int i : vec){
		for(int j = n ; j >= 0 ; j--){
			for(int k = 1 ; k <= i && k <= j ; k++){
				dp2[j] = (dp2[j] + dp2[j - k] * dp[i][k]) % MOD;
			}
	//		cout << j << sep << dp2[j] << endl;
		}
//		cout << "============" << endl;
	}
	ll ans = 0;
	for(int i = 0 ; i <= n ; i++){
		if(i % 2 == 0)	ans += dp2[i] * fact[n - i] % MOD;
		if(i % 2 == 1)	ans -= dp2[i] * fact[n - i] % MOD;
	}
	cout << (ans % MOD + MOD) % MOD;
	

    return 0;
}
/*

*/


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

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            var word = Console.ReadLine();
            a = int.Parse(word);
            if (((a > 2 && a < 4 )|| (a > 4 && a < 6) ||( a > 6 && a < 8)))
                Console.WriteLine("YES");
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadKey();

        }
    }
}



Measured memory_bytes: 13140
import numpy as np

n, m = map(int, input().split())
xl = [int(i) for i in input().split()]
xl.sort()
d = m - n
if d <= 0:
    print(0)
else:
    darray = np.sort(np.array(xl[1:]) - np.array(xl[:-1]))
    print(np.sum(darray[:d]))

Measured memory_bytes: 22312
#include<bits/stdc++.h>
using namespace std;
int n,a[100003],k,ans;
int main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		if(a[i]>=k)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
n=int(input())
P=list(map(int,input().split()))

nc=0
for i in range(1,n-1):
    p1=P[i-1]
    p2=P[i]
    p3=P[i+1]
    if p1>p2>=p3 or p1<=p2<p3:
        nc+=1
print(nc)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>

int head,tail;

struct prosess{
  char name[100];
  int time;
};

struct prosess Queue[100000];

void enqueue(struct prosess x){
  Queue[tail]=x;
  tail=(tail+1)%100000;
}

struct prosess dequeue(){
  struct prosess x=Queue[head];
  head=(head+1)%100000;
  return x;
}

int min(int a,int b){
  return a<b ? a:b;
}

int main(){
  int elaps=0,c;
  int n,q,i;
  struct prosess u;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s",Queue[i].name);
    scanf("%d",&Queue[i].time);
  }
  head=0;
  tail=n;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.time);
    u.time-=c;
    elaps+=c;
    if(u.time>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}
  
    



Measured memory_bytes: 11868
let z = 1000000007

let rec pow (x, n) =
  if n = 0 then 1
  else if n mod 2 = 0 then pow (x * x mod z, n / 2)
  else pow (x * x mod z, n / 2) * x mod z

let () =
  Scanf.scanf "%d %d\n" (fun m n -> (m, n))
  |> pow |> Printf.printf "%d\n"

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define INF 100000000

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}
		vector< vector<int> > cc(n, vector<int>(n, INF));
		vector< vector<int> > d(n, vector<int>(n, INF));
		int a, b, c;
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> c;
			cc[a-1][b-1] = cc[b-1][a-1] = d[a-1][b-1] = d[b-1][a-1] = c;
		}
		//cout << 'a' << endl;
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					cc[i][j] = min(cc[i][j], cc[i][k]+cc[k][j]);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			cc[i][i] = 0;
		}

		//cout << 'b' << endl;
		int MIN = cc[0][n-1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (d[i][j] != INF && d[j][k] != INF) {
						MIN = min(MIN, cc[0][i]+cc[k][n-1]);
					}
				}
			}
		}
		cout << MIN << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
N = int(input())
A = [[set() for _ in range(2)] for _ in range(N)]
for i in range(N):
    Ai = int(input())
    for _ in range(Ai):
        x, y = map(int, input().split())
        A[i][y].add(x - 1)

ans = 0
for bit in range(1 << N):
    truth = set()
    false = set()
    ppl_truth = set()
    ppl_false = set()
    for i in range(N):
        if (bit >> i) & 1:
            ppl_truth.add(i)
            truth |= A[i][1]
            false |= A[i][0]
        else:
            ppl_false.add(i)
    if ppl_truth >= truth and ppl_false >= false:
        ans = max(ans, len(ppl_truth))

print(ans)


Measured memory_bytes: 3064
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[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (l[i] < l[j] && l[j] < l[k]
							&& l[i] + l[j] > l[k]) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35940
n = int(input())
h = list(map(int, input().split()))
dp = [0]*(n+1)
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = dp[i-1] + abs(h[i]-h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                    dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 84960
#include <iostream>
#include <string>
#define D 6
using namespace std;

class dice {
    int m[D];
public:
    dice(int n[]) {
        for (int i = 0; i < D; i++)
            m[i] = n[i];
    }
    
    void roll(int a, int b, int c, int d) {
        int t = m[d];
        m[d] = m[c];
        m[c] = m[b];
        m[b] = m[a];
        m[a] = t;
    }
    
    void rollX() { roll(0, 2, 5, 3); }
    void rollY() { roll(0, 1, 5, 4); }
    void rollZ() { roll(1, 2, 4, 3); }
    int friend getR(dice d, int t, int f);
};

int getR(dice d, int t, int f) {
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 4; j++) {
            if (d.m[0] == t && d.m[1] == f)
                return d.m[2];
            d.rollZ();
        }
        if (i % 2 == 0)
            d.rollY();
        else
            d.rollX();
    }
    return -1;
}

int main()
{
    int num[D], q;
    for (int i = 0; i < D; i++)
        cin >> num[i];
    dice ob(num);
    
    cin >> q;
    while (q) {
        int  t, f;
        cin >> t >> f;
        cout << getR(ob, t, f) << endl;
        q--;
    }
}



Measured memory_bytes: 3076
const a1:array[0..32] of char=('0','1','2','3','4','5','6','7','8','9',
                               'A','B','C','D','E','F','G','H','I','J',
                               'K','L','M','N','O','P','Q','R','S','T',
                               'U','V','W');
var n,r,i,j,y,s,s1:longint;
var a:ansistring;
begin
  begin
    read(n); r:=-2;
    //if(n<0)then begin r:=-2;n:=-n;end;
    a:=''; s1:=n;s:=1;
    while s<>0 do
    begin
      s:=n div r;
      y:=n mod r;
      if y<0 then begin if s<0 then dec(s) else inc(s);y:=abs(s*r-n);end;
      n:=s;
      //writeln(y,' ',s);
      a:=a1[y]+a;
    end;
    writeln(a);
//    writeln(s1,'=',a,'(base',r,')');
  end;
end.

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define lint long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int col;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;col=0;
  }
};
signed main(){
  int n;cin>>n;
  vector<vector<int>> g(n+1,vector<int>(n+1,inf));
  vector<Node> node(n+1);
  rep(i,n+1){
    node[i].build(i);
  }
  rep1(i,n){
    string buf;
    cin>>buf;
    rep1(j,n){
      g[i][j]=buf[j-1]-'0';
      if(g[i][j]==0)g[i][j]=inf;
      if(g[i][j]==1){
        node[i].child.push_back(&node[j]);
        node[j].child.push_back(&node[i]);
      }
    }
  }
  queue<Node> que;
  node[1].col=1;
  que.push(node[1]);
  bool flag=true;
  while(!que.empty()){
    Node buf=que.front();que.pop();
    int num=buf.child.size();
    //cout<<buf.no<<endl;
    rep(i,num){
      if(buf.child[i]->col==0){
        buf.child[i]->col=buf.col*2%3;
        que.push(*buf.child[i]);
      }
      else{
        if(buf.child[i]->col==buf.col){
          flag=false;
        }
      }
    }
  }
  if(!flag){
    cout<<-1<<"\n";
    return 0;
  }
  int res=0;
  rep1(i,n){
    g[i][i]=0;
  }
  rep1(k,n){
    rep1(i,n){
      rep1(j,n){
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  rep1(i,n){
    rep1(j,n){
      res=max(res,g[i][j]);
    }
  }
  cout<<res+1<<"\n";
  return 0;
}

Measured memory_bytes: 2048
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=2e5+10;

int tree[4*N];

void update(int node,int beg,int en,int idx,int val)
{
    if(beg==en)
    {
        //base[idx]=val;
        tree[node]=val;
        return;
    }

    int mid=(beg+en)/2;
    if(beg<=idx and idx<=mid)
        update(2*node,beg,mid,idx,val);
    else
        update(2*node+1,mid+1,en,idx,val);

    tree[node]=max(tree[2*node],tree[2*node+1]);
}

int query(int node,int beg,int en,int l,int r)
{
    if(r<beg || en<l)
        return 0;

    if(l<=beg && en<=r)
        return tree[node];

    int mid=(beg+en)/2;
    int q1=query(2*node,beg,mid,l,r);
    int q2=query(2*node+1,mid+1,en,l,r);

    return max(q1,q2);
}

void solve()
{
    int n;
    cin>>n;

    vector<int> h(n),a(n);

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

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

    int tmp;
    for(int i=0;i<n;++i)
    {
        tmp=query(1,1,n,1,h[i]-1);
        update(1,1,n,h[i],a[i]+tmp);
    }

    int ans=query(1,1,n,1,n);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,n) for(int i=0 ; i < (int) (n) ; ++i )

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

    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;

    int ans=1000;
    rep(i,n)
    {
        // 最初はどこになるか
        bool flag = true;
        for (int j=0;j<n-i;j++)
        {
            if (s[i+j]!=t[j]) flag = false;
        }
        if (flag)
        {
            ans = min(ans, n + i);
        }
    }
    cout << min(ans, 2 * n) << endl;
}




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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

int n,m,x,y;
vii gragh;
/*FUNCs=================================================*/
vi dp;
// Node"u"から有向辺を辿れるNode辿っていき、道中 DPtable にメモしていく感じ
// ↑の動きを繰り返すことでいけるとこ全部のNodeの中で一番遠い場所までの距離がわかる
// "辿ったところはメモしていた値を使う"という"メモ化"の部分は一番最初のところ
int rec(int u) {
    if(dp[u] != -1) return dp[u];
    int res = 0;
    for(auto v : gragh[u]) {
        chmax(res, rec(v) + 1);
    }
    dp[u] = res;  // メモ
    return res;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    cin >> n >> m;
    gragh.resize(n);
    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        --x;--y;
        gragh[x].emplace_back(y);
    }

    dp.resize(n, -1);
    int res = 0;
    for(int u = 0; u < n; ++u) {
        chmax(res, rec(u));
    }

    cout << res << '\n';
}

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

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

    sort(a.rbegin(), a.rend());
    int score = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)
            score += a[i];
        else
            score -= a[i];
    }

    cout << score << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

ll a, b;
ll ans = -1;

int main() {

	cin >> a >> b;
	REP(i,1,2000) {
		if ((int)(i * 0.08) == a && (int)(i * 0.10) == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl ;
typedef long long ll ;


int main(){
    ll a , b , n ;
    cin >> a >> b >> n  ;
    if(n >= b ) cout << a*(b-1)/b << endl;
    else cout << a*n/b << endl;
}

Measured memory_bytes: 3592
def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    Q = int(input())
    ans = [i for i in range(N)]
    for _ in range(Q):
        b, e = [int(i) for i in input().split()]
        tmp = list(reversed(ans[b:e]))
        for i in range(b, e):
            ans[i] = tmp[i - b]
    prt = [0] * N
    for i in range(N):
        prt[i] = A[ans[i]]
    print(*prt)

resolve()



Measured memory_bytes: 5852
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
// const ll N = ;
// #define singleCase
#define multipleCase
const ll inf = 1e18;
ll n,a,b,c,d,price[4];
ll t[] = {2 , 3 , 5};
map <ll , ll> dp;

ll updiv(ll a , ll b) {
   ll q = a / b;
   return q * b < a ? q + 1 : q;
}

ll up(ll x , ll k) {
   ll q = updiv(x , k);
   return q * k;
}

ll down(ll x , ll k) {
   ll q = x / k;
   return q * k;
}

ll f(ll cur) {
   if (cur == 0) return 0;
   if (cur == 1) return price[3];
   if (cur > n) return inf;
   if (dp.count(cur)) return dp[cur];
   dp[cur] = (cur > inf / price[3]) ? inf : cur * price[3];
   for (ll i = 0 ; i < 3 ; i++) {
      ll tryUp = up(cur , t[i]);
      ll tryDown = down(cur , t[i]);
      dp[cur] = min(
         dp[cur],
         min(
            f(tryUp / t[i]) + abs(tryUp - cur) * price[3] + price[i],
            f(tryDown / t[i]) + abs(cur - tryDown) * price[3] + price[i]
         )
      );
   }
   return dp[cur];
}

void work() {
   in(n);
   for (ll i = 0 ; i < 4 ; i++) {
      in(price[i]);
   }
   dp.clear();
   printf("%lld\n" , f(n));
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 4304
import math
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(A, B):
    V = A % 100
    U = A // 100
    return U * B + V * B // 100
    

S = input().split()
A = int(S[0])
B = int(S[1].replace('.', ''))
print(calc(A, B))

Measured memory_bytes: 62016
n,l,t=map(int,input().split())
x=[]
w=[]
ans=[]
crash=0
for i in range(n):
    xx,ww=map(int,input().split())
    x.append(xx); w.append(ww)
    if w[i]==1: anss=(x[i]+t)%l
    else: anss=(x[i]-t+l)%l
    ans.append(anss)
    if i!=0 and w[i] != w[0]:
        if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1
        else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1

if w[0]==1: num0 =int(crash)%n
else: num0 =int(-crash)%n
nowplace = ans[0]
ans.sort()
num = ans.index(nowplace)
if w[0]==1 and ans.count(nowplace)==2: num += 1
gap = num-num0
for i in range(n):
    i = (i+gap)%n
    print(ans[i])

Measured memory_bytes: 12912
use input::*;
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;
    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn string() -> String {
        read()
    }
    pub fn int() -> i64 {
        read()
    }
    pub fn char() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn vecchar() -> Vec<char> {
        string().chars().collect()
    }
    pub fn vecint(n: i64) -> Vec<i64> {
        let mut vec = Vec::new();
        for i in 0..n {
            vec.push(int())
        }
        vec
    }
}
fn main() {
    let n = int() as usize;
    let mut a = vecint((n * 3) as i64);
    a.sort();
    a.reverse();
    let mut ans = 0;
    for i in 0..n {
        ans += a[2 * i + 1]
    }
    println!("{}", ans)
}


Measured memory_bytes: 10308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
ll d[1000001]={1,0,1},f[1000001]={1},g[1000001]={1,1};
const ll p=998244353 ;
ll mul(ll a,ll b)
{
    ll res=0,mod=p;
    while(b>0)
    {
        if(b&1) res=(res+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return res;
}
LL comb(LL a,LL b){
	if(a==b)return 1;
	if(b<a)return 0;
	return mul(mul(f[b],g[a]),g[b-a]); 
} 
LL lucas(LL a,LL b){
	return b==0?1:lucas(a/p,b/p)*comb(a%p,b%p)%p;
}

main(){
	ll n,A,B,k,ans=0,sum=0;
	for(int i=1;i<=1000001;i++)
		f[i]=f[i-1]*i%p;
	for(int i=2;i<=1000001;i++)
		g[i]=(p-p/i)*g[p%i]%p;	
	for(int i=2;i<=1000001;i++)
		g[i]=g[i]*g[i-1]%p; 
	scanf("%lld%lld%lld%lld",&n,&A,&B,&k);
	for(int i=0;i<=n&&i*B<=k;i++){
		if((k-i*B)%A==0){
			sum+=mul(lucas((k-i*B)/A,n),lucas(i,n));
			sum%=p;
		}
	}
	printf("%lld\n",sum);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

int main(){
  int h, w, m; cin >> h >> w >> m;
  vector<int> H(h);
  rep(i, h)H[i] = 0;
  vector<int> W(w);
  rep(i, w)W[i] = 0;
  set <P> grid;
  rep(i, m){
    int a, b; cin >> a >> b;
    a--;
    b--;
    H[a]++;
    W[b]++;
    grid.emplace(a, b);
  }
  
  int h_max = *max_element(H.begin(), H.end());
  int w_max = *max_element(W.begin(), W.end());
  vector<int> h_sec;
  vector<int> w_sec;
  rep(i, h){
    if (H[i] == h_max){
      h_sec.push_back(i);
    }
  }
  rep(i, w){
    if (W[i] == w_max){
      w_sec.push_back(i);
    }
  }
  int ans = h_max + w_max;
  int sub = 1;
  for (int i:h_sec){
    for (int j:w_sec){
      if (!grid.count(P(i, j))){
        sub = 0;
        break;
      }
    }
    if (sub == 0)break;
  }
  cout << ans-sub <<endl;
} 

Measured memory_bytes: 23792
#include<stdio.h>
int d,n;
int main(void){
    scanf("%d%d",&d,&n);
    if(d == 0){
        if(n == 100){
            printf("101");
        }else{
        printf("%d",n);
        
    }}else if(d == 1){
         if(n == 100){
            printf("10100");
        }else{
        printf("%d",n*100);
    }}else if(d == 2){
         if(n == 100){
            printf("1010000");
        }else{
        printf("%d",n*10000);
        }
    }

    return 0;
}

Measured memory_bytes: 128
import heapq

n,m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n) :
  a[i] *= -1

heapq.heapify(a)
for i in range(m) :
  at = -1*(-1*heapq.heappop(a)//2)
  heapq.heappush(a, at)

print(sum(a)*-1)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int Y=0;
  string S;
  cin >> N >> S;
  for (int X=0; X<N; X++){
    if (X+2<N){
      if ( S.at(X)=='A' && S.at(X+1)=='B' && S.at(X+2)=='C'){
        Y++;
      }
    }
  }
  cout << Y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n;
	long int luca[86]={1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843};
	scanf("%d", &n);
	printf("%ld", luca[n-1]);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
l=[np.array(input().split(), dtype=np.int64) for _ in [0]*n]
l+=np.diag([10**10]*n)

v=0
for i in range(n-1):
  for j,d1 in enumerate(l[i][i+1:]):
    d2=np.min(l[i]+l[j+i+1])
    if d1>=d2:
      if d1>d2:
        print(-1)
        exit()
    else:
      v+=d1
print(v)

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

bool isPalindromic(int num) {
    int first = num % 10;
    int fifth = num / 10000;

    int second = (num / 10) % 10;
    int forth = (num % 10000) / 1000;

    if (first != fifth)
        return false;
    
    if (second != forth)
        return false;

    return true;
}

int main() {
    int A, B;

    cin >> A >> B;

    int cnt = 0;

    for (int i = A; i <=B; i++)
    {
        if (isPalindromic(i))
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>

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

    while(true){
        int a, b;
        char op;
        std::cin >> a >> op >> b;
        int ans;
        switch(op){
            case '+': ans = a+b; break;
            case '-': ans = a-b; break;
            case '*': ans = a*b; break;
            case '/': ans = a/b; break;
            default : return 0;
        }
        std::cout << ans << "\n";
    }
}

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

int main() {
    int n;
    cin >> n;
    string x;
    cin >> x;
    int p = 0;
    rep(i, n)if(x[i] == '1')p++;
    vector<vector<int>> cnt(n, vector<int>(2, 0));
    int p1 = 1; int p2 = 1;
    for(int i = n-1; i >= 0; i--){
        cnt[i][0] = p1;
        cnt[i][1] = p2;
        (p1 *= 2) %= (p+1);
        if(p > 1)(p2 *= 2) %= (p-1);
    }
    int sum1 = 0;
    int sum2 = 0;
    rep(i, n){
        if(x[i] == '1'){
            (sum1 += cnt[i][0]) %= (p+1);
            if(p>1)(sum2 += cnt[i][1]) %= (p-1);
        }
    }
    
    rep(i, n){
        if(x[i] == '1'){
            if(p == 1){
                cout << 0 << endl;
            }else{
                int sum = (sum2 - cnt[i][1] + (p-1)) % (p-1);
                int ans = 1;
                while(sum > 0){
                    int c = __builtin_popcount(sum);
                    sum %= c;
                    ans++;
                }
                cout << ans << endl;
            }
        }else{
            int sum = (sum1 + cnt[i][0]) % (p+1);
            int ans = 1;
            while(sum > 0){
                int c = __builtin_popcount(sum);
                sum %= c;
                ans++;
            }
            cout << ans << endl;
        }
    }
    
}

Measured memory_bytes: 14480
n, m = list(map(int, input().split()))
H = list(map(int, input().split()))
d = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    a, b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)
cnt = 0
for i in range(1, n + 1):
    cmps = d[i]
    is_good = True
    for cmp in cmps:
        if H[i - 1] <= H[cmp - 1]:
            is_good = False
            break
    if is_good:
        cnt += 1
print(cnt)


Measured memory_bytes: 37704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << "AB";
  if (n < 1000)
    cout << 'C' << endl;
  else
    cout << 'D' << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

const inf = 1 << 60

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
	}
	sort.Ints(hs)

	minDiff := inf
	for i := 0; i < n-k+1; i++ {
		tmp := hs[i+k-1] - hs[i]
		if tmp < minDiff {
			minDiff = tmp
		}
	}
	fmt.Println(minDiff)
}


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

int main(){
	int n;
	cin >> n;
	int x=n%10;
	if(x==2 or x==4 or x==5 or x==7 or x==9){
		cout << "hon" << endl;
	}
	else if(x==3){
		cout << "bon" << endl;
	}
	else{
		cout << "pon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let l: usize = read(&mut stdin_lock, &mut buf, b' ');
    let r: usize = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 2019;
    for i in 0..2019 {
        for j in i + 1..2019 {
            let x = ((l + i) * (l + j)) % 2019;
            if x < ans && l + j <= r {
                ans = x;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int H, W;
    cin >> H >> W;
    vector<string>HWs(H);
    for (int i=0; i<H; i++){
        cin >> HWs[i];
    }

    vector<bool>rows(H);
    vector<bool>columns(W);

    string dots;
    for(int i=0;i<W; i++) dots += '.';
    

    for (int i=0; i<H; i++){
        if (HWs[i] == dots)rows[i] = false;
        else rows[i] = true;
    }

    dots = "";
    for(int i=0; i<H; i++) dots += '.';

    for (int i=0; i<W; i++){
        string row;
        for (int j=0; j<H; j++) row += HWs[j][i];

        if (row == dots)columns[i] = false;
        else columns[i] = true;
    }

    for (int i=0; i<H; i++){
        bool w = false;
        for (int j=0; j<W; j++){
            if (rows[i] && columns[j]){ cout << HWs[i][j]; w=true;}
        }
        if (w)cout << endl;
    }
}

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

using namespace std;
constexpr int NMAX = 1000010;

bool canAppear[NMAX];

int main() {
	int n; scanf("%d", &n);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
	for (int i = 1; i < NMAX; ++i) canAppear[i] = true;
	map<int, int> ocMap;
	for (int x : arr) ++ocMap[x];
	int ans = 0;
	for (auto v_ct : ocMap) {
//		printf("%d %d\n", v_ct.first, v_ct.second);
		if (canAppear[v_ct.first] && v_ct.second == 1) ++ans;
		for (int j = v_ct.first; j < NMAX; j += v_ct.first) {
			canAppear[j] = false;
//			if (j < 30) printf("%d bans %d\n", v_ct.first, j);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 14364
#include <iostream>
#include <vector>

using namespace std;

vector<long long int> ans;

long long int N, M, A[100005], B[100005]; 

int p[100005];

long long int num[100005];

int PARENT(int K) {
	if (p[K] == K) { return K; }

	int J = K;
	while (p[J] != J) {
		J = p[J];
	}
	p[K] = J;

	return J;
}

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
	}

	ans.push_back(N*(N - 1) / 2);

	for (int i = 1; i <= N; i++) {
		p[i] = i;
	}
	for (int i = 1; i <= N; i++) {
		num[i] = 1;
	}


	for (int i = (int)M; i >= 1; i--) {
		int I = PARENT(A[i]);
		int J = PARENT(B[i]);

		long long int last_ans = ans[M - i];
		

		//cout << "p[" << I << "]= " << p[I] << "  p[" << J << "]= " << p[J] << endl;

		if (I!= J) {
			//cout << "I= " << I << "   J= " << J << endl;
			ans.push_back(last_ans - num[I] * num[J]);
			p[I] = J;
			num[J] += num[I];
		}
		else {
			ans.push_back(last_ans);
		}
	}

	for (int i = 1; i <= (int )M; i++) {
		cout << ans[M - i] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


ll gcd(ll x, ll y) {
  return y ? gcd(y, x%y) : x;
}

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;  // (n の素因数 i , 素因数 i の個数)
  for (ll i = 2; i*i <= n; ++i) {
    if (n % i) continue;  // i で割り切れないときは無視
    res.emplace_back(i, 0);  // i について初期化
    while (n%i == 0) {  // i が何個含まれているかカウント
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

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

  ll C = gcd(A, B);
  auto f = factorize(C);
  int ans = f.size() + 1;  // 素因数の種類に 1 を加えた種類数が答え
  print(ans);

  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] split = str.split(" ",0);
			int[] number = new int[3];
			number[0] = Integer.parseInt(split[0]);
			number[1] = Integer.parseInt(split[1]);
			number[2] = Integer.parseInt(split[2]);

			Arrays.sort(number);
		
			System.out.println(number[0] + " " + number[1] + " " + number[2]);
		} catch (Exception e) {
			System.out.println("??¨??????");
		}
	}
}

Measured memory_bytes: 24396
#include <iostream>

using namespace std;

int N;

bool solve()
{
    const int a = 4, b = 7;

    for(int i = 0, rest; (rest = N - b * i) >= 0; i++){
        if(rest % a == 0) return true;
    }
    return false;

}

int main()
{
    cin >> N;
    string ans = solve() ? "Yes" : "No";
    cout << ans << endl;
}

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


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

	int result = 3;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a == b)result--;
	if (b == c)result--;
	if (a == c)result--;

	if (result == 0)result = 1;

	printf("%d", result);

	return 0;
}




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

using namespace std;

const double EPS = 1.0e-9;
const double INF = 1.0e20;

int dsign(double d) {
    if (fabs(d) < EPS) {
        return 0;
    } else {
        return d < 0 ? -1 : 1;
    }
}

struct Point {
    int x, y;

    Point(int x = 0, int y = 0) : x(x), y(y) {
    }

    bool operator<(const Point& other) const {
        return x < other.x || (x == other.x && y < other.y);
    }
};

double dist(const Point& a, const Point& b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double search(int i, int j, int n, vector<vector<double>>&d, vector<vector<double>>&dp) {
    if (dp[i][j] != -1) {
        return dp[i][j];
    }
    double result = INF;
    
    int v = max(i, j) + 1;
    
    if (v == n - 1) {
        result = d[i][v] + d[j][v]; 
    }
    else {
        result = min(search(v, j, n, d, dp) + d[i][v], search(i, v, n, d, dp) + d[j][v]);
    }
    dp[i][j] = result;
    
    return result;
}

double solve(vector<Point>& points, int n) {
    sort(points.begin(), points.end());

    vector<vector<double>> d(n, vector<double>(n, 0));
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = dist(points[i], points[j]);
        }
    }
    vector<vector<double>> dp(n, vector<double>(n, -1));
    
    return search(0, 0, n, d, dp);
}

int main() {
    int n;
    cin >> n;
    vector<Point> a;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.push_back(Point(x, y));
    }
    double ans = solve(a, n);

    cout << fixed << setprecision(9) << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
    int N;
    double R;
    cin >> N;
    for(int i = 0; i < N; i++){
        double x; cin >> x;
        R += 1.0/x;
    }
    cout << 1.0/R << endl;
   
    return 0;
}


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>
#include <assert.h>
#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
const long long MOD = 1000000007;
using namespace std;


const int max_comb=200000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    int n,a,b,c;
    scanf("%d%d%d", &n, &a, &b, &c);

    pre_comb();

    // if(c==0)
    ll ans = 0;
    int i;
    for(i=0; i<=n-1; i++) {
        ll tmp = (comb(n-1+i,i)*mpow(minv(a+b), n+i))%MOD;
        tmp = tmp * mpow(a, n-1) %MOD;
        tmp = tmp * mpow(b, i) %MOD;
        tmp = tmp * a * (n+i) %MOD;
        ans = (ans + tmp)%MOD;
    }

    for(i=0; i<=n-1; i++) {
        ll tmp = (comb(n-1+i,i)*mpow(minv(a+b), n+i))%MOD;
        tmp = tmp * mpow(b, n-1) %MOD;
        tmp = tmp * mpow(a, i) %MOD;
        tmp = tmp * b * (n+i) %MOD;
        ans = (ans + tmp)%MOD;
    }

    // c!=0
    ans = ((ans * 100)%MOD * minv(a+b))%MOD; 

    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for(ll i = 0;i < n; i++)
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<ll, vector<ll>> A; //降順にpop()
    //第三引数に greater<int> 入れると昇順にpop()
    REP(i,n) {
        ll a;
        cin >> a;
        A.push(a);
    }
    REP(i,m){
        cerr << A.top() << endl;
        A.push(A.top()/2);
        A.pop(); 
    }
    ll sum= 0;
    REP(i,n){
        cerr << sum << endl;
        sum+= A.top();
        A.pop();
    }
    cout << sum << endl;
}

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 100000
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int tc;


void sol()
{

    int a,b,t;
    cin>>a>>b>>t;
    t=t/a;
    cout<<t*b<<endl;


}

int main()
{

    _fastIO;

    //cin>>tc;while(tc--)
    sol();

    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]

ans = 0
ps = []
for i in range(n-2):
    a = p[i:i+3]
    if a[0] <= a[1] < a[2] or a[2] <= a[1] < a[0]:
        ans += 1

print(ans)

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int l[1000], r[1000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> l[i] >> r[i];

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += (r[i] - l[i] + 1);
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
  int n, t, M = 123457*2;
  vector<bool> E(M, true);
  vector<int> A(M, 0);
  t = sqrt(M) + 1;
  E[0] = false; E[1] = false;
  for (int i = 2; i < t; ++i) {
    if (E[i]) {
      for (int j = i; j*i < M; ++j) E[i*j] = false;
    }
  }
  for (int i = 2; i < M; ++i) {
    if (E[i]) A[i] = A[i-1] + 1;
    else A[i] = A[i-1];
  }
  while (cin >> n, n) {
    cout << A[2*n] - A[n] << endl;
  }
}

Measured memory_bytes: 3704