akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
vector<vector<pair<int, int>>>adj;

int val[25];
int anss=0;
bool dfs(int v, int p, int dest){
	if(v==dest){
		return 1;
	}
	for(auto u:adj[v]){
		if(u.f==p){
			continue;
		}
		if(dfs(u.f, v, dest)){
			anss=(anss|(1LL<<(u.s)));
			return 1;
		}
	}
	return 0;
}

main() {
	int n;
	cin>>n;
	adj.resize(n+1);
	for(int i=0; i<n-1; i++){
		int u, v;
		cin>>u>>v;
		adj[u].pb({v, i});
		adj[v].pb({u, i});
	}
	int m;
	cin>>m;
	vector<pair<int, int>>v;
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		v.pb({a, b});
	}
	for(int i=0; i<m; i++){
		bool b=dfs(v[i].f, 0, v[i].s);
		val[i]=anss;
		anss=0;
	}
	int ans=0;
	for(int i=0; i<(1LL<<m); i++){
		
		int bit=0;
		for(int j=0; j<m; j++){
			if(((1LL<<j)&i)==(1LL<<j)){
				bit=(bit|val[j]);
			}
		}
		int num=0;
		for(int j=0; j<51; j++){
			if(((1LL<<j)&bit)!=0){
				num++;
			}
		}
	
		int rem=n-1-(num);
		
		if(__builtin_popcount(i)%2==0){
			ans+=(1LL<<rem);
		}
		else{
			ans-=(1LL<<rem);
		}
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
main(){
long a,b=-1,n,res=-1;
cin>>n;
while(n--){
cin>>a;
if(a>b+1){
cout<<-1;
return 0;
}
res+=a>b?1:a;
b=a;
}
cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 404;

void nhap()
{
}

void solve()
{
    string s;
    string T = "keyence";
    cin >> s;
    int n = s.size();
    if (n == 7) {
        bool kt = true;
        for (int i = 0; i < 7; i++) {
            if (s[i] != T[i]) kt = false;
        }
        cout << (kt ? "YES" : "NO");
        return;
    }
    for (int len = n - 7; len <= n - 7; len++) {
        for (int i = 0; i <= n - len; i++) {
            int R = i + len - 1;
            string S = "";
            for (int j = 0; j < i; j++) S.push_back(s[j]);
            for (int j = R + 1; j < n; j++) S.push_back(s[j]);
            bool kt = true;
            for (int i = 0; i < 7; i++) {
                if (S[i] != T[i]) kt = false;
            }
            if (kt) {
                cout << "YES";
                return;
            }
        }
    }
    cout << "NO";
}
int main()
{
    nhap();
    solve();
}


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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(N).lower())

Measured memory_bytes: 9168
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(int x0, int y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    double norm(){
        return x * x + y * y;
    }
    double abs(){
        return sqrt(norm());
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        // if(x != p.x) return x < p.x;
        // else return y < p.y; 
        return x != p.x ? x < p.x : y < p.y ;
    }

};

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

int main(){
    int Q;
    cin >> Q;
    rep(i, Q){
        Point p0, p1, p2, p3;
        cin >> p0.x >> p0.y;
        cin >> p1.x >> p1.y;
        cin >> p2.x >> p2.y;
        cin >> p3.x >> p3.y;
        Vector s1 = p0 - p1, s2 = p2 - p3;
        if(equals(cross(s1, s2), 0)) cout << 2 << endl;
        else if (equals(dot(s1, s2), 0)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);

    rep(i, N) {
        cin >> d[i];
    }

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

    int l, r;
    l = d[(N / 2) - 1];
    r = d[N / 2];

    cout << r - l << endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=list(map(int, input().split()))
r=0
for i in range(0,n):
  if a[i]%2==1:
    r=r+1
if r%2==0:
  print('YES')
else:
  print('NO')
  



Measured memory_bytes: 14108
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }

    return 0;
}


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

int main()
{
  long A, B, C, D, E, F;
  std::cin >> A >> B >> C >> D >> E >> F;
  
  std::vector<long> dp(F + 1, -1);
  dp[0] = 0;
  
  for (long i = 0; i < F; ++i) {
    if (dp[i] < 0) continue;
    
    // 操作1
    dp[i + 100 * A] = std::max(dp[i + 100 * A], dp[i]);
    
    // 操作2
    dp[i + 100 * B] = std::max(dp[i + 100 * B], dp[i]);
    
    // 操作3
    if ((i + C) * E >= (dp[i] + C) * (100 + E)) {
      dp[i + C] = std::max(dp[i + C], dp[i] + C);
    }
    
    // 操作4
    if ((i + D) * E >= (dp[i] + D) * (100 + E)) {
      dp[i + D] = std::max(dp[i + D], dp[i] + D);
    }
  }
  
  long total = A * 100, sugar = 0;
  for (long i = 1; i <= F; ++i) {
    if (dp[i] < 0) continue;
    
    if (i * sugar < dp[i] * total) {
      total = i;
      sugar = dp[i];
    }
  }
  
  std::cout << total << ' ' << sugar << std::endl;
  
  return 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e6 + 7;
int n, f[N];
bool has[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    f[x]++;
  }
  for (int i = 1; i < N; i++) {
    if (f[i]) {
      if (f[i] >= 2) {
        has[i] = 1;
      }
      for (int j = 2 * i; j < N; j += i) {
        has[j] = 1;
      }
    }
  }
  int sol = 0;
  for (int i = 1; i < N; i++) {
    if (has[i] == 0) {
      sol += f[i];
    }
  }
  cout << sol << "\n";
  return 0;
}


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

int ans;

int run(vector<int> v){

    /*
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << " ";
    }
    */

    int min_elem = *min_element(v.begin(), v.end());
    ans = ans + min_elem;
    for(int i = 0; i < v.size(); i++){
        v[i] -= min_elem;
    }


    //cout << ":" << min_elem << endl;
    

    vector<int> nv;
    for(int i = 0; i < v.size(); i++){
        //cout << "i:" << i << " " <<  v[i] << endl;;
        if(v[i] != 0){
            nv.push_back(v[i]);
        }
        else{
            if(nv.size() > 0){
                run(nv);
                nv.clear();
            }
        }
    }
    if(nv.size() > 0) run(nv);
   

}

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

    vector<int> height(n);
    for(int i = 0; i < n; i++){
        cin >> height[i];
    }

    run(height);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sch[105][10]={0};
int pro[1024]={0};
int P[105][11]={0};
int Y[105]={0};

int main(int argc, char** argv) 
{
	int open[10]={0};
	int N,i,j,k;
	int max;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++)
		for(j=0;j<10;j++)
			scanf("%d",&sch[i][j]);
	
	for(i=0;i<N;i++)
		for(j=0;j<=10;j++)
			scanf("%d",&P[i][j]);
			
	for(i=1;i<1024;i++)
	{
		for(k=0;k<N;k++)
		Y[k]=0;
		
		for(j=9;j>=0;j--)
		{
			open[j]=(i>>(9-j))&1;
		}
		
		for(k=0;k<N;k++)
			for(j=0;j<10;j++)
				if(open[j]&&sch[k][j]) Y[k]++;
		
		for(k=0;k<N;k++)		
		pro[i]+=P[k][Y[k]];
	}
	
	max=1;
	for(i=2;i<1024;i++)
		if(pro[max]<=pro[i]) max=i;
		
	printf("%d\n",pro[max]);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int n, m, c;
typedef pair<long long int, int> P;
vector<P> g[100000];
long long int d[100000];
long long int INF = 1e18+7;
vector<P> e;
long long int ans = INF;
long long int a, b;

void dijkstra(){
	fill(d, d+n, INF);
	d[0] = 0;
	priority_queue <P, vector<P>, greater<P> > q;
	q.push(P(0, 0));
	while(!q.empty()){
		P p = q.top();
		q.pop();
		int v = p.second;
		for(int i=0; i<g[v].size(); ++i){
			if(d[g[v][i].second] > d[v] + g[v][i].first){
				d[g[v][i].second] = d[v] + g[v][i].first;
				q.push(P(d[g[v][i].second], g[v][i].second));
			}
		}
	}
}

int main(){
	scanf("%d %d %d", &n, &m, &c);
	for(int i=0; i<m; ++i){
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		g[t1-1].push_back(P(t3, t2-1));
		g[t2-1].push_back(P(t3, t1-1));
		b += t3;
	}
/*
	for(int i=0; i<n; ++i){
		for(int j=0; j<g[i].size(); ++j){
			printf("%d %d %lld\n", i+1, g[i][j].second+1, g[i][j].first);
		}
	}
*/
	dijkstra();

//	for(int i=0; i<n; ++i) printf("%lld\n", d[i]);

	for(int i=0; i<n; ++i)
		e.push_back(P(d[i], i));

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

//	for(int i=0; i<n; ++i) printf("%lld %d\n", e[i].first, e[i].second);

	for(int i=0; i<n; ++i){
		a = c * e[i].first;
		for(int j=0; j<g[e[i].second].size(); ++j){
			if(e[i].first > d[g[e[i].second][j].second]){
				b -= g[e[i].second][j].first;
			}else if(e[i].first == d[g[e[i].second][j].second]){
				b -= g[e[i].second][j].first;
				for(int k=0; k<g[g[e[i].second][j].second].size(); ++k){
					if(g[g[e[i].second][j].second][k].second == e[i].second){
						g[g[e[i].second][j].second][k].first = 0;
					}
				}
			}
		}
		ans = min(ans, a+b);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 18900
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

void dfs(int x, const vector<VI> &es, VI &top, int &current) {
  FOR(v,es[x]) {
    if(top[v]) {
      continue;
    }
    dfs(v, es, top, current);
  }
  top[x] = current--;
}

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<VI> es(n+1);
  vector<VI> rev(n+1);
  REP(i,0,n-1+m) {
    int a, b;
    cin >> a >> b;
    es[a].push_back(b);
    rev[b].push_back(a);
  }
  int current = n;
  VI top(n+1);
  int root = 0;
  REP(i,1,n+1) {
    if(rev[i].empty()) {
      root = i;
      break;
    }
  }
  dfs(root, es, top, current);
  REP(i,1,n+1) {
    int parent = 0;
    int maxt = -1;
    FOR(v,rev[i]) {
      if(top[v] > maxt) {
        parent = v;
        maxt = top[v];
      }
    }
    cout << parent << endl;
  }

  return 0;
}


Measured memory_bytes: 18432
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,a,b=parseMap(split(readline()))
    x=parseMap(split(readline()))
    ans=0
    for i in 2:n
        ans+=min((x[i]-x[i-1])*a,b)
    end
    println(ans)
end
main()

Measured memory_bytes: 167800
N, A, B, C, D = [int(_) for _ in input().split()]
distance = abs(A - B)
for i in range(N):
    if -D * i + C * (N - 1 - i) <= distance <= -C * i + D * (N - 1 - i):
        print('YES')
        exit()
print('NO')


Measured memory_bytes: 2940
import numpy as np

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)


Measured memory_bytes: 53520
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mn,mx;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n/2]-a[(n/2)-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int N = 3000;
int dp[N+1][N+1];
int main() {
    ios_base::sync_with_stdio(0);
    string s, t;
    cin >> s;
    cin >> t;
    for (int i = 1; i <= s.size(); ++i) {
        for (int j = 1; j <= t.size(); ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
            }
        }
    }
    string res;
    int i = s.size();
    int j = t.size();
    while (i >= 1 and j >= 1) {
        if (s[i-1] == t[j-1] and dp[i][j] == dp[i-1][j-1] + 1) {
            res += s[i-1];
            --i;
            --j;
        } else if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else {
            --j;
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 35584
#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 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
cout<<(a*x)/b-(x/b)*a;
return 0;
}

Measured memory_bytes: 3136
#![allow(non_snake_case, unused_imports)]

// Input macros
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        A: u64,
        B: u64,
    }
    println!("{}", 
        if (A*B)%2 == 0{
            "Even"
        }else{
            "Odd"
        }
    );
}


Measured memory_bytes: 4352
#include<cmath>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=100000+10;
ll f[maxn],xx[maxn];
ll n,e,t;
ll store;//fj-2xj+1
int main(){
	ll b1,b2,b3,b4;
	ll p;//定位
	scanf("%lld%lld%lld",&n,&e,&t);
	
	for (b1=1;b1<=n;b1++){
		scanf("%lld",&xx[b1]);
	}
	for (b1=1;b1<=n;b1++){
		f[maxn]=b1*t;
	}
	p=0;store=((ll)1<<60);
	for (b1=1;b1<=n;b1++){
		while (2*xx[p+1]<=2*xx[b1]-t){
			store=min(store,f[p]-2*xx[p+1]);
			p++;
		}
		f[b1]=min(2*xx[b1]+store,f[p]+t);
		f[b1]=min(f[b1-1]+t,f[b1]);
	}
	printf("%lld\n",f[n]+e);
	
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int P = 100;
const int N = 1000000;
const int mo = 1e9 + 7;

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

int n, ans;
int cx[N + 5], cy[N + 5];
int ix[N + 5], iy[N + 5];
int sx[N + 5], sy[N + 5], totX, totY;

inline int size(int x, int y) {
    return 1ll * sx[x] * sy[y] % mo;
}

int solve(int *cnt, int *id, int *s, int R, int C) {
    int l = R - cnt[0], r = (1ll * R * C - n - l) % mo;

    ++ s[0];
    for(int i = 1; i < C; ++i) {
        id[i] = id[i-1];

        if(!cnt[i] && !cnt[i-1]) {
            ans = (ans + 1ll * l * r) % mo;
        } else {
            ++ id[i];
        }
        ++ s[id[i]];
        l = (l + R - cnt[i]) % mo;
        r = (r + cnt[i] - R) % mo;
    }
    return id[C - 1] + 1;
}

int r, c;
int dis[P + 5][P + 5];
bool vis[P + 5][P + 5];
int x[P + 5], y[P + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(r), read(c), read(n);
    for(int i = 0; i < n; ++i) {
        read(x[i]), read(y[i]);
        ++ cx[x[i]], ++ cy[y[i]];
    }

    totY = solve(cy, iy, sy, r, c);
    totX = solve(cx, ix, sx, c, r);

    ans = ans * 2 % mo;
    for(int i = 0; i < n; ++i) vis[ix[x[i]]][iy[y[i]]] = true;
    for(int i = 0; i < totX; ++i) 
        for(int j = 0; j < totY; ++j) if(!vis[i][j]) {
            std::queue<pii> q;
            memset(dis, 0xff, sizeof dis);

            dis[i][j] = 0;
            q.push(mp(i, j));

            while(!q.empty()) {
                pii cur = q.front(); q.pop();

                ans = (ans + 1ll * dis[cur.fst][cur.snd] * size(cur.fst, cur.snd) % mo * size(i, j)) % mo;

                for(int d = 0; d < 4; ++ d) {
                    pii nxt = mp(cur.fst + dx[d], cur.snd + dy[d]);

                    if(nxt.fst >= 0 && nxt.fst < totX &&!~dis[nxt.fst][nxt.snd]
                    && nxt.snd >= 0 && nxt.snd < totY && !vis[nxt.fst][nxt.snd]) {
                        dis[nxt.fst][nxt.snd] = dis[cur.fst][cur.snd] + 1;
                        q.push(nxt);
                    }
                }
            }
        }

    printf("%lld\n", 1ll * ans * (mo + 1) / 2 % mo);

    return 0;
}


Measured memory_bytes: 18816
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans=100;
    REP(i,N){
        int a; cin>>a;
        int cnt=0;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
bigint dp[10000] ;
int main(){
    FAST_IO ;
    
    int N ; cin >> N ;
    if( N < 3 ){
        cout << 0 << endl ;
        return 0 ;
    }
    
    dp[0] = 1 ;
    
    for( int i = 3 ; i <= N ; i++ ){
        for( int j = i ; j >= 3 ; j-- ){
            (dp[i] += dp[i-j]) %= mod  ;
        }
    }
    cout << dp[N] << endl ;
    return 0 ;
  }





// dp[x] = represents the expected value of steps to get gcd = 1 when current gcd = x


// Exepected Value  = 1 + sigma ( dp[i] / M ) from i = 1 to M ;

// 001
// 110
// 011
// 100




Measured memory_bytes: 3596
a, b = map(int, input().split())
c = list(map(int,input().split()))

x = [(e + 1) / 2 for e in c]

t = sum(x[0:b])
res = t
for i in range(a - b):
  t -= x[i]
  t += x[i+b]
  res = max(res,t)

print('{:.12f}'.format(res))

Measured memory_bytes: 25060
#include<iostream>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    int X;std::cin >> X;
    std::string ans="No";

    if (X >= 30) {
        ans="Yes";
    }

    std::cout << ans;

    return 0 ;
}


Measured memory_bytes: 3608
h,w = map(int, input().split())

ab = list(input() for _ in range(h))

dp =[["_" for i in range(w+2)] for j in range(h+2)]

for i in range(h):
    for j in range(w):
        dp[i+1][j+1] = ab[i][j]

for i in range(h):
    for j in range(w):
        if dp[i+1][j+1] =="#":
            if dp[i][j+1]=="#" or dp[i+2][j+1]=="#" or dp[i+1][j] =="#" or dp[i+1][j+2]=="#":
                pass
            else:
                print("No")
                exit()
print("Yes")

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

using namespace std;

int main() {
  vector<int> abc(3);
  int K;
  for (int i = 0; i < 3; ++i) cin >> abc[i];
  sort(abc.begin(), abc.end(), greater<int>());
  cin >> K;
  for (int i = 0; i < K; ++i) {
    abc[0] *= 2;
  }

  int ans = 0;
  for (int i = 0; i < 3; ++i) ans += abc[i];
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int min = Integer.MAX_VALUE;
        int ans = 0;
        for (int i = 0 ; i < N; i++){
            int digit = sc.nextInt();
            if (min > digit){
                min = digit;
                ans ++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}


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

using namespace std;

const int maxn = (int)1e5 + 100;
int n;
struct node {
    int a, b;
}stu[maxn];

bool cmp(node q, node w) {
    return q.a < w.a;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> stu[i].a;
        stu[i].b = i;
    }
    sort(stu + 1, stu + 1 + n, cmp);
    for (int i = 1; i <= n; ++i) {
        if (i == n) {
            cout << stu[i].b << '\n';
        } else {
            cout << stu[i].b << " ";
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

    int N; cin >> N;

    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i] >> C[i];

    int a, b, c;

    vector<int> dp{A[0], B[0], C[0]};
    for (int i = 1; i < N; ++i) {
        a = max(dp[1], dp[2]) + A[i];
        b = max(dp[0], dp[2]) + B[i];
        c = max(dp[0], dp[1]) + C[i];
        dp = {a, b, c};
    }

    cout << max(dp[0], max(dp[1], dp[2])) << "\n";

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
//    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N;
    cin >> N;
    double p = (N+1)/2 /(1.0*N);
    printf("%.10f", p);

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<ll, ll>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;
const ll MAX = 1000005;

ll ans;
bool isprime[MAX];
vector<P> vv;

vector<long long> eratosthenes_seive(int n) {
	bool t[n+5];
	vector<long long> v;

	for (int i = 2; i <= n+1; i++) t[i] = true;

    for (int i = 2; i <= n+1; i++) {
    	if ( t[i] == true ) {
    		v.push_back((long long)i);
    		for (int j = i + i; j <= n+1; j += i) t[j] = false;
    	}
    }
    return v;
}

vector<pair<long long, long long> > prime_factrization(long long n) {

	vector<long long> v;
	vector<pair<long long, long long> > res;
	v = eratosthenes_seive((int)sqrt(n));

	for (int i = 0; i < v.size(); i++) {
		
		if (n % v[i] == 0) {
			long long _c = 0;
			while (n % v[i] == 0) {
				_c++;
				n /= v[i];
			}
			res.push_back(make_pair(v[i], _c));
		}
	}
	
	if (n > 1) res.push_back(make_pair(n, 1));
	return res;
}

int main(void) {
    ll N;
    cin >> N;


    vv = prime_factrization(N);

    for (auto x : vv) {

        ll xx = x.second;
        ll j = 1;
        while (xx-j>=0) {
            xx -= j;
            j++;
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5364
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@lru_cache(maxsize=None)
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    return gcd(b, a % b)

@mt
def slv(N, A):
    m = 10**9+7
    l = 1
    for a in A:
        l = a * l // gcd(a, l)

    l %= m
    M = Mod(10**9+7)
    ans = 0
    for a in A:
        ans = M.add(ans, M.div(l, a))

    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))

    # N = 10000
    # A = [random.randint(1, 10**6) for _ in range(N)]
    # print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 186848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    string s;
    cin >> s;
    s.at(3) = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            for(int a=-199; a < 200; a++)
            {
                for(int b=-200; b < a; b++)
                {
                    if (x == a * a * a * a * a - b * b * b * b * b)
                    {
                        Console.WriteLine(a + " " + b);
                        goto label;
                    }
                }
            }
        label:;
        }
    }
}


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

int main(void){
  int x,a;
  cin>>x>>a;

  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int main() {
	string S,T;
	getline(cin,S);
	getline(cin,T);

	bool ans = false;

	int len = S.length();

	REP(t,len){
		bool nans = true;
		REP(j,len){
			if (S[(j+t) % len] != T[j]) nans = false;
		}

		if (nans == true)ans = true;
	}

	if (ans == true) printf("Yes\n");
	else printf("No\n");


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll minthis(ll a, ll b){
if(a < b){
return a;
}
return b;
}
ll maxthis(ll a, ll b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
} 
 
void solve(){	
    int n,k,m;
   cin >> n >> k >> m;
   int val = n/k;
   if(n%k){
    val++;
   }
  cout << val*m << "\n"; 
}
 
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
	solve();
    }
    return 0; 
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    bool checker = true;
    ll sum = 0;
    ll mini = INF;
    for(int i = 1; i <= n; i++){
        ll a, b;
        cin >> a >> b;
        sum += b;
        if(a > b){
            mini = min(mini, b);
            checker = false;
        }
    }
    if(checker){
        cout << 0 << endl;
        return 0;
    }
    cout << sum - mini << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
//#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)

std::string highlight(std::string s) {
#ifdef _MSC_VER
    return s;
#else
    return "\033[33m" + s + "\033[0m";
#endif
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << highlight(os.str());                 \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << highlight(os.str());                 \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

using namespace std;

int main() {
    string s;
    while (cin >> s) {
        int n = s.size();
        int ans = n;
        for (int i = 0; i < n - 1; ++i) {
            if (s[i] != s[i + 1]) {
                ans = min(ans, max(i + 1, n - (i + 1)));
            }
        }
        cout << ans << endl;
    }
}

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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> A >> B >> C;

    if(B/A > C) cout << C << endl;
    else cout << B/A << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

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

int main() {
  vector<vector<int>> data(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) cin >> data[i][j];
  }
  int n; cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  
  bool bingo = false;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < n; k++){
        if(data[i][j]==vec[k]) data[i][j] = 0;
      }
    }
  }
  
 for (int i = 0; i < 3; i++)
   if(data[i][0] == 0 && data[i][1] == 0 && data[i][2] == 0) bingo = true;
 for (int i = 0; i < 3; i++) 
   if(data[0][i] == 0 && data[1][i] == 0 && data[2][i] == 0) bingo = true;
 if(data[0][0] == 0 && data[1][1] == 0 && data[2][2] == 0) bingo = true;
 if(data[0][2] == 0 && data[1][1] == 0 && data[2][0] == 0) bingo = true;
 
  if(bingo)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  char c;
  ci(c);
  'a' <= c && c <= 'z' ? co('a') : co('A');
}


Measured memory_bytes: 3624
var ModUtils = function(mod){
	this.mod = mod;
}
ModUtils.prototype.inv = function(n) {
  function euclidean(a,b){
  	if(a == 1 && b == 0)return {x:1,y:0};
  	var ans = euclidean(b,a%b);
    var x = ans.y;
    var y = ans.x - x * Math.floor(a/b);
    return {x:x,y:y};
  }
  var c = euclidean(this.mod,n).y;
  while(c < 0){c += this.mod}
  return c;
};
ModUtils.prototype.product = function() {
  var initVal = 1;
  var len = arguments.length;
  for(var i = 0; i < len;i++){
  	var elem = arguments[i];
  	initVal = this.times(initVal,elem);
  }
  return initVal;
};
ModUtils.prototype.times = function(hoge,fuga) {
	if(hoge*fuga > Number.MAX_SAFE_INTEGER){
  	var b = hoge % this.mod;
 		var d = fuga % this.mod;
    var min = Math.min(b,d);
    var max = Math.max(b,d);
    
    var hogehoge = 0;
    if(min % 2){
    	hogehoge += max;
      min -= 1;
    }
    var half = this.times(max,min/2);
    
    hogehoge += half;
    hogehoge %= this.mod;
    hogehoge += half;
    hogehoge %= this.mod;
    return hogehoge;
  }else{
  	return (hoge*fuga) % this.mod;
  }
};
ModUtils.prototype.combination = function(n,k){
  k = Math.min(k,n-k);
  var a = this.product(...Array.from({length:k},(v,k)=>n-k));
  var b = this.product(...Array.from({length:k},(v,k)=>k+1));
  var bInv = this.inv(b);
  return this.product(a,bInv);
}

function Main(input){
	var N = input.split(" ")[0];
	var M = input.split(" ")[1];

	N = ~~N;
  M = ~~M;
	var primeList = [2,3];
  
  input = M;
  
  var inputRoot = Math.floor(Math.sqrt(input));
  
  for(var i = primeList[primeList.length-1] + 1; i <= inputRoot;i++){
  	if(primeList.find(a=>i%a==0)===undefined)primeList.push(i);
  } 
  
  var primeFact = {};
  
  for(var elem of primeList){
  	while(input%elem == 0){
    	input /= elem;
      primeFact[elem] = (primeFact[elem] || 0)+1;
    }
  }
  
  if(input != 1){
  	primeFact[input] = (primeFact[input] || 0)+1;
  }
  
  var mod = 1000000007;
  var mu = new ModUtils(mod);
  
  var arr = [];
  for(var key in primeFact){
  	var elem = primeFact[key];
  	arr.push(mu.combination(elem+N-1,elem));
  }
  return mu.product(...arr);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
2 35
`);

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  ll ans = 700;
  rep(i, 0, 3) if(s.at(i) == 'o') ans += 100;
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
h = list(map(int, input().split()))

t = x[0]
a = x[1]
cnt = 1000000000000000000000
ans = 0
for i in range(n):
  tmp = abs(t-(h[i]*0.006)-a)
  if cnt > tmp:
    cnt = tmp
    ans = i+1
print(ans)


Measured memory_bytes: 9120
// https://atcoder.jp/contests/agc003/tasks/agc003_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    bool find_n = (s.find("N") != string::npos);
    bool find_s = (s.find("S") != string::npos);
    bool find_e = (s.find("E") != string::npos);
    bool find_w = (s.find("W") != string::npos);

    // NとSの片方のみ存在、もしくはEとWの片方のみ存在する場合
    if (find_n ^ find_s || find_e ^ find_w) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	int n,a[101];
	cin>>n;
	rep(i,0,n)cin>>a[i];
	sort(a,a+n,greater<int>{});
	int al=0,bo=0;
	rep(i,0,n){
//		cout<<a[i]<<endl;
		if(i%2==0)al+=a[i];
		else bo+=a[i];
	}
	cout<<al-bo<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  if (X<0) {
    X *= -1;
  }
  long long dis = X / D;
  long long ans;
  if (dis >= K) {
    ans = X - K*D;
  }
  else {
    if ((dis % 2) == (K % 2)) {
      ans = X % D;
    }
    else {
      ans = D- (X % D);
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3620
<?php
fscanf(STDIN, "%s %s %s", $a, $b, $k);

if($a<$k){
    $k-=$a;
    $a=0;
    if($b<$k){
        $b=0;
    }else{
        $b-=$k;
    }
}else{
    $a-=$k;
}

echo $a." ".$b."\n";
?>

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

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

int gcd(int a, int b) {
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int k;
    cin >> k;

    int sum = 0;

    iFOR(l, 1, k + 1) {
        iFOR(m, 1, k + 1) {
            int gcd_l_m = gcd(l, m);
            iFOR(n, 1, k + 1) {
                sum += gcd(gcd_l_m, n);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3648
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

data = [a1, a2, a3, b1, b2, b3]

yy = [0] * 4

for x in data:
    yy[x - 1] += 1

flag = True

for y in yy:
    if y > 2:
        flag = False
        break

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064