akhauriyash/Code-Regression huggingface dataset:
n = int(input())


for i in range(1,3501):
  for j in range(1,3501):
    if (4*i*j - n*i - n*j) == 0:
      continue
    w = i*j*n/(4*i*j - n*i - n*j)
    if w == int(w) and w > 0:
      print(i,j,int(w))
      exit()

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

using namespace std;

#define hell 1000000007
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define read(arr,n) for(long long i = 0; i<n; i++) cin>>arr[i]
#define print(arr,n) for(long long i = 0; i<n; i++) cout << arr[i] <<' '; cout <<'\n';
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define forl(i,a,b) for(ll i=a; i<b; i++)
#define rfor(i,a,b) for(ll i = a; i>=b; i--)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef map<string, int> msi;
typedef map<int, int> mii;

void solve()
{
	ll a,b,c;
	cin >> a >> b >> c;
	
	if(a+b+1 >= c)
	{
		cout << b+c <<endl;	
	}
	else
	{
		cout << a+2*b+1<<endl;
	}
}

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

	ll t=1;
    	//cin >> t;
    	while(t--)
    	{
        	solve();
	}
	return 0;
}


Measured memory_bytes: 256
<?php
$s=trim(fgets(STDIN));
$s=explode(" ",$s);
$dislikeNums=trim(fgets(STDIN));
$dislikeNums=explode(" ",$dislikeNums);
$cost=$s[0];

$check=0;
//var_dump($dislikeNums);
for($i=$s[0];$check===0;$i++){
	foreach($dislikeNums as $dislikeNum){
      	if(strpos(strval($i),$dislikeNum)!==false){
        	break;
        }elseif($dislikeNum===$dislikeNums[count($dislikeNums)-1]){
        	$check=1;
          	$answer=$i;
        }
    }
}
echo $answer;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  string s;cin>>s;
  int ans=0;
  for(int i=1;2*i<s.size();i++){
    if(s.substr(0,i)==s.substr(i,i)){
      ans = max(ans,2*i);
    }
  }
  cout<<ans<<endl;
}





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

signed main() {
  int N;
  cin >> N;
  
  vector<int>A(N);
  vector<int>B(N);
  
  for (int i = 0; i < N-1 ; i++){
    cin >> A.at(i);
  }
  
  for (int i = 0; i < N-1; i++){
    B.at(A.at(i)-1) += 1;
  }
  
  for (int i = 0; i < N-1; i++){
    cout << B.at(i) << endl;
  }
  cout << 0 << endl;
  
}


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

signed main() {
    int N, C;
    cin >> N >> C;
    vector<int> x(N), v(N), r_max(N), l_max(N);
    rep(i, N) cin >> x[i] >> v[i];
    
    int cal_r = 0, cal_l = 0;
    int ans = 0;
    rep(i, N) {
        int j = N - i - 1;
        cal_r += v[i];
        cal_l += v[j];
        int pre_r = i >= 1 ? r_max[i - 1] : 0;
        r_max[i] = max(pre_r, cal_r - x[i]);
        int pre_l = i >= 1 ? l_max[i - 1] : 0;
        l_max[i] = max(pre_l, cal_l - (C - x[j]));
        ans = max({ans, r_max[i], l_max[i]});
    }
    
    rep(i, N - 1) {
        int j = N - i - 1;
        int r = r_max[i] + l_max[N - i - 2] - x[i];
        int l = l_max[i] + r_max[N - i - 2] - (C - x[j]);
        ans = max({ans, r, l});
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

#define MAX 45

int solve(int);
int dp[MAX];

int main(){
  int n;

  scanf("%d" ,&n);
  printf("%d\n" ,solve(n));

  return 0;
}

int solve(int n){
  if(dp[n] > 0){
    return dp[n];
  }

  if(n <= 1){
    return 1;
  }else{
    return dp[n] = solve(n-1) + solve(n-2);
  }
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long LL;
using namespace std;

int main(){
    int n, m;
    int anchor_1_2;
    int anchor_1_4;
    LL ans = 0;
    LL tmp;
    vector<LL> a;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    anchor_1_2 = n-2;
    anchor_1_4 = n-2;
    for(int i=n-2; i>=0; i--){
        if(a[i]>=a[n-1]/2){
            anchor_1_2--;
            anchor_1_4--;
        }else if(a[i]>=a[n-1]/4){
            anchor_1_4--;
        }else{
            break;
        }
    }
    while(m>0){
        for(int i=n-1; i>anchor_1_2; i--){
            if(m>0){
                a[i] = a[i]/2;
                m--;
            }
        }
        anchor_1_2 = anchor_1_4;
        sort(a.begin()+anchor_1_2+1, a.end());
        for(int i=anchor_1_4; i>=0; i--){
            if(a[i]>=a[n-1]/4){
                anchor_1_4--;
            }else{
                break;
            }        
        }
    }
    for(int i=0; i<n; i++){
        ans  += a[i];
    }
    cout << ans << endl;
}

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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  bool flag = true;
  if(N % 2 == 0){
    for(int i = 0; i < N; i++){
      if(A[i] != ((i/2) * 2 + 1 )){
	flag = false;
      }
    }
  }else{
    for(int i = 0; i < N; i++){
      if(i % 2 == 0){
	if(A[i] != i){
	  flag = false;
	}
      }else{
	if(A[i] != i + 1){
	  flag = false;
	}
      }
    }
  }
  if(flag == false){
    cout << 0 << endl;
  }else{
    int tmp = N / 2;
    int res = 1;
    for(int i = 0; i < tmp; i++){
      res = res * 2 % MOD;
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
	ios::sync_with_stdio(false);

	int w,a,b;
	cin >> w >> a >> b;
	int ans = abs(a-b) - w;
	cout << max(0, ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>

using ll = long long;

using namespace std;
int main()
{
  ll n, k;
  cin >> n >> k;
  cout << ((n % k) > 0) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;class Main{public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));int m[][]=new int[16][16],a[]=new int[3],i,j,x,y,s,d;for(String t;(t=B.readLine())!=null;){g=t.split(",");for(i=0;i<3;)a[i]=Integer.parseInt(g[i++]);x=a[0]+3;y=a[1]+3;s=a[2];d=s>2?2:1;for(i=x-d;i<=x+d;i++)for(j=y-d;j<=y+d;j++){if(s!=2){if(x-d<i&&i<x+d&&y-d<j&&j<y+d)m[i][j]++;else if(i==x||j==y)m[i][j]++;}else m[i][j]++;}}s=d=0;for(i=3;i<13;i++)for(j=3;j<13;j++)if(m[i][j]<1)s++;else d=m[i][j]>d?m[i][j]:d;System.out.println(s+"\n"+d);}}


Measured memory_bytes: 24104
import sys
for s in sys.stdin:
    a,b,c,d,e,f=map(float,s.split())
    x=c*e-b*f
    y=a*f-c*d
    z=a*e-b*d
    def f(x,z):
        if x==0: return 0
        else: return x/z
    print "%.3f %.3f" %(f(x,z),f(y,z))

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int n, ans = 0, cnt = 0, dis[N][N], col[N], s[N], t[N];
bool flag = true;
char str[N];
int main () {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) dis[i][j] = (i == j) ? 0 : n + 1;
	}
	for (int i = 0; i < n; i++) {
		scanf("%s", str);
		for (int j = 0; j < n; j++) {
			if (str[j] == '1') dis[i][j] = 1;
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (dis[i][j] > dis[i][k] + dis[k][j]) dis[i][j] = dis[i][k] + dis[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++) col[i] = 0;
	for (int i = 0; i < n; i++) {
		if (!col[i]) {
			col[i] = ++cnt, s[cnt] = t[cnt] = i;
			for (int j = 0; j < n; j++) {
				if (dis[i][j] < n) col[j] = cnt;
			}
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (col[j] == cnt && col[k] == cnt && dis[s[cnt]][t[cnt]] < dis[j][k]) s[cnt] = j, t[cnt] = k;
				}
			}
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (col[j] == cnt && col[k] == cnt && dis[j][k] == 1 && dis[s[cnt]][j] == dis[s[cnt]][k]) flag = false;
				}
			}
			ans = max(ans, dis[s[cnt]][t[cnt]]);
		}
	}
	if (flag) printf("%d\n", ans + 1);
	else printf("-1\n");
	return 0;
}

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

const int MAX_N = 100;
const int INF = (1 << 21);

int N;
int A[MAX_N][MAX_N];
int d[MAX_N], c[MAX_N];

void dj() {
  d[0] = c[0] = 0;

  while (1) {
    int cost = INF;
    int cur = -1;

    for (int i = 0; i < N; i ++) {
      if (c[i] != 1 && d[i] < cost) {
        cost = d[i];
        cur = i;
      }
    }

    if (cur == -1) break;
    c[cur] = 1;

    for (int v = 0; v < N; v++) {
      if (c[v] != 1 && A[cur][v] != INF) {
        if (d[cur] + A[cur][v] < d[v]) {
          d[v] = d[cur] + A[cur][v];
          c[v] = 0;
        }
      }
    }
  }

  for (int i = 0; i < N; i++)
    cout << i << ' ' << d[i] << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++)
      A[i][j] = INF;
    d[i] = INF;
    c[i] = -1;
  }

  for (int i = 0; i < N; i++) {
    int cur, k; cin >> cur >> k;

    for (int j = 0; j < k; j++) {
      int u, v;
      cin >> u >> v;
      A[cur][u] = v;
    }
  }

  dj();

  return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
}
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  vector<int> left(N), right(N);
  left[0] = 0;// left[i]: 左端からi-1番目までのGCD (i番目は含まない)
  for(int i=1; i<N; i++){
    left[i] = gcd(left[i-1], A[i-1]);
  }
  right[N-1] = 0;//right[i]: 右端からi-1番目までのGCD (i番目は含まない)
  for(int i=1; i<N; i++){
    right[N-i-1] = gcd(right[N-i], A[N-i]);
  }

  int ans = 0;
  for(int i=0; i<=N; i++){ //A[i]を含まない数列Aのgcdを計算していく
    ans = max(ans, gcd(left[i], right[i]));
  }
  cout << ans << endl;
  return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll gozyou(ll num)
{
    return num * num * num * num * num;
}
int main()
{
    int x;cin >> x;
    ll a,b;
    for (a = -120; a <=120 ; a++)
    {
        for (b = -120; b <= 120; b++)
        {
            if(gozyou(a)-gozyou(b)==x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    
}

Measured memory_bytes: 3672
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    int n, m, s;
    cin >> n >> m >> s;
    int mxp = 0;
    vector<vector<array<int, 3>>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v, p, t;
        cin >> u >> v >> p >> t;
        --u, --v;
        g[u].pb({v, t, p});
        g[v].pb({u, t, p});
        cmax(mxp, p);
    }
    vector<pii> cities(n);
    for (auto &[t, a] : cities) {
        cin >> a >> t;
    }
    int maxc = mxp * (n - 1);
    cmin(s, maxc);
    vector<vector<int>> dist(n, vector<int>(maxc + 1, INF));
    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> q;
    dist[0][s] = 0;
    q.push({0, 0, s});
    while (len(q)) {
        auto [d, v, c] = q.top();
        q.pop();
        if (dist[v][c] != d) continue;
        for (auto &[u, t, p] : g[v]) {
            if (p > c) continue;
            if (cmin(dist[u][c - p], d + t)) q.push({d + t, u, c - p});
        }
        if (auto [t, a] = cities[v]; cmin(dist[v][min(c + a, maxc)], d + t)) {
            q.push({d + t, v, min(c + a, maxc)});
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << *min_element(all(dist[i])) << endl;
    }
}

Measured memory_bytes: 7340
import heapq
n, m = map(int, input().split())
edges = dict()
ans = [0 for _ in range(m + 1)]
graph = [set() for _ in range(n)]


for i in range(m):
    a, b, c = map(int, input().split())
    edges[i] = (a - 1, b - 1, c)
    graph[a - 1].add(i)
    graph[b - 1].add(i)

# (cost,done,node,edge)
for i in range(n):
    done = [True for _ in range(n)]
    D = [(0, 0, i, m), ]
    heapq.heapify(D)

    while D:
        d = heapq.heappop(D)
        cost, mark, node, edge = d

        if done[node]:
            done[node] = False
            ans[edge] = 1

            for g in graph[node]:
                a, b, c = edges[g]

                if b == node:
                    a, b = b, a

                if done[b]:
                    heapq.heappush(D, (cost + c, ans[g], b, g))

print(m - (sum(ans) - 1))


Measured memory_bytes: 9360
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int N;
	static int W[][], distance[], state[];
	static final int INF = 1000000000;

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

		W = new int[N][N];
		distance = new int[N];
		state = new int[N];

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				W[i][j] = INF;
			}
		}

		for (int i = 0; i < N; i++) {
			sc.nextInt(); // u を読み飛ばし
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				int c = sc.nextInt();
				W[i][v] = c;
			}
		}
		dijkstra(0);
		for (int i = 0; i < N; i++) {
			System.out.println(i + " " + distance[i]);
		}
	}

	private static int min(int a, int b) {
		if (a < b)
			return a;
		return b;
	}

	private static void dijkstra(int start) {
		// Arrasys.fill は配列の初期化がデキル便利メソッド．ただし1次元配列のみ
		Arrays.fill(distance, INF);
		Arrays.fill(state, 0);
		distance[start] = 0;

		int p = 0; // 確定頂点番号を保存する変数
		for (int step = 0; step < N; step++) {
			int minimum = INF;
			for (int x = 0; x < N; x++) {
				if (state[x] == 0 && distance[x] < minimum) {
					p = x;
					minimum = distance[x];
				}
			}
			if (minimum == INF) {
				System.err.println("Disconnected Graph!\n");
				System.exit(-1);
			}
			state[p] = 1;
			for (int x = 0; x < N; x++)
				distance[x] = min(distance[x], distance[p] + W[p][x]);
		}

	}
}



Measured memory_bytes: 40324
n=int(input())
s=list(input())
ans=0

for i in range(1000):
    num=list(str(i).zfill(3))
    k=0
    for j in range(n):
        if num[k]==s[j]:
            k+=1
            if k==3:
                break
    if k==3:
        ans+=1

print(ans)
    
    

Measured memory_bytes: 42732
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.1415926535
#define pb(a) push_back(a)
#define mp make_pair
#define sortv(a) sort(a.begin(),a.end())
#define sorta(a,n) sort(a,a+n)
#define fileio freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
const int INF = 0x3f3f3f3f;
ll gcd(ll a, ll b){
	if(a==0)return(b);
	return(gcd(b%a,a));
}
int main()
{
		ll n;
		cin>>n;
		ll arr[n];
		for(int i=0;i<n;i++)cin>>arr[i];
		ll ans=0;
		for(int i=1;i<n;i++){
			if(arr[i]<arr[i-1]){
				ans+=(arr[i-1]-arr[i]);
				arr[i]=arr[i-1];
			}
		}
		cout<<ans<<endl;
		
return(0);
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define maxn 200010
#define ll long long
using namespace std;
ll arr[maxn];
vector<pair<int, int> > vec;
int main()
{
	ios_base::sync_with_stdio(0);
	ll n; cin>>n;
	for (ll i = 0; i < n; ++i){
		cin>>arr[i];
		vec.push_back(make_pair(arr[i], i));
	}
	if(n == 1){
		cout<<"0\n";
		return 0;
	}
	sort(vec.begin(), vec.end());
	int max_streak = 0;
	int current_streak = 1;
	for (int i = 1; i < n; ++i)
	{
		if(vec[i - 1].second < vec[i].second ){
			current_streak++;
		}
		else
			current_streak = 1;
		max_streak = max(max_streak, current_streak);
	}
	cout<<n - max_streak<<endl;
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    vector<double> sum(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        sum[i] = p[i - 1] * (p[i - 1] + 1) / 2;
        sum[i] /= p[i - 1];
    }

    for (int i = 1; i <= N; i++) sum[i] += sum[i - 1];

    double ans = 0.0;
    for (int i = 0; i + K <= N; i++) {
        ans = max(ans, sum[i + K] - sum[i]);
    }

    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (h, w, n) = readIntegers()
    val map = hashMapOf<Point, Int>()
    for (i in 0 until n) {
        val (a, b) = readIntegers()

        if ((a in 2 until h) && (b in 2 until w)) {
            val point = Point(a, b)
            map[point] = map.getOrElse(point) { 0 } + 1
        }

        for (j in -1..1) {
            val row = a + j
            if (!(row in 2 until h)) {
                continue
            }

            for (k in -1..1) {
                val column = b + k
                if (!(column in 2 until w)) {
                    continue
                }

                if (j == 0 && k == 0) {
                    continue
                }

                val tmp = Point(row, column)
                map[tmp] = map.getOrElse(tmp) { 0 } + 1
            }
        }
    }

    val zeroCount = (h - 2).toLong() * (w - 2).toLong() - map.count()
    println(zeroCount)
    for (i in 1..9) {
        println(map.values.count { it == i })
    }
}

fun readStrings() = readLine()!!.split(" ")
fun readIntegers() = readStrings().map(String::toInt)

data class Point(val row: Int, val column: Int)


Measured memory_bytes: 162560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const ll INF = 1LL << 60;


int N;
int main(){
    cin >> N;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }

    string ans = "";
    while(N != 0) {
            int r = N % 2;
            r *= r;
            ans += (r ? '1' : '0');
            N = (N - r) / (-2);
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){
	//freopen("readme.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if(n%2 ==0) cout << n/2 << '\n';
	else cout << n/2 +1 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
struct Dice {
	int d[6], E, S, U;
	Dice(int a[]) {
		rep(i, 6)d[i] = a[i];
		E = 2; S = 1; U = 0;
	}
	void rotate(char C) {
		int a = E, b = S, c = U;
		switch (C) {
		case'E':E = U; U = 5 - a; break;
		case'N':U = S; S = 5 - c; break;
		case'S':S = U; U = 5 - b; break;
		case'W':U = E; E = 5 - c; break;
		case'R':S = E; E = 5 - b; break;
		case'L':E = S; S = 5 - a; break;
		}
	}
	int rotate(int a, int b) {
		rep(k, 2) {
			rep(i, 4) {
				rep(j, 4) {
					if (a == d[U] && b == d[S])return d[E];
					rotate('E');
				}
				rotate('S');
			}
			rotate('L');
		}
	}
	bool operator==(Dice b) {
		rep(k, 2) {
			rep(i, 4) {
				rep(j, 4) {
					if (b.d[b.U] == d[U] && b.d[b.S] == d[S] && b.d[b.E] == d[E] &&
						b.d[5 - b.U] == d[5 - U] && b.d[5 - b.S] == d[5 - S] && b.d[5 - b.E] == d[5 - E])
						return true;
					rotate('E');
				}
				rotate('S');
			}
			rotate('L');
		}
		return false;
	}
};
int main() {
	int a[6], b[6]; rep(i, 6)cin >> a[i]; rep(i, 6)cin >> b[i];
	Dice d(a), e(b);
	puts(d == e ? "Yes" : "No");
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, k, s[5100], ans;
ll dat[1100010];
void add(ll x, ll a) {
	x++;
	for (ll i = x; i <= 5100; i += i & -i) dat[i] += a;
}

ll sum(ll x) {
	if (x < 0)return 0;
	x++;
	ll res = 0;
	for (int i = x; i > 0; i -= i & -i) res += dat[i];
	return res;
}


bool dp[5100][5100]; //上限5001
int main() {
	cin >> n >> k;
	REP(i, n)cin >> s[i];
	dp[0][0] = 1;
	add(0, 1);
	REP(i, n) {
		REP(j, k + 1) {
			if (dp[i][j]) {
				dp[i + 1][j] = true;
				dp[i + 1][min((ll)5001, j + s[i])] = true;
			}
		}
	}
	REPR(i, n - 1) {
		bool ok = true;
		REP(j, k) {
			if (dp[i][j]) {
				if (sum(max(0ll, k - 1 - j)) - sum(k - s[i] - 1 - j) > 0) {
					ok = false;
				}
			}
		}
		if (ok)ans++;
		REPR(j, 5001) {
			if (sum(j) - sum(j - 1) > 0)add(min((ll)5001, j + s[i]), 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 26880
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else:
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a:
    print('Yes')
else:
    print('No')
        



Measured memory_bytes: 4596
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	REP(i, n - 1)v[i + 1] += v[i];
	ll ans = INF*INF;
	REP(i, n-1) {
		ans = min(ans, abs(v[n - 1] - 2*v[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
  int main(){
  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  int n,k;
  cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
  ll dp[n][k+1];
    memset(dp,0,sizeof(dp));
   for(int i=0;i<=a[n-1];i++)
     dp[n-1][i]=1;
    for(int i=0;i<n;i++)
      dp[i][0]=1;
    for(int i=n-2;i>=0;i--){
      for(int j=1;j<=a[i];j++)
        dp[i][j]=(dp[i][j-1]+dp[i+1][j])%mod;
      for(int j=a[i]+1;j<=k;j++)
        dp[i][j]=(dp[i][j-1]+dp[i+1][j]-dp[i+1][j-a[i]-1]+mod)%mod;
     }
                  cout<<dp[0][k]<<"\n";
  return 0;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    vector<int> A(3);
    rep(i,3)cin >> A[i];
    sort(A.begin(),A.end());
    cout << A[0]+A[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main()
{
    int k, n; cin >> k >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];    
    
    int maxDist = 0;
    for (int i = 0; i < n - 1; i++) {
        int tmpDist = a[i + 1] - a[i];
        chmax(maxDist, tmpDist);
    }
    int tmpDist = a[0] + (k - a[n - 1]);
    chmax(maxDist, tmpDist);

    cout << k - maxDist << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
	public static int Length(String[] a, String[] b) {
		int table[][] = new int [a.length+1][b.length+1];
		
		for (int i=0; i < a.length+1;i++) {
			for (int j=0; j<b.length+1; j++) {
				if (i==0 || j==0) {
					table[i][j] =0;
					
				}
				else if(a[i-1].equals(b[j-1])) {
					table[i][j] = table[i-1][j-1]+1;
				}
				else {
					table[i][j] = maxNum(table[i-1][j], table[i][j-1]);
				}
			}
		}
	
		return table[a.length][b.length];
	}
	
	public static int maxNum(int a, int b) {
		if (a>b) return a;
		else return b;
	}
	public static int minNum(int a, int b) {
		if(a<b) return b;
		else return a;
	}
	
	public static void main(String[] args) {
		// storing input as arrays
		Scanner s = new Scanner(System.in);
		int numSets = Integer.parseInt(s.nextLine());
		int answer[] = new int[numSets];
		for(int i=0; i < numSets;i++) {
			String[] a = s.nextLine().split("");
			String[] b = s.nextLine().split("");
			answer[i] = Length(a,b);
		}
		for (int j =0; j<numSets; j++) {
			System.out.println(answer[j]);
		}
	}
}


Measured memory_bytes: 61496
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n, m, k; cin >> n >> m >> k;
    FOR(i, 0, n) {
        FOR(j, 0, m) {
            ll tmp = i * m + j * n - 2 * i * j;
            if (tmp == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll m,n;
    cin>>n>>m;
    ll arr[n],sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        sum=sum+arr[i];
    }
    double x=(double)sum/(4*m);
    sort(arr,arr+n);
    if(arr[n-m]>=x)
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ll N, W;
ll w[101];
ll v[101];
ll dp[101][100010];

int main(){
    cin >> N >> W;
    for(ll i = 0; i < N; i++) cin >> w[i] >> v[i];
    for(ll i = N - 1; i>= 0; i--){
        for(ll j = 0; j <= W; j++){
            ll res = dp[i + 1][j];
            if(j - w[i] >= 0)
                res = max(res, dp[i + 1][j - w[i]] + v[i]);
            dp[i][j] = res;
        }
    }

    cout << dp[0][W] << endl;

    return 0;
}


Measured memory_bytes: 78336
import java.util.*;

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

		S = S.replaceAll("AAA","-");
		S = S.replaceAll("BBB","-");
		S = S.replaceAll("-","");
		if(S.length()==0){
			System.out.println("No");			
		} else {
			System.out.println("Yes");

		}

	}
}



Measured memory_bytes: 23892
#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;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int cost[3005], ok[3005][3005];
vector<int> g[N];
unordered_map<int, int> ans, vis;

void bfs(int s) {
    queue<int> q;
    vis.clear();
    vis[s] = 1;
    q.push(s);
    memset(cost, 0, sizeof cost);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g[u]) {
            if (vis[v] == 0) {
                q.push(v);
                vis[v] = 1;
                cost[v] = cost[u] + 1;
            } else if (cost[u] + 1 < cost[v]) {
                cost[v] = cost[u] + 1;
            }
        }
    }
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        g[i].push_back(i + 1);
        g[i +  1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    for (int i = 1; i <= n; i++) {
        bfs(i);
        for (int j = 1; j < n; j++) {
            if (ok[i][j] || ok[j][i]) {
                continue;
            }
            ans[cost[j]]++;
            ok[i][j] = ok[j][i] = 1;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 29184
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  ll ans = max(0ll, (C - (A - B)));

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


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

using namespace std;

typedef long long int llint;

int N, X, Y;

int main() {
	cin >> N >> X >> Y;
	vector<int> k(N - 1, 0);
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			int d;
			int d1 = j - i;
			int d2 = abs(X - i) + 1 + abs(j - Y);
			int d3 = abs(Y - i) + 1 + abs(j - X);
			d = min(d1, min(d2, d3));
			k[d-1]++;
		}
	}
	for (int i = 0; i < N - 1; i++) {
		cout << k[i] << endl;
	}
}

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

int main(){
  int H, W;
  
  while(1){
  	cin >> H >> W;
  	if ( H == 0 && W == 0 ) break;
  	
  	for ( int i = 0; i < H; i++ ){
  	  for ( int j = 0; j < W; j++ ){
  	  	if ( (i+j) % 2 == 0 ) cout << "#";
  	  	else cout << ".";
  	  }
  	  cout << endl;
  	}
  	cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n,i;
    cin >> n;
    vector<long long int> S(n+1);//ruisekiwa
    long long int a,b,c,ans=0;
    S.at(0)=0;
    for(i=0;i<n;i++){
        cin >> a;
        S.at(i+1) = S.at(i) + a;
    }
    sort(S.begin(),S.end());
    a=S.at(0);c=0;
    for(i=1;i<n+1;i++){
        b = S.at(i);
        if(b!=a){
            a = b;
            c = 0;
        }else{
            c++;
            ans += c;
        }   
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;++i)cin >> a[i];
    for (ll i = 1;i < n;++i)a[i] += a[i - 1];
    a.push_back(0);
    sort(a.begin(), a.end());
    ll ans = 0;
    ll cnt = 1;
    ll prev = 1e10;
    for (ll i = 0;i <= n;++i) {
        if (a[i] == prev) ++cnt;
        else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            prev = a[i];
        }
    }
    ans += cnt * (cnt - 1) / 2;
    cout << ans << endl;
}

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


#define INF 1000000000000


signed main()
 {
   int n;
   cin>>n;
   if(n<=999){cout<<"ABC";}
   else cout<<"ABD";
   
 }


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
INF = int(1e18)
ans = 1
for i in range(N):
  if(A[i]==0):
    print(0)
    exit()
for i in range(N):
  ans*=A[i]
  if(ans>INF):
    print(-1)
    exit()
print(ans)
  


Measured memory_bytes: 21780
n= int(input())
w=[]
w.append(input())
c=0
for i in range(n-1):
    s=input()
    if s not in w and w[i][len(w[i])-1] == s[0]:
        c+=1
        w.append(s)
    else:
        break
 
 
if c==n-1:
    print("Yes")
else:
    print ("No")

Measured memory_bytes: 3060
S = list(input().split('LR')) #map(lambda s:1 if s=='L' else -1, input().split())
lenS = len(S)
ret=""
for i in range(lenS):
  if lenS > 1:
    if i==0:
      S[i] = S[i]+'L'
    elif i==lenS-1:
      S[i] = 'R'+S[i]
    else:
      S[i] = 'R'+S[i]+'L'
  lenSi=len(S[i])
  r_count=S[i].count('R') 
  l_count=S[i].count('L')
  odd=(r_count+l_count) // 2
  even=odd
  if lenSi%2>0:
    odd += 1
  if r_count%2 > 0:
    r=odd
    l=even
  else:
    r=even
    l=odd
  tmp = [0]*lenSi
  tmp[r_count-1]=r
  tmp[r_count]=l
  ret += ' ' + ' '.join(str(e) for e in tmp)
print(ret)

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

signed main(){
	int n; cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
	if(n == 0 || n == 1 || n == 6|| n == 8) cout << "pon" << endl;
	if(n == 3) cout << "bon" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl
class UnionFind{
public:
	vector<int> par;
	//0-indexed
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		else par[x] = y;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N ,M ,ans = 0;
	cin >> N >> M;
	vector<ll> a(M),b(M);
	FOR(i,0,M)cin>>a[i]>>b[i];
	FOR(i,0,M){
		UnionFind uf;
		uf.init(N+1);
		FOR(j,0,M){
			if(j!=i)uf.unite(a[j],b[j]);
		}
		if(uf.root(a[i])!=uf.root(b[i]))ans++;
	}
	cout << ans << endl;
}


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

void f(string s,string t){
  vector<string> sv,sw,tv,tw;

  int j=0;
  string u;
  for(int i=0;i<s.size();i++){

    if(s[i]=='\"'){
      if(j%2){
        sw.PB(u);
      }
      else{
        sv.PB(u);
      }
      u="";
      j++;
    }
    else{
      u+=s[i];
    }
  }
  if(j%2){
    sw.PB(u);
  }
  else{
    sv.PB(u);
  }
  u="";
  j++;


  j=0;
  
  for(int i=0;i<t.size();i++){
    if(t[i]=='\"'){
      if(j%2){
        tw.PB(u);
      }
      else{
        tv.PB(u);
      }
      u={};
      j++;
    }
    else{
      u+=t[i];
    }
  }
  
  if(j%2){
    tw.PB(u);
  }
  else{
    tv.PB(u);
  }
  u="";
  j++;


  if(sv.size()!=tv.size()||sw.size()!=tw.size()){
    cout<<"DIFFERENT"<<endl;
    return;
  }

  for(int i=0;i<sv.size();i++){
    if(sv[i]!=tv[i]){
      cout<<"DIFFERENT"<<endl;
      return;
    }
  }

  int d=0;
  for(int i=0;i<sw.size();i++){
    if(sw[i]!=tw[i]){
      d++;
    }
  }

  if(d>1){
    cout<<"DIFFERENT"<<endl;
    return;
  }
  if(d==1){
    cout<<"CLOSE"<<endl;
    return;
  }

  cout<<"IDENTICAL"<<endl;
}




int main(){
  string s,t;
  while(true){
    cin>>s;
    if(s==".") break;
    cin>>t;
    f(s,t);
  }

}



Measured memory_bytes: 3036
from fractions import gcd
A, B, C, D = map(int, input().split())

both = C * D // gcd(C,D)

def hoge(n):
    c = n // C
    d = n // D
    cd = n // both
    non=  c + d - cd
    return n - non

up = hoge(B)
down  = hoge(A - 1)

ret = up - down
print(ret)



Measured memory_bytes: 63980
#include <stdio.h>

int main(void)
{
	static char prime[1000001];
	int i, j;
	int n;
	
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = 1;
	}
	prime[2] = 1;
	
	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = 0;
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		j = 0;
		for (i = 2; i <= n; i++){
			if (prime[i] == 1){
				j++;
			}
		}
		
		printf("%d\n", j);
	}
	
	return (0);
}

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

Measured memory_bytes: 52208
use proconio::input;
use proconio::marker::{Chars, Usize1};

fn main() {
    input! {
        h: usize,
        w: usize,
        c_h: Usize1,
        c_w: Usize1,
        d_h: Usize1,
        d_w: Usize1,
        s: [Chars; h]
    };

    let inf = 1_000_000_000_001_i64;
    let mut d = vec![vec![inf; w]; h];
    let mut pq = std::collections::BinaryHeap::new();
    pq.push(std::cmp::Reverse((0, c_h, c_w)));
    d[c_h][c_w] = 0;
    while let Some(std::cmp::Reverse((t_d, t_h, t_w))) = pq.pop() {
        if d[t_h][t_w] < t_d {
            continue;
        }

        let dhw = vec![(-1, 0), (0, -1), (0, 1), (1, 0)];
        for (d_h, d_w) in dhw.iter() {
            let u_h = t_h as i64 + d_h;
            let u_w = t_w as i64 + d_w;
            if (0..h as i64).contains(&u_h) && (0..w as i64).contains(&u_w) {
                let u_h = u_h as usize;
                let u_w = u_w as usize;
                let u_d = t_d;
                if s[u_h][u_w] == '.' && d[u_h][u_w] > u_d {
                    d[u_h][u_w] = u_d;
                    pq.push(std::cmp::Reverse((u_d, u_h, u_w)));
                }
            }
        }
        {
            let t_h = t_h as i64;
            let t_w = t_w as i64;
            for u_h in t_h - 2..=t_h + 2 {
                for u_w in t_w - 2..=t_w + 2 {
                    let u_d = t_d + 1;
                    if (0..h as i64).contains(&u_h) && (0..w as i64).contains(&u_w) {
                        let u_h = u_h as usize;
                        let u_w = u_w as usize;
                        if s[u_h][u_w] == '.' && d[u_h][u_w] > u_d {
                            d[u_h][u_w] = u_d;
                            pq.push(std::cmp::Reverse((u_d, u_h, u_w)));
                        }
                    }
                }
            }
        }
    }

    if d[d_h][d_w] == inf {
        println!("-1");
    } else {
        println!("{}", d[d_h][d_w]);
    }
}


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

struct City{int num,x,y;};
struct Edge{int u,v,cost;};

int N;
vector<City> city(111111);
vector<Edge> edge(222222);
vector<int> u_f(111111);
long long ans=0;

bool comp_x(const City& c1,const City& c2){
	if(c1.x!=c2.x) return c1.x<c2.x;
	else return c1.y<c2.y;
}

bool comp_y(const City& c1,const City& c2){
	if(c1.y!=c2.y) return c1.y<c2.y;
	else return c1.x<c2.x;
}

bool comp_cost(const Edge& e1,const Edge& e2){
	return e1.cost<e2.cost;
}

void init_unionfind(int N){
	for(int i=0;i<N;i++)u_f[i]=i;
}

int root(int a){
	if(u_f[a]==a)return a;
	else return u_f[a]=root(u_f[a]);
}

void unite(int a,int b){
	a=root(a);
	b=root(b);
	if(a==b)return;
	
	u_f[a]=b;
}

bool query(int a,int b){
	return root(a)==root(b);
}

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		int x,y;
		cin >> x >> y;
		city[i].num=i;
		city[i].x=x;
		city[i].y=y;
	}
	
	sort(city.begin(),city.begin()+N,comp_x);
	for(int i=0;i<N-1;i++){
		edge[i].u=city[i].num;
		edge[i].v=city[i+1].num;
		edge[i].cost=city[i+1].x-city[i].x;
	}
	
	sort(city.begin(),city.begin()+N,comp_y);
	for(int i=0;i<N-1;i++){
		edge[i+N-1].u=city[i].num;
		edge[i+N-1].v=city[i+1].num;
		edge[i+N-1].cost=city[i+1].y-city[i].y;
	}
	
	sort(edge.begin(),edge.begin()+N*2-2,comp_cost);
	
	init_unionfind(N);
	for(int i=0;i<2*N-2;i++){
		Edge e=edge[i];
		if(!query(e.u,e.v)){
			unite(e.u,e.v);
			ans+=e.cost;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){
    int k,a,b;
    bool flag=false;
    scanf("%d %d %d",&k, &a, &b);

    for(int i=a; i<=b; i++){
        if(i%k==0){
            flag=true;
            break;
        }
    }

    if(flag==true) printf("OK\n");
    else printf("NG\n");

    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
long long dp[51][2510];
int a[111];
int n, A;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> A;
	for(int i = 1; i <= n; i++) cin >> a[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int cnt = i; cnt >= 1; cnt--)
			for(int j = 0; j < 2510; j++)
				if(j >= a[i])
					dp[cnt][j] += dp[cnt - 1][j - a[i]];
	}
	long long ans = 0;
	for(int cnt = 1; cnt <= n; cnt++)
		ans += dp[cnt][A * cnt];
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,d;
    cin >> n >> d;
    int ans = n/(2*d + 1);
    if(n%(2*d+1))ans++;
    cout << ans << endl;  
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc134.contest.atcoder.jp/tasks/abc134_b

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)ans+=i;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
	string a;
 
  	cin >> a;
  	for(int n = 0; n < a.length() ;n++){
    	if(n % 2 == 0){
        	if(a[n] != 'h'){
              	cout << "No";
 				break;
            }
        }else{
            if(a[n] != 'i'){
              	cout << "No";
            	break;
            }
        }
     	if(n == a.length()-1 && n % 2 == 1){
     		cout << "Yes";
      	} else if (n == a.length()-1 && n % 2 == 0){
         	cout << "No";
        } 
    }	
	return 0;		 
}

Measured memory_bytes: 760