akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define CST 380000.0
using namespace std;

int main() 
{
    int n;
    cin >> n;
    double sum = 0;
    for (int i=0; i<n; i++)
    {
        double x; string s;
        cin >> x; cin >> s;
        if (s == "JPY")
            sum += x;
        else
            sum += x*CST;
    }
    printf("%.5f", sum); 
    return 0;
}

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


#include <bits/stdc++.h>

#define MOD 1e9+7

using namespace std;

class DHandstand2 {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int n;
    cin >> n;
    int64_t ans = 0;
    map<pair<int64_t, int64_t>, int64_t> m;
    for (int num = 1; num < n + 1; ++num) {
      string s = to_string(num);
      auto p = make_pair(s.front(), s.back());
      m[p]++;
    }
    for (int i = 0; i < n + 1; ++i) {
      string s = to_string(i);
      auto p = make_pair(s.front(), s.back());
      ans += m[make_pair(p.second, p.first)];
    }
    cout << ans << endl;
  }
};


int main() {
  DHandstand2 solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(void){

  int n,m,i,j,state=0;

  char u[256][11],t[256][11];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",u[i]);
  }

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",t[i]);
  }

  int p;

  for(i=0;i<m;i++){

    p=2;

    for(j=0;j<n;j++){
      if(strcmp(t[i],u[j])==0){
        if(state==0){
          p=1;
          state=1;
          break;
        }
        if(state==1){
          p=0;
          state=0;
        }
      }
    }

    if(p==0)printf("Closed by %s\n",t[i]);
    if(p==1)printf("Opened by %s\n",t[i]);
    if(p==2)printf("Unknown %s\n",t[i]);

  }
       
  return 0;
}

Measured memory_bytes: 612
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto x = new int[](n), y = new int[](n);
  foreach (i; 0..n) {
    auto rd = readln.splitter;
    x[i] = rd.front.to!int; rd.popFront();
    y[i] = rd.front.to!int;
  }

  struct ZI { int z; size_t i; }
  auto zix = new ZI[](n), ziy = new ZI[](n);
  foreach (i; 0..n) {
    zix[i] = ZI(x[i], i);
    ziy[i] = ZI(y[i], i);
  }
  zix.sort!"a.z < b.z";
  ziy.sort!"a.z < b.z";

  struct DI { int d; size_t a, b; }
  auto di = new DI[]((n-1)*2);
  foreach (i; 0..n-1) {
    di[i*2]   = DI(zix[i+1].z-zix[i].z, zix[i].i, zix[i+1].i);
    di[i*2+1] = DI(ziy[i+1].z-ziy[i].z, ziy[i].i, ziy[i+1].i);
  }
  di.sort!"a.d < b.d";

  auto uf = UnionFind(n), ans = 0L;
  foreach (dii; di) {
    if (!uf.isSame(dii.a, dii.b)) {
      uf.unite(dii.a, dii.b);
      ans += dii.d;
      if (uf.countForests == 1) break;
    }
  }

  writeln(ans);
}

struct UnionFind
{
  import std.algorithm, std.range;

  size_t[] p; // parent
  const size_t s; // sentinel
  const size_t n;
  size_t countForests; // number of forests
  size_t[] countNodes; // number of nodes in forests

  this(size_t n)
  {
    this.n = n;
    s = n;
    p = new size_t[](n);
    p[] = s;
    countForests = n;
    countNodes = new size_t[](n);
    countNodes[] = 1;
  }

  size_t opIndex(size_t i)
  {
    if (p[i] == s) {
      return i;
    } else {
      p[i] = this[p[i]];
      return p[i];
    }
  }

  bool unite(size_t i, size_t j)
  {
    auto pi = this[i], pj = this[j];
    if (pi != pj) {
      p[pj] = pi;
      --countForests;
      countNodes[pi] += countNodes[pj];
      return true;
    } else {
      return false;
    }
  }

  auto countNodesOf(size_t i) { return countNodes[this[i]]; }
  bool isSame(size_t i, size_t j) { return this[i] == this[j]; }

  auto groups()
  {
    auto g = new size_t[][](n);
    foreach (i; 0..n) g[this[i]] ~= i;
    return g.filter!(l => !l.empty);
  }
}


Measured memory_bytes: 12156
def prime_pair(n):
    pairs = {}
    tmp = n
    for i in range(2, n):
        if i * i > n:
            break
        if tmp % i != 0:
            continue
        ex = 0
        while tmp % i == 0:
            ex += 1
            tmp /= i
        pairs[i] = ex
    if tmp != 1:
        pairs[int(tmp)] = 1
    return pairs

N = int(input())
MOD = 10 ** 9 + 7

pp = {}
for i in range(N):
    i_pair = prime_pair(i+1)
    for k in i_pair.keys():
        if k in pp.keys():
            pp[k] += i_pair[k]
        else:
            pp[k] = i_pair[k]
res = 1
for p in pp.keys():
    res *= (pp[p] + 1)
    res %= MOD
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define fore(i,a) for(auto &i:a)
typedef long long ll;
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }

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




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

void _main(){

   int n, sum = 0;
   cin >> n;

   int a[2][n],sumup[n],sumdown[n];

   rep(i, 0, 2) rep(j, 0, n) cin >> a[i][j];

   rep(i,0,2){
      rep(j,0,n){
         if(i == 0){
            sum += a[i][j];
            sumup[j] = sum;
         }else{
            sum += a[i][n - j - 1];
            sumdown[n - j - 1] = sum;
         }
      }
      sum = 0;
   }

   int max = -1000000;

   // rep(i,0,n){
   //    cout << sumup[i] << " ";
   // }
   // cout << endl;

   // rep(i,0,n){
   //    cout << sumdown[i] << " ";
   // }

   // cout << endl;


   rep(i,0,n){
      if(sumup[i] + sumdown[i] > max){
         max = sumup[i] + sumdown[i];
      }
   }

   cout << max << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
LRD = [LIST() for _ in range(M)]

graph = [[] for _ in range(N)]
for L, R, D in LRD:
	graph[L-1].append((R-1, D))
	graph[R-1].append((L-1, -D))

check = [1]*N
i = 0
while i < N:
	while check[i] == 0:
		i += 1
		if i == N:
			print("Yes")
			exit()

	check[i] = 0
	dis = defaultdict(int)
	dis[i] = 0
	q = deque([i])
	while q:
		p = q.popleft()
		for v, dist in graph[p]:
			if check[v] == 1:
				check[v] = 0
				dis[v] = dis[p] + dist
				q.append(v)
			if check[v] == 0 and dis[v] != dis[p] + dist:
				print("No")
				exit()


Measured memory_bytes: 149208
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);

my @a = split('',sprintf("%d",$n));

my $s = 0;
for(my $i=0;$i<=$#a;$i++){
  $s += $a[$i];
}

my $r = 'No';
$r = 'Yes' if $n % $s == 0;

print "$r\n";



Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, M;
int X[100010];
std::vector<int> ds;

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
    scanf( "%d", X+i );

  std::sort( X, X+M );

  rep( i, M-1 )
    ds.push_back( X[i+1]-X[i] );

  std::sort( ds.rbegin(), ds.rend() );

  int ans = 0;

  repi( i, N-1, ds.size() )
    ans += ds[i];
  
  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 1276
#include<stdio.h>

typedef struct{
  int x, y;
}Place;

int max(int *);
int min(int, int);
int abs(int);
int countSize(Place, Place[], Place);
int howLong(Place, Place);
int countSlope(Place, Place);
int minOthersLong(Place[], Place);

int main(void){
  Place field, others[20], p;
  int size[20];
  int s, t, i;
  while(1){
    scanf("%d %d", &field.x, &field.y);
    if(field.x == 0 && field.y == 0){
      break;
    }

    scanf("%d", &s);
    for(i = 0; i < s; i++){
      scanf("%d %d", &others[i].x, &others[i].y);
    }
    others[s].x = 0;

    scanf("%d", &t);
    for(i = 0; i < t; i++){
      scanf("%d %d", &p.x, &p.y);
      size[i] = countSize(p, others, field);
    }
    size[t] = -1;

    printf("%d\n", max(size));
  }

  return 0;
}
int max(int *size){
  int max = 0;
  while(*size != -1){
    if(max < *size){
      max = *size;
    }
    size++;
  }
  return max;
}
int min(int x, int y){
  if(x < y){
    return x;
  }
  return y;
}
int abs(int x){
  if(x < 0){
    return x * -1;
  }
  return x;
}
int countSize(Place shop, Place others[], Place field){
  Place p;
  int size = 0;
  for(p.x = 1; p.x <= field.x; p.x++){
    for(p.y = 1; p.y <= field.y; p.y++){
      if(howLong(shop, p) < minOthersLong(others, p)){
        size++;
      }
    }
  }
  return size;
}
int howLong(Place p1, Place p2){
  int x = abs(p1.x - p2.x);
  int y = abs(p1.y - p2.y);

  return x + y - min(x, countSlope(p1, p2));
}
int countSlope(Place p1, Place p2){
  int y = p1.y - p2.y;
  int tan = (p1.x - p2.x) * (p1.y - p2.y);
  int m = p2.y % 2;

  if(y % 2 == 0){
    return abs(y) / 2;
  }
  else{
    if(tan < 0){
      return abs((y - 1) / 2 + m);
    }
    else{
      return abs((y - 1) / 2 - m + 1);
    }
  }
}
int minOthersLong(Place others[], Place p){
  int i, l, min = howLong(others[0], p);
  for(i = 1; others[i].x != 0; i++){
    l = howLong(others[i], p);
    if(min > l){
      min = l;
    }
  }
  return min;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<math.h>
#define PI 3.1415926353898
int main(){
	int n,c,i;
	int p,pmin,pfirst,f;
	double x[100],y[100],ymin,dir,t,tmin;
	while(scanf("%d",&n),n){
		f=0;
		for(i=0;i<n;i++){
			scanf("%lf,%lf",x+i,y+i);
			if(!f || y[i]<ymin) {
				ymin=y[i];
				p=pfirst=i;
				f=1;
			}
		}
		c=n;
		dir=0;
		//printf("p(%d) dir=%g\n", p, dir);
		do{
			f=0;
			for(i=0;i<n;i++){
				if(i==p) continue;
				t=atan2(y[i]-y[p],x[i]-x[p])-dir;
				while(t<0) t+=2*PI;
				if(!f || t<tmin) {
					tmin=t;
					pmin=i;
					f=1;
				}
			}
			p=pmin;
			dir=tmin+dir;
			//printf("p(%d) dir=%g\n", p, dir);
			c--;
		} while(p!=pfirst);

		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    int n;
    cin >> n;
    vi as(n + 1, 0);
    F0R (i, n - 1) {
        int t;
        cin >> t;
        ++as[t];
    }
    FOR (i, 1, n + 1)
        cout << as[i] << endl;

    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
//using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
//#define int long long

std::vector<long long> binomial_coefficient(long long N){
    const long long MOD = 998244353;
    std::vector<long long> fac;
    std::vector<long long> facIE;
    std::vector<long long> comb;
    for(int i=0;i<=N;i++){
        if(i==0){
            fac.push_back(1);
        }else{
            fac.push_back(i*fac[i-1]%MOD);
        }
    }
    for(int i=0;i<=N;i++){
        long long r=1,b=fac[i],e=MOD-2;
        while(e){
            if(e&1){
                r=(r*b)%MOD;
            }
            b=(b*b)%MOD;
            e >>=1;
        }
        facIE.push_back(r);
    }
    for(int i=0;i<=N;i++){
        long long r=fac[N];
        r = (r*facIE[i])%MOD;
        r = (r*facIE[N-i])%MOD;
        comb.push_back(r);
    }
    return comb;
}



signed main(void){
    long long N,A,B,K;
    std::cin >> N >> A >> B >> K;
    std::vector<long long> nC;
    nC = binomial_coefficient(N);
    
    const long long MOD = 998244353;
    long long Ans=0;
    
    //REP(i,N+1){cout << nC[i] << " ";}cout << endl;
    
    REP(i,N+1){
        long long b=K-A*i;
        if(b>=0 && b%B==0 && b/B<=N){
            b/=B;
            Ans+=nC[i]*nC[b];
            Ans%=MOD;
        }
    }
    std::cout << Ans << std::endl;
    return 0;
}


Measured memory_bytes: 16492
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ans = a + b;
  if(ans >= 24) ans -= 24;
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n")[0].split("");
    let diff01: number = 0;
    let diff10: number = 0;
    let n01: string = "0";
    tmp.forEach(n => {
      if (n != n01) {
        ++diff01;
      } else {
        ++diff10;
      }
      n01 = n01 == "0" ? "1" : "0";
    })
    return `${Math.min(diff01, diff10)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 8268
#include <cstdio>
#include <vector>
#define maxn 110
#define INF 1e9
using namespace std;
int n,m,f[maxn][maxn],ans;
struct edge {
    int to,ca;
};
vector<edge> map[maxn];
int main() {
    scanf("%d %d",&n,&m);
    for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			f[i][j]=INF;
    for (int i=1;i<=m;i++) {
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		edge x; x.to=b; x.ca=c;
		map[a].push_back(x);
		x.to=a;
		map[b].push_back(x);
		f[a][b]=c; f[b][a]=c;
    }
    for (int i=1;i<=n;i++)
		f[i][i]=0;
    for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
				if (f[i][k]+f[k][j]<f[i][j]) {
					f[i][j]=f[i][k]+f[k][j];
				}
    ans=0;
    for (int i=1;i<=n;i++) {
		for (int j=0;j<map[i].size();j++) {
			bool T=false;
			for (int s=1;s<=n;s++) {
				for (int t=s+1;t<=n;t++)
				if (f[s][t]==f[s][i]+f[map[i][j].to][t]+map[i][j].ca
				||f[s][t]==f[s][map[i][j].to]+f[i][t]+map[i][j].ca) {
					T=true;
					break;
				}
				if (T)
					break;
			}
			if (!T) {
				ans++;
			}
		}
    }
    printf("%d\n",ans/2);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
using namespace std;
const int N=300005;
int n,L,ans=1,cnt,ok;
int x[N],t[N],l[N],r[N];
int main(){
	n=read();L=read()<<1;
	for(int i=1;i<=n;i++)x[i]=read()<<1;
	for(int i=1;i<=n;i++)t[i]=read();
	for(int i=1;i<=n;i++){
		int v=t[i]%L;
//		ans+=t[i]/L+(t[i]%L!=0);
		ans+=(1ll*t[i]+L-1)/L;
		l[i]=(0<v&&v<=x[i]);
		r[i]=(0<v&&v<=L-x[i]);
	}
	for(int i=1;i<n;i++)
		if(cnt&&r[i]){if(l[i])++ok;--ans;--cnt;}
		else if(l[i]) ++cnt;
		else if(r[i]&&ok) --ok,++cnt;
	if(r[n])ans--;
	printf("%lld\n",1ll*ans*L);
	return 0;
}


Measured memory_bytes: 4992
N = int(input())
st = 0
sx = 0
sy = 0
flg = False
for _ in range(N):
    t,x,y = map(int,input().split())

    if abs((x+y)-(sx+sy)) > (t-st) or (t-st) % 2 != abs((x+y)-(sx+sy)) % 2:
        flg = True
        break
    else:
        st = t
        sx = x
        sy = y
print('No' if flg else 'Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
bool f[101];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=1;
	f[a]++;
	if(!f[b]){
		ans++;
		f[b]++;
	}
	if(!f[c]){
		ans++;
		f[c]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(0,N,1)]
count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        dist = 0
        for k in range(0,D,1):
            dist+=(X[i][k]-X[j][k])**2

        for k in range(0,dist+1,1):
            if k**2 == dist:
                count+=1
                break

print(count)




Measured memory_bytes: 3064
#!/usr/bin/env python3
a, b, c = map(int, input().split())
o = 0
if a == b == c:print(a%2-1);exit() 
while 1-any([a%2, b%2, c%2]):
    a, b, c = (b+c)//2, (c+a)//2, (a+b)//2
    o += 1
print(o) 

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX = 100005;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main()
{
    COMinit();
    string l; cin >> l;
    int n = l.length();
    vector<int> dp1(n+1, 0), dp2(n+1, 0);

    dp1[0] = 1; dp2[0] = 0;
    rep(i, n){
        if(l[n-1-i]=='1'){
            dp1[i+1] = (2*dp1[i])%MOD + (dp1[i] + dp2[i])%MOD;
            dp2[i+1] = 2*dp2[i];
        }else{
            dp1[i+1] = dp1[i];
            dp2[i+1] = ((2*dp1[i])%MOD + (2*dp2[i])%MOD)%MOD + dp2[i]; 
        }
        dp1[i+1] %= MOD;
        dp2[i+1] %= MOD;
    }
    pr(dp1[n]);
    return 0;}

Measured memory_bytes: 6700
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
#include <cassert>
using namespace std;

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

    if(N == 1){
        cout << "Yes" << endl;
        cout << "2" << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }


    long long K = 0;
    for(long long k=0; k<=N; k++){
        if(k*(k-1)==2*N){
            K = k;
            break;
        }
    }
    if(K == 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << K << endl;
    vector<int> v(K);

    vector<vector<int>> ans(K);

    int cur = 0;
    for(int i=0; i<K; i++){
        v[i] = cur;
        for(int j=0; j<i; j++){
            ans[i].push_back(v[j]);
            v[j]++;
        }
        for(int j=i; j<K-1; j++){
            ans[i].push_back(cur);
            cur++;
        }
    }
    for(int i=0; i<K; i++){
        cout << K-1 << " ";
        for(int j=0; j<K-1; j++)
            cout << ans[i][j]+1 << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2304
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { a: usize, b: usize, c: usize }
    if a == b + c || b == a + c || c == a + b {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define fr first
#define sc second
#define mp make_pair
const int N=100005;
multimap<LL,int> S;
LL a[N],ans[N];
int q[N];
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,n,tot=0;LL cnt=0,sum=0;S.insert(mp(-1,-1));
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (i=1;i<=n;i++) if (a[i]>a[q[tot]]) q[++tot]=i;
    q[tot+1]=n+1;
    for (i=tot;i>=1;i--)
    {
        sum=cnt*(a[q[i]]-a[q[i-1]]);
        for (j=q[i];j<q[i+1];j++) S.insert(mp(a[j],j));
        map<LL,int>::iterator i1=S.end();i1--;   
        while ((*i1).fr>a[q[i-1]])
        {
            cnt++;sum+=(*i1).fr-a[q[i-1]];
            S.erase(i1);i1=S.end();i1--;
        }
        ans[q[i]]=sum;
    }
    for (i=1;i<=n;i++) printf("%lld\n",ans[i]);
    
    return 0;
}


Measured memory_bytes: 7552
#!/usr/bin/ruby
#encoding: utf-8

n,q = gets.split.map(&:to_i)
$ans = Array.new(n,0)

# 隣接リストで木を表現する。
$to = Array.new(n){ [] }

(n-1).times do |i|
  a,b = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  $to[a].push(b)
  $to[b].push(a)
end

# 累積和を取るためのdfs
def dfs(v,p=-1)
  $to[v].each do |u|
    if u == p 
      next
    end
    $ans[u] += $ans[v]
    dfs(u,v)
  end
end

q.times do |i|
  p,x = gets.split.map(&:to_i)
  p -= 1
  $ans[p] += x
end

# dfsで累積和を取る。
#dfs(0)

# 累積和を取る(スタックによるdfs)
visited = Array.new(n,false) #訪れたか否か、bool値で持つ
# 探査候補スタック
queue = [0]

until queue.empty?
  c = queue.shift
  visited[c] = true
  $to[c].each do |u|
    next if visited[u]
    $ans[u] += $ans[c]

    # 未探索かつ候補にも入っていない地点なので、探索候補スタックに追加する。
    queue << u
  end
end

(0..n-1).each do |i|
  puts $ans[i]
end


Measured memory_bytes: 25524
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k, q; cin >> n >> k >> q;
  vector<int> a(n); REP(i, n) cin >> a[i];
  map<int, vector<int> > mp;
  REP(i, n) mp[a[i]].emplace_back(i);
  vector<int> sorted(a);
  sort(ALL(sorted));
  int ans = sorted[q - 1] - sorted[0];
  vector<int> st{-1, n};
  int idx = 0, cnt = n - k + 1;
  for (auto &pr : mp) {
    idx += pr.second.size();
    for (int e : pr.second) st.emplace_back(e);
    sort(ALL(st));
    vector<int> nozoku;
    int sz = st.size();
    REP(i, sz - 1) {
      vector<int> tmp;
      FOR(j, st[i] + 1, st[i + 1]) tmp.emplace_back(a[j]);
      sort(ALL(tmp));
      REP(j, st[i + 1] - st[i] - 1 - k + 1) nozoku.emplace_back(tmp[j]);
    }
    sort(ALL(nozoku));
    if (nozoku.size() < q) break;
    ans = min(ans, nozoku[q - 1] - nozoku[0]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
buffer = []
while True:
    x,y = map(int, input().split())
    if x==0 and y==0:
        break
    buffer.append([x,y])
for n in range(len(buffer)):
    for r in range(buffer[n][0]):
        for c in range(buffer[n][1]):
            print('#', end = '')
        print('')
    print('')


Measured memory_bytes: 7016
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int h,w;
vector<string> board;
vector<vector<ll>> memo;

bool is_valid_move(int y, int x){ //座標(y,x)からの移動は可能？
  if(y<0 || y>=h || x<0 || x>=w) return false;
  return true;
}

ll f(ll y, ll x){
    if(memo.at(y).at(x)!=-1){
        return memo.at(y).at(x);
    }
    if(board.at(y).at(x) == '#'){
        memo.at(y).at(x) = 0;
        return 0;
    }
    //cout << y << x << endl;
    ll rec;
    ll utd = 0,ltr = 0;
    if(is_valid_move(y-1,x)) utd = f(y-1,x);
    if(is_valid_move(y,x-1)) ltr = f(y,x-1);
    //cout << utd << " " << ltr << endl;
    rec = (utd + ltr)%mod;
    memo.at(y).at(x) = rec;
    return rec;
}

int main(){
    cin >> h >> w;
    board.resize(h);
    memo.resize(h,vector<ll>(w,-1));
    rep(i,h) cin >> board.at(i);
    memo.at(0).at(0) = 1;

    cout << f(h-1,w-1) << endl;
  
    //rep(i,h){rep(j,w){cout << memo.at(i).at(j);} cout << endl;}
}

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

int main() {
  int n,k,q;
  cin >> n >> k >> q;
  
  vector<int> a(q);
  for(int i=0; i<q; i++){
    cin >> a[i];
  }
  
  vector<int> p(n);
  for(int i=0; i<n; i++){
    p[i] = 0;
  }
  for(int i=0; i<q; i++){
    p[a[i]-1]++;
  }
  
  for(int i=0; i<n; i++){
    if(q-p[i] <= k-1){
      cout << "Yes" << endl;
    }
    if(q-p[i] >= k){
      cout << "No" << endl;
    }
  }
    
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MOD = 1e9+7;

ll N, M, K;

int pow(ll n, ll k, int mod) {
    ll res = 1;
    while (k > 0) {
        if (k&1) res = res*n%mod;
        n = n*n%mod;
        k >>= 1;
    }
    return res;
}

int inv(int n) {
    return pow(n, MOD-2, MOD);
}

int comb(int n, int k) {
    ll res = 1;
    FOR (i, 1, n+1) res = res*i%MOD;
    FOR (i, 1, k+1) res = res*inv(i)%MOD;
    FOR (i, 1, n-k+1) res = res*inv(i)%MOD;
    return res;
}

ll query(int w, int h) {
    ll res = 0;
    ll c = comb(N*M-2, K-2);
    FOR (d, 1, w) {
        res += (w-d) * d % MOD * h % MOD * h % MOD * c;
        res %= MOD;
    }
    return res;
}

int solve() {
    return (query(N, M) + query(M, N)) % MOD;
}

int main() {
    cin >> N >> M >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<PII, vector<PII>, greater<PII> > que;
    REP(i, N){
        int d;
        cin >> d;
        que.push({d, 1});
    }
    REP(i, M){
        int b, c;
        int count;
        cin >>b >> c;
        for(count=0;que.top().first < c && count < b;){
            if(b - count >= que.top().second){
                count += que.top().second;
                que.pop();
            }else{
                PII d = que.top();
                que.pop();
                que.push({d.first, d.second - (b - count)});
                count = b;
            }
        }
        if(count > 0){
            que.push({c, count});
        }
    }
    long long sum = 0;
    while(!que.empty()){
        sum += (long long)que.top().first * que.top().second;
        que.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int main() {
	int n;
	cin >> n;
		string s,s1,s2;
	while( n > 0 ) { 
		typedef set <string> set_t;
		set_t A;
		cin >> s;
		for (int i = 0; i < s.length() - 1;i++) {
			s1 = s[0];
			s2 = s[i+1];
			for (int j = 1; j <= i; j++) {
				s1 = s1 + s[j];
			}
			for (int j = i + 2 ; j < s.length(); j++) {
				s2 = s2 + s[j];
			}
			A.insert(s1+s2);
			A.insert(s2+s1);
			reverse(s1.begin(), s1.end());
			A.insert(s1+s2);
			A.insert(s2+s1);
			reverse(s2.begin(), s2.end());
			A.insert(s1+s2);
			A.insert(s2+s1);
			reverse(s1.begin(), s1.end());
			A.insert(s1+s2);
			A.insert(s2+s1);
		}
		cout << A.size() << endl; 
		n = n-1;
		}
}

Measured memory_bytes: 1292
n = int(input())
a = list(map(int,input().split()))
ans = 0
flag = True
while flag:
    for i in range(n):
        if a[i] % 2 != 0:
            flag = False
            break
        else:
            a[i] /= 2
            if i == n-1:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	if(a[0]!=0) {
		cout<<-1<<endl;
		return 0;
	}
	bool d=false;
	ll ans=0;
	FOR(i,1,n) {
		if(a[i]==0) continue;
		if(a[i]<=a[i-1]+1) {
			if(a[i]==a[i-1]+1) ans++;
			else ans+=a[i];
		} else d=true;
	}
	if(!d) cout<<ans<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 1792
def main():
    N = int(input())
    Boss = [int(a) for a in input().split()]
    count = [0]*N

    for i in range(N-1):
        count[Boss[i] - 1] += 1
    for i in range(N):
        print(count[i])
if __name__ == "__main__":
    main()

Measured memory_bytes: 32188
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let s = sc.next_string().unwrap();
    let mut cs = vec![0; 26];
    for c in s.into_bytes().into_iter() {
        cs[(c - 97) as usize] += 1;
    }
    let m = (1e9 as i64) + 7;
    let mut res = 1i64;
    for i in 0..26 {
        res = res * (cs[i] + 1) % m;
    }
    res -= 1;
    if res < 0 {
        res += m;
    }
    println!("{}", res);
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


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

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

    const int inf = 1e18;
    map<char, set<int>> m;
    for (int i = 0; i < s.size(); i++) {
        m[s[i]].insert(i);
    }
    for (auto& e : m) e.second.insert(inf);

    int ans = 0;
    int last = -1;
    for (char c : t) {
        const set<int>& se = m[c];
        if (se.empty()) {
            cout << -1 << endl;
            return 0;
        }
        int idx = *se.upper_bound(last);
        if (idx == inf) idx = *se.begin();
        if (idx <= last) ans += s.size();
        last = idx;
    }
    ans += last + 1;
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


            
int main(){
    ll h,a;cin>>h>>a;
    if(h%a==0){
        cout<<h/a<<endl;
    }else{
        cout<<1+(h/a)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100000

int partition(void);
void swap(int*,int*);

int n,A[N];

int main(){
  int i, r;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  
  r = partition();
  
  for(i = 0; i < n; i++){
    if( i != 0 ){
      printf(" ");
    }
    if(r==i) printf("[%d]" ,A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  
  return 0;
}
int partition(void){
  int i, j, p, r;
  
  r = A[n - 1];
  i = -1;
  
  for(j = 0; j < n - 1; j++){
    if(A[j] <= r){
      i++;
      swap(&A[i], &A[j]);
    }
  }
  
  swap(&A[i+1], &A[n-1]);
  
  return i + 1;
}

void swap(int *x, int *y){
  int tmp;
  
  tmp = *x;
  *x = *y;
  *y = tmp;
  return ;
}

Measured memory_bytes: 992
import java.io.IOException;
import java.util.Stack;


public class Main {
	static class Inp extends Stack<Integer> {}

	static class Lst {
		private	int[]	d = new int[10000];
		private	int		h = 0;
		private	int		t = 0;

		public void add(int e) {
			d[t++] = e;
		}

		public int get(int i) {
			return d[h+i];
		}

		public int size() {
			return t-h;
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Inp		inp = new Inp();
		Lst		lst = new Lst();
		int[]	ans = new int[10001];
		int		num = 0;
		int		max = 0;

		while((num = parseNum()) != 0) {
			inp.push(num);
			max = (num > max)?num:max;
		}

		getList(max, lst, ans);

		while (inp.size() > 0) {
			int o = ans[inp.remove(0)];
			System.out.println((o-2)+" "+o);
		}
	}

	private static void getList(int max, Lst lst, int[] ans) {
		lst.add(2);
		lst.add(3);

		for(int num = 5; num <= max; num += 2) {
			for (int i = 0; i < lst.size(); i++) {
				int	nWk = lst.get(i);
				if (nWk > (int)Math.sqrt(num)) {
					if (num-lst.get(lst.size()-1)==2) {
						ans[num] = num;
					}
					lst.add(num);
					break;
				}
				if (num % nWk == 0) {
					break;
				}
			}
		}

		for(int i = 1; i <= max; i++) {
			ans[i] = (ans[i]==0)?ans[i-1]:ans[i];
		}
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if ((skp == 0 || buf == -1) && buf != '.') {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 25204
a,b = map(int,input().split())
# (R1)+(R2)/(R1*R2) = 1/(R3)
# (R1)+(R2)*(R3) = (R1*R2)
# (R3) = (R1*R2)/(R1)+(R2)
S = a+b
print(float((a*b)/S))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  if(N >= 500){
    ans += ceil(N/500)*1000;
    N -= ceil(N/500)*500;
  }
  if(N >= 5){
    ans += ceil(N/5)*5;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let mut a: i64 = s.next().unwrap().parse().unwrap();
	let mut b: i64 = s.next().unwrap().parse().unwrap();
	let mut k: i64 = s.next().unwrap().parse().unwrap();
	let eat = std::cmp::min(a, k);
	a -= eat;
	k -= eat;
	b -= std::cmp::min(b, k);
	println!("{} {}", a, b);
}


Measured memory_bytes: 4352
def main():
  s=input()
  #while s%10==0:
  #    s//=10
  #s=9**100
  #s=str(s)
  lens=len(s)

  d=int(s[0])
  p=11-int(s[0])

  for c in s[1:]:
      j=int(c)
      a=min(d+j,p+j)
      b=min(d+11-j,p+9-j)
      d,p=a,b

  print(min(d,p))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string O,E;
    cin >> O >> E;
    int len_O = O.size();
    int len_E = E.size();
    string pw = "";
    if (len_O - len_E == 1){
        rep(i,len_E){
            pw += O.substr(i,1);
            pw += E.substr(i,1);
        }
        pw += O.substr(len_O - 1,1);
    }
    else{
        rep(i,len_E){
            pw += O.substr(i,1);
            pw += E.substr(i,1);
        }
    }
    cout << pw << endl;
}



Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0
check=1000
for i in range(n):
    j=a[i]
    ans+=b[j-1]
    if check+1 == j:
        ans+=c[check-1]
    
    check=j
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int a[3][3];
    rep (i, 3) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    string ans = "No";
    bool flag[3][3];
    rep (i, 3) {
        rep (j, 3) {
            flag[i][j] = false;
        }
    }
    int n;
    cin >> n;
    rep (i, n) {
        int b;
        cin >> b;
        rep (j, 3) {
            rep (k, 3) {
                if (a[j][k]==b) flag[j][k] = true;
            }
        }
    }
    
    rep (i, 3) {
        if (flag[i][0] && flag[i][1] && flag[i][2]) ans = "Yes";
        if (flag[0][i] && flag[1][i] && flag[2][i]) ans = "Yes";
    }
    if (flag[0][0] && flag[1][1] && flag[2][2]) ans = "Yes";
    if (flag[0][2] && flag[1][1] && flag[2][0]) ans = "Yes";
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m;
    vvi v(100,vi()); cin>>n>>m;
    rep(i,m){
        pii ujimatu; cin>>ujimatu.first>>ujimatu.second;
        v[ujimatu.first].push_back(ujimatu.second);
        v[ujimatu.second].push_back(ujimatu.first);
    }
    rep(i,n)cout<<v[i+1].size()<<endl;
    
}

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

int main() {
  int X;
  cin >> X;
  int x=0;
  int ans;
  for (int i=0;  ; i++) {
    x+=i;
    if (x>=X) {
      ans=i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define N 1000000

void mergeSort(int [ ], int , int);
void merge(int [ ], int , int , int );

int cnt=0;

int main()
{
  int i,S[N],n;

  while(1)
    {
      scanf("%d",&n);
      if(n <= N && n > 0) break;
    }

  for(i=0;i<n;i++)
      scanf("%d",&S[i]);

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++)
    printf("%d ",S[i]);
  
  printf("%d\n%d\n",S[i],cnt);
  
  return 0;
}

void mergeSort(int A[ ], int left, int right)
{
  int mid;
  if(left+1 < right)
    {   
      mid = (left + right) / 2;
      mergeSort(A,left,mid);
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
}

void merge(int A[ ], int left, int mid, int right)
{
int i,j,k,n1,n2;
int *sl,*sr;

  n1 = mid - left;
  n2 = right - mid;

  sl = malloc(sizeof(int) * n1 + 1);
  sr = malloc(sizeof(int) * n2 + 1);
  
  for (i = 0; i < n1; i++)
    sl[i] = A[left + i];
  
  sl[n1] = (int)INFINITY;
  
  for (j = 0; j < n2;j++)
    sr[j] = A[mid + j];
  
  sr[n2] = (int)INFINITY;
  i = 0;         
  j = 0;       

  for (k = left; k < right; k++)
    {
      if (sl[i] <= sr[j])
	{
	  A[k] = sl[i];
	  i++;
	}
      else
	{
	  A[k] = sr[j];
	  j++;
	}
      cnt++;
    }

  free(sl);
  free(sr);
}





Measured memory_bytes: 5472
using System;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        var line = Console.ReadLine();
        var words = line.Split(' ');

        bool[] nums = new bool[1000000001];
        for (int i = 0; i < n; i++)
        {
            int num = int.Parse(words[i]);
            if (nums[num])
            {
                Console.WriteLine("NO");
                return;
            }
            nums[num] = true;
        }
        Console.WriteLine("YES");
    }
}

Measured memory_bytes: 1004660
from collections import Counter
c = Counter()
N = int(input())


for i in range(2, N+1):
  tmp = i
  for j in range(2, i+1):
    while tmp % j == 0:
      c[j] += 1
      tmp //= j

def num(m):
  return len(list(filter(lambda x: x >= m - 1, c.values())))

ans = 0
ans += num(75)
ans += (num(5) - 1) * num(15)
ans += (num(3) - 1) * num(25)
ans += (num(3) - 2) * num(5) * (num(5) - 1) // 2
print(ans)

Measured memory_bytes: 38760