akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    PRINT(180*(n-2));
}


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

int main(){
 int N, M, p, t;
 string ans = "Yes";
  cin >> N >> M;
  vector<int>H(N, 0);
  rep(i, N){
   cin >> p;
   t += p;
   H.push_back(p);   
  }
  
  sort(H.begin(), H.end(), greater<int>());
  rep(i, M){
    //cout << "H" << H[i] << "Ave" << d << endl;
   if( H[i]*M*4 < t){
     ans = "No";
   }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
    }

    let twos = [1, 2, 4, 8, 16, 32, 64];
    println!("{}", twos.iter().rev().find(|&&x| x <= n).unwrap());
}


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

int P[101010], Y[101010];

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> y[101010];
    map<int, int> mp[101010];
    rep(i, M) {
        cin >> P[i] >> Y[i];
        y[P[i]].push_back(Y[i]);
        mp[P[i]][Y[i]];
    }

    rep(i, N+1) {
        int cur = 1;
        for (auto & tmp : mp[i]) tmp.second = cur++;
    }

    rep(i, M) {
        printf("%06d%06d\n", P[i], mp[P[i]][Y[i]]);
    }

}


Measured memory_bytes: 17152
#include<iostream>
using namespace std;
int main(void){
	int a,b,c,d,sum=0;
	cin>>a>>b>>c>>d;
	if(a>b)
	sum+=b;
	else sum+=a;
	if(c>d)
	sum+=d;
	else sum+=c;
	cout<<sum<<endl;
	
}


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

vector<int> ed[100001];

int dfs(int node,int p){


int ans=0;


int i;
for(i=0;i<ed[node].size();i++){

    int x=ed[node][i];
    if(x==p)
        continue;
    int u=1+dfs(x,node);
    ans=ans^u;



}

return ans;



}


int main(){
int n;
cin>>n;
int i;
for(i=1;i<n;i++)
{

    int x,y;
    cin>>x>>y;
    ed[x].push_back(y);
    ed[y].push_back(x);



}

int g=dfs(1,0);

if(g)
    cout<<"Alice"<<endl;
else
    cout<<"Bob"<<endl;



return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> m(h);
    vector<vector<int>> c(h, vector<int>(w, -1));
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    for (int i = 0; i < h; i++) {
        cin >> m[i];
    }
    stack<pair<int, int>> s, s2;
    s.push(make_pair(ch, cw));
    c[ch][cw] = 0;
    auto check = [&](int i, int j) {
        if (i < 0 || j < 0 || i >=h || j >= w) {
            return false;
        }
        if (c[i][j] != -1 || m[i][j] != '.') {
            return false;
        }
        return true;
    };
    do {
        while (!s.empty()) {
            auto p = s.top();
            if (p.first == dh && p.second == dw) {
                cout << c[p.first][p.second] << endl;
                return 0;
            }
            s2.push(p);
            s.pop();
            auto move = [&](int i, int j) {
                if (check(i, j)) {
                    s.push(make_pair(i, j));
                    c[i][j] = c[p.first][p.second];
                }
            };
            move(p.first + 1, p.second);
            move(p.first - 1, p.second);
            move(p.first, p.second + 1);
            move(p.first, p.second - 1);
        }
        while (!s2.empty()) {
          auto p = s2.top();
          s2.pop();
          auto warp = [&](int i, int j) {
            if (check(i, j)) {
              s.push(make_pair(i, j));
              c[i][j] = c[p.first][p.second] + 1;
            }
          };
          warp(p.first + 1, p.second + 1);
          warp(p.first - 1, p.second + 1);
          warp(p.first + 1, p.second - 1);
          warp(p.first - 1, p.second - 1);
          for (int i = 0; i < 5; i++) {
            warp(p.first - 2, p.second - 2 + i);
            warp(p.first - 2 + i, p.second - 2);
            warp(p.first + 2, p.second - 2 + i);
            warp(p.first - 2 + i, p.second + 2);
          }
        }
    } while (!s.empty());
    cout << -1 << endl;
}


Measured memory_bytes: 9484
use std::collections::VecDeque;

fn main() {
    proconio::input! {
        n: usize,
        edge: [(proconio::marker::Usize1, proconio::marker::Usize1); n-1],
        mut c: [i64; n]
    }
    c.sort();
    println!("{}", c[0..n-1].iter().sum::<i64>());
    let mut g = vec![Vec::new(); n];
    let mut deg = vec![0; n];
    for &e in &edge {
        g[e.0].push(e.1);
        g[e.1].push(e.0);
    }
    let mut qu = VecDeque::new();
    for i in 0..n {
        deg[i] = g[i].len();
        if deg[i] == 1 { qu.push_back(i) }
    }
    let mut res = vec![0; n];
    let mut idx = 0;
    while !qu.is_empty() {
        let p = qu.pop_front().unwrap();
        res[p] = c[idx];
        idx += 1;
        for &nxt in &g[p] {
            deg[nxt] -= 1;
            if deg[nxt] == 1 { qu.push_back(nxt) }
        }
    }
    print!("{}", res[0]);
    for i in 1..n { print!(" {}", res[i]) }
    println!("");
}


Measured memory_bytes: 3364
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,j,n,t;cin>>n;t=n;
	if(n%2==0){t=n+1;}
	cout<<n*(n-1)/2-t/2<<endl;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			if(i+j!=t){cout<<i<<" "<<j<<endl;}
		}
	}
	return 0;
}
//13 32
//

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	string s;
	cin>>s;
	if(s.at(s.size()-1)=='s') cout<<s+"es"<<endl;
	else cout<<s+"s"<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

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

int LCM(int a,int b){
	return a/__gcd(a,b)*b;
}

int main(){
	int n;
	ll sum = 0;
	cin>>n;
	int a[100001] = {0};
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		sum+=b;
		a[b]+=1;
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int b,c;
		cin>>b>>c;
		if(a[b] == 0){
			cout<<sum<<endl;
			continue;
		}
		else{
			for(int j=a[b];j>0;j--){		
				a[b]-=1;
				a[c]+=1;
				if(b < c){
					sum = sum+(c-b);
				}
				if(b > c){
					sum = sum-(b-c);
				}
				if(b == c){
					continue;
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3988
input_line = input().split(" ")
N=int(input_line[0])
M=int(input_line[1])
count=0

input_line = input().split(" ")
total=0
for i in range(len(input_line)):
    total=total+int(input_line[i])

border=total/(4*int(M))

for i in range(len(input_line)):
    if int(input_line[i])>=border:
        count=count+1
    

if count>=M:
    print("Yes")
else:
    print("No")

# input_line=' '.join(input_line)

Measured memory_bytes: 3064
N, K = list(map(int, input().split()))

A = [[False for _ in range(K)] for _ in range(N)]
for i in range(K):
    d = int(input())
    row = list(map(int, input().split()))
    for j in row:
        A[j-1][i] = True

cnt = 0
for row in A:
    if not any(row):
        cnt += 1

print(cnt)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int main() {
	char ch[2][3];
	int i, j;
	vector<char>v;
	vector<char>v1;
	
	
	for(i=0;i<2;i++)
	for(j=0;j<3;j++)
	cin>>ch[i][j];
	  
	  for(int i=0;i<3;i++)
	  {
	      v.push_back(ch[0][i]);
	      
	  }
	  
	
	 for(int i=0;i<3;i++)
	  {
	      v1.push_back(ch[1][i]);
	      
	  }
	  reverse(v.begin(),v.end());
	  int flag=0;
	  for(int i=0;i<v.size();i++)
	  {
	      if(v[i]!=v1[i])
	      {
	          cout<<"NO";
	          flag=1;
	          break;
	      }
	  }
	  if(flag==0)
	  {
	      cout<<"YES";
	  }
	  
}

Measured memory_bytes: 256
N, K = map(int, input().split())
if K > (N - 1) * (N - 2) // 2:
    print(-1)
    exit()

ans = []
for i in range(2, N + 1):
    ans.append((1, i))

P = (N - 1) * (N - 2) // 2
k = 2
while P > K:
    for i in range(k + 1, N + 1):
        ans.append((k, i))
        P -= 1
        if P == K:
            break
    k += 1

print(len(ans))
for a, b in ans:
    print(a, b)


Measured memory_bytes: 43120
#include<iostream>
using namespace std;
int main(void)
{
	char c;
	cin >> c;
	if (c == 'a') {
		cout << "vowel";
	}
	else if (c == 'i') {
		cout << "vowel";
	}
	else if (c == 'u') {
		cout << "vowel";
	}
	else if (c == 'e') {
		cout << "vowel";
	}
	else if (c == 'o') {
		cout << "vowel";
	}
	 else {
		cout << "consonant";
	}
	return 0;
}

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

using namespace std;

int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int H, W;
        double N;
        cin >> H >> W >> N;

        double larger_dim = max(H,W);
                
        cout << ceil(N/larger_dim) << "\n";
        return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
        for (int k = 0; k <= c; k++) {
          if (500*i+100*j+50*k==d) {
            ans++;
          }
        }
        }
        }
          
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int H,W;
  string s[9];
  cin >> H >> W;
  for ( int i = 0; i < H; i++ ) {
    cin >> s[i];
  }

  int cnt = 0;
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if ( s[i][j] == '#' ) cnt++;
    }
  }

  if ( cnt == H+W-1 ) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


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

num_ma = h[0]
ans = 0
flag = True


for i in range(n):
    if h[i] >= num_ma:
        num_ma = h[i]
        flag = True
    else:
        ans += num_ma-h[i]
        num_ma = h[i]
        flag = False

ans += h[n-1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define mi(N) int N; cin >> N;
#define ms(s) string s; cin >> s;
#define md(d) double d; cin >> d;
#define mv(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

template<typename T>
T max(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())maxi(ret, v[i]);
	return ret;
}

template<typename T>
T min(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())mini(ret, v[i]);
	return ret;
}

signed main() {
	mi(a);
	mi(b);
	say(max(a + b, max(2 * a - 1, 2 * b - 1)));
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cerr << i << ' '; cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll a[9] = {1, 1, 2, 3, 5, 8, 13, 21, 34};

int main(void){
	ll h, w, k;
	cin >> h >> w >> k;
	ll dp[h + 1][w];
	fill(dp[0], dp[h + 1], 0);
	dp[0][0] = 1;

	repn(i, h){
		rep(j, w){
			dp[i][j] += dp[i - 1][j] * a[j] * a[w - 1 - j];
			if(j){
				ll t = 1;
				t *= dp[i - 1][j - 1] * a[w - 1 - j];
				if(j - 1 >= 0) t *= a[j - 1];
				dp[i][j] += t;
			}
			if(j < w - 1){
				ll t = 1;
				t *= dp[i - 1][j + 1] * a[j];
				if(j + 1 < w) t *= a[w - 2 - j];
				dp[i][j] += t;
			}
			dp[i][j] %= MOD;
		}
	}
	co(dp[h][k - 1]);

	return 0;
}


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

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if ( (a == 5 && b == 5 && c == 7) ||  (a == 5 && b == 7 && c == 5 ) ||  (a == 7 && b == 5 && c == 5))
        cout << "YES" << endl;
    else 
        cout << "NO" << endl;
    return 0;
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (V < W) {
        cout << "NO" << endl;
        return 0;
    }

    ll D = abs(A - B);

    cout << (D <= (V - W) * T ? "YES" : "NO") << endl;

    return 0;
}


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

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

	int *ptr = new int[n];
	int *ptr2 = new int[n];
	for(int i=0; i<n; i++)
	{
		cin>>ptr[i];
		ptr2[i] = ptr[i];

	}

	sort(ptr2, ptr2+n);

	/*for(int i=0; i<n; i++)
	{
		cout<<*(ptr2+i)<<endl;
	}*/

	int count=0;

	for(int i=0; i<n; i++)
	{
		if(ptr[i]!=ptr2[i])
			count+=1;
		if(count>2)
			break;
	}

	if(count>2)
		cout<<"NO";
	else
		cout<<"YES";
	
	delete[] ptr;
	delete[] ptr2;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <stack>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;



int main() {

  int A, B;
  int ans = 1;
  int i = 0;

  cin >> A >> B;

    while(1){
      if(ans >= B ) break;
      ans += ( A - 1 );
      i++;
    }



  cout << i << endl;
 
  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
from math import *

def S(p):
	return sum([sin(a*pi/180) for a in p])+sin((360-sum(p))*pi/180)

while 1:
	try:
		p1=[int(raw_input()) for i in range(input()-1)]
		p2=[int(raw_input()) for i in range(input()-1)]
		s1,s2=S(p1),S(p2)
		if    s1-s2>1e-10: print 1
		elif  s2-s1>1e-10: print 2
		else:print 0
	except:break

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll N;
  cin >> N;
  
  vector<ll> A(N);
  map<ll, ll> cnt;
  REP(i, N) { 
      cin >> A[i];
      cnt[A[i]]++;
  }
  sort(ALL(A));
  ll ans = 0;
  ll Amax = 1000000;
  vector<bool> dp(Amax+1, true);
  vector<bool> cnts(Amax+1, false);
  REP(i, N) {
    if (cnts[A[i]]) continue;
    cnts[A[i]] = true;
    for(ll j = A[i]*2; j <= Amax; j+=A[i]) {
      dp[j] = false;
    }
  }
  REP(i, N) {
    if (cnt[A[i]] == 1 && dp[A[i]]) ans++;
  }
  PRINT(ans);
  return 0;
} 


Measured memory_bytes: 17352
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 1, now = 0;
  for (int i = 0; i < n; i++){
    now += a[i];
    if (now > x)
      break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	var sushi [4]int
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	fmt.Fscan(fp, &n)

	dp := make([]float64, (n+1)*(n+1)*(n+1))
	for i := 0; i < n; i++ {
		fmt.Fscan(fp, &a)
		sushi[a]++
	}

	fmt.Println(calc(n, sushi[1], sushi[2], sushi[3], dp))
}

func calc(n int, c1 int, c2 int, c3 int, dp []float64) float64 {
	cSum := c1 + c2 + c3

	if cSum == 0 {
		return 0.0
	}

	i := c1*n*n + c2*n + c3
	if dp[i] > 0 {
		return dp[i]
	}

	result := float64(n) / float64(cSum)
	if c1 > 0 {
		result += calc(n, c1-1, c2, c3, dp) * float64(c1) / float64(cSum)
	}
	if c2 > 0 {
		result += calc(n, c1+1, c2-1, c3, dp) * float64(c2) / float64(cSum)
	}
	if c3 > 0 {
		result += calc(n, c1, c2+1, c3-1, dp) * float64(c3) / float64(cSum)
	}
	dp[i] = result
	return result
}

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

int main(){
  while(1){
    double A[2][3];
    for(int i=0;i<2;i++){
      for(int j=0;j<3;j++){
	cin>>A[i][j];
	if(cin.eof()) return 0;
      }
    }
    for(int i=0;i<2;i++){
      for(int j=i+1;j<3;j++){
	A[i][j] /= A[i][i];
      }
      for(int k=0;k<2;k++){
	if(k!=i){	  
	  for(int j=i+1;j<3;j++) A[k][j] -= A[k][i]*A[i][j];
	}
      }
    }
    cout<<fixed<<setprecision(3)<<A[0][2]<<" "<<A[1][2]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return ('0' <= c && c <= '9')?(c - '0'):-1;}


bool isPrime(ll n) {
  if(n == 1)return false;
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<int> b(n);
  
  int m = n-1;
  int cnt = 0;
  while(m >= 0){
    b[cnt++] = a[m];
    m-=2;
  }
  for(int i = n&1;i < n;i+=2){
    b[cnt++] = a[i];
  }
  rep(i,n)cout<<b[i]<<" ";
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll f[n] = {};
    ll ans = 0;

    ll one = 0;
    ll cnt = 0;
    ll all = 0;
    ll zero;
    int leftone = -1;
    rep(i,n){
        if(s[i] == '1'){
            all++;
            if(leftone == -1){
                leftone = i;
            }
        }
    }
    zero = n - all;

    if(all == 0){
        cout << 0 << endl;
        return 0;
    }

    ans += (all/2)*(all/2+1);
    if(all % 2 == 1){
        ans += all/2+1;
    }

    // cout << ans << endl;

    rep(i,n){
        if(s[i] == '0'){
            cnt = 0;
        }else{
            cnt++;
            if(cnt % 2 == 0 && cnt >= 2){
                one++;
                f[i] = 1;
                f[i-1] = 1;
            }
        }
    }

    ans += one * zero;
    // cout << ans << endl;

    
    
    cnt = 0;
    rep(i,n){
        if(s[i] == '1' && f[i] == 0)cnt++;
    }

    

    leftone = -1;
    rep(i,n){
        if(f[i] == 0 && s[i] == '1'){
            leftone = i;
            break;
        }
    }

    if(leftone == -1){
        cout << ans << endl;
        return 0;
    }

    int flag = 0;
    ll onecount = 0;
    ll cnt2 = 0;

    /*
    drep(i,n){
        if(i == leftone)break;
        if(f[i] == 1)continue;
        if(s[i] == '0'){
            if(flag == 0)continue;
            if(onecount % 2 == 1)continue;
            f[i] = 1;
            cnt2++;
            // cnt--;
            ans += (cnt + 1) / 2;
            // if(cnt % 2 == 1) ans += cnt2;
            ans += onecount / 2;
            flag = 0;
        }else{
            onecount++;
            cnt--;
            flag = 1;
        }
    }
    */
    

    ll rightflag = -1;
    drep(i,n){
        if(s[i] == '1' && f[i] == 0){
            rightflag = i;
            break;
        }
    }

    cnt = 0;
    rep(i,n){
        if(s[i] == '1' && f[i] == 0)cnt++;
    }
    int cnt3 = 0;
    flag = 0;
    onecount = 0;
    rep(i,n){
        if(i == rightflag){
            break;
        }
        if(f[i] == 1)continue;
        if(s[i] == '1'){
            cnt3++;
            flag = 1;
            continue;
        }
        if(flag == 0)continue;
        if(true){
            flag = 0;
            f[i] = 1;
            ans += cnt3+1;
            ll tmp = cnt - cnt3-1;
            ans += tmp / 2;
        }
    }

    /*

    rep(i,n)cout << f[i];
    cout << endl;
    cout << ans << endl;

    */

    cnt = 0;
    rep(i,n){
        if(s[i] == '1' && f[i] == 0)cnt++;
    }

    // cout << "cnt = " << cnt << endl;
    cnt2 = 0;
    ll odd = 0;
    ll even = 0;

    drep(i,n){
        if(f[i] == 1)continue;
        if(s[i] == '0'){
            ans += cnt;
            ans += even;
            swap(odd, even);
        }else{
            odd++;
            cnt--;
        }
    }

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




Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define eb emplace_back
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,m,i,j;char ch;
    cin>>n>>m;
    vector<char> v[n];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
        {
            cin>>ch;
            v[i].eb(ch);
        }
    lli dp[n][m]={};
    for(i=0;i<m;i++)
        if(v[0][i]!='.')
            break;
        else
            dp[0][i]=1;
    while(i!=m)
        dp[0][i]=0,++i;
    for(i=0;i<n;i++)
        if(v[i][0]!='.')
            break;
        else
            dp[i][0]=1;
    while(i!=n)
        dp[i][0]=0,++i;
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
            if(v[i][j]=='.')
                dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
            else
                dp[i][j]=0;
    }
    /*for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    i=dp[n-1][m-1]%mod;
    cout<<i;
    return 0;
}


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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  int ans0 = 0;
  int ansN = 0;
  for (int i = 0;i < M;i++) {
    int a;
    cin >> a;
    if (a < X) ans0++;
    else ansN++;
  }
  cout << min(ans0,ansN) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int numbers[11] = {0};
    int A, B, C;
    cin >> A >> B >> C;
    numbers[A] += 1;
    numbers[B] += 1;
    numbers[C] += 1;
    if(numbers[5] == 2 and numbers[7] == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math
cnt=defaultdict(lambda:1)
n=int(input())
prime_number='2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 ' \
             '73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 ' \
             '179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 ' \
             '283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 ' \
             '419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 ' \
             '547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 ' \
             '661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 ' \
             '811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 ' \
             '947 953 967 971 977 983 991 997'
prime=list(map(int,prime_number.split()))
num=math.factorial(n)
for i in range(n):
    if i>=len(prime):
        break
    while num%prime[i]==0:
            num//=prime[i]
            cnt[prime[i]]+=1
ans=1
for i in cnt.values():
    ans*=i
print(ans%(10**9+7))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N,ans;
map<int,int> m;
typedef pair<int,int> P;

signed main(){
  cin>>N;
  while(N--){int a;cin>>a;m[a]++;}
  vector<P> l;
  for(auto p:m)l.push_back(p);
  for(int i=0;i<l.size();i++){
    for(int j=0;j<=i;j++){
      for(int k=0;k<=j;k++){
        if(l[j].first+l[k].first<=l[i].first)continue;
        if(i==j&&j==k)ans+=l[k].second*(l[k].second-1)*(l[k].second-2)/6;
        else if(i==j)ans+=l[k].second*(l[j].second)*(l[j].second-1)/2;
        else if(j==k)ans+=l[i].second*(l[j].second)*(l[j].second-1)/2;
        else ans+=l[i].second*l[j].second*l[k].second;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

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

	vector<int> diff(n, 0);
	for (int i = 0; i < n; i++) {
		diff[i] = a[i] - b[i];
	}

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

	long long total_diff = 0;
	int ans = 0;
	if (diff[0] >= 0) {
		cout << ans << endl;
		return 0;
	}

	for (int i = 0; i < n; i++) {
		if (diff[i] >= 0) {
			break;
		}
		total_diff += diff[i];
		ans++;
// printf("- %d: %lld\n", diff[i], total_diff);
	}

	for (int i = n - 1; i >= 0 && total_diff < 0; i--) {
		if (diff[i] <= 0) {
			break;
		}

		total_diff += diff[i];
		ans++;
// printf("+ %d: %lld\n", diff[i], total_diff);
	}


	if (total_diff < 0) {
		ans = -1;
	}

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


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> p(n), q(n);
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];

	vector<int> a(n);
	rep(i, n)a[i] = i + 1;
	map<vector<int>, int> m;

	do {
		m[a] = m.size();
	} while (next_permutation(a.begin(), a.end()));

	int ans = abs(m[p] - m[q]);
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define db(x) cerr << #x << ": " << x << "\n";

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

    string N;
    cin >> N;
    bool ans = false;
    for(char c : N)
        if(c == '7') ans = true;
    cout << (ans ? "Yes\n" : "No\n");
}


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

static constexpr unsigned long long MAX_S = 2000;
static constexpr unsigned long long MAX_BASKETS = (MAX_S / 3) + 1;
static constexpr unsigned long long MAX_N = MAX_S + MAX_BASKETS;

static constexpr unsigned long long MOD = 1e9 + 7;

std::vector<std::vector<unsigned long long>> binCoeffTable(unsigned long long N) {
    std::vector<std::vector<unsigned long long>> dp(N+1, std::vector<unsigned long long>(N+1, 0));
    for (unsigned long long i = 0; i <= N; ++i) {
        dp[i][0] = dp[0][i] = dp[i][i] = 1;
    }

    for (unsigned long long i = 2; i <= N; ++i) {
        for (unsigned long long k = 1; k < N; ++k) {
            dp[i][k] = (dp[i - 1][k] + dp[i - 1][k - 1]) % MOD;
        }
    }

    return dp;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    
    auto bc = binCoeffTable(MAX_N);
    unsigned long long S;
    std::cin >> S;
    if (S < 3) {
        std::cout << 0 << std::endl;
        return 0;
    }

    unsigned long long sequences = 0;
    for (unsigned long long baskets = 1; 3 * baskets <= S; ++baskets) {
        unsigned long long free = S - 3 * baskets;
        sequences += bc[free + baskets - 1][baskets - 1];
        sequences %= MOD;
    }

    std::cout << sequences << std::endl;
    return 0;
}

Measured memory_bytes: 58824
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<e?a=c:b=c;return d[a]<e?b:a};
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
var fact=[1,1];
function factmod(n){for(var i=fact.length;i<=n;)fact[i]=abmod(fact[i-1],i++);return fact[n];}
function modinv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function nPrmod(n,r){return abmod(factmod(n),modinv(fact[n-r]));}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.l();
  var b = o.l();
  if(Array.from(new Set(a)).length !== a.length)return 0;
  if(Array.from(new Set(b)).length !== b.length)return 0;
  a.sort((a,b)=>a-b);
  b.sort((a,b)=>a-b);
  var ans = 1;
  var x = 0, y = 0, k = 1;
  while(x < n && y < m){
    var t;
    if(a[x] < b[y]){
      t = m - y;
      ans = abmod(ans, t, nPrmod(a[x]-k, t-1));
      x++;
    }else if(a[x] === b[y]){
      t = m - y + n - x - 1;
      ans = abmod(ans, nPrmod(a[x]-k, t-1));
      x++, y++;
    }else{
      t = n - x;
      ans = abmod(ans, t, nPrmod(b[y]-k, t-1));
      y++;
    }
    k += t;
  }
  return ans;
}

Measured memory_bytes: 36720
import math
N,D = map(int,input().split())

l = []
for i in range(N):
    data = list(map(int,input().split()))
    l.append(data)

def dist(a,b):
    cnt = 0
    for i in range(len(a)):
        cnt += (a[i]-b[i])**2
    #print(cnt,math.sqrt(cnt))
    return math.sqrt(cnt)

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if dist(l[i],l[j])%1 == 0:
            ans += 1
            #print(dist(l[i],l[j]))

print(ans)

Measured memory_bytes: 3064
N = gets.to_i
ai = gets.chomp.split(" ").map(&:to_i)
bi = gets.chomp.split(" ").map(&:to_i)
ci = gets.chomp.split(" ").map(&:to_i)

ans = 0

for i in 0...N do
  ans += bi[ai[i]-1]
  if ai[i+1] == ai[i] + 1 then
    ans += ci[ai[i]-1]
  end
end

p ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int N=15;
char s[N][10000];
int cnt[N];
int h,w,K,ans=0x3f3f3f3f;
int main()
{
	scanf("%d %d %d",&h,&w,&K);
	for(int i=0;i<h;i++) cin>>s[i];
	for(int i=0;i<1<<h-1;i++) //枚举横切 
	{
		memset(cnt,0,sizeof cnt); //记录每一块区域1的个数 
		bool f=0;
		int now=0;
		for(int j=0;j<h-1;j++) if(i>>j&1) now++;
		for(int j=0;j<w;j++)
		{
			int id=0;
			bool flag=0;
			for(int k=0;k<h;k++)
			{
				cnt[id]+=(s[k][j]=='1');
				if(cnt[id]>K)  flag=1;
				if(i>>k&1) id++;
			}
			if(flag==1)
			{
				now++;
		
				for(int k=0;k<=id;k++) cnt[k]=0;
				id=0;
				for(int k=0;k<h;k++)
				{
					cnt[id]+=(s[k][j]=='1');
					if(cnt[id]>K)  f=1;
					if(i>>k&1) id++;
				}
			}
		}
		if(!f&&now<ans)
		{
			ans=now;
		}
	}
	cout<<ans<<endl;
}

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

int n;
char f[10];
bool left, right, now; // true > UP

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    int counter = 0;
    left = right = now = false;
    for (int i = 0; i < n; i++) {
      scanf("%s", f);
      if (f[0] == 'r') {
        if (f[1] == 'u') {
          right = true;
          if (!now && left) {
            now = true;
            counter++;
          }
        } else {
          right = false;
          if (now && !left) {
            now = false;
            counter++;
          }
        }
      } else {
        if (f[1] == 'u') {
          left = true;
          if (!now && right) {
            now = true;
            counter++;
          }
        } else {
          left = false;
          if (now && !right) {
            now = false;
            counter++;
          }
        }
      }
    }
    printf("%d\n", counter);
  }
}



Measured memory_bytes: 2692
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0114
"""
import sys


def lcm(x, y):
    return x*y//gcd(x, y)


def gcd(x, y):
    if x < y:
        temp = x
        x = y
        y = temp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x


def calc_cycle(a, m):
    x = 1
    cycle = 0
    while True:
        x = (a * x) % m
        cycle += 1
        if x == 1:
            break
    return cycle


def solve(data):
    a1, m1, a2, m2, a3, m3 = data
    x_cycle = calc_cycle(a1, m1)
    y_cycle = calc_cycle(a2, m2)
    z_cycle = calc_cycle(a3, m3)

    return lcm(lcm(x_cycle, y_cycle), z_cycle)


def main(args):
    # data = [2, 5, 3, 7, 6, 13]
    #data = [517, 1024, 746, 6561, 4303, 3125]
    while True:
        data = [int(x) for x in input().split(' ')]
        if data.count(0) == 6:
            break
        result = solve(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  while (N != 0) {
    int c = 0, c2 = 0, sum = 0;
    for (int i = 0; i < N; i++) {
      int k;
      cin >> k;
      if (k >= 2) c++;
      if (k >= 1) c2++;
      sum += k;
    }
    if (c == 0) {
      cout << "NA" << endl;
    } else if (c == 1 && sum < 2) {
      cout << 2 << endl;
    } else {
      cout << c2+1 << endl;
    }
    cin >> N;
  }
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

double dist(int x, int y, int nx, int ny) {
  return sqrt(pow(nx - x, 2) + pow(ny - y, 2));
}

int main() {
  int input(n);
  vector<int> x(n), y(n);
  REP(i, n) cin >> x[i] >> y[i];
  vector<int> index(n);
  REP(i, n) index[i] = i;
  double ans = 0;
  ll cnt = 0;
  do {
    cnt++;
    REP(i, n - 1) {
      ans += dist(x[index[i]], y[index[i]], x[index[i + 1]], y[index[i + 1]]);
    }
  } while(next_permutation(index.begin(), index.end()));
  printf("%.10f\n", ans / cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int ans = 0;
  REP(i,k) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a=0,b=0;
	int i;
	for(i=0;i<4;i++){
		int c;
		
		scanf("%d",&c);
		a+=c;
		
	}
	for(i=0;i<4;i++){
		int d;
		
		scanf("%d",&d);
		b+=d;
		
	}
	
	printf("%d\n",a>=b?a:b);
	return 0;
}

Measured memory_bytes: 592