akhauriyash/Code-Regression huggingface dataset:
// Template //
#include<bits/stdc++.h>
using namespace std;

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;

    vli A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    vplili task;
    rep(i, N) task.push_back(make_pair(B[i], A[i]));
    sort(task);
    vplili taskac;
    lint ac = 0;
    rep(i, N) {
        ac += task[i].second;
        taskac.push_back(make_pair(ac, task[i].first));
    }
    bool flag = false;
    rep(i, N) {
        if (taskac[i].first > taskac[i].second) {
            flag = true; break;
        }
    }
    flag ? n() : y();
}

Measured memory_bytes: 14956
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

bool pd(string s){
	bool flag=true;
	for(int i=0;i<s.length();i++){
		if(s[i]!=s[s.length()-1-i]){
			flag=false;
			break;
		}
	}
	return flag;
}
int main(){
	// in;
	// out;
	string s,ss,sss;
	ss="0";
	cin>>s;
	sss=s;
	s=ss+s;
	string s1,s2;
	s1="";
	s2="";
	for(int i=1;i<=(s.length()-1)/2;i++){
		s1+=s[i];
	}
	for(int i=(s.length()-1)/2+2;i<=s.length()-1;i++){
		s2+=s[i];
	}
	// cout<<s<<endl;
	// cout<<s1<<endl;
	// cout<<s2<<endl;
	if(pd(sss)&&pd(s1)&&pd(s2)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a, b, c;

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

  if(a < b && b < c){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;

}

Measured memory_bytes: 1820
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  rep(i, M){
    cin >> p.at(i) >> S.at(i);
    p.at(i)--;
  }
  vector<pair<bool, int>> res(N);
  rep(i, N){
    res.at(i) = make_pair(false, 0);
  }
  rep(i, M){
    if(S.at(i) == "AC"){
      res.at(p.at(i)).first = true;
    }
    else if(!res.at(p.at(i)).first){
      res.at(p.at(i)).second++;
    }
  }
  int ac = 0;
  int pn = 0;
  rep(i, N){
    if(res.at(i).first){
      ac++;
      pn += res.at(i).second;
    }
  }
  cout << ac << " " << pn << endl;
}

Measured memory_bytes: 6912
import bisect
import itertools

A,B,Q = map(int,input().split())

INF = float('inf')
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result

for x in X:
  ans = solve(x)
  print(ans)


Measured memory_bytes: 104280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
long long dp[1000000][5], a[1000000], n;
char op[1000000];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; if (i != n - 1)cin >> op[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 5; j++)dp[i][j] = -1LL << 62;
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (dp[i][j] == -1LL << 62)continue;
			if (i == 0 || op[i - 1] == '+') {
				if (j % 2 == 0) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i]);
					if (j >= 1)dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + a[i]);
				}
				if (j % 2 == 1) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - a[i]);
					if (j >= 1)dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] - a[i]);
				}
			}
			else {
				if (j % 2 == 0) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - a[i]);
					dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - a[i]);
					if (j >= 1)dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] - a[i]);
				}
				if (j % 2 == 1) {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i]);
					dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i]);
					if (j >= 1)dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + a[i]);
				}
			}
		}
	}
	cout << max(dp[n][0], max(dp[n][1], max(dp[n][2], dp[n][3]))) << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
vec costdp;
vec height;
ll n,k;
ll func(ll ind) {
	if(ind > n - 1)
		return inf;
	if(costdp[ind] != -1)
		return costdp[ind];
	if(ind == n - 1)
		return 0;
	ll res = inf;
	for(int i = 1; i <= k; i++) {
		if(ind + i > n - 1)
				break;
		res = min(res,func(ind+i) + abs(height[ind] - height[ind + i]));
	}
	return costdp[ind] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
	height.resize(n);
	ll i;
	costdp.assign(n,-1);
	for(i = 0; i < n ; i++) cin >> height[i];
	cout << func(0);
	return 0;
}	

Measured memory_bytes: 6528
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		List<Integer> list = new ArrayList<Integer>();

		while (stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();

			list.add(String.valueOf((a + b)).length());
		}

		for (int value : list)
		{
			System.out.println(value);
		}
	}
}

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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	map<string, long> mp;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	long ans = 0;
	for (auto &p : mp)
	{
		ans += p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	double kaga,laura;
	int d[13];
	while(cin>>kaga){
		if(kaga<0)break;
		laura=128;
		for(int i=1;i<=12;i++,laura*=0.5){
			d[i]=0;
			if(kaga>=laura){
				d[i]=1;
				kaga-=laura;
			}
		}
		if(kaga==0){
			for(int i=1;i<=12;i++){
				cout<<d[i];
				if(i==8)cout<<".";
			}
			cout<<endl;
		}
		else cout<<"NA"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	long long x,y,k;
	cin>>x>>y>>k;
	long long t=min(x,k);
	x-=t,k-=t;
	t=min(y,k);
	y-=t;
	cout<<x<<' '<<y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
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; }
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); }	//最小公倍数
#define deg_to_rad(deg) (((deg)/360)*2*PI);
#define rad_to_deg(rad) (((rad)/2/PI)*360);
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)
struct aaa { aaa() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }aaa;


void Main() {
	ll a, b, k; cin >> a >> b >> k;
	ll c = (a - k);
	//cout << c << endl;
	ll d=b;
	if (c < 0) {
		c = -c;
		d = b - c;
		c = 0;
	}
	if (d < 0)d = 0;
	cout << c << " " << d;


}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+2,0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }

    vector<int> S;
    int sum = 0;
    for(int i=1;i<=N+1;i++){
        S.push_back(abs(A[i]-A[i-1]));
        sum += S[i-1];
    }

    vector<int> ans;
    for(int i=1;i<=N;i++){
        ans.push_back(sum-S[i-1]-S[i]+abs(A[i+1]-A[i-1]));
    }

    for(int x : ans){
        cout << x << endl;
    }
}


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

int main(){
    string s,t; cin >> s >> t;
    bool flag = 0;
    int n = s.size();
    int count = 0;
    while(flag == 0 && count <n){
        if(s==t) flag = 1;
        s = s[n-1]+s;
        s.pop_back();
        count ++;
    }
    cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
       int a,i=1;
       while(1){
       scanf("%d",&a);
          if (a == 0){
            break;
          }else{
         printf("Case %d: %d\n" ,i,a);
          i++;
             }
          }
          
         return 0;
          }


Measured memory_bytes: 2624
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

import numpy as np

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

c = 0

def div(a):
    global c
    for i in a:
        if i%2==1:
            print(c)
            sys.exit()
    ll = list(map(lambda x : x/2, a))
    c += 1
    div(ll)

div(a)


Measured memory_bytes: 12404
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a, b := scanInt(), scanInt()
	if b%a == 0 {
		fmt.Fprintln(wr, a+b)
	} else {
		fmt.Fprintln(wr, b-a)
	}
}


Measured memory_bytes: 1776
A,B=map(int,input().split())

def tax(A,B):
    count=0
    x=B/0.1
    if int(x*0.08)>A:
        return '-1'
    y=int(x*0.08)
    while True:
        if y<A:
            count+=1
            x+=1
            y=int(x*0.08)
        else:
            if count>9:
                return '-1'
            else:
                return int(x)
            break

print(tax(A,B))

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

void max_heapify(vi& a, int i) {
    int h = a.size() - 1;
    int l = 2 * i;
    int r = 2 * i + 1;
    int max_index = i;

    if (l <= h && a[max_index] < a[l]) { max_index = l; }
    if (r <= h && a[max_index] < a[r]) { max_index = r; }

    if (max_index != i) {
        swap(a[i], a[max_index]);
        max_heapify(a, max_index);
    }
}

void build_maxheap(vi& a) {
    rrep(i, 1, (a.size() - 1) / 2 + 1) { max_heapify(a, i); }
}

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

    int h;
    cin >> h;

    vi a(h + 1);
    rep(i, 1, h + 1) { cin >> a[i]; }

    build_maxheap(a);

    rep(i, 1, h + 1) { cout << " " << a[i]; }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4944
n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)
divide_times = as.inject(0) do |sum, n|
  times = 0
  while(n % 2 == 0) do
    n = n / 2
    times += 1
  end
  sum + times
end
puts divide_times


Measured memory_bytes: 2428
s = input().strip()
a, b = int(s[:2]), int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
	print('AMBIGUOUS')
elif 1 <= a <= 12:
	print('MMYY')
elif 1 <= b <= 12:
	print('YYMM')
else:
	print('NA')

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

signed main(){
  
  double w,h,x,y;

  cin >> w >> h >> x >> y;

  double tot = (w*h)/2.0;

  cout << tot << endl;

  if(x*2 == w && y*2 == h)cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}
    
  


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

typedef long long ll;

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

int main(){
    while(1){
        int n, m, K;
        cin >> n >> m >> K;
        if(n==0){
            break;
        }

        ll dp[n+1][m*n+1];
        REP(i, n+1){
            REP(j, m*n+1){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        REP(i, n){
            REP(j, m*(i+1)){
                int k;
                if(j>=m){
                    k = m;
                } else {
                    k = j+1;
                }

                ll s = 0;
                REP(l, k){
                    s += dp[i][j-l];
                }
                dp[i+1][j+1] = s;
            }
        }

        ll sum[n*m+1];
        REP(i, n*m){
            sum[i+1] = 0;
        }

        REP(i, n*m){
            if(i+1<=K){
                sum[1] += dp[n][i+1];
            } else {
                sum[i+1-K] += dp[n][i+1];
            }
        }

        /*
        REP(i, n*m){
            cout << sum[i+1] << " ";
        }
        cout << endl;
        */

        ll d = pow(m, n);
        double exp = 0;
        REP(i, n*m){
            exp += double(sum[i+1]) * (i+1) / d;
        }

        cout << fixed << setprecision(8) << exp << endl;
    }
}

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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int mod = 1e9+7;
const int N = 1e3+5;
const int inf = 1e18;

void solve()
{
    int k, a, b;
    cin >> k >> a >> b;

    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return;
        }
    }

    cout << "NG" << endl;
}			 	      		        

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
    	// cout << "Case #" << i << ": ";
    	solve();
    }
    //starboy1299();
}

Measured memory_bytes: 3616
import Control.Applicative
import qualified Data.Vector.Unboxed as UV

main :: IO ()
main = do
    [k, s] <- map read . words <$> getLine
    let xs = UV.fromList ([0..k] :: [Int])
    print $ UV.foldr (\x xc -> xc + UV.foldr (\y yc -> if 0 <= s - x - y && s - x - y <= k then yc + (1 :: Int) else yc) 0 xs) 0 xs

Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// for prime mod
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
//	cout << fixed << setprecision(15);
	int m, n;
	cin >> m >> n;
	mint a(m);
	cout << a.pow(n).x << endl;
}



Measured memory_bytes: 3112
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n=0,a=0,b=0,c=0,x=0,d=0,count=0,x2=0,count_sum=0,i,j;
    int y[10000]={0};
    while (1) {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&x);
        if (n==0&&a==0&&b==0&&c==0&&x==0) {
            break;
        }
        
        for (i=0; i<n; i++) {
            scanf("%d",&y[i]);
        }
        
        for (i=0; i<n; i++) {
            
            
            while (1) {
                
                x2 = (a*x+b)%c;
                
                if (x==y[i] && n-1==i) {
                    x=x2;
                    break;
                } else if (x==y[i]){
                    x=x2;
                    count++;
                    break;
                }
                
                if (count > 10000) {
                    break;
                }
                count++;
                x=x2;
            }
            
            count_sum+=count;
            if (count_sum > 10000) {
                break;
            }
            count=0;
            
        }
        
        if (count_sum < 10001) {
            printf("%d\n",count_sum);;
        } else {
            printf("-1\n");
        }
        count_sum=0;
        count=0;
    }
    
    return 0;
}

Measured memory_bytes: 656
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<string, int> P;
int dx[4] = {-1,1,-4,4};
map<string,int> strMap;
bool check(int num){
	if(num >= 0 && num <= 7){
		return true;
	}
	return false;
}

void BFS(string s){
	queue<P> que;
	strMap.insert(P(s,0));
	que.push(P(s,0));
	while(que.size()){
		P temp = que.front();
		que.pop();
	//	cout << temp.first  << endl;
		string strTemp = temp.first;
		int ZeroPos = 0;
		for(int i = 0; i < 8; ++i){
			if(strTemp[i] == '0'){
				ZeroPos = i;
				break;
			}
		}
		for(int i = 0; i < 4;++i){
			if(check(ZeroPos + dx[i])){
				if(ZeroPos == 3 && dx[i] == 1){  //不能从3移&#21160;到4或 4移&#21160;到3
					continue;
				}
				if(ZeroPos == 4 && dx[i] == -1){
					continue;
				}
 				swap(strTemp[ZeroPos], strTemp[ZeroPos+dx[i]]);
				string strTemp2 = strTemp;
				if(strMap.find(strTemp2) == strMap.end()){
					strMap.insert(P(strTemp2,temp.second + 1));
					que.push(P(strTemp2,temp.second + 1));
				}
				swap(strTemp[ZeroPos], strTemp[ZeroPos+dx[i]]);
			}
		}
	}
}

int main(){
	string s;
	string des = "01234567";
	 
	while(getline(cin,s)) {
		s.erase(remove(s.begin(), s.end(), ' '), s.end());
		BFS(des);
		int result = strMap.find(s) -> second;
		cout << result <<endl;
	}
	return 0;
}

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


int main(){
	int a, b, c, d;
	char ca, cb, cc, cd;
	cin >> ca >> cb >> cc >> cd;
	a = ca - '0';
	b = cb - '0';
	c = cc - '0';
	d = cd - '0';
	if (a + b + c + d == 7) { cout << a << "+" << b << "+" << c << "+" << d<<"=7"; }
	else if(a+b+c-d==7){ cout << a << "+" << b << "+" << c << "-" << d << "=7"; }
	else if(a+b-c+d==7){ cout << a << "+" << b << "-" << c << "+" << d << "=7"; }
	else if(a+b-c-d==7){ cout << a << "+" << b << "-" << c << "-" << d << "=7"; }
	else if(a-b+c+d==7){ cout << a << "-" << b << "+" << c << "+" << d << "=7"; }
	else if(a-b+c-d==7){ cout << a << "-" << b << "+" << c << "-" << d << "=7"; }
	else if(a-b-c+d==7){ cout << a << "-" << b << "-" << c << "+" << d << "=7"; }
	else if(a-b-c-d==7){ cout << a << "-" << b << "-" << c << "-" << d << "=7"; }
	return 0;
}

Measured memory_bytes: 256
N, M=list(map(int,input().split()))
p=10**9+7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, M+1):
    fact.append((fact[-1] * i) % p) # [-1]は後ろから?
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n-r]) % p
def pmt(n,r,p):
    if (r < 0) or (n < r):
        return 0
    return (fact[n] * factinv[n-r]) % p
C=0
for s in range(N+1):
    C=(C+(-1)**s*cmb(N,s,p)*pmt(M,N,p)*pmt(M-s,N-s,p)) %p
print(C)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;

	auto sum = [](int n){ return ((ll)n*(n+1))/2; };
	ll ans = sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15;

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

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n; 
	cin >> n;
	For(i,1,10){
		For(j,1,10){
			if(n==i*j){
				coY();
				return 0;
			}
		}
	}
	coN();

}


Measured memory_bytes: 256
def main():
    N = int(input())

    ctr = [1] * (N + 1)
    for d in range(2, N + 1):
        j = d
        while j <= N:
            ctr[j] += 1
            j += d

    ans = 0
    for i in range(1, N + 1):
        ans += i * ctr[i]
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int n,m,keta,l;
    string a;
    bool flag;
    cin>>n>>m;
    vector<int> s(m);
    vector<char> c(m);
    rep(i,m) {
        cin>>s[i]>>c[i];
        s[i]--;
    }
    for (int x=0; x<1000; x++) {
        flag=true;
        a=to_string(x);
        if (a.size()!=n) continue;
        rep(i,m) {
            if (a[s[i]]!=c[i]) flag=false;    
        }
        if (flag) {
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

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

int main(){

    int a,b;
    char op;


    while( op != '?'){
        cin >> a >> op >> b;
        
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
    
    }
    
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int i,j,k,N,M,K,ans,a;

using Graph=vector<vector<int>>;

Graph BL,FL;

vector<int> par,num;

int root(int x)
{
  if(par[x]==x)
  {
    return x;
  }
  else
  {
    return par[x]=root(par[x]);
  }
}
 
int unite(int x,int y)
{
  x=root(x);
  y=root(y);
  if(x==y)
  {
    return 0 ;
  }
  
  par[x]=y;
  
  num[y]+=num[x];
  
  return 0;
}
int main()
{
  cin >> N>>M>>K;
  
  FL.assign(N,vector<int>());
  BL.assign(N,vector<int>());
  par.assign(N,0);
  num.assign(N,1);
  
  for(i=0;i<M;i++)
  {
    cin>>j>>k;
    
    j--;
    k--;
    FL[j].push_back(k);
    FL[k].push_back(j);
  }
  
  for(i=0;i<K;i++)
  {
    cin>>j>>k;
    
    j--;
    k--;
    BL[j].push_back(k);
    BL[k].push_back(j);

  }
  
  for(i=0;i<N;i++)
  {
    par[i]=i;
  }
  
  for(i=0;i<N;i++)
  {
    for(auto u:FL[i])
    {
      unite(u,i);
    }
  }
  
 
  for(i=0;i<N;i++)
  {
    ans=num[root(i)];
    
    ans--;
    
    for(auto u:FL[i])
    {
      if(root(u)==root(i))
      {
        ans--;
      }
    }
    
    for(auto u:BL[i])
    {
      if(root(u)==root(i))
      {
        ans--;
      }
    }
    
    cout << ans <<" " ;
    
  }
  
  
  
}

Measured memory_bytes: 12792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
using namespace std;
int main(){
    map<string,int>p;
    int N;
    cin>>N;
    vector<string>s(N);
    for(int i=0;i<N;i++)cin>>s[i];
    for(int i=0;i<N;i++){
        p[s[i]]+=1;
    }
    int mx=0;
    for(auto x:p){
        mx=max(x.second,mx);
    }
    for(auto x:p){
        if(x.second!=mx)continue;
        else cout<<x.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 22272
main :: IO ()
main = do
  [n, a, b] <- map (read :: String -> Int) . words <$> getLine
  print $ solve n a b

solve :: Int -> Int -> Int -> Int
solve n a b
  | n == 1 && b - a > 0 = 0
  | b - a < 0 = 0
  | otherwise = (n-2) * (b-a) + 1
                


Measured memory_bytes: 508
#include <stdio.h>

int search(int A[], int n, int key)
{
	int i=0;
	A[n]=key;
	while(A[i]!=key)
	i++;
	return i!=n;
 } 
 
 int main()
 {
 	int n,m,key,A[10001],i,sum=0;
 	scanf("%d",&n);
 	for(i=0;i<n;i++)
 	scanf("%d",&A[i]);
 	scanf("%d",&m);
 	for(i=0;i<m;i++)
 	{
 		scanf("%d",&key);
 		if(search(A,n,key)) sum++;
	 }
	 printf("%d\n",sum);
	 return 0;
 }


Measured memory_bytes: 2100
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	string a;
	bool c=false,f=false;
	int c1,f1;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C'){
			c=true;
			c1=i;
			break;
		}
	}
	for(int i=a.size()-1;i>=0;i--){
		if(a[i]=='F'){
			f=true;
			f1=i;
			break;
		}
	}
	if(c==true&&f==true&&c1<f1){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,w;
long long p=1000000007;
long long memo[201][10001];
vector<int> fre,sum;
long long solve(int unuse,int leftw){
	if(leftw<0) return 0;
	if(sum[unuse]<=leftw) return 1;
	if(memo[unuse][leftw]!=-1) return memo[unuse][leftw];
	memo[unuse][leftw]=(solve(unuse-1,leftw)+solve(unuse-1,leftw-fre[unuse-1]))%p;
	return memo[unuse][leftw];
}
int main() {
    cin >> n >> w;
   	for(int i=0;i<201;++i) for(int j=0;j<10001;++j)
   		memo[i][j]=-1;
   	fre.assign(n,0);
   	for(int i=0;i<n;++i)
   		cin >> fre[i];
   	sort(fre.begin(),fre.end());
   	sum.assign(n+1,0);
   	for(int i=0;i<n;++i)
   		sum[i+1]=sum[i]+fre[i];
    cout << solve(n,w) << endl;
    return 0;
}

Measured memory_bytes: 16932
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INF =1e9+5;
ll max(ll& a, ll b) {
    return a>b?a:b;
}
int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll> dp(w+1);
    for(int i=0;i<n;i++)
    {
        ll wt,v;
        cin>>wt>>v;
        for(ll j=w-wt;j>=0;j--)
        {
            dp[j+wt]=max(dp[j+wt],(dp[j]+v));
            //cout<<dp[j+wt]<<endl;
        }
    }
    //cout<<dp[w];
   ll maxx=0;
    for(ll i=0;i<=w;i++)
    {
        maxx=max(maxx,dp[i]);
    }
   cout<<maxx;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, M = map(int, input().split())
    H_list = list(map(int, input().split()))
    edge_list = [ [] for i in range(N)]
    # i番目の展望台と道でつながっている展望台の番号のリスト、のリスト。
    for i in range(M):
        A, B = map(int, input().split())
        edge_list[A-1].append(B-1)
        edge_list[B-1].append(A-1)
    answer = 0
    for i in range(N):
        H_i = H_list[i]
        No_i_is_good = True
        for j in edge_list[i]:
            if H_list[j] >= H_i:
                No_i_is_good = False
                break
        if No_i_is_good:
            answer += 1
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 29412
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M,Q;
int a[50],b[50],c[50],d[50];
int ans=0;

void dfs(vector<int> A){
    if(A.size()==N+1){
        int res=0;
        rep(i,Q){
            if(A[b[i]]-A[a[i]]==c[i]){
                res+=d[i];
            }
        }
        ans=max(ans,res);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=M){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin>>N>>M>>Q;
    rep(i,Q) cin>>a[i]>>b[i]>>c[i]>>d[i];

    dfs(vector<int>(1,1));

    cout<<ans<<endl;
}

Measured memory_bytes: 3600
import java.util.*;
import java.lang.*;


public class Main {

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

        int n = sc.nextInt();
        String[] a = new String[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.next();
        }
        
        String[] bubble = Arrays.copyOf(a, n);
        String[] selection = Arrays.copyOf(a, n);
        
        // bubble sort
        for (int i = 0; i < n; i++) {
            for (int j = n - 1; j > i; j--) {
                if (Character.getNumericValue(bubble[j].charAt(1)) <
                    Character.getNumericValue(bubble[j - 1].charAt(1))) {
                    String tmp = bubble[j];
                    bubble[j] = bubble[j - 1];
                    bubble[j - 1] = tmp;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.print(bubble[i]);
            if (i != n - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
        System.out.println("Stable");
        
        
        // selection
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i; j < n; j++) {
                if (Character.getNumericValue(selection[j].charAt(1)) <
                    Character.getNumericValue(selection[minj].charAt(1))) {
                    minj = j;
                }
            }
            String tmp = selection[i];
            selection[i] = selection[minj];
            selection[minj] = tmp;
        }
        for (int i = 0; i < n; i++) {
            System.out.print(selection[i]);
            if (i != n - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
        
        if (Arrays.equals(bubble, selection)) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
    }
}



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

int main() {
	string N;
	cin >> N;
	if (N[0] == N[2]) cout << "Yes";
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

各桁を独立して判断できるときは、整数ではなく文字列として読み込むと各桁を独立に取り出せるので便利
今回は3桁であるから、2桁目は無視してよく、1桁目と3桁目が一致しているか否かのみを判定すれば良い
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef unsigned long lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n, k, sum = 0;
    lli ara[1007];
    cin >> n >> k;
    for(lli i=0; i<n; i++) cin >> ara[i];
    sort(ara, ara+n);
    for(lli i=0; i<k; i++) sum += ara[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int W,H,c[50][50];
void island(int h, int w){
    c[h][w]=0;
    for(int i=h-1; i<h+2; i++){
        for(int j=w-1; j<w+2; j++){
            if(c[i][j]==1 && i>=0 && j>=0 && i<H && j<W) island(i,j);
        }
    }
}

int main(void){
    int count;
    while(1){
        cin>>W>>H;
        count=0;
        if(W==0 && H==0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cin>>c[i][j];
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(c[i][j]==1){
                    count++;
                    island(i,j);
                }
            }
        }
        cout<<count<<endl;
    }
}



Measured memory_bytes: 3172
//ライブラリテスト
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int n, s, g, c;

VVI _map;
//ワーシャルフロイド
void warshall_floyd( VVI &root ) {
	for ( int i = 0; i < root.size(); i++ ) {
		for ( int j = 0; j < root.size(); j++ ) {
			for ( int k = 0; k < root.size(); k++ ) {
				root[ j ][ k ] = root[ k ][ j ] = min( root[ j ][ k ], root[ j ][ i ] + root[ i ][ k ] );
			}
		}
	}
}

//ユーグリッド互除法
int gcd( int n, int m ) {
	if ( m == 0 ) {
		return n;
	}
	return gcd( m, n % m );
}

//素数の配列を作成
void make_prime( VI &pm, int max ) {
	vector<bool> is_pm( max + 1, true );
	is_pm[ 0 ] = is_pm[ 1 ] = false;
	for ( int i = 2; i * i <= max; i += 2 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j <= max; j += i ) {
				is_pm[ j ] = false;
				if ( i != 2 ) {
					j += i;
				}
			}
			if ( i == 2 ) {
				--i;
			}
		}
	}
	for ( int i = 2; i <= max; i += 2 ) {
		if ( is_pm[ i ] ) {
			pm.push_back( i );
			if ( i == 2 ) {
				--i;
			}
		}
	}
}


int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		_map.resize( 100 );
		for ( int i = 0; i < 100; i++ ) {
			_map[ i ].resize( 100 );
			for ( int j = 0; j < 100; j++ ) {
				if ( i == j ) {
					_map[ i ][ j ] = 0;
				}
				else {
					_map[ i ][ j ] = INF;
				}
			}
		}
		int max_town = 0;
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d %d %d", &s, &g, &c );
			_map[ s ][ g ] = _map[ g ][ s ] = c;
			max_town = max( max_town, max( g, s ) + 1 );
		}
		warshall_floyd( _map );
		int ans_cost = INF, ans_town;
		for ( int i = 0; i < max_town; i++ ) {
			int cost = 0;
			for ( int j = 0; j < max_town; j++ ) {
				cost += _map[ i ][ j ];
			}
			if ( ans_cost > cost ) {
				ans_cost = cost;
				ans_town = i;
			}
		}
		printf( "%d %d\n", ans_town, ans_cost );
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k;
  cin >> n >> k;
  if(k<=(n+1)/2){
    print("YES");
  }
  else{
    print("NO");
  }
}

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

int w,h;
int mas[21][21];

int rec(int x,int y){
  if(x >= w || x < 0 || y >= h || y < 0) return 0;
  if(mas[y][x] == 1) return 0;
  if(y == h-1 && x == w-1) return 1;
  return rec(x,y+1) + rec(x+1,y);
}

int main(){
  int n;
  while(cin >> w >> h,h||w){
    memset(mas,0,sizeof(mas));
    cin >> n;
    for(int i=0;i<n;i++){
      int x,y; cin >> x >> y;
      mas[y-1][x-1] = 1;
    }
    cout << rec(0,0) << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  long long l = 1;
  for(auto a : A){
    l = l/__gcd(a/2,l)*a/2;
  }
  for(auto a : A){
    if((l/(a/2))%2) continue;
    cout << 0 << endl;
    return 0;
  }
  cout << (M/l+1)/2 << endl;
}


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

int Search(long long int box) {
	long long int bag = N;
	while (bag%box == 0)bag /= box;
	return (bag%box) == 1;
}

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

	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int H, W, N;
	scanf ("%d", &H);
	scanf ("%d", &W);
	scanf ("%d", &N);
	if (H < W)
	{
		H=W;
	}
	if (N % H == 0){
		printf ("%d", N/H);
	}
	else if (N % H != 0){
		printf ("%d", (N/H) + 1);
	}
return 0;
}

Measured memory_bytes: 1732
sub f{print"? @_
"}$L=0,$|=$R=10,$_.=${f(($_.($%=$L+$R>>1))*1e9),<>=~Y?$R:$L=$%while$R-$L>1;L}while$i++<9;f++$_+s/0*$//;f 1+($_.=0)while<>=~(/^9*$/?Y:N);print"! $_"

Measured memory_bytes: 852
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
using namespace std; 

int main(){
    int n,k; cin >> n >> k;
    int a=1;
    while (true){
        if (n<k) break;
        n=n/k;
        a++;
    }
    cout << a << "\n";
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, m; cin >> n >> m; int ans(m);
	vector<int>v;
	rep(i, 0, n) {
		int a, b; cin >> a >> b;
		v.push_back(a - b);
	}
	rep(i, 0, n) {
		m += v[i];
		ans = max(ans, m);
		if (m < 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3156
from math import factorial
n, m = [int(i) for i in input().split()]
const = 10**9 + 7
nf = factorial(n) % const
mf = factorial(m) % const
ret = (nf * mf) % const
if n - m == 1 or m - n == 1:
    ret = (nf * mf) % const
elif n == m:
    ret *= 2
    ret %= const
else:
    ret = 0
print(ret)

Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  cout << (a > b ? "Alice" : a < b ? "Bob" : "Draw") << '\n';
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < m; i++) {
		int p, q;
		cin >> p >> q;
		a[p - 1]++;
		a[q - 1]++;
	}

	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 640