akhauriyash/Code-Regression huggingface dataset:
//2/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;


int main(){
    _fastio
    ll k,a,b;
    cin>>k>>a>>b;
    ll x=a/k;
    ll y=x*k;
    if(y<a) y+=k;
    if(y>=a&&y<=b) cout<<"OK"<<en;
    else cout<<"NG"<<en;




    return 0;
}


Measured memory_bytes: 3628
from itertools import accumulate
from bisect import bisect_left

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

P = list(accumulate(A))
P.insert(0, 0)

ans = float('inf')
for i in range(2, N-1):
    # 左
    Lmid = P[i] / 2
    Lx = bisect_left(P, Lmid)
    if abs(P[Lx] - Lmid) > abs(P[Lx-1] - Lmid):
        Lx -= 1

    # 右
    Rmid = (P[i] + P[N]) / 2
    Rx = bisect_left(P, Rmid)
    if abs(P[Rx] - Rmid) > abs(P[Rx-1] - Rmid):
        Rx -= 1

    M = max(P[Lx], P[i]-P[Lx], P[Rx]-P[i], P[N]-P[Rx])
    m = min(P[Lx], P[i]-P[Lx], P[Rx]-P[i], P[N]-P[Rx])

    ans = min(ans, M-m)

print(ans)


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	unordered_map<ll,ll> a;
	ll val, ans = 1;

	for(ll i=2;i<=n;i++) {
		val = i;
		for(ll j=2;j<=i;j++) {
			while(val%j==0) {
				a[j]++;
				val/=j;
			}
		}
	}

	for(auto it : a) {
		ans = (ans * (it.s + 1))%MOD;
	}

	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 237984
/*
░░░░░░░▄▀▀▀▀▀▀▀▄▄░░░░░░
░░░░░░▐░░░▄▄▄▄▄░ ▀▀▄
░░░░░▐░$░▐▀░░░░▀▀▀▀▄▀
░░░░░▌░░▐░░░░░░░░░░▄▄
░░░░▐░░░░▀▄▄▄▄▄▄▀▀▀░▄▀
░░░░▌▒░▒░▒░▒░░░▄▄▄▀▀
░░░░▌▒▒░▒▒▒▒▄▄▀▀
░░░▐░░▒▒▒▄▀▀░░░░░░░
░░░▐░▒▒▒▐░░░░░░░░░
░░░▐▒▒▒▒▌░░░░░░░░
░░░▐▒▒▒░▐░░░░░░░░░▄▀▄
░░░▐▒▒░▒▐▄▄▀▀▀▀▄▄▄▀░▌
░░░▐░▒▒░▄▄▄▄▀▀▄▄▄▄▄▀
░░▐▒▒▄▒▒▀▄▄▄▄▄▀░░░▄▌░░
░░▌▒▐░▀▀▄▄▄▄▄▄▄▀▀▀░░░░
░▐▒▒▌░░░░░░░░░░░░░ 
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(n - 1);
    vector <int> b(n);
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        b[u]++;
        b[v]--;
    }
    int res = 0;
    for (int i = 0; i < n - 1; i++)
    {
        res += b[i];
        if (res % 2)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


Measured memory_bytes: 1024
n,l=map(int,input().split())
x=[]
for i in range(n):
    x.append(i+l)

if max(x)*min(x)<=0:
    print(sum(x))
elif min(x)>0:
    print(sum(x)-min(x))
elif max(x)<0:
    print(sum(x)-max(x))

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
X = sorted(li())

sa = []

for i in range(1, M):
    sa.append(X[i]- X[i-1])

sa = sorted(sa)
#print(sa)
print(sum(sa[:max(M-N, 0)]))


Measured memory_bytes: 20644
// https://atcoder.jp/contests/abc059/tasks/abc059_a

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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }
    if b - a == c - b {
        println!("YES")
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
int main(){
string s;
cin>>s;
 int x=0;
  for(int i=0;i<s.size();i++){
  	x+=s.at(i)-'0';
  }
  x%=9;
  if(x==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

ll min64(ll x, ll y){
    if(x>y){
        return y;
    }else{
        return x;
    }
}

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    //cout << ans << endl;
    for(ll i=1;i*i<=n;i++){
        if(n%i!=0) continue;
        ans = min64(ans,i+(n/i)-2);
    }
    cout << ans << endl;

}

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

int main(){

    int n;
    string s;
    bool flag = false;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "Y") flag = true;
    } 
    if (flag) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll dp[300005][3],a[200005];
string s;
int main(){
    cin >> s;
    
    for(int i=1; i<=s.size(); i++)
        a[i] = s[i - 1];
    
    dp[1][1] = 1;
    dp[2][2] = 1;
    
    for(int i=1; i<=(int)s.size(); i++){
        if(i > 2){
            dp[i][2] = dp[i - 2][1] + 1;
            if(a[i - 3] != a[i - 1] || a[i] != a[i - 2])
                dp[i][2] = max(dp[i][2] , dp[i-2][2] + 1);
        }
        if(a[i] != a[i - 1])
            dp[i][1] = dp[i - 1][1] + 1;
        dp[i][1] = max(dp[i][1] , dp[i - 1][2] + 1);
    }
    
    cout << max(dp[(int)s.size()][1] , dp[(int)s.size()][2]);
    
    
    
    return 0;
}


Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a.begin(), a.end());
	
	int ans = 0;
	rep(i, 0, k)ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=2005;
//i_am_noob
int n,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep2(i,1,n+1) if(i%3!=0&&i%5!=0) ans+=i;
	print1(ans);
	return 0;
}

Measured memory_bytes: 3628
/*
[abc165] A - We Love Golf
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int K;
int A, B;

ll solve() { return B / K * K >= A; }

int main() {
    cin >> K;
    cin >> A >> B;

    cout << (solve() ? "OK" : "NG") << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//~ #define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}


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

int main() {
	ll n,d; cin >> n >> d;
	d*=d;
	int ans=0;
	rep(i,n) {
		ll x,y; cin >> x >> y;
		x*=x; y*=y;
		ans += (x+y)<=d ? 1 : 0;
	}
	cout << ans << endl;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    
    double res = 0.0;
    for (long long n = 1; n <= N; ++n) {
        double tmp = 1.0;
        long long nn = n;
        while (nn < K) nn *= 2, tmp /= 2.0;
        res += tmp;
    }
    res /= N;
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
long long s;
int main()
{
    scanf("%lld",&s);
    if (s<=1000000000)
    {
        printf("%d %d %d %d %lld %d\n",0,0,0,1,s,0);
        return 0;
    }
    int t=sqrt(s);
    while (1LL*t*t<s) ++t;
    for (int i=0;i<1000;i++)
        for (int j=0;j<1000;j++)
        {
            int c=t+i,d=t+j;
            if (c>1000000000||d>1000000000) continue;
            long long x=1LL*c*d-s;
            if (x==0LL)
            {
                printf("%d %d %d %d %d %d\n",0,c,d,0,d,c);
                return 0;
            }
            for (int i=1;1LL*i*i<=x;i++)
                if (x%i==0&&c>i&&d>x/i)
                {
                    int a=c-i;
                    int b=d-x/i;
                    printf("%d %d %d %d %d %d\n",0,a,b,0,d,c);
                    return 0;
                }
        }
    return 0;
}

Measured memory_bytes: 3812
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int M = sc.nextInt();
	    long A [] = new long [N];
	    
	    for(int i = 0; i < N; i++) {
	    	A[i]=sc.nextLong();
	    }
	    Arrays.sort(A);
	   
	    TreeMap <Long, Long> store = new TreeMap <Long, Long>();
	    
		long Bi=0;
		long Ci=0;
		for (int i = 0; i<M; i++){
			Bi = sc.nextLong();
			Ci = sc.nextLong();
 
			if (store.containsKey(Ci)) 
				store.put(Ci, store.get(Ci) + Bi);
			 else 
				store.put(Ci, Bi);
			}
		sc.close();
		int right = 0;
		
		while (store.isEmpty()==false) {
			
			long c=store.lastKey();
			long b=store.lastEntry().getValue();
			
			long count = 0;
			while (right<(long)(N) && A[right]<c && count<b){
				A[right]=c;
				right++;
				count++;
			}
			
			
			store.pollLastEntry();
		}
		long sum [] = new long [N+2];
		long current = 0;
		
	    for(int i = 0; i < N; i++) {
	    	current = A[i]+current;
	    	sum [i+1]=current;
	    }
	    System.out.println(sum[N]);
		
		
	}

}


Measured memory_bytes: 100544
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;


long long X;
int main() {
  while (cin >> X) {
	long long lo = 0, hi = 1LL<<30;
	while (hi - lo > 1) {
	  long long mid = (hi + lo) / 2;
	  
	  long long sum = mid * (mid + 1) / 2;
	  if (sum >= X) hi = mid;
	  else lo = mid;
	}
	cout << hi << endl;
  }
}





Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long a,b;
  char op;
  long ans;

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

  if(op == '+') ans = a+b;
  if(op == '-') ans = a-b;

  printf("%d", ans);

  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
using namespace std;

int main() {
  int x, n,n1;
  cin >> x;
  n = ceil(x/1.08);
  n1 = n*1.08;
  if (n1==x) {
    cout << n << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int a[19];
int n,k,t;
int  fun(int n)
{
	int t;
	while(n)
	{
		t=n%10;
		n/=10;
		if(a[t]==1)
			return 0;
	}
	return 1;
}
int main()
{
	int i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)
	{
		scanf("%d",&t);
		a[t]=1;
	}
	for(i=n;i;i++)
	{
		if(fun(i))
		{
			printf("%d\n",i);
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 128
import itertools
N = int(input())
XY = [[int(_) for _ in input().split()] for _ in range(N)]
xy1 = []
xy2 = []
xy3 = []
xy4 = []
for x, y in XY:
    if x >= 0:
        if y >= 0:
            xy1 += [[x, y]]
        else:
            xy4 += [[x, y]]
    else:
        if y >= 0:
            xy2 += [[x, y]]
        else:
            xy3 += [[x, y]]
xy1.sort(key=lambda xy: float('inf') if xy[0] == 0 else xy[1] / xy[0])
xy2.sort(key=lambda xy: xy[1] / xy[0])
xy3.sort(key=lambda xy: xy[1] / xy[0])
xy4.sort(key=lambda xy: -float('inf') if xy[0] == 0 else xy[1] / xy[0])
XY = xy1 + xy2 + xy3 + xy4
N = len(XY)
XY *= 2
acc = list(
    itertools.accumulate(XY, func=lambda a, b: [a[0] + b[0], a[1] + b[1]]))
ans = 0
for i in range(N):
    for j in range(i + 1, i + N + 1):
        x = acc[j][0] - acc[i][0]
        y = acc[j][1] - acc[i][1]
        ans = max(ans, x**2 + y**2)
print(ans**0.5)


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

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

    int a, b;
    cin >> a >> b;

    string A = "", B = "";
    rep(i, b) A += ""s + to_string(a);
    rep(i, a) B += ""s + to_string(b);

    if (A > B) {
        cout << B << endl;
    } else {
        cout << A << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(cin >> a >> b&&a||b){
    int cnt=0;
    for(int i=1;i<=a;i++){
      for(int j=i+1;j<=a;j++){
	for(int k=j+1;k<=a;k++){
	  if(i+j+k==b)cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef pair<int,int> pii;
const int N = 10000;

void compute(int i,int *buf){
  buf[0]=i/1000%10;
  buf[1]=i/100%10;
  buf[2]=i/10%10;
  buf[3]=i%10;
}

pii hitAndBlow(int n,int q){
  int hit=0,blow=0;
  int buf1[5],buf2[5];
  compute(n,buf1);
  compute(q,buf2);
  rep(i,4){
    rep(j,4){
      if (buf1[i] == buf2[j]){
	if (i == j)hit++;
	else blow++;
      }
    }
  }
  return make_pair(hit,blow);
}

int solve(vector<int> &a,vector<int> all){
 // if (a.size() > 15)return -1;
  rep(i,all.size()){
    int buf[5];
    bool isok=true;
    int cnt[5][5]={0};
    rep(j,a.size()){
      pii tmp = hitAndBlow(a[j],all[i]);
      cnt[tmp.first][tmp.second]++;
      if (cnt[tmp.first][tmp.second] > 1)isok=false;
    }
    if (isok)return all[i];
  }
  return -1;
}

main(){
  int n;
  vector<int> all(N);
  rep(i,N){
    int buf[4];
    compute(i,buf);
    bool isok=true;
    rep(j,4)REP(k,j+1,4)if (buf[j] == buf[k]){isok=false;}
    all[i]=(isok?i:-1);
  }
  sort(all.begin(),all.end());
  all.erase(remove(all.begin(),all.end(),-1),all.end());
  while(cin>>n && n){

    vector<pii> in(n);
    vector<int> cand,query(n);
    rep(i,n)cin>>query[i]>>in[i].first>>in[i].second;
    rep(i,all.size()){
      bool isok=true;
      int buf[5];
      rep(j,n){
	pii tmp =hitAndBlow(all[i],query[j]);
	if (tmp.first == in[j].first && tmp.second == in[j].second);
	else {
	  isok=false;
	}
      }
      if (isok)cand.push_back(all[i]);
    }
    sort(cand.begin(),cand.end());

    /*    vector<int> cand;
    cand=all;
    rep(k,n){
      vector<int> b;
      int q,hit,blow;
      cin>>q>>hit>>blow;
      rep(i,cand.size()){
	bool isok=true;
	pii tmp =hitAndBlow(q,cand[i]);
	if (hit == tmp.first && blow == tmp.second);
	else {
	  isok=false;
	}
	if (isok)b.push_back(cand[i]);
      }
      cand=b;
    }
    */
    int ans = cand.size() == 1?cand[0]:solve(cand,all);
    if (ans !=-1)printf("%04d\n",ans);
    else puts("????");
  }
  return false;
}

Measured memory_bytes: 996
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"AC"<<endl
#define printno cout<<"WA"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i,N=-1;
  string s;
  cin>>s;
  For(i,2,s.size()-1)if(s[i]=='C')N=i;
  if(s[0]!='A'||N==-1){
    printno;
    return 0;
  }
  s[N]+=32;
  rep1(i,s.size()){
    if(s[i]<'a'){
      printno;
      return 0;
    }
  }
  printyes;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
dp = np.zeros((N,3))
a,b,c = map(int,input().split())
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c
for i in range(1,N):
  a,b,c = map(int,input().split())
  dp[i][0] = max(dp[i-1][1]+a,dp[i-1][2]+a)
  dp[i][1] = max(dp[i-1][0]+b,dp[i-1][2]+b)
  dp[i][2] = max(dp[i-1][1]+c,dp[i-1][0]+c)
print(int(np.max(dp)))

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

using namespace std;

int main() {
  string a;
  std::cin >> a;

  char t = a[0];

  bool exists = false;
  for (int i = 1; i < a.length(); i++) {
    if (a[i] != t) {
      exists = true;
      break;
    }
    t = a[i];
  }

  if (exists) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
n=list(input())
temp=""
temp=temp.join(map(str,n))
temp=int(temp)
if n[0]==n[1]==n[2]:
    temp=""
    temp=temp.join(map(str,n))
    temp=int(temp)
    print(temp)
else:
    a=n[0]*3
    a=int(a)
    b=(str(int(n[0])+1))*3
    b=int(b)
    if a<temp:
        print(b)
    else:
        print(a)


Measured memory_bytes: 3064
use std::io;

macro_rules! get {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.parse::<$t>().unwrap()
        }
    };
    ($($t: ty), *) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            let mut inter = x.split_whitespace();
            (
                $(inter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

macro_rules! insert_vec {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.split_whitespace().map(|x| x.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

macro_rules! word_chars_vec {
    () => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.chars().collect::<Vec<_>>()
        }        
    };
}
fn main() {
    let (mut n, mut l) = get!(i64, i64);
    let mut taste_vec: Vec<i64> = (l..l+n).collect();
    let mut ans:i64 = taste_vec.iter().sum();
    if taste_vec.iter().find(|&&x| x == 0 ) == Some(&0) {
        println!("{}", ans);
    } else if taste_vec.iter().max().unwrap() < &0 {
        println!("{}", ans - taste_vec.iter().max().unwrap() )
    } else {
        println!("{}", ans - taste_vec.iter().min().unwrap() )
    };
    
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int A,B,C,D,E;
    cin >>A >>B >>C >>D >>E;
    
    vector<pair<int, int>> pairs(5);
    pairs[0]=make_pair(((10-(A%10))%10),A);
    pairs[1]=make_pair(((10-(B%10))%10),B);
    pairs[2]=make_pair(((10-(C%10))%10),C);
    pairs[3]=make_pair(((10-(D%10))%10),D);
    pairs[4]=make_pair(((10-(E%10))%10),E);
    
    SORT(pairs);
    
    int sum=0;
    sum += pairs[0].first + pairs[1].first + pairs[2].first + pairs[3].first +
         pairs[0].second + pairs[1].second + pairs[2].second + pairs[3].second + pairs[4].second;

    
    cout <<sum <<endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  a.erase(unique(all(a)), a.end());

  if(n != a.size()) cout <<"NO\n";
  else cout << "YES\n";
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = s.length() - 1;
	if (!n) {
		cout << s << endl;
		return 0;
	}
	ll sum = 0;
	for (int tmp = 0; tmp < (1 << n); tmp++) {
		bitset<9> bs(tmp);
		string t = s;
		rep(i, n) {
			if (bs[i]) {
				sum += stol(t.substr(0, i + 1));
				t = string(i + 1, '0') + t.substr(i + 1);
			}
			if (i == n - 1 && t.length())
				sum += stol(t);
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<ctype.h>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline long long read(){
	long long x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    long long a=read(),b=read(),x=read();
    long long o=a/x;if(a%x)o++;
	printf("%lld",b/x-o+1);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 1; i < 10; i++) {
        if (N % i == 0 && 1 <= N / i && N / i < 10) {
            flag = true;
        }
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,m,min,max,j;
    scanf("%d",&n);
    m=n-1;
    int r[m];
    scanf("%d",&r[0]);
    for(n=1;n<=m;n++){
        scanf("\n%d",&r[n]);
    }
    min=r[0];
    for(j=1;j<=m;j++){
        if(j==1){
            max=r[1]-min;
        }
        if(max<r[j]-min){
            max=r[j]-min;
        }
        if(min>r[j]){
            min=r[j];
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2572
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>

using namespace std;

enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif

signed main() {
#ifndef CrafterKolyan
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n;
    cin >> n;
    int sum = -n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << sum << endl;
    return 0;
}


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

int main (){
  int a, b;
  string y = "Yes";
  string n = "No";
  
  cin >> a >> b;
  
  if ( a <= b || a % 500 == 0 || a % 500 < b ||(a - b) % 500 == 0 ) {
    cout << y << endl;
  } else {
    cout << n << endl;
  }
}

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

import sys
import os
import math

class Vector2():
    def __init__(self, x, y):
        self._x = float(x)
        self._y = float(y)

    def normalize(self):
        norm = self.norm()
        return Vector2(self._x / norm, self._y / norm)

    def norm(self):
        return math.sqrt(self._x ** 2 + self._y ** 2)

    def dot(self, other):
        return self._x * other._x + self._y * other._y

    def __add__(self, other):
        return Vector2(self._x + other._x, self._y + other._y)

    def __sub__(self, other):
        return Vector2(self._x - other._x, self._y - other._y)

    def __str__(self):
        round_x = round(self._x, 6)
        round_y = round(self._y, 6)
        return "{} {}".format(round_x, round_y)

    def __mul__(self, scale):
        return Vector2(self._x * scale, self._y * scale)


for s in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, s.split(','))

    OP1 = Vector2(x1, y1)
    OP2 = Vector2(x2, y2)
    OQ = Vector2(xq, yq)

    P2P1 = OP2 - OP1
    N = P2P1.normalize()

    P1Q = OQ - OP1

    # projection
    dot = P1Q.dot(N)
    P1O = N * dot

    QO = P1O - P1Q
    OR = OP1 + P1O + QO

    print(OR)

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

using namespace std;

typedef long long ll;

ll merge_cnt(vector<int> &a) {
  int n = a.size();
  if (n <= 1) { return 0; }
  ll cnt = 0;
  vector<int> b(a.begin(), a.begin()+n/2);
  vector<int> c(a.begin()+n/2, a.end());
  cnt += merge_cnt(b); cnt += merge_cnt(c);
  int ai = 0, bi = 0, ci = 0;
  while (ai < n) {
    if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) { a[ai++] = b[bi++]; }
    else { cnt += n / 2 - bi; a[ai++] = c[ci++]; }
  }
  return cnt;
}
int main() {
  const ll mod = (ll)1e9 + 7;
  ll n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) { cin >> a[i]; }
  ll ans = (merge_cnt(a) % mod) * (k % mod);
  sort(a.begin(), a.end(), greater<int>() );
  ans += ( (k * (k-1) / 2) % mod ) * ( merge_cnt(a) % mod );
  cout << ans % mod << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N, T, i, j, Ca=0, ir;
  scanf("%d", &N);
  scanf("%d", &T);
  int c[N];
  int t[N];
  for(i=0; i<N; i++){
    scanf("%d", &c[i]);
    scanf("%d", &t[i]);
    if (T < t[i]){
      t[i] = 1000;
      c[i] = 1000;
      Ca = Ca + 1;
    }
    else{
    }
  }
  for (i=0; i < N; i++){
    for (j=1; j<N; j++){
      if (c[i] > c[j]){
        ir = c[i];
        c[i] = c[j];
	c[j] = ir;
      }
      else{
      }
    }
  }
  if (Ca==N){
    printf("TLE");
  }
  else{
    printf("%d", c[0]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    int H, W;
    int H_i, W_i;
    while(1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) break;
        for (H_i = 0; H_i < H; H_i++) {
            for (W_i = 0; W_i < W; W_i++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

const int p=1000000007;
void inline check(int &x){x-=p,x+=x>>31&p;}
int N,M;
int pow2[250];
int g[15][15];
int G[15][32768];

int F[32768];

int main(){
	scanf("%d%d",&N,&M);
	pow2[0]=1;for(int i=1;i<250;i++) check(pow2[i]=pow2[i-1]+pow2[i-1]);
	for(int i=1;i<=M;i++){
		int u,v;scanf("%d%d",&u,&v);u--;v--;
		g[u][v]=1;
	}
	for(int u=0;u<N;u++)
	for(int v=0;v<N;v++)
	for(int s=0;s<(1<<N);s++) if((s>>v)&1)
		G[u][s]+=g[u][v];
	for(int s=0;s<(1<<N);s++) if((s&3)==3){
		for(int A=s;A;A=(A-1)&s) if((A&3)==0){
			int B=s^A,tmp=F[B];
			for(int u=0;u<N;u++) if((B>>u)&1)
				tmp=1LL*tmp*(pow2[G[u][A]]-1)%p;
			for(int u=0;u<N;u++) if((A>>u)&1)
				tmp=1LL*tmp*pow2[G[u][B]]%p;
			check(F[s]+=tmp);
		}
		for(int A=s;A;A=(A-1)&s) if((A&3)==3){
			int B=s^A,tmp=1;
			for(int u=0;u<N;u++) if((B>>u)&1)
				tmp=1LL*tmp*(pow2[G[u][A]]-1)%p*pow2[G[u][B]]%p;
			for(int u=0;u<N;u++) if((A>>u)&1)
				tmp=1LL*tmp*pow2[G[u][B]]%p;
			check(F[s]+=tmp);
		}
	}
	printf("%d\n",(pow2[M]-F[(1<<N)-1]+p)%p);
}

Measured memory_bytes: 5856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int h,w;cin >> h >> w;
    vector<vector<int>> g(10, vector<int>(10, INF));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> g[i][j];
        }
    }
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                g[j][k]=min(g[j][k], g[j][i]+g[i][k]);
            }
        }
    }

    vector<int> a(10);
    for(int i = 0; i < h*w; i++) {
        int x;cin >> x;
        if(x>=0) a[x]++;
    }

    int ans=0;
    for(int i = 0; i < 10; i++) {
        ans += a[i]*g[i][1];
    }

    cout << ans << endl;

    return 0;
}

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

#define MAX_N 2000

using namespace std;

typedef pair<int, int> P;

int dist[MAX_N][MAX_N]; // dist[u][v] = 頂点 u と頂点 v の距離
int num[MAX_N]; // num[v] = 頂点 v からの距離が K/2 以上の頂点の個数

int N, K;
vector<int> G[MAX_N];
P edges[MAX_N];

void distDFS( int root, int v, int d, int par )
{
    dist[root][v] = dist[v][root] = d;

    for ( auto u : G[v] )
    {
        if ( u == par ) continue;

        distDFS( root, u, d + 1, v );
    }
}

int main( int argc, char **argv )
{
    cin >> N >> K;

    for ( int i = 0; i < N - 1; i++ )
    {
        int A, B;
        cin >> A >> B;

        G[A - 1].push_back( B - 1 );
        G[B - 1].push_back( A - 1 );

        edges[i] = P( A - 1, B - 1 );
    }

    for ( int i = 0; i < N; i++ ) distDFS( i, i, 0, -1 );

    int ans = ( 1 << 30 );
    if ( K % 2 == 0 )
    {

        for ( int u = 0; u < N; u++ )
        {
            int num = 0;
            for ( int v = 0; v < N; v++ )
                if ( dist[u][v] > K / 2 ) num++;
            ans = min( num, ans );
        }
    }
    else
    {
        for ( int i = 0; i < N - 1; i++ )
        {
            int u1 = edges[i].first;
            int u2 = edges[i].second;

            int num = 0;
            for ( int v = 0; v < N; v++ )
                if ( min( dist[u1][v], dist[u2][v] ) > K / 2 ) num++;
            ans = min( num, ans );
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	bool judge = false;
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = k; i <= b; i += k)
	{
		if (a <= i) { judge = true; }
	}
	if (judge) { cout << "OK\n"; }
	else { cout << "NG\n"; }
	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
   for (int i = 0; i < N; i++) {
     string s;
     cin >> s;
     
     if (s == "Y") {
       cout << "Four" << endl;
       break;
     }
     
     else if (i == N - 1) {
       cout << "Three" << endl;
     }
   }

}

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

int c=0, N;
map<int, vector<int>> m;

void osp(int a, int t, set<int> s) {
  for(int x : m.at(a)) {
    int z=t+1;
    set<int> y;
    for(auto n : s)
      y.insert(n);
    if(!y.count(x)) {
      y.insert(x);
      if(z==N)
        c++;
      else
        osp(x, z, y);
    }
    /*
    for(int x : s)
      cout << x << " ";
    cout << endl;
    */
  }
}

int main() {
  int M,i,a,b;
  cin >> N >> M;
  
  for(i=0; i<M; i++) {
    cin >> a >> b;
    if(!m.count(a)) {
      m[a].push_back(b);
    } else {
      m.at(a).push_back(b);
    }
    if(!m.count(b)) {
      m[b].push_back(a);
    } else {
      m.at(b).push_back(a);
    }
  }
  
  /*
  for(auto k : m) {
    for(int n : k.second)
      cout << n << " ";
    cout << endl;
  }
  cout << endl;
  */

  set<int> seen;
  seen.insert(1);
  osp(1,1,seen);

  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(void){
   string a, b;
   cin>>a>>b;
   if(a.length()>b.length()){
        cout<<"GREATER";
        return 0;
   }else if(a.length()<b.length()){
        cout<<"LESS";
        return 0;
   }else{
        for(int i=0;i<a.length();i++){
            if(a[i]>b[i]){
                cout<<"GREATER";
                return 0;
            }else if(a[i]<b[i]){
                cout<<"LESS";
                return 0;
            }else continue;
        }
   }
   cout<<"EQUAL";
}


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

char s[200005];

int n,cnt[200005];

long long ans;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) cnt[s[i]-'a']++;
	for(int i=0;i<26;i++) for(int j=i+1;j<26;j++) ans+=1ll*cnt[i]*cnt[j];
	printf("%lld",ans+1);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
class Hjo {
  static void Main(){
    string aho = Console.ReadLine();
    var retu = new List<char>();
    var S  = aho.Length;
    var zero = 0;
    var iti = 0;
     for (int i = 0; i < aho.Length; i++)
     {
       if(aho[i] =='0'){
         zero += 1;
       }
       else{
         iti += 1;
       }
     }
   var nokori =  Math.Abs(zero - iti);
    Console.WriteLine(S-nokori);
  
       
  }
}

Measured memory_bytes: 13280
N=int(input())
D=list(map(int,input().split()))
MOD=998244353

import collections
dic = collections.Counter(D)

maxkey = max(dic.keys())

ans=dic[0]
if ans == 1 and D[0] == 0:
    for i in range(1,maxkey): 
        ans=ans*(dic[i]**dic[i+1])%MOD
    print(ans)
else:
    print(0)

Measured memory_bytes: 18936
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    int r,g,b;
    cin >> r >> g >> b;

    int res = r*100 + g *10 + b;

    if((res%4) != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    
    return 0;
}

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

int main() {
  int N;
  string S, T, M = "";
  cin >> N;
  cin >>S>>T;
  //vector<int> p(N);
  
  rep(i, N){
    M.append(S, i, 1);
    M.append(T, i, 1);
  }
  
  cout<<M<<endl;
  
  return 0;
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true){
        C -= B;
        if (C<=0){
            break;
        }
        A -= D;
        if (A<=0){
            break;
        }
    }
    if (C<=0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int n,sum =0;
  cin >> n;
  vector<int> p(n);
  for(int i = 0 ;i < n ;++i){
      cin >> p.at(i);
  }

  for(int i = 0 ;i < n - 2 ;++i){
      if(p.at(i) < p.at(i + 1) && p.at(i + 1) < p.at(i + 2)){
          sum++;
      }
      else if(p.at(i) > p.at(i + 1) && p.at(i + 1) > p.at(i + 2)){
          sum++;
      }
  }
  cout << sum << endl;
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

V<string> v;
string s;

void go(int n, int c = 0) {
	if(n == 0) {
		v.PB(s);
		return;
	}
	for(int i=0;i<c;i++) {
		s.PB('a'+i);
		go(n-1, c);
		s.pop_back();
	}
	s.PB('a'+c);
	go(n-1, c+1);
	s.pop_back();
}

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	go(n);
	sort(ALL(v));
	for(string t:v) cout << t << '\n';
}





Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

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



Measured memory_bytes: 3124
#include<stdio.h>
#include<math.h>

int main() {
	int i;
	int	N;
	int flag = 0;
	int check;
	int a[100100];

	scanf("%d", &N);

	for (i = 0;i < N;i++) {
		scanf("%d", &a[i]);
	}

	check = 0;
	for (i = 0; i < N; i++) {
		check = check ^ a[i];
	}
	if (check == 0) {
		flag = 1;
	}

	if (flag == 1) {
		printf("Yes");
	}
	else if (flag == 0) {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 512
n = int(input())
an = list(map(int, input().split()))
classify = [0 for i in range(3)]
#4の倍数、2の倍数、奇数
for i in range(len(an)):
    if an[i] % 4 == 0:
        classify[0] += 1
    elif an[i] % 2 == 0:
        classify[1] += 1
    else:
        classify[2] += 1
if classify[1]==0:
    if(classify[0]+1) < classify[2]:
        print("No")
    else:
        print("Yes")

elif (classify[0]) < classify[2]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 20500
#include <iostream>

int main() {
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    if (A > D || C > B) {
        std::cout << 0;
    } else if (A > C) {
        if (B > D) {
            std::cout << D - A;
        } else {
            std::cout << B - A;
        }
    } else if (B > D) {
        std::cout << D - C;
    } else {
        std::cout << B - C;
    }

    std::cout << std::endl;

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

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

    ll N;
    cin >> N;
    vector<ll> C(N);
    REP(i, N) cin >> C[i];

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

    ll res = 0;
    REP(i, N){
    	//dump((C[i] * (N+1-i) % mod))
    	res += (C[i] * (N+1-i) % mod);
    	res %= mod;
    }
    res *= powLL(4, N-1);
    res %= mod;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int N, V[20], C[20];
	int X = 0, Y = 0, i;

	scanf("%d", &N);

	for(i = 0; i < N; i++){
		scanf("%d", &V[i]);
	}

	for(i = 0; i < N; i++){
		scanf("%d", &C[i]);
	}

	for(i = 0; i < N; i++){
		if(V[i] - C[i] > 0 ){
			X += V[i];
			Y += C[i];
		}
	}

	printf("%d\n", X - Y);

	return 0;
}


Measured memory_bytes: 128