akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr long long INF = 1e18;
 
signed main(){
	string t,s = "0";
	cin >> t;
	s += t;
	vector<vector<int>>dp(s.size()+1,vector<int>(2,INF));
	dp[0][0] = 0;
	REP(i,s.size()){
		CHMIN(dp[i+1][0],dp[i][0] + (s[i] - '0'));
		CHMIN(dp[i+1][0],dp[i][1] + 9 - (s[i] - '0')+1);
		CHMIN(dp[i+1][1],dp[i][0] + (s[i] - '0') + 1);
		CHMIN(dp[i+1][1],dp[i][1] + 9 - (s[i] - '0') + (i == s.size()-1));
	}
	out(min(dp[s.size()][0],dp[s.size()][1]));
}
/*
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr long long INF = 1e18;
 
signed main(){
	string t,s = "0";
	cin >> t;
	s += t;
	vector<vector<int>>dp(s.size()+1,vector<int>(2,INF));
	dp[0][0] = 0;
	REP(i,s.size()){
		CHMIN(dp[i+1][0],dp[i][0] + (s[i] - '0'));
		CHMIN(dp[i+1][0],dp[i][1] + 10 - (s[i] - '0'));
		CHMIN(dp[i+1][1],dp[i][0] + (s[i] - '0') + 1);
		CHMIN(dp[i+1][1],dp[i][1] + 10 - (s[i] - '0') - 1);
	}
	out(min(dp[s.size()][0],dp[s.size()][1]));
}*/

Measured memory_bytes: 56836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	map<int,int> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	int cnt=0;
	int ans=mp.size();
	for(auto itr:mp){
		if(itr.se%2==0) cnt++;
	}
	if(cnt%2==0) cout<<ans<<endl;
	else cout<<ans-1<<endl;
}

Measured memory_bytes: 5376
#include<stdio.h>

int main(void)
{
  int a,b,n,sum=0,i,j,min=99999999;
  scanf("%d",&n);
  for(j=1;j<n/2+1;j++)
    {
      a = j;
      b = n - a;
      sum = 0;
      for(i=0;i<6;i++)
	{
	  sum += (a%10)+(b%10);
	  a /= 10;
	  b /= 10;
	}
      if(min > sum)
	{
	  min = sum;
	}
    }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a*b%2 == 0){
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  //入力終了

  //答えは，必ず2の冪乗になることに注目する
  int n;
  for(n=N; n>0; n--){
    int tmp = n;
    //偶数である間割り続ける
    while(tmp%2 == 0 && tmp>=0)
      tmp /= 2;
    
    //2^0までたどり着けば終了
    if(tmp == 1)
      break;
  }

  //解答
  cout << n << endl;

  return 0;
}


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

int main(){
  string S; cin >> S;
  
  bool jud = true;
  
  if(S[0] == S[1]){
    jud = false;
  }
  else if(S[1] == S[2]){
    jud = false;
  }
  else if(S[2] == S[3]){
    jud = false;
  }
  
  if(jud){
    cout << "Good" << endl;
  }
  
  else{
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    rep(i, 1000) {
        int cnt = 0;
        int x = i;
        string t;
        rep(j, 3) {
            t += '0' + x % 10;
            x /= 10;
        }
        rep(j, n) {
            if(t[cnt] == s[j]) cnt++;
        }
        if(cnt >= 3) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

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

using namespace std;

int main(void) {
	int N; cin >> N;
	ll ans = 0;

	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define P 1000000007
using namespace std;

int powmp(long long x,long long n){
	const long long p = 1000000007;
	if(n==0) return 1;
	long long y = x%p;
	if(n==1) return y;
	long long tmp = (powmp(y,n/2))%p;
	if(n%2==0) return (tmp*tmp)%p;
	else return (powmp(y,n-1)*y)%p;
}

int main(int argc, char const *argv[])
{
	bool bo = false;
	int n,m,k;
	cin >> n >> m >> k;
	REP(a,n+1){
		REP(b,m+1){
			if(b*n+a*m-2*a*b==k) bo = true;
		}
	}
	if(bo)cout << "Yes"<<"\n";
	else cout << "No"<<"\n";
	return 0;
}	

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val l = sc.nextInt()
    val r = sc.nextInt()
    val d = sc.nextInt()
    println(problem2020a(l, r, d))
}

fun problem2020a(l: Int, r: Int, d: Int): Int {
    var count = 0
    for (i in l..r) {
        if (i % d == 0) count++
    }
    return count
}

Measured memory_bytes: 36364
# -*- coding: utf-8 -*-
import sys
# from collections import defaultdict, deque
# from math import sqrt, gcd, factorial, tan, pi, sin, cos
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = [x for x in input()]
    t = [x for x in input()]
    n = len(s)
    m = len(t)
    l = -1
    for i in range(n - m + 1):
        ok = 1
        for j in range(m):
            if s[i+j] != t[j] and s[i+j] != '?':
                ok = 0
        if ok:
            l = i
    if l == -1:
        print("UNRESTORABLE")
    else:
        for j in range(m):
            s[j+l] = t[j]
        for i in range(n):
            if s[i] == '?':
                s[i] = 'a'
        
        print(''.join(s))



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)

"""



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

ll md=1e9+7;

struct mat_exp{
    vector<vector<ll>> mat;
    vector<vector<ll>> iden;
    ll mod=1;
    int n;
    void init(vector<vector<ll>> mt,ll md=1){
        mod=md;
        mat=mt;
        n=mt.size();
        iden.resize(n,vector<ll> (n,0));
        for(int i=0;i<n;i++){
            iden[i][i]=1;
        }
    }

    void add_self(ll &a,ll b){
        a+=b;
        if(a>=mod)a-=mod;
    }

    ll mul_self(ll a,ll b){
        a=(a*b)%mod;
        return a;
    }

    vector<vector<ll>> matmul(vector<vector<ll>> a,vector<vector<ll>> b){
        vector<vector<ll>> ret(n,vector<ll> (n,0));
        debug(ret);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    add_self(ret[i][j],mul_self(a[i][k],b[k][j]));
                }
            }
        }
        return ret;
    }

    vector<vector<ll>> exponentiate(ll exp){
        if(exp==1){
            return mat;
        }
        vector<vector<ll>> resid=iden;
        if(exp%2){
            resid=mat;
        }
        vector<vector<ll>> bin=exponentiate(exp/2);
        bin=matmul(bin,bin);
        //debug(bin,"Done_2");
        return matmul(resid,bin);
    }
};

int main(){
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vector<vector<ll>> adj(n,vector<ll> (n));
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>adj[i][j];
    mat_exp mt;
    mt.init(adj,1e9+7);
    vector<vector<ll>> an=mt.exponentiate(k);
    debug(an);
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            mt.add_self(ans,an[i][j]);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5000
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        var answer = 0;
        for (int i = N - 1; i >= 0; i--)
            if (i % 2 == 0) answer += a[i];
            else answer -= a[i];
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27456
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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 pair<int, int> P;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> to(N);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    to[u].push_back(v);
  }
  int S, T;
  cin >> S >> T;
  S--; T--;
  vector<vector<int>> node(N, vector<int>(3, -1));
  node[S][0] = 0;
  queue<P> que;
  que.push({S, 0});
  while(!que.empty()) {
    int a, b;
    tie(a, b) = que.front();
    que.pop();
    int next = (b+1)%3, cost = (next ? 0 : 1);
    for(const int& e : to[a]) {
      if(node[e][next] == -1) {
        node[e][next] = node[a][b]+cost;
        que.push({e, next});
      }
    }
  }
  cout << node[T][0] << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

const ll MAX_V = 50;
const ll MAX_S = MAX_V*50+5;

struct Edge {
    ll to, a, b;
    Edge(ll to, ll a, ll b):to(to),a(a),b(b) {}
};

struct Data {
    ll v, s, x;
    Data(ll v, ll s, ll x):v(v),s(s),x(x) {}
    bool operator<(const Data& a) const {
        return x > a.x;
    }
};

int main() {
    ll n, m, s;
    cin >> n >> m >> s;
    chmin(s, MAX_S);
    
    vector<vector<Edge>> G(MAX_V);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;  v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    
    vvl dp(MAX_V, vl(MAX_S+10, INF));
    priority_queue<Data> Q;
    auto push = [&](ll v, ll s, ll x) {
        if(s < 0) {
            return;
        }
        if(dp[v][s] <= x) {
            return;
        }
        dp[v][s] = x;
        Q.emplace(v, s, x);
    };
    
    vl c(n), d(n);
    rep(i, n) {
        cin >> c[i] >> d[i];
    }

    push(0, s, 0);
    while(!Q.empty()) {
        Data hoge = Q.top();  Q.pop();
        ll v = hoge.v, s = hoge.s, x = hoge.x;
        if(dp[v][s] != x) {
            continue;
        }
        ll ns = min(s + c[v], MAX_S);
        push(v, ns, x + d[v]);
        for(Edge e : G[v]) {
            push(e.to, s - e.a, x + e.b);
        }
    }

    exrep(i, 1, n-1) {
        ll ans = INF;
        rep(j, MAX_S+10) {
            chmin(ans, dp[i][j]);
        }
        out(ans);
    }

    re0;
}

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

void rec(int num, vector<int> &vec){
  if(num > 3234566667) return;
  vec.push_back(num);
  int x = num % 10;
  rec(num * 10 + x, vec);
  if(x != 0) rec(num * 10 + x - 1, vec);
  if(x != 9) rec(num * 10 + x + 1, vec);
}

signed main(){
  int K; cin >> K;
  vector<int> vec;
  for(int i = 1; i < 10; i++) rec(i, vec);
  sort(vec.begin(), vec.end());
  cout << vec[K - 1] << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
int num[2019]={0};
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    string s;
    cin>>s;
    int n=s.size();
    num[0]=1;
    int ans=0;
    int now=0,t=1;
    for(int i=n-1;i>=0;i--){
        now=(now+(s[i]-'0')*t%2019)%2019;
        t=(t*10)%2019;
        ans+=num[now];
        num[now]+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    int w, a, b, ans;
    cin>>w>>a>>b;
    if(a > b){
        if(b+w <= a){
            ans = a-b-w;
        }
        else ans = 0;
    }
    else if(a == b){
        ans = 0;
    }
    else if(a < b){
        if(a+w >= b){
            ans = 0;
        }
        else ans = b-a-w;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;

     signed main(){
  int q,h,s,d,n;cin>>q>>h>>s>>d>>n;
  h=min(2*q,h);s=min(2*h,s);d=min(d,2*s);cout<<(n/2)*d+(n%2)*s<<endl;

         
}

        


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

int main()
{
	int a, b, ans;
	string op;

	// while(true)で書きたくなかったけど、ほかの方法が思いつかなかった
	while(true)
	{
		cin >> a >> op >> b;
		
		if(op=="?")
		{ 
			break;
		}

		if (op == "+")
		{
			ans = a + b;
		}
		else if (op == "-")
		{
			ans = a - b;
		}
		else if (op == "*")
		{
			ans = a * b;
		}
		else if (op == "/")
		{
			ans = a / b;
		}
		cout << ans << '\n';
	}

	return 0;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

const int N = 1e6 + 2137;
int sito[N];

int nwd(int a, int b) {
	while(b != 0) {
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(LL i=2; i<=N; i++) {
		if(sito[i] == 0) {
			for(LL j = i*i; j<=N; j+=i) {
				if(sito[j] == 0)
					sito[j] = i;
			}
		}
	}
	int n;
	cin>>n;
	int a[n];
	int gcd = 0;
	for(int i=0; i<n; i++) {
		cin>>a[i];
		gcd = nwd(gcd, a[i]);
	}
	if(gcd != 1) {
		cout<<"not coprime";
		return 0;
	}
	//vector<int> primes[n];
	map<int, bool> M;
	for(int i=0; i<n; i++) {
		int x = a[i];
		vector<int> V;
		while(x > 1) {
			if(sito[x] == 0) {
				//primes[i].push_back(x);
				auto it = M.find(x);
				if(it != M.end()) {
					cout<<"setwise coprime";
				//  - "<<sito[x]<<" - "<<i<<"\n"
					return 0;
				}
				//M[x] = 1;
				V.push_back(x);
				break;
			}
			//primes[i].push_back(sito[x]);
			auto it = M.find(sito[x]);
			if(it != M.end()) {
				cout<<"setwise coprime";
				//  - "<<sito[x]<<" - "<<i<<"\n"
				return 0;
			}
			//M[sito[x]] = 1;
			V.push_back(sito[x]);
			x /= sito[x];
		}
		for(int y : V)
			M[y] = 1;
	}
	cout<<"pairwise coprime";
}


Measured memory_bytes: 11548
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int s, w;


	scanf("%d%d", &s, &w);

	if (s <= w) {
		printf("un");
	}

	printf("safe\n");

	return 0;
}


Measured memory_bytes: 3828
var lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

var s = lines[0].split("");
var t = lines[1].split("");

var compareFunc = (a, b) => {
  return (b>a?1:-1);
};

s = s.sort();
t = t.sort(compareFunc);

s = s.join("")
t = t.join("")

if(s < t){
  console.log("Yes")
}else{
  console.log("No")
}

Measured memory_bytes: 11596
# include <bits/stdc++.h>
using namespace std;
list<int>l;
int main()
{
    int n, m, t=1;
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
    {
        scanf("%d",&m);
        t = !t;
        if(t) l.push_back(m);
        else l.push_front(m);
    }
    if(!(n&1)) l.reverse();
    for(auto i=l.begin();i!=l.end();++i)
        printf("%d ",*i);
    return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

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

    i32 dp0 = 0, dp1 = 1;
    for (auto& e : n) {
        i32 d = e - '0';
        tie(dp0, dp1) = make_tuple(
            min(dp0 + d, dp1 + (10 - d)),
            min(dp0 + d + 1, dp1 + (10 - (d + 1))));
    }

    cout << dp0 << endl;
}


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

using namespace std;

typedef long long llint;

const int MAXN = 51;
const llint INF = 1000000000000000000LL;

llint n, x, d, sol;
llint val[MAXN], cost[MAXN], par[MAXN], lim[MAXN], br[MAXN];
llint dp[MAXN][MAXN * MAXN * MAXN];
int r[MAXN];

void calc () {
    for (int w = 1; w <= 125000; w++) dp[0][w] = INF;
    for (int pos = 1; pos <= n; pos++) {
        for (int w = 0; w <= 125000; w++) {
            llint res = INF;
            int to = min((llint) w / val[pos], br[pos]);
            for (int take = 0; take <= to; take++) {
                res = min(res, dp[pos - 1][w - take * val[pos]] + take * cost[pos]);
            }
            dp[pos][w] = res;
        }
    }
}

bool cmp (int x, int y) {
    return val[x] * cost[y] > val[y] * cost[x];
}

llint f (llint ost) {
    llint res = 0;
    for (int i = 1; i <= n; i++) {
        int ind = r[i];
        int take = min(ost / cost[ind], br[ind]);
        res += take * val[ind];
        ost -= take * cost[ind];
    }
    return res;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x >> d;
    lim[1] = INF;
    for (int i = 1; i <= n; i++) {
        r[i] = i;
        cin >> cost[i];
        if (i > 1) cin >> par[i];
        if (i > 1) lim[i] = d;
    }
    for (int i = n; i >= 1; i--) {
        val[i]++;
        br[i] = min(lim[i], 50LL);
        val[par[i]] += val[i];
        cost[par[i]] += cost[i];
    }
    sort(r + 1, r + 1 + n, cmp);
    calc();
    for (int i = 1; i <= n; i++) {
        br[i] = max(0LL, lim[i] - 50);
    }
    for (int w = 0; w <= 125000; w++) {
        if (dp[n][w] <= x) {
            sol = max(sol, w + f(x - dp[n][w]));
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 52864
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n, m, link[150005], siz[150005];

void initDSU(){
    for(int i=1;i<=n;i++){
        link[i]=i;
        siz[i]=1;
    }
}

int find(int v) {
    if (v == link[v])
        return v;
    return link[v] = find(link[v]);
}

void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (siz[a] < siz[b]){
            swap(a,b);
        }
        siz[a] += siz[b];
        link[b] = a;
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    initDSU();
    while(m--){
        int a,b,c;
        cin >> a >> b >> c;
        unite(a, b);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(find(i)==i){
            cnt++;
        }
    }
    cout << cnt << el;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};
struct Node T[N];

void preorder(int nodeid) {
  
  printf(" %d",nodeid);
  if(T[nodeid].left != NIL)
    preorder(T[nodeid].left);  
  
  if(T[nodeid].right != NIL) 
    preorder(T[nodeid].right);
}

void inorder(int nodeid) {
  
  if(T[nodeid].left != NIL)
    inorder(T[nodeid].left);
  
  printf(" %d",nodeid);
  
  if(T[nodeid].right != NIL) 
    inorder(T[nodeid].right);
}		 

void postorder(int nodeid) {
  if(T[nodeid].left != NIL)
    postorder(T[nodeid].left);
  
  if(T[nodeid].right != NIL)  
    postorder(T[nodeid].right);
  
  printf(" %d",nodeid);
}

int main(void) {
  
  int n,i,x;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    T[i].parent = T[i].left = T[i].right = NIL; 
  
  for(i=0;i<n;i++) {
    scanf("%d",&x);
    scanf("%d%d",&T[x].left,&T[x].right);
    T[T[x].left].parent = x; 
    T[T[x].right].parent = x;
  }
  
  for(i=0;i<n;i++) 
    if(T[i].parent == NIL) 
      break;
  
  printf("Preorder\n");
  preorder(i);
  printf("\nInorder\n");
  inorder(i);
  printf("\nPostorder\n");
  postorder(i);
  printf("\n");
  
  return 0;    
  
}  

Measured memory_bytes: 616
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

struct edge {
    int to, cost;
};
typedef pair<int, int> pii;

int V;
vector<edge> G[1000000];
ll d[1000000];

void dijkstra(int s) {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    fill(d, d + V + 10, llmax);
    d[s] = 0;
    que.push(pii(0, s));

    while (!que.empty()) {
        pii p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    V = N;
    for (int i = 0; i < N - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edge e1;
        e1.to = b;
        e1.cost = c;
        G[a].push_back(e1);
        edge e2;
        e2.to = a;
        e2.cost = c;
        G[b].push_back(e2);
    }
    int Q, K;
    cin >> Q >> K;
    dijkstra(K);
    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
}


Measured memory_bytes: 31604
# -*- coding: utf-8 -*-

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

ans1 = 0
sum1 = 0
sign1 = 1
for a in A:
    sum1 += a
    if sign1 == 1:
        ans1 += max(0, 1-sum1)
        sum1 += max(0, 1-sum1)
    else:
        ans1 += -min(0, -1-sum1)
        sum1 += min(0, -1-sum1)
    sign1 *= -1

ans2 = 0
sum2 = 0
sign2 = -1
for a in A:
    sum2 += a
    if sign2 == 1:
        ans2 += max(0, 1-sum2)
        sum2 += max(0, 1 - sum2)
    else:
        ans2 += -min(0, -1-sum2)
        sum2 += min(0, -1 - sum2)
    sign2 *= -1

print(min(ans1, ans2))


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P3 = std::tuple<int,int,int>;

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

template <int n>
struct UnionFind{
    UnionFind(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    void init(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
};

UnionFind<20100> uf;

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

    while(true){
        uf.init();
        
        int N, M;
        std::cin >> N >> M;
        if(!N){break;}
    
        vector<P3> packets;
        for(int i=0;i<M;++i){
            int t, s, d;
            std::cin >> t >> s >> d;

            packets.emplace_back(t, s, d);
        }

        sort(packets.begin(), packets.end());

        for(auto &p : packets){
            int s, d;
            tie(ignore, s, d) = p;

            if(uf.same(1, s)){
                uf.unite(s, d);
            }
        }

        int res = 0;
        for(int i=1;i<=N;++i){
            if(uf.same(1, i)){++res;}
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if(i*j==n){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scan_init()
	k := scanInt()
	// count := 0
	if k%2 == 0 {
		fmt.Println(-1)
	} else {
		sum := 7
		kCount := 0
		output := 0
		for i:= 1; i<k; i= i*10 {
			kCount++
		}
		for ; ; sum= sum*10 + 7 {
			if output > 999999 {
				output = -1
				break
			}
			// fmt.Println(sum, "check")
			keisan := sum / k
			sum = sum - k*keisan
			// fmt.Println(sum,keisan, k, output)
			if sum == 0 {
				output++
				break
			} else {
				output ++
			}
		}
		fmt.Println(output)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;

int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < 3; i++) if (S[i] == T[i]) ans++;
	cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  vector<int> B(N); REP(i, N) cin >> B[i];
  vector<int> C(N - 1); REP(i, N - 1) cin >> C[i];
  ll ans = 0;
  REP(i, N) {
    ans += B[A[i] - 1];
    if(i == 0) continue;
    if(A[i] - A[i - 1] == 1) {
      ans += C[A[i - 1] - 1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int>>;
const int INF= 1e9;

void solve(const Graph &weights, Graph *dp){
  const int N= weights.size();

  for(int k=0; k<N; k++){
    for(int from=0; from<N; from++){
      for(int to=0; to<N; to++){
        dp->at(from).at(to)= min(dp->at(from).at(to), dp->at(from).at(k)+ dp->at(k).at(to));
      }
    }
  }
}

int main(){
  int N,M,R;
  cin >> N >> M >> R;

  vector<int> checkpoints(R);
  for(int i=0; i<R; i++){
    cin >> checkpoints.at(i);
    checkpoints.at(i)--; // 1-indexed -> 0-indexed
  }
  vector<int> route(R);
  iota(route.begin(), route.end(), 0);

  Graph gph(N, vector<int>(N, INF));
  for(int v=0; v<N; v++){
    gph.at(v).at(v)= 0;
  }
  int v1,v2,dist;
  for(int j=0; j<M; j++){
    cin >> v1 >> v2 >> dist;
    v1--; v2--; // 1-indexed -> 0-indexed
    gph.at(v1).at(v2)= dist;
    gph.at(v2).at(v1)= dist;
  }

  Graph dp= gph;
  solve(gph, &dp);

  int ans= INF;
  do{
    int cand= 0;
    for(int i=1; i<R; i++){
      int from= checkpoints.at(route.at(i-1));
      int to  = checkpoints.at(route.at(i));
      cand+= dp.at(from).at(to);
    }
    ans= min(ans, cand);
  } while(next_permutation(route.begin(), route.end()));

  cout << ans << endl;
}

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

const int MaxN=2e5+5;
const int Mod=1e9+7;

int N,X,Y,M,Sum,Ans;
int C[MaxN],W[MaxN];
int Mn[MaxN],Cnt[MaxN],Inv[MaxN];

int main(){
	int i,mn=0x3f3f3f3f;
	scanf("%d%d%d",&N,&X,&Y);
	memset(Mn,0x3f,sizeof(Mn));
	for(i=1;i<=N;i++){
		scanf("%d%d",&C[i],&W[i]);
		Mn[C[i]]=min(Mn[C[i]],W[i]);
		Cnt[C[i]]++;
	}
	for(i=1;i<=N;i++)
		if(Mn[i]<Mn[M])
			M=i;
	for(i=1;i<=N;i++)
		if(C[i]^M)
			mn=min(mn,W[i]);
	for(i=1;i<=N;i++){
		if(W[i]^Mn[C[i]]&&W[i]+Mn[C[i]]<=X)
			continue;
		if(W[i]+(C[i]^M?Mn[M]:mn)<=Y)
			continue;
		Cnt[C[i]]--;
	}
	Inv[0]=Inv[1]=1;
	for(i=2;i<=N;i++)
		Inv[i]=1llu*(Mod-Mod/i)*Inv[Mod%i]%Mod;
	for(i=2;i<=N;i++)
		Inv[i]=1llu*Inv[i-1]*Inv[i]%Mod;
	Sum=Cnt[M],Ans=Inv[Cnt[M]];
	for(i=1;i<=N;i++)
		if(i^M&&Mn[i]+Mn[M]<=Y)
			Sum+=Cnt[i],Ans=1llu*Ans*Inv[Cnt[i]]%Mod;
	for(i=2;i<=Sum;i++)
		Ans=1llu*Ans*i%Mod;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>

int main(){
	int a;
	char dummy;
	std::string blood;
	int A=0,B=0,O=0,AB=0;
	while(std::cin>>a>>dummy>>blood){
		if(blood=="A")A++;
		if(blood=="B")B++;
		if(blood=="O")O++;
		if(blood=="AB")AB++;
	}
	std::cout<<A<<std::endl;
	std::cout<<B<<std::endl;
	std::cout<<AB<<std::endl;
	std::cout<<O<<std::endl;
	return 0;
}

Measured memory_bytes: 1204
N = int(input())
p = [0]*N
p = list(map(int, input().split()))
q = [0]*N
ans = int(0)

q = sorted(p)

for i in range(N):
    if p[i]!=q[i]:
        ans +=1

if (ans<=2):
    print("YES")
else:
    print("NO")

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

using namespace std;

int main(void) {
  int x, y; cin >> x >> y;
  string group = " ACABABAABABA";

  if (group[x] == group[y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import defaultdict


n, X = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s, reverse=True)

mod = 10 ** 9 + 7

dp = defaultdict(int)
dp[X] = 1

for i in range(n):
    new_dp = defaultdict(int)

    for x in dp:
        mod_x = x % s[i]
        new_dp[x] += dp[x] * (n - i - 1)
        new_dp[mod_x] += dp[x]

    dp = new_dp

total = 0
for x in dp:
    total += dp[x] * x

total %= mod

print(total)


Measured memory_bytes: 8964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll A[100000],B[100000];
int main(){
	cin>>N;
	rep(i,N) cin>>A[i]>>B[i];
	ll now = 0;
	ll ans = 0;
	for(int i=N-1;i>=0;i--){
		A[i]+=now;
		ll tar = (B[i] - A[i]%B[i]);
		if(tar == B[i]) tar=0;
		ans+=tar;
		now+=tar;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#define N 105
#define M 40005
using namespace std;

int n, a[M], t[M], v[N];
double s;
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &t[i]), t[i] *= 2, t[i] += t[i - 1];
	for (i = 1; i < t[n]; i++) a[i] = 1e9;
	t[n + 1] = t[n];
	for (i = 1; i <= n; i++) scanf("%d", &v[i]), v[i] *= 2;
	for (i = j = 1; i <= n; i++)
		for (; j <= t[i]; j++) a[j] = min(a[j], min(v[i], a[j - 1] + 1));
	for (i = n + 1, j = t[n] - 1; i > 0; i--)
		for (; j >= t[i - 1]; j--) a[j] = min(a[j], min(v[i], a[j + 1] + 1));
	for (i = 0; i <= t[n]; i++) s += a[i];
	printf("%.6f", s / 4);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;
	int ans = A * B;
	if (10 <= A or 10 <= B) cout << -1 << endl;
	else cout << ans << endl;
	return;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
bool compare(pll l, pll r)
{
    double al = atan2((double)l.ss, (double)l.ff);
    double ar = atan2((double)r.ss, (double)r.ff);
    //cout<<al<<" "<<ar<<endl;
    return al<ar;
}
double dis(pll a)
{
    double dis = sqrt(a.ff*a.ff + a.ss*a.ss);
    return dis;
}
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int i;
    vector< pll > co;
    FOR0(i, n)
    {
        pll temp;
        cin>>temp.ff>>temp.ss;
        co.pb(temp);
    }
    sort(co.begin(), co.end(), compare);
    FOR0(i, n) co.pb(co[i]);
    // FOR0(i, 2*n)
    // {
    //     cout<<co[i].ff<<" "<<co[i].ss<<" "<<atan2(co[i].ss, co[i].ff)<<endl;
    // }
    FOR(i, 1, 2*n)
    {
        co[i].ff += co[i-1].ff; co[i].ss += co[i-1].ss;
    }
    int j;
    double ans = -1;
    FOR0(i, n)
    {
        pll left = co[i];
        FOR(j, i, i+n)
        {
            pll cur = co[j];
            if(i > 0)
            {
                cur.ff -= co[i-1].ff;
                cur.ss -= co[i-1].ss;
            }
            if( ans < dis(cur))
                ans = dis(cur);
        }
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }

  ll ans=0;
  ll cnt=0;
  while(1){
    ll div = pow(5, cnt) * 10;
    if(div>n)break;
    ans += (n / div);
    cnt++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i] == s[i+1]){
            cout<<"Bad"<<endl;
            return 0 ;
        }
    }
    cout<<"Good"<<endl;

    return 0 ;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

ll powerMOD(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return powerMOD(x,y/2)*powerMOD(x,y/2)%MOD;
  }else{//奇数
    return powerMOD(x,y-1)*x%MOD;
  }
}


int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  vector<ll> c(N); FOR(i,N){ cin >> c[i]; }

  //main
  sort(c.begin(),c.end(),greater<ll>());//降順にソート。
  
  ll ans = 0;
  if(N != 1){
    ll p_0 = powerMOD(2,N), p_1 = powerMOD(2,N-1), p_2 = powerMOD(2,N-2);
    FOR(i,N){ ans = (ans+(c[i]*(p_1+p_2*i%MOD)%MOD)%MOD)%MOD; }
    ans = ans*p_0%MOD;
  }else{
    ans = 2*c[0]%MOD; 
  }
  
  // output
  cout << ans << endl;
  //cout << (25*48+52*40+67*32+72*24+79*16)*32 << endl;

  return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    X[p].append(s)

def wacnt(y):
    if y.count("AC") == 0: return 0
    re = 0
    for a in y:
        if a == "AC": return re
        re += 1
ac = sum([min(x.count("AC"), 1) for x in X])
wa = sum([wacnt(x) for x in X])
print(ac, wa)

Measured memory_bytes: 21204
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n=sc.nextInt();
       int m=sc.nextInt();
       int l=sc.nextInt();
       if(n<=l&&n+m>=l)System.out.println("YES");
       else System.out.println("NO");
    }
    }

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i,2,MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod(ll a) {
  return (a % MOD + MOD) % MOD;
}

bool flags[100000];
vector<ll> Sieve() {
  flags[0] = true;
  flags[1] = true;
  const int sqrt_x = ceil(sqrt(100000) + 0.1);
  FOR(p,2,sqrt_x){
    if (flags[p])continue;
    for (int mult = p * p; mult < 100000; mult += p)
      flags[mult] = true;
  }
  vector<ll> ret;
  rep(i,100000)if(!flags[i])ret.pb(i);
  return ret;
}

int main(){
  COMinit();
  ll n,m;cin>>n>>m;
  vector<ll> v=Sieve();
  vector<ll> v_num(v.size()+1);
  rep(i,v.size()){
    while(m%v[i]==0){
      v_num[i]++;
      m/=v[i];
    }
  }
  ll ans=1;
  if(m!=1){
    ans*=n;
  }
  rep(i,v.size()){
    ans=mod(ans*COM(v_num[i]+n-1,n-1));
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  cin >> n;
  for(int i=1;i<n;i+=2){
    int count=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0)count++;
    }
    if(count==8)cnt++;
  }
 if(n%2==1){
   int count=0;
   for(int i=1;i<=n;i+=2){
     if(n%i==0)count++;
   }
   if(count==8)cnt++;
 }
  cout << cnt << endl;
}

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

int main() {
	double N, M, D;
	scanf("%lf%lf%lf", &N, &M, &D);
	printf("%.15lf\n", D > 0 ? 2 * (M - 1) * (N - D) / (N * N) : (M - 1) / N);
	return 0;
}

Measured memory_bytes: 256
var
    s,s0: String;
    i,j,len:Integer;
begin
    readln(s);
    s0:=s;
    len:=Length(s);
    j:=0;
    for i := 1 to len do
    begin
        if s[i]<>'B' then
        begin
            inc(j);
            s0[j]:=s[i];
        end else begin
            if j>0 then
            begin
                dec(j);
            end;
        end;
    end;
    for i := 1 to j do
    begin
        write(s0[i]);
    end;
    writeln;
    readln;
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



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

	cout << min(A*N, B) << endl;

	return 0;
}


Measured memory_bytes: 256