akhauriyash/Code-Regression huggingface dataset:
S = input()
front = S[:2]
last = S[2:]
MM = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
if front in MM and last in MM:
  print("AMBIGUOUS")
elif front in MM:
  print("MMYY")
elif last in MM:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int k,x;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(k),read(x);
	k*=500;
	puts(k>=x?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
arrv = gets.split(" ").map(&:to_i)
arrc = gets.split(" ").map(&:to_i)
ans = 0
for i in 0..n-1 do
    if arrv[i] - arrc[i] > 0
        ans += arrv[i] - arrc[i]
    end
end

puts ans

Measured memory_bytes: 1788
/* Author rumoisen */
/* created 2018/10/24 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

string d[4]={"dream","dreamer","erase","eraser"};
int main(void)
{
    string a,b;
    cin>>a>>b;
    string c=a+b;
    int x=atoi(c.c_str());
    bool flag=false;
    for(int i=1;i<1000;i++){
        if(i*i==x) flag=true;
    }
    if(flag) yes();
    else no();
    return 0;
}

Measured memory_bytes: 256
import heapq

N,M = map(int, raw_input().split())
A = map(int, raw_input().split())
h = []
for a in A:
    heapq.heappush(h, (-a,a))

for i in range(M):
    #A = sorted(A, reverse=True)
    a = int(heapq.heappop(h)[1]/2)
    heapq.heappush(h, (-a,a))

#print h
print sum([x[1] for x in h])

Measured memory_bytes: 48668
num = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(1, num + 1):
    judge = str(input())
    if judge == "AC":
        ac += 1
    elif judge == "WA":
        wa += 1
    elif judge == "TLE":
        tle += 1
    elif judge == "RE":
        re += 1
        
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

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

ll f(ll n){
  if(n % 2){
    int a = (n + 1)/2;
    if(a % 2) return 1;
    else return 0;
  } else {
    int a = n / 2;
    if(a % 2) return (ll)1 ^ n;
    else return n;
  }
}

int main(){
  ll A, B;
  cin >> A >> B;
  ll ans;
  if(A == 0) ans = f(B);
  else ans = f(A-1) ^ f(B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 1000000000+7

z=0

zz = ((N-K+1)+N)*K//2 - (0+(K-1))*K//2 + 1
zz = zz % mod

for x in range(K+1, N+3):
#  print(zz)
  z = (z + zz) % mod
  zz += (N-x+1) - (x-1)
  zz = zz % mod
#
print(z)



Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int n;
    while (cin >> n) {
        map<string, int> m;
        int t = 0;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            m[s] += 1;
            t = max(m[s], t);
        }
        for (auto& it : m) {
            if (it.second == t) {
                cout << it.first << "\n";
            }
        }
    }
    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {
	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	static int gcd(int a, int b, int c) {
		return gcd(a, gcd(b, c));
	}
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long r = 0;
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) {
				for (int k=1;k<=n;k++) {
					r += gcd(i, j, k);
				}
			}
		}
		
		System.out.println(r);
	}
}


Measured memory_bytes: 35732
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int i = 0; i < S.length(); i++) {
		if ((i + 1) % 2 == 1) {
			cout << S[i];
		}
	}
	cout << endl;
	
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	string S;
  	int cnt=0;
	cin >> S; 
  	if(S[0] == '1') cnt++;
  	if(S[1] == '1') cnt++;
  	if(S[2] == '1') cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    int N,nmax,nmin;
    while(1){
        cin >> N;
        cin >> nmin >> nmax;
        if(N+nmax+nmin==0) return 0;
        nmin--; nmax--;
        int P[N];
        for(int i=0;i<N;i++) cin >> P[i];

        int ans = 0,gap=P[nmin]-P[nmin+1];
        for(int i=nmin;i<=nmax;i++){
            //cout << P[i]-P[i+1] << endl;
            if(gap <= P[i]-P[i+1]){
                ans = i+1;
                gap = P[i]-P[i+1];
            }
        }
        cout << ans << endl;

    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
const int N=200050;
const ll inf=1e16;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct date{
  int x,s;
  bool operator < (const date &c) const {
    return s<c.s;
  }
}w[N];
inline ll Min(ll a,ll b){
  return a<b?a:b;
}
struct seg{
  ll tr[N<<2];
#define ls (x<<1)
#define rs (x<<1|1)
  void build(int x,int l,int r){
    tr[x]=inf;
    if (l==r) return;
    int mid=(l+r)>>1;
    build(ls,l,mid),build(rs,mid+1,r);
    return;
  }
  ll query(int x,int l,int r,int ql,int qr){
    if (ql<=l && r<=qr) return tr[x];
    int mid=(l+r)>>1; ll ans=inf;
    if (ql<=mid) ans=Min(ans,query(ls,l,mid,ql,qr));
    if (qr>mid) ans=Min(ans,query(rs,mid+1,r,ql,qr));
    return ans;
  }
  void insert(int x,int l,int r,int y,ll s){
    if (l==r) { tr[x]=s; return; }
    int mid=(l+r)>>1;
    if (y<=mid) insert(ls,l,mid,y,s);
    else insert(rs,mid+1,r,y,s);
    tr[x]=Min(tr[ls],tr[rs]);
    return;
  }
}tr1,tr2;
int rk[N],x[N];
ll sum[N];
int main(){
  gi(); int n=gi(),a=gi(),b=gi();
  for (int i=1; i<=n; ++i){
    w[i]=(date){i,x[i]=gi()};
    sum[i]=abs(w[i].s-w[i-1].s)+sum[i-1];
  }
  w[0]=(date){0,x[0]=a};
  sort(w,w+n+1);
  for (int i=0; i<=n; ++i)
    rk[w[i].x]=i+1;
  tr1.build(1,1,n+1),tr2.build(1,1,n+1);
  tr1.insert(1,1,n+1,rk[0],abs(b-x[1])-sum[1]-x[0]);
  tr2.insert(1,1,n+1,rk[0],abs(b-x[1])-sum[1]+x[0]);
  ll s;
  for (int i=2; i<=n; ++i){
    s=Min(tr1.query(1,1,n+1,1,rk[i])+x[i]+sum[i-1],tr2.query(1,1,n+1,rk[i],n+1)-x[i]+sum[i-1]);
    tr1.insert(1,1,n+1,rk[i-1],s-sum[i]-x[i-1]);
    tr2.insert(1,1,n+1,rk[i-1],s-sum[i]+x[i-1]);
  }
  ll ans=inf;
  for (int i=1; i<=n; ++i)
    ans=Min(ans,tr1.query(1,1,n+1,rk[i-1],rk[i-1])+sum[n]+x[i-1]);
  for (int i=0; i<=n; ++i)
    if (w[i].x==0)
      w[i].s=b;
  sort(w,w+n+1);
  for (int i=0; i<=n; ++i)
    rk[w[i].x]=i+1;
  tr1.build(1,1,n+1),tr2.build(1,1,n+1);
  x[0]=b;
  tr1.insert(1,1,n+1,rk[0],abs(a-x[1])-sum[1]-x[0]);
  tr2.insert(1,1,n+1,rk[0],abs(a-x[1])-sum[1]+x[0]);
  for (int i=2; i<=n; ++i){
    s=Min(tr1.query(1,1,n+1,1,rk[i])+x[i]+sum[i-1],tr2.query(1,1,n+1,rk[i],n+1)-x[i]+sum[i-1]);
    tr1.insert(1,1,n+1,rk[i-1],s-sum[i]-x[i-1]);
    tr2.insert(1,1,n+1,rk[i-1],s-sum[i]+x[i-1]);
  }
  for (int i=1; i<=n; ++i)
    ans=Min(ans,tr1.query(1,1,n+1,rk[i-1],rk[i-1])+sum[n]+x[i-1]);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    string s;
    cin >> s;
    bool yes = true;

    rep(i, s.length()) {
        if ((s[i] == 'L' && i % 2 == 0) || (s[i] == 'R' && i % 2 == 1)) {
            yes = false;
            break;
        }
    }
    Yes(yes);
    return 0;
}


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

int main(){
    int n,k;cin>>n>>k;
    vector<ll> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }

    sort(h.begin(),h.end());
    
    ll ans= 1e18+7;

    for(int i=0;i<n-k+1;i++){
        ans = min(ans,abs(h[i+k-1]-h[i]));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int num_of_switches;
  int num_of_light_bulbs;
  int num_of_operations;
  while(~scanf("%d %d %d",
               &num_of_switches,
               &num_of_light_bulbs,
               &num_of_operations)){
    if(num_of_switches == 0
       && num_of_light_bulbs == 0
       && num_of_operations == 0) break;

    bool flags[50] = {};
    bool states[50][1001] = {};
    vector<string> light_bulbs_log;
    for(int operation_i = 0; operation_i < num_of_operations; operation_i++){
      string switches;
      string light_bulbs;
      cin >> switches >> light_bulbs;
      for(int switch_i = 0; switch_i < switches.size(); switch_i++){
        if(switches[switch_i] == '1'){
          flags[switch_i] = !flags[switch_i];
        }
        states[switch_i][operation_i] = flags[switch_i];
      }
      light_bulbs_log.push_back(light_bulbs);
    }
    
    for(int light_i = 0; light_i < num_of_light_bulbs; light_i++){

      vector<int> candidates;
      for(int switch_i = 0; switch_i < num_of_switches; switch_i++){
        bool isok = true;
        for(int operation_i = 0; operation_i < light_bulbs_log.size(); operation_i++){
          bool state = (light_bulbs_log[operation_i][light_i] == '1' ? true : false);
          if(states[switch_i][operation_i] != state){
            isok = false;
            break;
          }
        }

        if(isok){
          candidates.push_back(switch_i);
        }
      }

      if(candidates.size() != 1){
        printf("?");
      }
      else{
        if(candidates[0] >= 10){
          printf("%c",candidates[0] - 10 + 'A');
        }
        else{
          printf("%c",candidates[0] + '0');
        }
      }
    }
    cout << endl;
  }
}

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

bool month(int x)
{
	return x>=1 && x<=12;
}

int main()
{
	string str;
  	cin>>str;
  	bool first=month(stoi(str.substr(0,2)));
  	bool second=month(stoi(str.substr(2,2)));
  	if(first && second)
    cout<<"AMBIGUOUS";
  	else if(first)
    cout<<"MMYY";
  	else if(second)
    cout<<"YYMM";
  	else
    cout<<"NA";
  	cout<<endl;
	return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<queue<int>> a(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            int aij; cin >> aij; aij--;
            a[i].push(aij);
        }
    }

    int ans = 0;

    queue<int> check;
    for (int i = 0; i < n; i++) check.push(i);
    while (true) {
        bool possible = false;
        bool end = true;
        vector<bool> seen(n, false);
        queue<int> check_next;
        while (!check.empty()) {
            int i = check.front(); check.pop();
            if (!a[i].empty()) {
                end = false;

                if (seen[i]) {
                    continue;
                }

                seen[i] = true;
                int op = a[i].front();
                if (!a[op].empty() && i == a[op].front() && !seen[op]) {
                    possible = true;
                    seen[op] = true;
                    a[i].pop();
                    a[op].pop();
                    check_next.push(i);
                    check_next.push(op);
                }
            }
        }
        if (end) break;

        if (!possible) {
            ans = -1;
            break;
        }

        ans++;
        check = check_next;
    }

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

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

    int a = S/1000;
    int b = S/100 - a*10;
    int c = S/10 - a*100 - b*10;
    int d = S -a*1000 -b*100-c*10;


    int X = 10*a + b;
    int Y = 10*c + d;

    string ans;

    if (0<X && X<13){
        if (0<Y && Y<13)
        {
            ans = "AMBIGUOUS";
        }else
        {
            ans = "MMYY";
        }
    }else if (0<Y && Y<13)
    {
        ans = "YYMM";
    }else
    {
        ans = "NA";
    }
    
    cout << ans << endl;

    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18
const long long MOD = 1000000007;

using namespace std;

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

    long long ans = 0;
    for (long long i = k; i <= n + 1; i++)
    {
        long long min = (i - 1) * i / 2;
        long long max = (2 * n - i + 1) * i / 2;
        ans += max - min + 1;
        ans %= MOD;
    }

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;
namespace io {
  const int SZ = (1 << 22) + 1;
  char buf[SZ], *ptr = NULL, *bnd = NULL;
  #define GC() ((ptr == bnd) ? (ptr = buf, bnd = buf + fread(buf, 1, SZ, stdin), (ptr == bnd) ? EOF : (*(ptr++))) : (*(ptr++)))
  #define STATE(c) { if (c == '-') sgn = -1; else if (c == EOF) return false; }
  inline bool skip(const char& c) { return c < '0' || c > '9'; }
  template <class V>
  inline bool Read(V &v) {
    register char c, sgn = 1;
    while (skip(c = GC())) STATE(c);
    for (v = c - '0'; !skip(c = GC()); v = v * 10 + c - '0');
    return (v *= sgn), true;
  }
  char oBuf[SZ], *oCur = oBuf, *oBnd = oBuf + SZ, oStk[21], top = 0;
  inline void flush() { if (oCur - oBuf) fwrite(oBuf, 1, oCur - oBuf, stdout), oCur = oBuf; }
  inline void pc(char c) { *(oCur++) = c; if (oCur == oBnd) flush(); }
  template <class V>
  inline void Print(V v) {
    if (!v) return pc('0');
    if (v < 0) v = -v, pc('-');
    while (v) oStk[top++] = v % 10, v /= 10;
    while (top) pc(oStk[--top] + '0');
  }
  template <class V>
  inline void Println(const V& v) { Print(v), pc('\n'); }
  struct flusher { ~flusher() { flush(); } } __flusher__;
}
using io::Read;
using io::Println;
const int N = 1e3 + 5;
int a[N][N], nx[N];
bool vis[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  // Read(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      // Read(a[i][j]);
    }
  }

  int ans = 0, flg = 1, cnt = 0;
  while (flg) {
    flg = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (nx[i] == n || vis[i]) continue;
      int t = a[i][nx[i]];
      if (i == a[t][nx[t]] && !vis[t]) {
        flg = 1;
        vis[i] = vis[t] = 1, cnt++;
        nx[t]++, nx[i]++;
      }
    }
    if (flg) ans++;
  }
  if (cnt != n * (n - 1) / 2) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 4352
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
const long long mod = 1000000007;
long long pw[200200] = { 1 };

int main() {
  fastio;

	map<pair<ll, ll>, pair<int, int> > chk;

	for (int i = 1; i < 200200; i++) pw[i] = (pw[i - 1] * 2) % mod;

	ll a = mod - 1;
	int n; scanf ("%d", &n); while (n--){
	  ll x, y;
		scanf ("%lld %lld", &x, &y);
		if (x == 0 && y == 0){ a++; continue; }
		if (make_pair(x, y) < make_pair(0ll, 0ll)) x = -x, y = -y;
		ll g = __gcd(abs(x), abs(y));
		x /= g; y /= g;
		if (y > 0) chk[{x, y}].first++;
		else chk[{-y, x}].second++;
	}

	ll r = 1;
	for (auto& p : chk) {
		r = r * (pw[p.second.first] + pw[p.second.second] - 1) % mod;
	}

	cout << (a + r) % mod << "\n";
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 17712
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

carryover = 0
ans = 0
for i in range(N):
    if carryover > 0:
        if A[i] < carryover:
            ans += A[i]
            A[i] = 0
        else:
            ans += carryover
            A[i] = A[i] - carryover
            
    if A[i] < B[i]:
        ans += A[i]
        carryover = B[i] - A[i]
    else:
        ans += B[i]
        carryover = 0
        
if carryover > 0:
    if A[N] < carryover:
        ans += A[N]
    else:
        ans += carryover

print(ans)

Measured memory_bytes: 18752
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
k = inp()
a = inpl()
res = 0
for i,x in enumerate(a):
    res += min(abs(k-x)*2, x*2)
print(res)

Measured memory_bytes: 10396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<vector<pair<int, ll>>> g(100001);
vector<bool> vi(100001, false);
vector<ll> ans(100001, 0);

void dfs(int a, ll w) {
	vi[a] = true;
	for (auto& c : g[a]) {
		if (vi[c.first]) continue;
		vi[c.first] = true;
		ans[c.first] = w + c.second;
		dfs(c.first, ans[c.first]);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n - 1) {
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		g[u].emplace_back(pair<int, ll>(v, w));
		g[v].emplace_back(pair<int, ll>(u, w));
	}
	dfs(0, 0);
	rep(i, n) dunk(ans[i] % 2);
	return 0;
}


Measured memory_bytes: 10240
#include <stdio.h>
 
int main(void){
    int x[1024] = {0},y[2048] = {0},z[4096] = {0},w[4096] = {0},i,j,n;
    for(i = 0;i <= 1000;i++){
        x[i]++;
    }
    for(i = 0;i <= 1000;i++){
        for(j = 0;j <= 1000;j++){
            y[i + j] += x[i];
        }
    }
    for(i = 0;i <= 2000;i++){
        for(j = 0;j <= 1000;j++){
            z[i + j] += y[i];
        }
    }
    for(i = 0;i <= 3000;i++){
        for(j = 0;j <= 1000;j++){
            w[i + j] += z[i];
        }
    }
    while(scanf("%d",&n) != EOF){
        printf("%d\n",w[n]);
    }
    return 0;
}

Measured memory_bytes: 648
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e4 + 7, K = 107, MOD = 1e9 + 7;
int n, d, dp[2][K][N];
string num;

int calc(int f, int rem, int len) {
    if (len == n) {
        return rem == 0;
    }
    int & res = dp[f][rem][len];
    if (res != -1) {
        return res;
    }
    res = 0;
    int tmp = num[len] - '0';
    if (f == 0) {
        for (int i = 0; i < 10; i++) {
            res += calc(0, (rem + i) % d, len + 1);
            if (res >= MOD) {
                res -= MOD;
            }
        }
    }   else {
        for (int i = 0; i < tmp; i++) {
            res += calc(0, (rem + i) % d, len + 1);
            if (res >= MOD) {
                res -= MOD;
            }
        }
        res += calc(1, (rem + tmp) % d, len + 1);
        if (res >= MOD) {
            res -= MOD;
        }
    }
    return res;
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    memset(dp, -1, sizeof(dp));
    cin >> num >> d;
    n = sz(num);
    cout << (calc(1, 0, 0) - 1 + MOD) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 17792
#include<cstdio>
char s[1000005];
long long sumM[1000005];

long long solve(int n,int k){
    long long res = 0;
    long long cnt = 0, sum = 0;
    for(int i = 1; i <= n; i++){
        int delet = i-k;
        if(delet>=1 && s[delet]=='D'){
            long long minus = sumM[i-1]-sumM[delet];
            sum -= minus;
            cnt--;
        }
        if(s[i]=='D') cnt++;
        else if(s[i]=='M') sum += cnt;
        else if(s[i]=='C') res += sum;
    }
    return res;
}

int main(){
    int n;
    scanf("%d%s",&n,s+1);
    sumM[0] = 1;
    for(int i = 1; i <= n; i++) sumM[i] = sumM[i-1]+(s[i]=='M');
    int q;
    scanf("%d",&q);
    while(q--){
        int k;
        scanf("%d",&k);
        printf("%lld\n",solve(n,k));
    }
    
    return 0;
}


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

using namespace std;

int main(){
    int N,M,ans=0;
    cin >> N >> M;
    vector<vector<vector<int>>> graph(M,vector<vector<int>>(N));
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        for(int j=0;j<M;j++){
            if(i==j){
                continue;
            }else{
                graph[j][a].push_back(b);
                graph[j][b].push_back(a);
            }
        }
    }

    for(int i=0;i<M;i++){
        queue<int> Q;
        vector<int> color(N,-1);
        bool ok = false;
        color[0] = 1;
        Q.push(0);

        while(!Q.empty()){
            int now = Q.front();
            Q.pop();
            for(int j=0;j<graph[i][now].size();j++){
                if(color[graph[i][now][j]] == -1){
                    color[graph[i][now][j]] = 1;
                    Q.push(graph[i][now][j]);
                }
            }
        }

        for(int j=0;j<N;j++){
            if(color[j]==-1){
                ok = true;
            }
        }

        if(ok){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>

int main(){
  int x, y;
  while(scanf("%d %d", &x, &y)!=EOF){
    if(x==0 && y==0){
      return 0;
    }
    else if(x>=y){
      std::cout << y << " " << x << std::endl; 
    }else{
      std::cout << x << " " << y << std::endl;
    }
  }
  
}

Measured memory_bytes: 3124
# じょえチャンネルおもしろいよ～～～
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

n,d=map(int,input().split())
ans=0
for i in range(n):
  x,y=map(int,input().split())
  if x**2+y**2<=d**2:ans+=1
print(ans)

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

n,a,b = map(int, input().split())
s=input()

b_all=a+b
n_all=0
n_int=0
for i in s:
    if i=='a':
        if n_all<b_all:
            n_all+=1
            print("Yes")
        else:
            print("No")
    elif i=='b':
        if n_all<b_all and n_int<b:
            n_all+=1
            n_int+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No")



Measured memory_bytes: 4016
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def main():
    n, k = list(map(int, input().split()))
    As = list(map(int, input().split()))
    ans = 0
    x = 0
    for i in range(43, -1, -1):
        pow2i = 1 << i
        c = 0
        for a in As:
            if (a >> i) & 1:
                c += 1
        if n - c > c and x + pow2i <= k:
            ans += (n - c) * pow2i
            x += pow2i
        else:
            ans += c * pow2i
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 15004
n=int(input())
X=[[0]*3 for i in range(n)]
for i in range(n):
  a,b=map(int,input().split())
  X[i]=[a+b,a,b]
X=sorted(X)
l=X[0][0]
ans=1
for i in range(n):
  if X[i][1]-X[i][2]>=l:
    ans+=1
    l=X[i][0]
print(ans)

Measured memory_bytes: 25176
X = int(input())
if X>=400 and X <=599:
    print("8")
if X>=600 and X <=799:
    print("7")
if X>=800 and X <=999:
    print("6")
if X>=1000 and X <=1199:
    print("5")
if X>=1200 and X <=1399:
    print("4")
if X>=1400 and X <=1599:
    print("3")
if X>=1600 and X <=1799:
    print("2")
if X>=1800 and X <=1999:
    print("1")

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

using namespace std;

int main(){

    int N, A;

    cin >> N >> A;

    //cout << N/500 << " " << (N/500)*500 << " " << N%500 << endl;
    if(N % 500 <= A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i, j, k ,l;
	int N, M;
	int result;
	int kl_break;
	char **a, **b;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	M = atoi(ch);

	a = (char **)calloc(N, sizeof(char *));
	for(i = 0; i < N; i += 1) {
		a[i] = (char *)calloc(64, sizeof(char *));
	}
	b = (char **)calloc(N, sizeof(char *));
	for(i = 0; i < M; i += 1) {
		b[i] = (char *)calloc(64, sizeof(char *));
	}

	for(i = 0; i < N; i += 1) {
		fgets(a[i], sizeof(buf), stdin);
	}
	for(i = 0; i < M; i += 1) {
		fgets(b[i], sizeof(buf), stdin);
	}

	result = 0;
	for(i = 0; i < N - M + 1; i += 1) {
		for(j = 0; j < N - M + 1; j += 1) {
			kl_break = 0;
			//bの左上はaのi,jにある
			for(k = 0; k < M; k += 1) {//bと(aの一部)の一致を調べる
				for(l = 0; l < M; l += 1) {//bと(aの一部)の一致を調べる
					if(a[i + l][j + k] != b[l][k]) {
						kl_break = 1;
						break;//if 1 pixel different exit kl loop
					}
				}
				if(kl_break == 1) {//if 1 pixel different exit kl loop
					break;
				}
			}
			if(kl_break == 0) {//if all pixels same in kl loop exit ij loop
				result = 1;
				break;
			}
		}
		if(result == 1) {
			break;
		}
	}

	if(result == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	for(i = 0; i < N; i += 1) {
		free(a[i]);
	}
	free(a);
	for(i = 0; i < M; i += 1) {
		free(b[i]);
	}
	free(b);

	return 0;
}


Measured memory_bytes: 2060
($N,$M,$a,@A)=glob`dd`;($b=$_)+=$b<$a&&$M,$s+=$k=$b-$a,$@[$b-1]-=$k,$@[$a]++,$a=$_,$@[$b]+=$k-1for@A;@@=map$c+=$_,$c=0,@@for a,b;$%+=$-=$@[$_]+$@[$_+$M]-$%for@A;print$s-$%

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<ll>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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(a>b){a=b;return true;}return false;}

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    vi a(3);
    REP(i,3){
        cin>>a[i];
    }
    sort(all(a));
    cout<<a[2]-a[0]<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	vector<bool> water(3010);
	vector<bool> sugar(3010);
	water[0] = true;
	for (int i = 100; i <= 3000; i += 100) {
		if (i >= a * 100 && water[i - a * 100]) water[i] = true;
		if (i >= b * 100 && water[i - b * 100]) water[i] = true;
	}
	sugar[0] = true;
	for (int i = 1; i <= 3000; i++) {
		if (i >= c && sugar[i - c]) sugar[i] = true;
		if (i >= d && sugar[i - d]) sugar[i] = true;
	}
	double x = 0;
	int anssum = a * 100; int anssugar = 0;
	for (int i = 100; i <= 3000; i += 100) {
		for (int j = 0; j <= 3000; j++) {
			if (water[i] && sugar[j]) {
				if (i / 100 * e >= j && i + j <= f) {
					double d = (double)j / (double)(i + j);
					if (chmax(x, d)) {
						anssum = i + j; anssugar = j;
					}
				}
			}
		}
	}
	cout << anssum << ' ' << anssugar << endl;
}

Measured memory_bytes: 256
import copy
n = int(input())
ab = sorted([list(map(int,input().split())) for _ in range(n)],reverse=True)
cd = sorted([list(map(int,input().split())) for _ in range(n)],key = lambda x:x[1])
ans = 0
#print(ab,cd)
for i in range(n):
  for j in range(len(cd)):
    if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
      ans += 1
      cd.remove(cd[j])
      break
print(ans)     


Measured memory_bytes: 39408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

ll ans = 0;

void f(ll P, ll Q) {
    if (P < Q) swap(P,Q);
    ll s = P / Q;
    ll t = P % Q;
    if (t==0) {
        ans += (s-1LL)*Q*2LL;
        return;
    }
    ans += (s*2LL-1LL)*Q+t;
    f(Q,t);
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,X; cin >> N >> X;
    ans += X;
    f(N,N-X);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int64_t x=0;
  for(int i=0;i<N;i++){
    if(i%2==0){x+=a[i];}
    else{x-=a[i];}
  }
  x/=2;
  vector<int>ans(N);
  ans[0]=x*2;
  for(int i=0;i<N-1;i++){
    ans[i+1]=2*(a[i]-ans[i]/2);
  }
  for(int i=0;i<N;i++){
    cout<<ans[i];
    if(i<N-1){cout<<" ";}
  }cout<<endl;
  return 0;
}

Measured memory_bytes: 3960
#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() {
  int n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i, m) cin >> p[i].first >> p[i].second;
  rep(x, 1000) {
    int keta = 1;
    int nx = x / 10;
    vector<int> d(1, x % 10);
    while (nx) {
      keta++;
      d.push_back(nx % 10);
      nx /= 10;
    }
    if (keta != n) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(i, m) {
      if (d[p[i].first - 1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
# union find
def find_root(x):
    if parent[x] == x:
        return x
    else:
        return find_root(parent[x])


# x,yの属する集合の併合
def unite(x, y):
    x = find_root(x)
    y = find_root(y)

    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
            size[y] += size[x]
        else:
            parent[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1


# xとyが同じグループかどうか判定
def same(x, y):
    return find_root(x) == find_root(y)


n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(m)]

# 初期化
parent = [i for i in range(n)]  # 根
rank = [1] * n  # 深さ
size = [1] * n  # iを根とするグループのサイズ

# 前処理
edge = [[xyz[m - 1 - i][0] - 1, xyz[m - 1 - i][1] - 1] for i in range(m)]

# 結合後、rootをそれぞれ検索
res = []
for i in range(m):
    unite(edge[i][0], edge[i][1])

arr = [0] * n
for i in range(n):
    arr[i] = find_root(i)
print(len(set(arr)))


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

template <typename t>
void mi(t& a, const t& b) { a = min(a, b); }

template <typename t>
void ma(t& a, const t& b) { a = max(a, b); }

constexpr int g1 = 1000 * 1000 * 1000, si = 1024 * 1024, si_log = 10 + 10, mod = static_cast<int>(1e9) + 7;
constexpr long double eps = 1.0e-9;
int n, m, ar[si], br[si];
int64_t ans;

void vi(const int pos = 0)
{
   if (n == pos)
   {
      int ok = 0;
      for (int i = 0; i < n && 0 == ok; i++)
      {
         ok = 0 == (br[i] & 1);
      }
      ans += ok;
      return;
   }

   vi(pos + 1);

   br[pos]++;
   vi(pos + 1);

   br[pos]-=2;
   vi(pos + 1);

   br[pos]++;
}

int64_t sol()
{
   auto ret = 0 * numeric_limits<int64_t>::max();
   vi();
   ret += ans;
   return ret;
}

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

   while (cin >> n)
   {
      //memset(ar, 0, sizeof ar);
      ans = 0;
      for (int i = 0; i < n; i++)
      {
         cin >> ar[i];
         ar[i] = ar[i] & 1;
      }
      memcpy(br, ar, 8 * 100);
      {
         auto s =
            sol();
         //puts(s ? "yes" : "no");
         cout << s << '\n';
      }
#ifndef _DEBUG
      break;
#endif
   }
   return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long a,b,n,res,m;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>n;
	if(((n+1)>=b)){
		cout<<a-(a+b-1)/b<<endl;
		return 0;
	}
	else{
		cout<<(a*n)/b<<endl;
	}
	return 0;
}


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){cin >> a[i]; a[i] -= (i+1);}
	sort(a.begin(), a.end());
	ll b = a[n/2];
	ll ans = 0;
	REP(i, n){
		ans += abs(b-a[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] N = sc.next().toCharArray();
    
    for (char c : N) {
      if (c == '9') {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
import sys
def ipt():
    return map(int, sys.stdin.readline().strip().split())

_A, _B, m = ipt()
a = list(ipt())
b = list(ipt())
data = [list(ipt()) for _ in range(m)]
 
ans = min(a) + min(b)
for x, y, c in data:
  case = a[x-1] + b[y-1] - c
  ans = min(ans, case)
print(ans)

Measured memory_bytes: 38440
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=924844033;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char S[110000];
char T[110000];
long long gcd(long long a,long long b){
	while(a){
		b%=a;swap(a,b);
	}return b;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s%s",S,T);
	long long t=(long long)a/gcd(a,b)*b;
	int g=gcd(a,b);
	for(int i=0;i<g;i++){
		if(S[a/g*i]!=T[b/g*i]){
			printf("-1\n");return 0;
		}
	}
	printf("%lld\n",t);
}

Measured memory_bytes: 384
<?php

fscanf(STDIN, "%d", $n);
$V = array_map('intval', explode(' ',  trim(fgets(STDIN))));

sort($V);

$sum = ($V[0] + $V[1]) / 2;
for ($i = 2; $i < $n; ++$i) {
    $sum = ($sum + $V[$i]) / 2;
}

echo $sum;


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

int n, m;
vector<int> g[10];
bool bio[10];

int dfs(int u=0, int cnt=1) {
	if (cnt == n) return 1;
	bio[u] = true;
	int ret = 0;
	for (int v: g[u]) {
		if (bio[v]) continue;
		ret += dfs(v, cnt+1);
	}
	bio[u] = false;
	return ret;
}

void solve() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		g[--u].push_back(--v);
		g[v].push_back(u);
	}
	printf("%d", dfs());
	
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << endl;
    return 0;
}


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

int n, m;
vector<vector<int>> g(0, vector<int>(0));
int solve(int x, int cnt, vector<int> c){
  c.at(x) = 1;
  bool ok = true;
  for(auto now : c) if(!now) ok = 0;
  if(ok) return ++cnt;
  
  for(auto now : g.at(x)){
    if(c.at(now)) continue;
    cnt = solve(now, cnt, c);
  }
  return cnt;
}

int main() {
  cin >> n >> m;
  g.resize(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
  }
  
  vector<int> check(n);
  int ans = solve(0, 0, check);
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>

using namespace std;

typedef long long ll;

typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;

int occs[(int)1e6 + 5], tree[1000123], n, ans[1000123];

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
{

    int q, s, e;
    vector<node> v;
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }

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

    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }

    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 25352
from collections import deque

sa = deque(input())
sb = deque(input())
sc = deque(input())

order = deque()
order.append('a')
while True:
    if order[-1] == 'a':
        if len(sa) == 0:
            print('A')
            exit()
        order.append(sa.popleft())
    elif order[-1] == 'b':
        if len(sb) == 0:
            print('B')
            exit()
        order.append(sb.popleft())
    else:
        if len(sc) == 0:
            print('C')
            exit()
        order.append(sc.popleft())


Measured memory_bytes: 3316
/**
 * File              : B.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 22.12.2019
 * Last Modified Date: 22.12.2019
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    return 0;
}


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

const int maxn = 13000;
int n, _x;
vector<int> a, ans;

bool extend() {
    int sz = a.size();
    for(int i = sz - 1; i >= 0; --i) {
        if(a[i] == i + 1) {
            for(int j = i; j < sz - 1; ++j)
                swap(a[j], a[j + 1]);
            a.pop_back();
            ans.push_back(i + 1);
            return true;
        }
    }
    return false;
}

int main() {
    #ifdef FREOPEN
        freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    scanf("%d", &n);
    rep(i, n) scanf("%d", &_x), a.push_back(_x);
    rep(i, n) if(!extend()) {
        puts("-1");
        return 0;
    }
    reverse(ans.begin(), ans.end());
    for(auto g : ans) printf("%d\n", g);
    
    return 0;
}

Measured memory_bytes: 256