akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int a,b,c;
 cin>>a>>b>>c;
 swap(a,b);
 swap(a,c);
 cout<<a<<" "<<b<<" "<<c;
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3604
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
int low[MAX], dis[MAX];
int  a[MAX],vis[MAX];
vector<int>adj[MAX];
void dfs(int vertex, int par, int tim){
	dis[vertex]=low[vertex]=tim+1;
	int c=0;
	int f=0;
	vis[vertex]=1;
	for(int i=0;i<adj[vertex].size();i++){
		if(!vis[adj[vertex][i]]){
			c=c+1;
			dfs(adj[vertex][i],vertex,tim+1);
			low[vertex]=min(low[adj[vertex][i]], low[vertex]);
			if(par>=0&&dis[vertex]<=low[adj[vertex][i]])
				f=1;

		}
		else if(par!=adj[vertex][i])
			low[vertex]=min(low[vertex], dis[adj[vertex][i]]);
	}
	if(par==-1&&c>1)
		a[vertex]=1;
	if(f)
		a[vertex]=1;

}
int main(){
	int i,j,k ,n,m;
	cin>>n>>m;
	for(i=0;i<=n;i++){
		vis[i]=0;
		dis[i]=0;
		low[i]=0;
		a[i]=0;
	}
	while(m--){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(0,-1 ,0);
	for(i=0;i<n;i++){
		if(a[i])
			cout<<i<<"\n";
	}

}


Measured memory_bytes: 7068
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from bisect import bisect_left

def main():
  N_a, N_b, N_q = map(int, input().strip().split(' '))
  As = list(map(int, [input().strip() for _ in range(N_a)]))
  Bs = list(map(int, [input().strip() for _ in range(N_b)]))
  Qs = list(map(int, [input().strip() for _ in range(N_q)]))

  for q in Qs:
    min_a_l = -(2*(10**10)+1)
    min_b_l = -(2*(10**10)+1)
    min_a_r = 2*(10**10)+1
    min_b_r = 2*(10**10)+1
    a_index = bisect_left(As, q)
    if len(As) > a_index-1 >= 0:
      min_a_l = As[a_index-1] - q
    if a_index < len(As):
      min_a_r = As[a_index] - q

    b_index = bisect_left(Bs, q)
    if len(Bs) > b_index-1 >= 0:
      min_b_l = Bs[b_index-1] - q
    if b_index < len(Bs):
      min_b_r = Bs[b_index] - q

    score = min([
      min_a_r if min_a_r > min_b_r else min_b_r,
      abs(min_a_l) if min_a_l < min_b_l else abs(min_b_l),
      2*min_a_r + abs(min_b_l) if min_a_r < abs(min_b_l) else min_a_r + 2*abs(min_b_l),
      2*abs(min_a_l) + abs(min_b_r) if abs(min_a_l) < abs(min_b_r) else abs(min_a_l) + 2*abs(min_b_r)])
    print(score)

  pass

if __name__=='__main__':
  main()

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

int main(){
	ll n,z,w;
	cin >> n >> z >> w;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
	}
	ll ans;
	if(n == 1){
		ans = abs(a[0] - w);
	}else{
		ans = max(abs(a[n-1]-w), abs(a[n-1] - a[n-2]));
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// caddi2018b_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n, count = 0;
  cin >> n;
  while (n > 0) {
    if ((n % 10) == 2) count++;
    n /= 10;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 1) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

#define eb emplace_back
#define ld long double
#define ll long long

using namespace std;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int sum = 0;
	for (char x: s) {
		sum += x - '0';
	}
	cout << (sum % 9 == 0 ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  rep(bit, (1 << 3)){
    int ans = (int)(s[0] - '0');
    rep(i, 3){
      if(bit & (1 << i)){
	ans += (int)(s[i + 1] - '0');
      } else {
	ans -= (int)(s[i + 1] - '0');
      }
    }
    if(ans == 7){
      cout << s[0];
      rep(i, 3){
	if(bit & (1 << i)){
	  cout << '+';
	} else {
	  cout << '-';
	}
	cout << s[i + 1];
      }
      cout << "=7\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<P> c1; //fueru
  vector<P> c2; //heru
  int op=0;
  int cl=0;
  rep(i,n){
    string s; cin >> s;
    int m = s.size();
    int a=0, b=0;
    rep(j,m){
      if(s[j]=='('){
        a++; 
      } else {
        if(a==0){ b++; }else{ a--; }
      }
    }
    if(a==0&&b==0) continue;
    if(a==0){ cl+=b; continue; }
    if(b==0){ op+=a; continue; }
    if(a>=b){ c1.emplace_back(b,a); } else { c2.emplace_back(b,a-b); }
  }
  sort(c1.begin(),c1.end());
  sort(c2.rbegin(),c2.rend());
  for(auto it:c1){
    if(op>=it.F){
      op = op-it.F+it.S;
    } else {
      cout << "No" << endl; return 0;
    }
  }
  for(auto it:c2){
    if(op>=it.F){
      op = op+it.S;
    } else {
      cout << "No" << endl; return 0;
    }
  }
  if(op==cl){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 5296
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int maxn = 55;

int cal(ll x){
  int ret=0;
  while(x){
    x/=10;
    ret++;
  }
  return ret;
}

int main() {
 // freopen("in.cpp","r",stdin);
  ll n;
  cin>>n;
  int ret=1000000;
  for(int i=1;i*(ll)i<=n;i++){
    if(n%i!=0)continue;
    int tmp=max(cal(i),cal(n/i));
    ret=min(ret,tmp);
  }
  cout<<ret<<endl;
  return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(auto& it:a) cin>>it;
    sort(all(a));
    int sum=0;
    forn(i,k) sum+=a[i];
    cout<<sum;
    return 0;
}



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

int N;
const int MAX_N = 1.0e5 + 100;
map<int, int> mpA;

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

    int ans = 0;
    for (auto itr = mpA.begin(); itr != mpA.end(); itr++) {
        int val = itr->second;

        if (val % 2 == 1) ans++;
    }

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


Measured memory_bytes: 4992
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
typedef struct Node{
  int p,l,r;
    }Node;
Node T[MAX];
 
int depht(int);
void print_degree(int);
 
int main(){
 
  int n,i,j,node,degree,child,sibling;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&node,&degree);
    for(j = 0; j < degree; j++){
      scanf("%d",&child);
      T[child].p = node;
      if(j == 0)
        T[node].l = child;
      else
        T[sibling].r = child;
      sibling = child;
    }
  }
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    if(T[i].p == NIL)
      printf("root, [");
    else if(T[i].l == NIL)
      printf("leaf, [");
    else
      printf("internal node, [");
    print_degree(T[i].l);
    printf("]\n");
  }
 
  return 0;
}
 
  int depth(int node){
    if(T[node].p == NIL){
      return 0;
    } 
    else {
      return depth(T[node].p) + 1;
    }
  }
 
void print_degree(int i){
 
  if(i != NIL){
    if(T[i].r == NIL)
      printf("%d",i);
    else printf("%d, ",i);
  print_degree(T[i].r);
  }
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
struct edge{int to,cost;};
typedef pair<int,int> P;
int w,h;
char c[21][21];
bool visited[21][21];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool field(int x,int y){
    if(x>=0&&y>=0&&x<w&&y<h&&(!visited[y][x])&&(c[y][x]=='.')){
        return true;
    }
    return false;
}
void dfs(int x,int y){
    visited[y][x]=true;
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(field(nx,ny)){
            dfs(nx,ny);
        }
    }
    return;
}
int main(){
    while(cin>>w>>h,w+h){
        int sx,sy;
        for(int i=0;i<h;i++){
            cin>>c[i];
            for(int j=0;j<w;j++){
                if(c[i][j]=='@'){
                    sx=j;
                    sy=i;
                }
            }
        }
        int ans=0;
        dfs(sx,sy);
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(visited[i][j]){
                    ans++;
                    visited[i][j]=false;
                }
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3036
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long int lli;
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << fixed << setprecision(10) << 0.5 << endl;
	}
	else {
		cout << fixed << setprecision(10) << ((double)(n / 2 + 1)) / (double)n << endl;
	}

	return 0;
}

Measured memory_bytes: 256
num=int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

line=prime_factorize(num)
value=0
time=1
ans=0


while len(line)>0:
  value1=line[0]
  if value1!=value:
    num=num/value1
    value=value1
    del line[0]
    time=1
    ans+=1
    
    
  else:
    time+=1
    if line.count(value)<time:
      del line[0:line.count(value)]
      continue
      
    value1=value**time
    num=num/value1
    del line[0:time]
    ans+=1

print(ans)

Measured memory_bytes: 9244
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
    	int H2 = sc.nextInt();
        int M2 = sc.nextInt();
      	int K = sc.nextInt();
      	int min = (H2 * 60 + M2) - (H1 * 60 + M1) -K;
        System.out.println(min);
    }
}

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

int main()
{
    int p[5][5][4];
    for (int i = 0; i < 5; i++)
        for (int j = 0; j < 5; j++ )
            for (int k = 0; k < 4; k++) p[i][j][k] = 0;
    string s;
    for (int i = 0; i < 4; i++) {
        cin >> s;
        for (int j = 0; j < 4; j++) {
            if (s[j] == '1') {
                p[i][j][1] = p[i][j+1][3] = 1;
            }
        }
        cin >> s;
        for (int j = 0; j < 5; j++) {
            if (s[j] == '1') {
                p[i][j][2] = p[i+1][j][0] = 1;
            }
        }
    }
    cin >> s;
    for (int j = 0; j < 4; j++) {
        if (s[j] == '1') {
            p[4][j][1] = p[4][j+1][3] = 1;
        }
    }
    string DIR = "URDL";
    int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
    int px = 0, py = 1, dir = 1;
    cout << "R";
    int q = 0;
    while ((px != 0 || py != 0) && q++ < 40) {
        for (int i = 0; i < 4; i++) {
            if (p[px][py][(((dir + 3) % 4) + i) % 4] == 1) {
                dir = (((dir + 3) % 4) + i) % 4;
                px += dx[dir];
                py += dy[dir];
                cout << DIR[dir];
                break;
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1180
n = int(input())
answer = n

i = 2
while i ** 2 <= n:
    if n % i == 0:
        answer *= (1 - 1 / i)

        while n % i == 0:
            n //= i

    i += 1

if n != 1:
    answer *= (1 - 1 / n)

print(int(answer))



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
long long a,n,m,k,s=0,p,ar[10001],ar1[10001],i,j,c=0,r,t;
int main()
{
	cin>>a;
	long long mn=0,mx=0;
	for(i=0;i<a;i++)
		cin>>ar1[i];
	for(i=0;i<a;i++)
	{
		if(ar1[i]>=1 && ar1[i]<=399) ar[0]++;
		if(ar1[i]>=400 && ar1[i]<=799) ar[1]++;
		if(ar1[i]>=800 && ar1[i]<=1199) ar[2]++;
		if(ar1[i]>=1200 && ar1[i]<=1599) ar[3]++;
		if(ar1[i]>=1600 && ar1[i]<=1999) ar[4]++;
		if(ar1[i]>=2000 && ar1[i]<=2399) ar[5]++;
		if(ar1[i]>=2400 && ar1[i]<=2799) ar[6]++;
		if(ar1[i]>=2800 && ar1[i]<=3199) ar[7]++;
		if(ar1[i]>=3200) ar[8]++;
	}
	for(i=0;i<8;i++)
	{
		if(ar[i]>1) ar[i]=1;
		mn=ar[i]+mn;
	}
	
	if(ar[8]>1 || ar[8]==0) mx=ar[8]+mn;
	else 
	{
		mx=mn+ar[8];
	}
	if(mn==0) mn++;
	cout<<mn<<" "<<mx;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
   ll n; cin >> n;
   ll a[n+1];
   ll c = 0;
    for(ll i = 0; i < n; i++)  cin >> a[i];
   sort(a, a+n);
   for(ll i = 0; i < n; i++) {
    for(ll j = i+1; j < n; j++) {
        for(ll k = j + 1; k < n; k++) {

            if((a[i] + a[j]) > a[k] && (a[i] != a[j] && a[j] != a[k] && a[k] != a[i])) c++;
        }
    }
   }

   cout << c << endl;
        return 0;

}


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

int main()
{
    int n, k;
    cin >> n >> k;
    bool b[102]{0};
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            a--;
            b[a] = true;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) if(!b[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3648
#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 ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

typedef pair<double, int> pdi;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

double x[1002], y[1002], r[1002];
double d[1002];
int n;

int main() {
	REP(i, 2) {
		scanf("%lf %lf", x + i, y + i);
		r[i] = 0;
	}
	
	cin >> n;
	FOR(i, 2, n + 2) scanf("%lf %lf %lf", x + i, y + i, r + i);
	
	fill(d, d + n + 2, 1e11);
	
	priority_queue<pdi, vector<pdi>, greater<pdi> > pq;
	pq.push(pdi(0, 0));
	d[0] = 0;
	
	while (!pq.empty()) {
		pdi now = pq.top(); pq.pop();
		
		double cost = now.first;
		int pos = now.second;
		
		if (d[pos] < cost) continue;
		
		REP(i, n + 2) {
			if (i == pos) continue;
			double nextcost = cost + max<double>(0, hypot(x[pos] - x[i], y[pos] - y[i]) - (r[pos] + r[i]));
			
			if (d[i] <= nextcost) continue;
			pq.push(pdi(nextcost, i));
			d[i] = nextcost;
		}
	}
	
	printf("%.15lf\n", d[1]);
	
	return 0;
}

Measured memory_bytes: 5616
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N, M;
    
    void Solve()
    {
        N = cin.Nextint;
        M = cin.Nextint;
        var G = Enumerable.Range(0, N).Select(i => new List<int>()).ToArray();
        for (int i = 0; i < M; i++)
        {
            int a = cin.Nextint - 1;
            int b = cin.Nextint - 1;
            G[a].Add(b);
            G[b].Add(a);
        }

        bool flag = false;
        foreach (var v in G[0])
        {
            foreach (var u in G[v])
            {
                if (u == N - 1) flag = true;
            }
        }

        if (flag)
        {
            WriteLine("POSSIBLE");
        }
        else
        {
            WriteLine("IMPOSSIBLE");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  if (B < K) {
    cout << "NG" << endl;
  }
  else if (A % K == 0) {
    cout << "OK" << endl;
  }
  else if(A / K != B / K) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve(void)
{
  int row,col;
  cin>>row>>col;
  vector<vector<int> > data(row,vector<int>(col,0));
  for (int i = 0; i < row; i++)
  {
    for (int j = 0; j < col; j++)
    {
      cin>>data[i][j];
    }
  }

  vector<vector<int> > data_o(row + 1,vector<int>(col + 1,0));

  int sum = 0;
  for (int i = 0; i < row; i++)
  {
    for (int j = 0; j < col; j++)
    {
       sum+=data[i][j];
    }
    data_o[i][col] = sum;
    sum = 0;
  }
    for (int j = 0; j < col; j++) 
  {
     for (int i = 0; i < row; i++)
    {
       sum+=data[i][j];
    }
    data_o[row][j] = sum;
    sum = 0;
  }
  
  for (int i = 0; i < row; i++)
  {
    sum+=data_o[i][col];
  }
  
  for (int i = 0; i < row; i++)
  {
    for (int j = 0; j < col; j++)
    {
      data_o[i][j] = data[i][j];
    }
    
  }
  
  data_o[row][col] = sum;

  for (int i = 0; i <= row; i++)
  {
    for (int j = 0; j <= col; j++)
    {
      cout<<data_o[i][j];
      if(j != col)cout<<" ";
    }
    cout<<endl;
  }
  
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3208
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
string s;
cin>>s;
if(s=="ABC")
{
    cout<<"ARC"<<endl;
}else
{
    cout<<"ABC"<<endl;
}
return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, M;
  string S;
  cin >> N >> M >> S;
  vector<ll> vec;
  for (ll i = 0; i < N + 1; i++) {
    if (S[i] == '0') vec.push_back(i);
  }
  ll current = N;
  vector<ll> ans;
  while (current > 0) {
    ll tmp = current - M;
    tmp = max(tmp, 0ll);
    auto it = lower_bound(vec.begin(), vec.end(), tmp);
    ll can_jump = *it;
    if (can_jump == current) {
      cout << -1 << endl;
      return;
    }
    ans.push_back(current - can_jump);
    current = can_jump;
  }
  reverse(ans.begin(), ans.end());
  bool flag = false;
  for (auto it: ans) {
    if (flag) cout << ' ';
    flag = true;
    cout << it;
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2628
#include "iostream"

using namespace std;

const int N = 2e5 + 5;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int res = 0;
  for (int r = 0; r <= 3000; r ++) {
    for (int g = 0; g <= 3000; g++) {
        int rem = N - r * R - g * G;
        if (rem < 0) break;
        if (rem % B == 0) res ++;
    }
  }

  printf("%d\n", res);
}

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

int M,N,K,D;
int cal[6];

#define HE (M)
#define CH (M+1)
#define pb push_back
#define INF (1<<24)

class Edge
{
public:
	int u,v,c;
	Edge(int u, int v, int c)
	:u(u),v(v),c(c)
	{}
};



int toNum(string s)
{
	if(s[0]=='H') return HE;
	else if(s[0]=='D') return CH;
	else
	{
		string d=s;
		s.assign(s.begin()+1, s.end());
		istringstream ss(s);
		int t;
		ss >> t;
		if(d[0]=='C') return t-1;
	
		return t+M+1;
	}
}

int main()
{
	while(cin >> M >> N >> K >> D, (M||N||K||D))
	{
		vector<Edge> eg;
		
		for(int i=0; i<M; i++)
			cin >> cal[i];
			
		for(int i=0; i<D; i++)
		{
			string a,b;
			int s,d,c;
			cin >> a >> b >> c;
			s=toNum(a); d=toNum(b);
			
			eg.pb(Edge(s,d,c*K));
			eg.pb(Edge(d,s,c*K));
		}
		
		int dist[300][(1<<6)];
		for(int i=0; i<(1<<M); i++)
		for(int j=0; j<M+N+2; j++)
			dist[j][i]=INF;
			
		dist[HE][0]=0;
		
		while(1)
		{
			bool update=false;
			for(int i=0; i<eg.size(); i++)
			for(int j=0; j<(1<<M); j++)
			{
				Edge e=eg[i];
				if(dist[e.u][j]==INF) continue;
				if(e.v<M)
				{
					if(j&(1<<e.v)) continue;
					
					if(dist[e.u][j]+e.c-cal[e.v] < dist[e.v][j|(1<<e.v)])
					{
						update=true;
						dist[e.v][j|(1<<e.v)]=dist[e.u][j]+e.c-cal[e.v];
					}
				}
				else
				{
					if(dist[e.u][j]+e.c < dist[e.v][j])
					{
						update=true;
						dist[e.v][j]=dist[e.u][j]+e.c;
					}
				}
			}
			
			if(!update) break;
		}
		
		int ans=INF;
		for(int i=0; i<(1<<M); i++)
			ans=min(ans, dist[CH][i]);
			
		cout << ans << endl;
	}
}

Measured memory_bytes: 980
n, m = map(int, input().split())
h_list = [[int(h), []] for h in input().split()]
for i in range(m):
    a, b = map(int, input().split())
    h_list[a - 1][1].append(b - 1)
    h_list[b - 1][1].append(a - 1)
ans = 0
for h in h_list:
    if all([h[0] > h_list[h_][0] for h_ in h[1]]):
        ans += 1
print(ans)

Measured memory_bytes: 37224
#define P(b,c)(x[b]*x[1+c]-x[1+b]*x[c])
float s,t,x[];main(i){for(;~scanf("%f,",&s);i-9||memset(x,!puts((s=P(3,5))*(t=P(5,7))&&P(1,3)*s>0&t*P(7,1)>0?"YES":"NO",i=1),36))x[i]+=s,x[++i%8+1]-=s;}

Measured memory_bytes: 0
x =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[int(input())-1])

Measured memory_bytes: 3060
#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 main(){

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = a * c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
import sys
from collections import deque

sys.setrecursionlimit(10**9)

N, Q = map(int, input().split())
tree = [[] for _ in range(N)]
ans = [0]*N
queue = deque()

for _ in range(N-1):
    aa, bb = map(int, input().split())
    tree[aa-1].append(bb - 1)
    tree[bb-1].append(aa - 1)


for _ in range(Q):
    q, x = map(int, input().split())
    ans[q-1] += x

# def DFS(x, pre):
#     global ans
#     for i in tree[x]:
#         if i==pre:
#             continue
#
#         ans[i] += ans[x]
#         DFS(i, x)
#
#     return
#
# for _ in range(Q):
#     q, x = map(int, input().split())
#     ans[q-1] += x

def DFS(x, pre):
    global ans
    for i in tree[x]:
        if i==pre:
            continue

        ans[i] += ans[x]
        queue.append((i, x))

queue.append((0, -1))
while queue:
    DFS(*queue.pop())

for x in ans:
    print(x)



Measured memory_bytes: 103372
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    int w = a*7+b;
    int ans = c/w;
    int sum = ans*w;
    ans *= 7;
    rep(i,7)if(sum < c){
        ans++;
        sum += a;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
ans = "Yes"
for _ in range(N):
    t, x, y = map(int, input().split())
    if t - prev_t < abs(prev_x - x) + abs(prev_y - y):
        ans = "No"
    if (abs(prev_x - x) + abs(prev_y - y)) % 2 != (t - prev_t) % 2:
        ans = "No"
    prev_t, prev_x, prev_y = t, x, y
print(ans)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template<class T,class E> struct LSeg{
    typedef function<T(T,T)> F;
    typedef function<T(T,E)> G;
    typedef function<E(E,E)> H;
    typedef function<E(E,int)> P;
    int n;F f;G g;H h;T et;E ee;P p;
    vector<T> dat;
    vector<E> lazy;
    LSeg(int n_,F f_,G g_,H h_,T et_,E ee_,P p_=[](E a,int b){return a;}){
        f=f_;g=g_;h=h_;et=et_;ee=ee_;p=p_;
        n=1;
        while(n<n_) n*=2;
        dat.resize(2*n-1,et);
        lazy.resize(2*n-1,ee);
    }
    inline void prop(int k,int l,int r){
        if(lazy[k]==ee) return;
        if(r-l>1){
            lazy[k*2+1]=h(lazy[k*2+1],lazy[k]);
            lazy[k*2+2]=h(lazy[k*2+2],lazy[k]);
        }
        dat[k]=g(dat[k],p(lazy[k],r-l));
        lazy[k]=ee;
    }
    T ud(int be,int en,E t,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return dat[k];
        if(be<=l&&r<=en){
            lazy[k]=h(lazy[k],t);
            return g(dat[k],p(lazy[k],r-l));
        }
        return dat[k]=f(ud(be,en,t,k*2+1,l,(l+r)/2),ud(be,en,t,k*2+2,(l+r)/2,r));
    }
    T ud(int be,int en,E t){
        ud(be,en,t,0,0,n);
    }
    T gt(int be,int en,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return et;
        if(be<=l&&r<=en) return dat[k];
        T vl=gt(be,en,k*2+1,l,(l+r)/2),vr=gt(be,en,k*2+2,(l+r)/2,r);
        return f(vl,vr);
    }
    T gt(int be,int en){
        return gt(be,en,0,0,n);
    }
};

template<class T> void cc(vector<T> a,map<T,int>& nm,vector<int>& c){
    sort(a.begin(),a.end());
    fr(i,a.size()){
        if(i<a.size()-1&&a[i]==a[i+1]) continue;
        nm[a[i]]=c.size();
        c.pb(a[i]);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N=0,M,q,A,B,C;
    map<ll,int> nm;vector<ll> a;vector<int> c;
    cin>>M>>q;
    vector<ll> d(q);
    vector<pair<ll,pair<ll,ll>>> xst;
    fr(i,M){
        cin>>A>>B>>C;
        if(B<C) continue;
        if(A<C) A=C;
        xst.emplace_back(C,mp(A,B));
        if(A>C) a.pb(A-C);
        a.pb(B-C);
        N++;
    }
    fr(i,q){
        cin>>d[i];
        a.pb(d[i]);
    }
    a.pb(0);
    sort(a.begin(),a.end());
    cc(a,nm,c);
    auto mn=[](int a,int b){return min(a,b);};
    LSeg<int,int> sg(c.size(),mn,mn,mn,INT_MAX,INT_MAX);
    fr(i,N){
        sg.ud(nm[-(xst[i].ft-xst[i].sd.ft)],nm[-(xst[i].ft-xst[i].sd.sd)],xst[i].ft);
    }
    fr(i,q){
        ll ans=sg.gt(nm[d[i]],nm[d[i]]+1);
        if(ans==INT_MAX) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 71112
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int N;
P red[100], blue[100];

int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        red[i] = P(a, b);
    }
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        blue[i] = P(a, b);
    }

    sort(red, red + N);
    sort(blue, blue + N);

    int res = 0;
    bool used[100] = {0};
    for(int i = 0; i < N; i++){
        int right = lower_bound(red, red+N, blue[i]) - red;
        int max = -1, max_num = -1;
        for(int j = 0; j < right; j++){
            if(used[j]) continue;
            if(red[j].second < blue[i].second and red[j].second > max){
                max = red[j].second;
                max_num = j;
            }
        }
        if(max_num != -1){
            used[max_num] = true;
            res++;
        }
    }
    
    cout << res << '\n';

    return 0;
}

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

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;


int x, a, b;
int main() {
    cin >> x >> a >> b;
    if (b <= a) {
        cout << "delicious" << endl;
    } else if (b - a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

using namespace std;

int main() {

    int n = 3;
    int a[4];
    string s; cin >> s;
    rep(i,4) a[i]  = (int)(s[i]-'0');
    int cal = 0;
    char e[3];

    for(int bit = 0; bit < (1<<3); ++bit){
        cal = a[0];
        for(int i = 0; i < n; i ++){
            if(bit & (1 << i)){
                e[i] = '+';
                cal += a[i+1];
            }else{
                e[i] = '-';
                cal -= a[i+1];
            }
        }
        if(cal == 7){
            break;
        }
    }

    cout << a[0] << e[0] << a[1] << e[1] << a[2] << e[2] << a[3] << "=7";
    return 0;
}











Measured memory_bytes: 3640
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
int a, b, c, d;
int dp[1003][1003];
LL MOD = 1000000007;
LL ncr[1003][1003];
LL ifact[1003];

LL bigmod(LL a, LL n) {
	if (n == 0) return 1;
	LL x = bigmod(a, n / 2);
	x *= x;
	x %= MOD;
	if (n & 1) x = (x * a) % MOD;
	return x;
}

int DP(int n, int sz) {
	if (n == 0) return 1;
	if (sz > b) return 0;
	int &ret = dp[n][sz];

	if (ret != -1) return ret;

	ret = 0;
	ret = DP(n, sz + 1);
	if (sz * c > n) return ret;

	LL now = 1;
	for (int i = 1; i < c; i++) {
		now = (now * ncr[n - sz * (i - 1)][sz]) % MOD;
	}
	for (int i = c; i <= d; i++) {
		if (sz * i > n) break;
		now = (now * ncr[n - sz * (i - 1)][sz]) % MOD;
		LL z = (DP(n - sz * i, sz + 1) * now) % MOD;
		z = (z * ifact[i]) % MOD;
		ret += z;
		ret %= 1000000007;
	}
	return ret;
}

int main()
{
	ifact[0] = ifact[1] = 1;
	for (int i = 2; i <= 1000; i++) {
		ifact[i] = (ifact[i - 1] * bigmod(i, MOD - 2)) % MOD;
	}
	ncr[0][0] = 1;
	int limncr = 1000;
	for (int i = 1; i <= limncr; i++)
		for (int j = 0; j <= limncr; j++)
		{
			if (j>i) ncr[i][j] = 0;
			else if (j == i || j == 0) ncr[i][j] = 1;
			else ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % MOD;
		}

	scanf("%d", &n);
	scanf("%d %d %d %d", &a, &b, &c, &d);
	MEM(dp, -1);
	int ans = DP(n, a);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 12160
#include <stdio.h>
 
int main() {
  int num[5];
  int i, j;
  int temp;
  for(i = 0; i < 5; i++) {
    scanf("%d", &num[i]);
  }
  for(j = 0; j < 5; j++) {
    for(i = 4; i > j; i--) {
      if(num[i] > num[i-1]) {
    temp = num[i-1];
    num[i-1] = num[i];
    num[i] = temp;
      }
    }
  }
  for(i = 0; i < 5; i++) {
    printf("%d", num[i]);
    if(i < 4) printf(" ");
  }
  printf("\n");
  return 0;
}

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

using namespace std;

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

int g(int a, int b){return b ? g(b, a % b) : a;}

int main(){
  int n;
  cin >> n;
  uint64_t r = 0;
  REP(i, n) REP(j, n) REP(k, n){
    r += g(g(i + 1, j + 1), k + 1);
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3632
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		int n,y;
		n = int.Parse(s[0]);
		y = int.Parse(s[1]);
		
		int[] c = new int[n];
		int[] t = new int[n];
		for (int i = 0; i < n; i++){
			s = Console.ReadLine().Trim().Split(' ');
			c[i] = int.Parse(s[0]);
			t[i] = int.Parse(s[1]);
		}
		
		int ans = 0;
		Array.Sort(c, t);
		bool f = false;
		for (int i = 0; i < n; i++){
			if(!f){
				if(t[i]<=y){
					f = true;
					ans = c[i];
				}
			}
		}
		
		if(f) Console.WriteLine(ans);
		if(!f) Console.WriteLine("TLE");
	}
}


Measured memory_bytes: 11220
import Foundation

func main(){
   let n = Int(readLine()!)!
   let line = readLine()!.split(separator: " ")
   
   let s = Array(line[0])
   let t = Array(line[1])
   
   var answer = ""
   for i in 0..<n {
      answer += "\(s[i])\(t[i])"
   }
   print(answer)
}
main()

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

int cnt[33];

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	string s; cin >> s;
	for(auto &x: s) cnt[x - 'A']++;
	for(int i = 0; i < 26; i++) {
		if(cnt[i] != 0 && cnt[i] != 2) {
			cout << "No\n";
			exit(0);
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long
using namespace std;
 
int main(int argc, const char *argv[]) {
  long int N, A, B;
  long int blue = 0;
  cin >> N >> A >> B;
 
  if(A == 0){
    cout << 0 << endl;
    return 0;
  }
  blue = (N / (A + B)) * A;
  if(N % (A + B) <= A){
    blue += (N % (A + B));
  }else{
    blue += A;
  }
  cout << blue << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    cin >> n;
    pair<P,ll> p[n];
    ll time[n] = {},memo = 0;

    rep(i,0,n){
        ll a,b;
        cin >> a >> b;
        p[i] = pair<P,ll>(P(b,a),i);
    }

    sort(p,p+n);

    rep(i,0,n){
        time[p[i].sc] = (memo += p[i].fs.sc);

    }

    rep(i,0,n){
        if(time[p[i].sc] > p[i].fs.fs){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
using namespace std;
int n,m=2000000;
int sum(int a)
{
    int b=0;
    while(a>0)
    {
        b+=a%10;
        a/=10;
    }
    return b;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n/2;i++)
        m=min(m,sum(i)+sum(n-i));
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];
// char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;
	ull result;
	const size_t len = strlen(s);

	result = len * (len - 1);
	for (i = 0; i < len - 1; i++) {
		if (s[i] == 'U') {
			result += i;
		} else {
			result += (len - i - 1);
		}
	}

	printf("%llu\n", result);

	return 0;
}
 
int main(void){
	int i, j;
	const int x[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
 
	scanf("%d%d", &i, &j);

	// solve();

	if (x[i] == x[j]) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 128