akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
	string a,b;
	cin >> a >> b;
	if(a.size() > b.size()){
		cout << "GREATER" << endl;
	} else if(a.size() < b.size()){
		cout << "LESS" << endl;
	} else {
		for(int unsigned i=0;i<a.size();i++){
			if((int)a[i] > (int)b[i]){
				cout << "GREATER" << endl;
				return 0;
			} else if((int)a[i] < (int)b[i]){
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}

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

int main(){
 int c,l,ms;
 string s,s2,s2fr,s2br;
 set<string> m;
 cin>>c;
 for(int i=0;i<c;i++){
   cin >>s;
   l=s.size();
   for(int j=1;j<l;j++){
     s2=s;
     m.insert(s2);
     s2.clear();

     s2.append(&s[j],&s[l]);s2.append(&s[0],&s[j]);
     m.insert(s2);
     s2.clear();

     s2fr.clear();
     s2br.clear();
     for(int k=j;k>0;k--){
	s2fr+=s[k-1];
     }
     for(int k=l;k>j;k--){
	s2br+=s[k-1];
     }

     s2+=s2fr;s2.append(&s[j],&s[l]);
     m.insert(s2);
     s2.clear();

     s2.append(&s[j],&s[l]);s2+=s2fr;
     m.insert(s2);
     s2.clear();

     s2.append(&s[0],&s[j]);s2+=s2br;
     m.insert(s2);
     s2.clear();

     s2+=s2br;s2.append(&s[0],&s[j]);
     m.insert(s2);
     s2.clear();

     s2=s2fr+s2br;
     m.insert(s2);
     s2.clear();

     s2=s2br+s2fr;
     m.insert(s2);
     s2.clear();
   }
   ms=m.size();
   cout<<ms<<endl;
   m.clear();
 }
 return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long i,n,ans=0;
  cin >> n;
  vector<long long> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(i=0;i<n/2;i++){
    ans+=vec.at(i);
  }
  if(n%2==1){
    for(i=1;i<n/2+1;i++){
      ans+=vec.at(i);
    }
  }else{
    for(i=1;i<n/2;i++){
      ans+=vec.at(i);
    }
  }
  cout << ans;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll power(ll x, ll pw, ll mod) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) {
    return power(n, p-2, p);
}
unordered_map<ll, int> get_fac(ll n) {
    unordered_map<ll, int> ret;
    while (n%2 == 0) {
        ret[2] += 1;
        n/= 2;
    }
    ll n2 = n;
    for(ll i = 3; i*i <= n; i+=2) {
        while(n2 % i == 0) {
            ret[i] += 1;
            n2 /= i;
        }
    }
    if (n2 > 1)
        ret[n2] += 1;
    return ret;
}
int main() {
    int n, val;
    cin >> n;
    unordered_map<ll, int> my_lcm;
    vector<ll> arr(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        for(auto p: get_fac(arr[i])) {
            if (my_lcm.count(p.first) > 0) {
                my_lcm[p.first] = max(my_lcm[p.first], p.second);
            } else {
                my_lcm[p.first] = p.second;
            }
        }
        // cout << "finish " << arr[i] << endl;
    }
    ll mod = 1e9 + 7;
    ll lcm_fac = 1;
    ll ans = 0;
    for(auto p: my_lcm) {
        while (p.second--) {
            lcm_fac *= p.first;
            lcm_fac %= mod;
        }
    }
    for(int i = 0; i < n; i++) {
        ans += lcm_fac * modInverse(arr[i], mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 768
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		int n1 = Integer.parseInt(s);
		int n2 = 0;
		for (int i = 0; i < s.length(); i++)
		{
			n2 += Integer.parseInt(s.charAt(i) + "");
		}
		scan.close();
		System.out.println(n1 % n2 == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 2002;

LL F[MAX * MAX];
LL RF[MAX * MAX];
LL DP[MAX][MAX];

LL bp(LL a, int n)
{
    LL res = 1;
    while(n)
    {
        if (n & 1)res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
}

LL C(int n, int k)
{
    if (n < 0)return 0;
    if (k > n)return 0;
    return (F[n] * RF[k] % MOD) * RF[n-k] % MOD;
}


int main()
{
    //freopen("input.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    
    F[0] = RF[0] = 1;
    FOR(i, 1, MAX * MAX)
    {
        F[i] = F[i-1] * i % MOD;
        RF[i] = bp(F[i], MOD-2);
    }
    
    int n, k;
    cin >> n >> k;
    
    if(k == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    
    DP[0][0] = 1;
    
    FOR(i, 0, n + 1)
    {
        FOR(j, 0, i+1)
        {
            if (DP[i][j] == 0)continue;
            
            DP[i+1][j] += DP[i][j];
            if (DP[i+1][j] >= MOD)DP[i+1][j] -= MOD;
            
            if (j != i)
            {
                int left = n * k - (i + j * (k-1));
                DP[i][j+1] += (C(left-1, k-2) * DP[i][j] % MOD) * (n - j) % MOD;
                if (DP[i][j+1] >= MOD)
                    DP[i][j+1] -= MOD;
            }
        }
    }
    cout << DP[n][n] << endl;
}


Measured memory_bytes: 92800
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    ll ans = 0;
    REP(i,n) cin >> a[i];
    REP(i,n-1){
        ans += a[i]/2;
        ll tmp = min(a[i]%2, a[i+1]);
        ans += tmp;
        a[i+1]-=tmp;
    }
    ans += a[n-1]/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define fi cin
#define fo cout 
#define repi(i,a,n) for(i=a;i<n;i++)
#define repie(i,a,n) for(i=a;i<=n;i++)
#define repd(i,a,n) for(i=n;i>a;i--)
#define repde(i,a,n) for(i=n;i>=a;i--) 
#define pb(n) push_back(n)
#define ff first
#define ss second
#define dfo if(0) cout
#define mod 1000000007

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	fi.tie(0);
	fo.tie(0);

	ll a,b,c;

	fi>>a>>b>>c;

	if(a+b >= c)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;		
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int d=0;
        for (int i = 0; i < n; i++) {
            d+=sc.nextInt()%2;
        }
        out.println(d%2==0?"YES":"NO");
    }
}

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

using namespace std;

int main(){
  int N;
  vector<int> d;
  cin >> N;
  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    d.push_back(tmp);
  }
  sort(d.begin(), d.end());

  int h = N / 2, ans;
  ans = d[h] - d[h-1];
  printf("%d\n", ans);
}


Measured memory_bytes: 3904
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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 INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int k, t;
    cin>>k>>t;
    vi as(t);
    cin>>as;
    sort(rng(as));

    if (t == 1) {
        cout<<as[0] - 1<<endl;
        return 0;
    }

    int cnt = as[0] + 1;
    int ans = 0;
    rep(i, t - 1) {
        if (cnt - 2 <= as[i + 1]) ans = 0;
        if (cnt < as[i + 1]) ans += as[i + 1] - cnt;
        cnt += as[i + 1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val L = readLine().split(" ").map(_.toInt)

  def solve() = {
    var ans = 0
    for {
      i <- 0 until n
      j <- i until n
      k <- j until n
    } {
      val list = Seq(L(i), L(j), L(k))
      val max = Math.max(Math.max(L(i), L(j)), L(k))
      val isTriangle = max < (L(i)+L(j)+L(k)) - max
      val isUnique = L(i) != L(j) && L(i) != L(k) && L(j) != L(k)
      if(isTriangle && isUnique) ans += 1
    }
    ans
  }

  println(solve())

}



Measured memory_bytes: 56696
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] d = new int[N];
        for (int i = 1; i < N; i++) {
            for (int j = i+1; j <= N; j++) {
                int dist = Math.min(j-i, Math.abs(X-i)+Math.abs(Y-j)+1);
                d[dist]++;
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 1; i < N; i++) {
            ans.append(d[i]).append('\n');
        }

        System.out.print(ans);
    }
}



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

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n,m;
    cin >> n >> m;
    char s[n+1];
    cin >> s;
    int nextZero[n+1], z;
    for (int i=0; i<=n; ++i) {
        if (s[i] == '0') z = i;
        nextZero[i] = z;
    }

    pair<int,int> dp[n+1];
    bool failed = false;
    for (int x=n-1; x>=0; --x) {
        if (s[x] == '1') continue;
        int leap = nextZero[min(x+m, n)];
        if (leap == x) {
            cout << -1;
            failed = true;
            break;
        }

        int keep = dp[leap].second;

        int k=leap;
        for (int b=m; b>=1; b/=2) {
            while (k-b>x) {
                int check = nextZero[k-b];
                if (check <= x || dp[check].second != keep) break;
                k = check;
            }
        }
        dp[x] = {k-x, dp[k].second+1};
    }
    if (!failed) {
        int x = 0;
        while (x != n) {
            cout << dp[x].first << " ";
            x += dp[x].first;
        }
    }
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<map>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
#pragma GCC optimize "trapv"
using namespace std;
typedef long long int ll;
int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    //
    int ct=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k] && a[k]+a[j]>a[i] && a[i]+a[k]>a[j] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                {
                    ct++;
                }
            }
        }
    }
    cout<<ct<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int par[210000]; //親
int ran[210000]; //木の深さ

// n要素を初期化
void init(int n){
  for(int i=0;i<=n;i++){
    par[i]=i;
    ran[i]=0;
  }
}

//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;

  if(ran[x]<ran[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
  return find(x)==find(y);
}

int main(){
  int k[210000],l[210000];
  int N,K,L,p,q;
  cin>>N>>K>>L;
  init(N+1);
  for(int i=0;i<K;i++){
    cin>>p>>q;
    unite(p,q);
  }

  for(int i=1;i<=N;i++){
    k[i]=find(i);
  }
  init(N+1);

  for(int i=0;i<L;i++){
    cin>>p>>q;
    unite(p,q);
  }

  for(int i=1;i<=N;i++){
    l[i]=find(i);
  }

  map<P,int> M;

  for(int i=1;i<=N;i++){
    if(M.find(P(k[i],l[i]))==M.end()) M[P(k[i],l[i])]=0;
    else M[P(k[i],l[i])]++;
  }

  for(int i=1;i<=N;i++){
    cout<<M[P(k[i],l[i])]+1<<endl;;
  }
}











Measured memory_bytes: 15104
// ABC141_B
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str ,str1;
    cin >> str;
    int cnt=0;
    for(int i=0;i <str.size(); i++){

            if((i+1)%2 == 1){
                if(str.at(i) == 'R' || str.at(i) == 'U' || str.at(i) == 'D'){
                    cnt++;
                }
            }else{
                if(str.at(i) == 'L' || str.at(i) == 'U' || str.at(i) == 'D'){
                    cnt++;
                }
            }

        }
    if(cnt == str.size()){
        cout <<"Yes" << endl;
    }
    else{
        cout << "No" << endl;
      
    }


    }




Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

typedef struct
{
  char name[11];
  int time;
  int sum;
} ps;

int isEmpty();
int isFull();
void enqueue(ps);
ps dequeue();

int head = 0, tail = 0;
ps que[MAX];

int main()
{
  int i, n, q, st=0;
  ps x, a[MAX];
  x.sum=0;
  
  scanf("%d%d", &n, &q);
  for(i=0; i<n; i++)
    {
      scanf("%s%d", x.name, &x.time);
      enqueue(x);
    }

  i=0;
  while(!isEmpty())
    {
      x = dequeue();
      if(x.time > q)
	{
	  st += q;
	  x.time -= q;
	  enqueue(x);
	}
      else
	{
	  x.sum += x.time+st;
	  a[i] = x;
	  i++;
	  st += x.time;
	}
    }
  
  for(i=0; i<n; i++)
    {
      printf("%s %d\n", a[i].name, a[i].sum);
    }
  
  return 0;
}

int isEmpty()
{
  return head == tail;
}
int isFull()
{
  return head == (tail+1)%MAX;
}
void enqueue(ps x)
{
  if(isFull())
    {
      printf("OVF\n");
    }
  que[tail] = x;
  if(tail+1 == MAX)
    {
      tail = 0;
    }
  else
    {
      tail++;
    }
} 
ps dequeue()
{
  if(isEmpty())
    {
      printf("UNF\n");
    }
  ps x = que[head];
  if(head+1 == MAX)
    {
      head = 0;
    }
  else
    {
      head++;
    }
  return x;
}

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

#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef pair<int, int> iPair;
const int MOD = 1e9+7;

int32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

    int t = 1;
    int i,j;
    // cin>>t;
    
    while(t--)
    {
        int n;
        cin >> n;
        vector <double> arr(n);
        FOR(i, n) cin >>arr[i];
        double dp[n+1][n+1];

        double tail = 1 - arr[0];
        dp[1][0] = tail;
        for(int i = 2; i <= n; ++i)
        {
            tail *= (1 - arr[i-1]);
            dp[i][0] = tail;
        }

        double head = arr[0];
        dp[1][1] = head;
        for(int i = 2; i <= n; ++i)
        {
            head *= arr[i-1];
            dp[i][i] = head;
        }


        for(int i = 2; i <= n; ++i)
        {
            for(int j = 1; j < i; ++j)
            {
                dp[i][j] = dp[i-1][j-1] * arr[i-1] + dp[i-1][j] * (1 - arr[i-1]);
            }
        }

        double ans = 0;
        for(int i = n/2+1; i <= n; ++i)
        {
            ans += dp[n][i];
        }
        cout.precision(17);
        cout<<ans;

    }

	return 0;
}


Measured memory_bytes: 70272
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val n = s.size
  val v = "keyence"

  val res = for {
    i <- 0 to 7
    j <- 0 to 7
    if s.take(i) + s.takeRight(j) == v
  } yield true

  val ans = if(res.nonEmpty) "YES" else "NO"
  println(ans)
}

Measured memory_bytes: 25412
N = gets.to_i
A = gets.split.map(&:to_i).sort.reverse
result = A.shift
n = N - 2
warn result.inspect
if n == 0
    puts result
    exit
end

a = A.shift
cnt = 0
while n > 0 do
    if cnt < 2
        result += a
        cnt += 1
    else
        a = A.shift
        result += a
        cnt = 1
    end
    n -= 1
end

puts result

Measured memory_bytes: 31252
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL mod=1e9+7;
LL bm(LL b,LL p,LL m){
	LL a=1;
	while(p){
		if(p&1)a=(a*b)%m;
		b=(b*b)%m;
		p>>=1;
	}
	return a;
}

int main(){
	int m,n;cin>>m>>n;
	cout<<bm(m,n,mod)<<endl;
}

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

using namespace std;

int main() {
	int n, x, m;
	cin >> n >> x;

	int ans = n;
	int mini = 1e9;
	for (int i = 0; i < n; i++) {
		cin >> m;
		x -= m;
		mini = min(mini, m);
	}

	ans += x / mini;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int a,b;
bool check(int x,int y)
{
	if(a%3==0||b%3==0||(a+b)%3==0) return 1;
	else return 0;
}
int main()
{
    cin>>a>>b;
    if(check(a,b)==1) cout<<"Possible";
    else cout<<"Impossible";
    
    return 0;
}

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

using namespace std;
typedef unsigned long long ull;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

int main(int argc, char const *argv[]) {
    int N;
    ull x;
    cin >> N >> x;
    vector<ull> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ull ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }

    for (int i = 0; i < N-1; i++) {
        ull s = a[i] + a[i+1];
        if (s > x) {
            ans += s - x;
            a[i+1] = x - a[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll A,B,C,ans=0;
  cin>>A>>B>>C;
  
  if(A+B>=C-1) ans=B+C;
  else ans=A+2*B+1;
  
  co(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int solve(int N, int M){
  if(N == 1 && M == 1) return 1;
  if(N == 1) return M-2;
  if(M == 1) return N-2;

  return (N-2)*(M-2);
}

signed main() {
  int N, M; 
  cin >> N >> M;

  cout << solve(N, M) << "\n";

  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input().rstrip("\n"))
    current , *numbers = [int(x) for x in input().rstrip("\n").split(" ")]
    while current >= 2 and numbers:
        next_value = numbers.pop(0)
        a, b = min(current, next_value), max(current, next_value)
        while b % a > 0:
            a, b = (b % a), a
        current = a
    print(current)
    

if __name__ == '__main__':
    main()


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

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

constexpr ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<vector<vector<int>>> F(N, vector<vector<int>>(5, vector<int>(2)));
    vector<vector<int>> P(N, vector<int>(11));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 5; ++j) {
            for(int k = 0; k < 2; ++k) {
                cin >> F[i][j][k];
                assert(F[i][j][k] <= 1);
            }
        }
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }
    ll res = -INF;
    for(int S = 1; S < (1 << 10); ++S) {
        ll p = 0;
        vector<int> cnt(N);
        for(int i = 0; i < N; ++i) {
            for(int day = 0; day < 5; ++day) {
                for(int t = 0; t < 2; ++t) {
                    if(!(S & (1 << (day * 2 + t)))) {
                        continue;
                    }
                    cnt[i] += F[i][day][t];
                }
            }
        }
        for(int i = 0; i < N; ++i) {
            p += P[i][cnt[i]];
        }
        res = max(res, p);
    }
    cout << res << endl;
}


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

using namespace std;









const int INF = 10E8 + 5;

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

	vector<int> h(n);
	vector<int> dp(n, INF);
	for(int &i : h){
		cin >> i;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j <= i + k; j++){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin>>a;
  int b=a/100;
  int c=a%100/10;
  int d=a%10;
  
 if(b!=7 && c!=7 && d!=7){
   cout<<"No"<<endl;
 }
  else{
    cout<<"Yes"<<endl;
  }
}
   
  

Measured memory_bytes: 3632
import bisect

N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
X, H = zip(*XH)

K = [-(-h // A) for h in H]
L = [0] * (N + 2)

ans = 0
for i in range(N):
    L[i + 1] += L[i]
    s = max(K[i] - L[i + 1], 0)
    ans += s
    L[i + 1] += s
    L[bisect.bisect_right(X, X[i] + 2 * D) + 1] -= s

print(ans)


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))


int main()
{
    int i,j,k,l,m,n;

    cin >> n >> m;

    int ar[n+10];

    memset(ar,-1,sizeof ar);
    bool ok = true;

    for(i=0; i<m; i++)
    {
        cin >> l >> k;

        if(ar[l] != -1 && ar[l] != k)
            ok=false;

        ar[l] = k;
    }

    if(ar[1] == 0 && n>1)ok = false;

    if(!ok)cout<<-1<<endl;
    else
    {
          for(i=2;i<=n;i++)
          {
              if(ar[i] == -1)ar[i] = 0;
          }
          if(ar[1]==-1)
          {
              if(n>1)
              ar[1] = 1;
              else ar[1]=0;
          }
          for(i=1;i<=n;i++)cout << ar[i] ;

          cout << endl;

    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
signed main() {
	ll n, a, cnt = 0, ans = 0; cin >> n;
	vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
		if (h > 0) {
			if (v[h - 1] == v[h]) { cnt++; }
			else { cnt++; ans += cnt / 2; cnt = 0; }
		}
	}
	cnt++; ans += cnt / 2;
	cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int x,n;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<endl;
        return 0;
    }
    int a[n];
    
    unordered_map<int,int> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]=1;
    }
    //int mn=*min_element(a,a+n);
    //int mx=*max_element(a,a+n);
    int ans,mnn=INT_MAX;
    for(int i=0;i<=105;i++)
    {
        if(m.find(i)==m.end())
        {
            if(abs(i-x)<mnn)
            {
                ans=i;
                mnn=abs(i-x);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
N,Q = gets.split.map(&:to_i)
S = gets.chomp * 2

a = [0]
(S).each_char.with_index do |s,i|
  next if i == 0
  a[i] = a[i-1]
  next if S[i] != 'C'
  next if S[i-1] != 'A'
  a[i] += 1
end

Q.times do
  l,r = gets.split.map {|s| s.to_i - 1 }
  l = (l < N*2) ? a[l] : (a[l%N+N]-a[l%N]) * (l/N)
  r = (r < N*2) ? a[r] : (a[r%N+N]-a[r%N]) * (r/N)
  puts r - l
end


Measured memory_bytes: 4476
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = 1000000000 + 7;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




ll pow(ll a, ll b) {


	if (b == 0) return 1;

	if (a % 2 == 1) {
		a * pow(a, b - 1);
	}
	else {
		ll ret = pow(a, b / 2);
		return ret * ret;
	}
}


ll A[100005];
map<ll, ll> m;
ll Sum[100005];


int main() {
	ll N, M;
	


	cin >> N >> M;


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

	}


	ll ans = 0;
	Sum[0] = A[0];
	
	m[Sum[0] % M] = 1;
	
	if (Sum[0] % M == 0)
		ans += 1;

	rep(i, N-1) {

		Sum[i + 1] = A[i + 1] + Sum[i];
		if (m.find(Sum[i + 1] % M) != m.end()) {
			ans += m[Sum[i + 1] % M];
			m[Sum[i + 1] % M] += 1;	
		}
		else
			m[Sum[i + 1] % M] = 1;

		
	
		if (Sum[i+1] % M == 0)
			ans += 1;





	}

	cout << ans << endl;

	


	
	return 0;
}

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

char Trump;
string cards[4][13];
string strength="23456789TJQKA";

int comp(string s,string t){
    if (s[1]==Trump&&t[1]!=Trump) return 1;
    if (s[1]!=Trump&&t[1]==Trump) return 0;
    if (s[1]!=t[1]) return 0;
    int s_strength,t_strength;
    for (int i=0;i<13;++i){
        if (s[0]==strength[i]) s_strength=i;
        if (t[0]==strength[i]) t_strength=i;
    }
    if (t_strength<s_strength) return 1;
    return 0;
}

void solve(){
    int ns=0,ew=0,winner=0;
    for (int j=0;j<13;++j){
        int nxt=winner; string Max=cards[winner][j];
        for (int i=1;i<4;++i){
            if (comp(cards[(winner+i)%4][j],Max)){
                Max=cards[(winner+i)%4][j]; nxt=(winner+i)%4;
            }
        }
        winner=nxt;
        ++(winner==0||winner==2?ns:ew);
    }
    cout << (ew<ns?"NS":"EW") << ' ' << max(ns,ew)-6 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> Trump,Trump!='#'){
        for (int i=0;i<4;++i)
            for (int j=0;j<13;++j)
                cin >> cards[i][j];
        solve();
    }
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 105;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
const int MOD = 1e9+7;
int h[N];
int Has[N]; int tot;
ll dp[N][N];
ll Pow(ll x, ll y) {
    if(y <= 0) return 1;
    ll result = 1;
    while(y) {
        if(y & 1)
            result = result * x % MOD;
        y >>= 1;
        x = x*x % MOD;
    }
    return result;
}
int main() {
    int n;
    while(~scanf("%d", &n)) {
        tot = 0;
        memset(dp, 0, sizeof(dp));
        h[0] = 0;
        dp[0][0] = 1;

        for(int i = 1; i <= n; ++i) {
            scanf("%d", &h[i]);
            Has[++tot] = h[i];
        }
        sort(Has + 1, Has + tot + 1);
        tot = unique(Has+1, Has + tot + 1) - Has - 1;

        for(int i = 1; i <= n; ++i) {
            h[i] = lower_bound(Has + 1, Has + tot + 1, h[i]) - Has;
        }
        for(int i = 1; i <= n; ++i) {
            dp[i][0] = dp[i-1][0] * 2 % MOD;
            for(int j = h[i] + 1; j <= h[i-1]; ++j) dp[i][0] = (dp[i][0] + dp[i-1][j] * 2 % MOD) % MOD;
            ll tmpPow = Pow(2, Has[h[i]] - Has[h[i-1]]);
            for(int j = 1; j <= min(h[i-1], h[i]) ; ++j)
                dp[i][j] = dp[i-1][j] * tmpPow % MOD;
            for(int j = h[i-1] + 1; j <= h[i]; ++j) {
                dp[i][j] = (dp[i][j] + j==1? ( dp[i-1][0] * ( Pow(2, Has[j]) - 2) % MOD * Pow(2, Has[h[i]] - Has[j]) % MOD ) :
                                             ( dp[i-1][0] * 2 * (Pow(2, Has[j]-Has[j-1]) - 1) % MOD * Pow(2, Has[h[i]]-Has[j]) % MOD )
                                             ) %MOD;
            }
        }
        ll result = 0;
        for(int i = 0; i <= tot; ++i)
            result = (result + dp[n][i]) % MOD;
        printf("%lld\n", result);
    }
}


Measured memory_bytes: 384
import java.util.*;

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

    int n = sc.nextInt();
    int[] a = new int[n];
    double numer = 1;
    double denom = 0;
    double ans;

    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      numer *= a[i];
    }

    for(int i = 0; i < n; i++){
      denom +=  numer / a[i];
    }
    
    ans = numer / denom;
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

int main() {

	int N;
	int p[20];
	int max = 0;
	int sum = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		sum += p[i];
		if (p[i] > max)max = p[i];
	}
	sum -= max;
	max /= 2;
	sum += max;

	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 3123;
const double pi = 3.14159265359;
const double eps = 0.00000001;

int n;
double p[MAXN];
double dp[MAXN][MAXN];
bool seen[MAXN][MAXN];

double sol(int i, int qtd) {
    if (i == n) {
        return !qtd;
    }
    if (seen[i][qtd]) {
        return dp[i][qtd];
    }
    seen[i][qtd] = 1;
    return dp[i][qtd] = sol(i + 1, qtd - 1) * p[i] + sol(i + 1, qtd) * (1 - p[i]);
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lf", &p[i]);
    }
    double ans = 0;
    for (int i = n/2+1; i <= n; ++i) {
        ans += sol(0, i);
    }
    printf("%.10lf\n", ans);
}


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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> freq(N + 1);

    for (int i = 0; i < N - 1; ++i) {
        int p; cin >> p;
        freq[p]++;
    }
    for (int i = 1; i <= N; ++i) {
        cout << freq[i] << "\n";
    }
}

Measured memory_bytes: 3584
import math
ans = []
while True:
    ufo = []
    n = raw_input().split()
    if n == ["0", "0"]:
        for an in ans:
            print an
        break
    else:
        R = int(n[0])
        for i in range(int(n[1])):
            m = [int(f) for f in raw_input().split()]
            l = math.sqrt(m[0] ** 2 + m[1] ** 2)
            ufo.append([l, l, (m[0], m[1]), m[2], m[3]])
        a = 0
        while len(ufo) > 0:
            flag = True
            for xs in ufo: xs[0] -= xs[4]
            ufo.sort()
            for xs in ufo[:]:
                if xs[0] <= R:
                    a += 1
                    ufo.remove(xs)
                    continue
                elif flag:
                    r = xs[1]
                    pos = xs[2]
                    ufo.remove(xs)
                    flag = False
                    continue
                else:
                    d = xs[0] / xs[1] * abs(pos[0] * xs[2][1] - pos[1] * xs[2][0]) / r
                    if d <= xs[3]:
                        if xs[0] * math.cos(math.atan2(xs[2][1], xs[2][0]) - math.atan2(pos[1], pos[0])) + math.sqrt(xs[3] ** 2 - d ** 2) > R:
                            ufo.remove(xs)
        else:
            ans.append(a)

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

int main(){
  int n;
  cin >> n;
  int array[n];

  for(auto &i : array){
    cin >> i;
  }
  bool isAllEven = true;
  auto count = 0;

  while(true){
    for(auto i : array){
     if(i % 2 != 0){
       isAllEven = false;
       break;
     }
    }
    if(isAllEven){
      for(auto &i : array) i /= 2;
      count++;
    }else break;
  }

  cout << count << "\n";

  return 0;
}



Measured memory_bytes: 256
#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;
  string X;
  cin >> N >> X;
  bitset<200000> x(X);

  int cnt = x.count();
  int hp = cnt + 1;
  int lp = max((int)(cnt - 1), 1);
  int hr = 0;
  int lr = 0;
  vector<int> H(N, (1 % hp));
  vector<int> L(N, (1 % lp));
  rep(i, N) {
    if (i != 0) {
      H.at(i) = H.at(i - 1) * 2 % hp;
      L.at(i) = L.at(i - 1) * 2 % lp;
    }
    if (!x.test(i)) continue;
    hr += H.at(i);
    hr %= hp;
    lr += L.at(i);
    lr %= lp;
  }

  rep(i, N) {
    int p = cnt + (x.test(N - 1 - i) ? -1 : 1);
    if (p == 0) {
      cout << 0 << endl;
      continue;
    }

    int r = 0;
    if (p == hp) {
      r = hr;
      r += H.at(N - 1 - i);
    } else if (p == lp) {
      r = lr;
      r -= L.at(N - 1 - i);
      if (r < 0) r += p;
    }
    r %= p;

    int ans = 1;
    while (r != 0) {
      r %= bitset<20>(r).count();
      // r %= __builtin_popcount(r);
      ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 5076
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int m[10][10];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(m, 0, sizeof(m));
    int n = gi();
    for (int i = 1; i <= n; i++) {
        int f = i%10;
        int l = i;
        while (l > 9)
            l /= 10;
        m[f][l]++;
    }

    ll res = 0;
    for (int i = 1; i < 10; i++)
        for (int j = 1; j < 10; j++)
            res += m[i][j] * m[j][i];

    cout << res << endl;

    return 0;
}


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

using namespace std;

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        cout << (b / x) + 1;
    } else {
        cout << (b / x) - ((a - 1) / x);
    }
    return 0;
}


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

using namespace std;

int v2(int n) {
    assert (n > 0);
    int s = 0;
    while (n % 2 == 0) {
        ++s;
        n /= 2;
    }
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> as(n);
    for (int i = 0; i < n; ++i) {
        as[i] = (int) (s[i] - '1');
    }

    bool all_even = true;
    for (auto a : as) {
        if (a % 2 == 1) {
            all_even = false;
        }
    }
    
    if (all_even) {
        for (auto& a : as) {
            a = a / 2;
        }
    }
    
    int result_parity = 0;
    int v2_binom = 0; // v_2(\binom{n}{i})
    for (int i = 0; i < n; ++i) {
        // result_parity += \binom{n-1}{i} * as[i]
        if (v2_binom == 0) {
            result_parity += as[i];
        }
        if (i + 1 <= n - 1) {
            // \binom{n-1}{i+1} / \binom{n-1}{i} = (i)! (n-1-i)! / ((i+1)! (n-i-2)!) = (n-1-i) / (i + 1)
            v2_binom += v2(n - 1 - i);
            v2_binom -= v2(i + 1);
        }
    }

    result_parity = result_parity % 2;

    int answer = all_even ? result_parity * 2 : result_parity;
    cout << answer << endl;

    return 0;
}


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

#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    long long int sum = 0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i % 3 == 0 || i % 5 == 0)
            continue;
        sum += i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int x=read(),y=read(),ans=0;
	if (x==1) ans+=300000;
	if (y==1) ans+=300000;
	if (x==2) ans+=200000;
	if (y==2) ans+=200000;
	if (x==3) ans+=100000;
	if (y==3) ans+=100000;
	if (x==1&&y==1) ans+=400000;
	printf("%d\n",ans);
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    lli ans=0;
    cin>>n;
    n++;
    vector<lli> p(n);
    rep(i,n){
        cin>>p.at(i);
    }
    vector<lli> b(n+1);
    b.at(n-1)=p.at(n-1);
    for(int i=n-1;i>=0;i--){
        b.at(i)=b.at(i+1)+p.at(i);    
    }
    b.at(0)=1;
    for(int i=1;i<n;i++){
        b.at(i)=min((b.at(i-1)-p.at(i-1))*2,b.at(i));
        ans+=b.at(i);
    }
    rep(i,n){
        if(b.at(i)<p.at(i)){
            out(-1);
            return 0;
        }
    }
    ans+=1;
    out(ans);
}

Measured memory_bytes: 4840
HW = input()
HW_ = HW.split()
H = int(HW_[0])
W = int(HW_[1])
hw = input()
hw_ = hw.split()
h = int(hw_[0])
w = int(hw_[1])

ans = H * W - (h * W + w * H - h * w)
print(ans)

Measured memory_bytes: 3060