akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
int W,H,N,i,x,y,x2,y2,xx,yy,a=0;
scanf("%d%d%d",&W,&H,&N);
for(i=0;i<N;i++){
scanf("%d%d",&x,&y);
if(i!=0){
xx=x-x2;
yy=y-y2;
if(xx<0){xx*=-1;}if(yy<0){yy*=-1;}
if(x>=x2&&y<=y2||x<=x2&&y>=y2){
a+=xx+yy;
}
else if(x>x2&&y>y2||x<x2&&y<y2){
	if(xx>yy){
	a+=yy+(xx-yy);
	}else if(xx<yy){
	a+=xx+(yy-xx);
	}else{
	a+=xx;
	}

}

}
x2=x;
y2=y;
}
printf("%d\n",a);
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<cmath>
#include<complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
typedef double elem;typedef complex<elem> point,vec;
elem cross(point a, point b){ return imag(conj(a)*b); }elem AreaOfPolygon(const vector<point> &vp){int n = vp.size();elem ret=0;REP(i,n){ret+=cross(vp[i],vp[(i+1)%n]);}return ret/2.;}int main(){int tc=0;while(true){int n;tc++;vector<point> vp;cin >> n;if(n==0)break;for(int i = 0; i < n; ++i){elem x,y;cin>>x>>y;vp.push_back(point(x,y));}printf("%d %.1lf\n", tc, -AreaOfPolygon(vp) );}return 0;}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    string s; cin >> s;

    if( N % 2 == 1 ){
        cout << "No" << endl;
    }else{
        REP( i, N / 2 ){
            if( s[i] != s[N / 2 + i] ){
                cout << "No" << endl;
                return 0;
            }
        }

        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	int n;
	while (cin >> n && n){
		bool f = 1;
		vector<string> s(n);
		REP(i,n) cin >> s[i];
		VVI e(26,VI(26));
		REP(i,n-1){
			string a = s[i], b = s[i+1];
			REP(j,min(a.length(), b.length())){
				if (a[j] != b[j]){
					e[a[j]-'a'][b[j]-'a'] = 1;
					break;
				}
				if (j == min(a.length(), b.length())-1 && a.length() > b.length())
					f = 0;
			}
		}
		REP(i,26){
			VI visit(26);
			queue<int> que;
			que.push(i);
			while (!que.empty()){
				int x = que.front();
				que.pop();
				REP(j,26){
					if (!e[x][j] || visit[j]) continue;
					visit[j] = 1;
					que.push(j);
				}
			}
			if (visit[i]) f = 0;
		}
		cout << (f ? "yes" : "no") << endl;
	}
    return 0;
}

Measured memory_bytes: 3220
input()
S = input()
tmp = sum([1 for s in S[1:] if s == "E"])
ans = tmp
for i in range(1, len(S)):
    if S[i-1] == "W":
        tmp += 1
    if S[i] == "E":
        tmp -= 1
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(ll i=k;i<n;i++)
#define all(x) x.begin(),x.end()
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define xx first
#define yy second
#define MOD 1000000007
#define pb push_back
typedef long long ll;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

vector<int> g[100000];
int dp[100000];

int calc(int i){
	if(dp[i] != -1) return dp[i];
	dp[i] = 0;
	for(int to:g[i])
		dp[i] = max(dp[i],1 + calc(to));
	return dp[i];
}

int main(){
	FAST
	int n,m,a,b;
	cin >> n >> m;
	memset(dp,-1,sizeof(dp));
	rep(i,m){
		cin >> a >> b;
		g[a-1].pb(b-1);
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans,calc(i));
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s, t; cin >> s >> t;
  rep(i, n) {
    if(s.substr(i) == t.substr(0, n-i)) {
      cout << 2*n-(n-i) << endk;
      return 0;
    }
  }
  cout << 2*n << endk;
  return 0;
}


Measured memory_bytes: 3604
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;


int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  ll res = 0; ll prev = 0;
  rep(i, 1, n) {
    ll x;
    cin >> x;
    res += min(prev, x);
    x -= min(prev, x);
    res += x / 2;
    x -= 2*(x / 2);
    prev = x;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    string s;
    cin >> s;
    set<char> su;
    for(char c: s){
        su.insert(c);
    }
    if(len(su) == 26){
        cout << "None" ;
        return 0;
    }
    char c = 'a';
    for(int i = 1; i < 30; ++i){
        if(su.count(c)){
            c++;
        }
        else{
            cout << c;
            return 0;
        }
    }
}

Measured memory_bytes: 3788
// ------------------------------------
// Date:2018/ 2/22
// Problem:ABC 044 TakAndHotels a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

int main()
{
  int N,K,X,Y,res = 0;
  cin >> N >> K >> X >> Y;
  REP(i,N) res += i<K?X:Y;
  cout << res << endl;
  return 0;
}


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

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

    int res = 1;
    bool single = true;
    for (int i = 1; i < (int)S.size(); i++) {
        if (single && S[i] == S[i - 1]) {
            single = false;
            i++;
            if (i >= S.size()) break;
        } else {
            single = true;
        }
        res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    
    if( A == 1 || B == 1 ){
        if( A == B ) cout << "Draw" << endl;
        else if( A == 1 ) cout << "Alice" << endl;
        else if( B == 1 ) cout << "Bob" << endl;
    } else {
        if( A == B ) cout << "Draw" << endl;
        if( B < A ) cout << "Alice" << endl;
        else if( A < B ) cout << "Bob" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s,t;

int main(void){
	int i,n,ans=0;
	std::cin >> s >> t;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		if(s[i]!=t[i]){
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define mp make_pair 
#define pb push_back 
#define fi first
#define se second

#define MOD 40000
#define DOMOD(d) if ((d) >= MOD) d %= MOD;
#define DONEGMOD(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;

#define inp(a) scanf("%d", &a)
#define inp2(a,b) scanf("%d %d", &a, &b)
#define inp3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define inp4(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define inpl(a) scanf("%lld", &a)
#define inpl2(a,b) scanf("%lld %lld", &a, &b)
#define inpl3(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define inpl4(a,b,c,d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repv(u) for (int i=0;i<(int) u.size() ; i++ ) 
#define mset(a,val) memset(a,val,sizeof(a))
#define printv(v) for (int i=0;i<(int) v.size(); i++) cout<<v[i]<<" " 
#define MAX 1000005
using namespace std ;
typedef long long int ll ;
typedef pair<int,int> pii ;
typedef pair<long long , long long > pll ;




int main()
{
  
  
  int n ; inp(n) ;
  int o = 0 , e = 0 ; 
  int x ;
  for (int i=0;i<n;i++)
  {
	  inp(x) ;
	  if (x%2==0) e++ ;
	  else o++ ;
  }
  if (o%2!=0 && n!=1) cout<<"NO"<<endl ;
  else cout<<"YES"<<endl ; 	
  
  return 0 ;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 try{

			 int S = Integer.parseInt(br.readLine());

			 System.out.printf("%d:%d:%d\n",S/3600,(S%3600)/60,S%60);

		 }catch(IOException e){
			 e.printStackTrace();
		 }
	}
}


Measured memory_bytes: 24684
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

vector<int> as;
VV(int) G;
int cycroot = -1;
vector<char> vis;
vector<int> cyc;
vector<char> incyc;

int dfs1(int u){
	int &r = as[u];
	if(r != -1){
		if(r == -2){ cycroot = u; }
		return r;
	}
	r = -2;
	set<int> st;
	for(int v : G[u]){
		int t = dfs1(v);
		if(!incyc[v]){
			st.insert(t);
		}
	}
	for(r = 0; st.count(r); ++r);
	return r;
}

void assignval(){
	int n = G.size();
	as.assign(n, -1);
	for(int i = 0; i < n; ++i){
		if(as[i] == -1){
			dfs1(i);
		}
	}
}

bool check(){
	int n = G.size();
	for(int i = 0; i < n; ++i){
		set<int> st;
		for(int u : G[i]){
			st.insert(as[u]);
		}
		if(st.count(as[i])){ return false; }
		for(int j = 0; j < as[i]; ++j){
			if(!st.count(j)){ return false; }
		}
	}
	return true;
}

bool dfs2(int u){
	cyc.push_back(u);
	vis[u] = 1;
	for(int v : G[u]){
		if(v == cyc[0]){ return true; }
		if(!vis[v]){
			if(dfs2(v)){ return true; }
		}
	}
	cyc.pop_back();
	return false;
}

void mainmain(){
	int n;
	scanf("%d", &n);
	G.resize(n);
	vis.resize(n);
	incyc.resize(n);
	for(int i = 0; i < n; ++i){
		int p;
		scanf("%d", &p);
		--p;
		G[p].push_back(i);
	}

	assignval();

	int ok = 0;

	if(check()){
		ok = 1;
	}
	else{
		dfs2(cycroot);
		int sz = cyc.size();
		if(sz % 2 == 0){ ok = 2; }
		else{
			for(int u : cyc){ incyc[u] = 1; }
			assignval();

			for(int i = 1; i < sz; ++i){
				if(as[cyc[0]] != as[cyc[i]]){ ok = 3; }
			}
		}
	}

	puts(ok ? "POSSIBLE" : "IMPOSSIBLE");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 33180
#pragma GCC optimize("O3")
#pragma GCC target("avx")

#include <stdio.h>

template <const unsigned int max_x, const unsigned int max_n, const unsigned int mod>
class shuumai{
private:
    // Pow[x][n] = x^n
    unsigned int Pow[max_x + 1][max_n + 1];
    // Sum[n][x] = ∑_{y ≤ x} y^n
    unsigned int Sum[max_x + 1][max_n + 1];
public:
    constexpr shuumai(void): Pow(), Sum(){
        for(unsigned int x = 1; x <= max_x; ++x){
            Pow[x][0] = 1;
            for(unsigned int k = 1; k <= max_n; ++k){
                Pow[x][k] = (unsigned long long int)(x) * Pow[x][k - 1] % mod;
            }
        }
        for(unsigned int n = 0; n <= max_n; ++n){
            for(unsigned int x = 1; x <= max_x; ++x){
                Sum[n][x] = Sum[n][x - 1] + Pow[x][n];
                if(Sum[n][x] >= mod) Sum[n][x] -= mod;
            }
        }
    }
    unsigned int karashi(const unsigned int a, const unsigned int b, const unsigned int n)const{
        return (Sum[n][a - 1] <= Sum[n][b]) ? Sum[n][b] - Sum[n][a - 1] : Sum[n][b] + mod - Sum[n][a - 1];
    }
};

constexpr unsigned int MAX_V = 400;
constexpr unsigned int MAX_C = 400;
constexpr unsigned int mod = 1000'000'007;
//constexpr 
shuumai<MAX_V, MAX_C, mod> enpitsu;

constexpr unsigned int MAX_N = 400;
unsigned int A[MAX_N], B[MAX_N];

unsigned long long int DP[MAX_N + 1][MAX_C + 1];

int main(void){
    unsigned int n, C; scanf("%u%u", &n, &C);
    for(unsigned int i = 0; i < n; ++i) scanf("%u", A + i);
    for(unsigned int i = 0; i < n; ++i) scanf("%u", B + i);

    DP[0][0] = 1;
    for(unsigned int i = 0, ip = 1; i < n; ++i, ++ip){
        for(unsigned int c = 0; c <= C; ++c){
            for(unsigned int a = 0, b = c; a <= c; ++a, --b){
                (DP[ip][c] += enpitsu.karashi(A[i], B[i], a) * DP[i][b]) %= mod;
            }
        }
    }
    printf("%llu\n", DP[n][C]);
    return 0;
}

Measured memory_bytes: 1408
n,*a=map(int,open(0).read().split());k=10**9+7
c=(1<<n)%k-1
for l in a:
	X=Y=j=Z=1;d=k-2
	for i in range(l):X=X*(n-i)%k
	while j<=l:Y=Y*j%k;j+=1
	while d>0:Z=Z*Y%k if d&1==1 else Z;Y=Y*Y%k;d>>=1
	c-=X*Z%k
print(c%k)

Measured memory_bytes: 263412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

ll range_sum(ll low, ll high) {
    if (low > high) return 0ll;
    if (low == high) return low;
    if (low == 1ll) return (high * (high + 1)) / 2;
    return (high * (high + 1)) / 2 - ((low - 1) * low) / 2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll d = (ll)floor(sqrt(n));
    ll total = 0;
    for (ll i = 1; i <= d; i++) {
        ll count = n / i;
        total += range_sum(1, count) * i;      // i + 2*i + ... + k*i <= n  i.e. counting where i contributes to
        total += range_sum(d + 1, count) * i;  // (d + 1)*i + ... + k*i <= n i.e. counting where the numbers bigger than d contribute to with i.
    }
    cout << total << endl;
}

Measured memory_bytes: 3724
N = int(input())
S = []
temp = 0

cnt = {"M":0, "R":0, "A":0, "C":0, "H":0}

for i in range(N):
    S.append(input())

for s in S:
    if s[0] in list(cnt.keys()):
        cnt[s[0]] += 1

for i in list(cnt.keys()):
    for j in list(cnt.keys()):
        for k in list(cnt.keys()):
            if i != j and j != k and i != k:
                temp += cnt[i]*cnt[j]*cnt[k]

print(int(temp/6))

Measured memory_bytes: 9760
#include <iostream>

using namespace std;

int N, M;
int cnt[100005];

int main(void)
{
	cin >> N >> M;
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		cnt[a]++, cnt[b]++;
	}
	
	bool ans = true;
	for(int i = 1; i <= N; i++){
		if(cnt[i] % 2){
			ans = false;
			break;
		}
	}
	
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

count = {}
for x in A:
    if count.get(x):
        count[x] += 1
    else:
        count[x] = 1

sub = {}
s = 0
for i, x in count.items():
    count[i] = x * (x - 1) // 2
    s += count[i]
    sub[i] = (x-1) * (x - 2) // 2

for i in range(N):
    print(s - count[A[i]] + sub[A[i]])


Measured memory_bytes: 96716
#include <bits/stdc++.h>
#define EPS (1e-10)
using namespace  std;

typedef complex<double> V;

int n;
vector<V> points;

pair<V, V> circles(const V& a, const V& b) {
  V v = a - b;
  double dist = abs(v);
  V n1 = (v * V(0, 1)) / dist;
  V n2 = (v * V(0, -1)) / dist;

  dist /= 2;
  double x = sqrt(1 - (dist * dist));

  return make_pair((b + v / 2.) + x * n1, (b + v / 2.) + x * n2);
}

int countInCircle(const V& center) {
  int count = 0;
  for (auto p : points) {
    if (abs(p - center) < 1 + EPS) count++;
  }
  return count;
}

int solve() {
  int count = 1;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (abs(points[i] - points[j]) < 2 + EPS) {
	auto c = circles(points[i] , points[j]);
	count = max(count, countInCircle(c.first));
	count = max(count, countInCircle(c.second));
      }
    }
  }
  return count;
}

int main() {
  while(cin >> n, n) {
    points = vector<V>(n);
    for (int i = 0; i < n; ++i) {
      double x, y;
      cin >> x >> y;
      points[i] = V(x, y);
    }

    cout << solve() << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
<?php
    $n;
    $max = (int)0;
    $min = (int)1e9;
    fscanf(STDIN, "%d", $n);
    $input = fgets(STDIN);
    $a = explode(" ", $input);
    for($i = 0; $i < $n; $i++){
        $b = (int)$a[$i];
        if($b > $max)$max = $b;
        if($b < $min)$min = $b;
    }
    echo $max - $min, "\n";
?>

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

int main(){
	////freopen("input.txt","r",stdin);
//	///freopen("output.txt","w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s;
	cin >> s;
	if (s=="Sunny"){
		cout << "Cloudy" << endl;
		return 0;
	}
	else if (s=="Rainy"){
		cout << "Sunny" << endl;
		return 0;
	}
	else if (s=="Cloudy"){
		cout << "Rainy" << endl;
		return 0;
	}
	}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd
#include <deque>	//deque

using namespace std;

int main() {

	int a, b;
	cin >> a >> b;

	int max = a + b;
	if (max < a - b) {
		max = a - b;
	}
	if (max < a * b) {
		max = a * b;
	}

	cout << max << endl;

	return 0;

}

Measured memory_bytes: 3620
n, k = gets.split.map(&:to_i)
A = []
B = []

n.times do
  a, b = gets.split.map(&:to_i)
  A << a
  B << b
end

array = Array.new(10**5 + 1) { 0 }

n.times do |i|
  array[A[i]] += B[i]
end

sum = 0
array.each_with_index do |v, i|
  sum += v
  if sum >= k
    puts i
    break
  end
end


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

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

  int r;
  cin >> r;

  cout << r * 2 * M_PI << '\n';

  return (0);
}

Measured memory_bytes: 3772
N = gets.to_i
as = Array.new(N) { gets.to_i }

i = 1
ans = 0
until i == 2 || i.zero?
  ans += 1
  i2 = as[i - 1]
  as[i - 1] = 0
  i = i2
end

puts i == 2 ? ans : -1


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
  string S;
  char s;
  cin>>S;
  if(S.size()==2){cout<<S<<endl;}
  else{s=S[0]; S[0]=S[2]; S[2]=s; cout<<S<<endl;}
}

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

typedef long long ll;

ll N;
vector<ll> W;
ll Sum;
ll R = 1 << 30;

int main() {
  cin >> N;
  W.resize(N);
  for (ll i = 0; i < N; ++i) {
    cin >> W[i];
    Sum += W[i];
  }
  ll xsum = 0;
  for (ll i = 0; i < N - 1; ++i) {
    xsum += W[i];
    R = min(R, abs(Sum - 2 * xsum));
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N;
  cin >> N;
  long long ans = 0;
  rep(i, N)
  {
    long long n = i + 1;
    if (n % 3 != 0 && n % 5 != 0)
      ans += n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main(){
	ll n,m;
	cin>>n>>m;
	ll a[n][m];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			char x;
			cin>>x;
			if(x=='.')
			a[i][j]=1;
			else
			a[i][j]=0;
		}
	}
	
	
	ll dp[n][m];
	memset(dp,0,sizeof(dp));
	
	for(ll i=0;i<n;i++){
		if(a[i][0])
		dp[i][0]=1;
		else
		break;
	}
	
	for(ll i=0;i<m;i++){
		if(a[0][i])
		dp[0][i]=1;
		else
		break;
	}
	dp[0][0]=0;
	
	for(ll i=1;i<n;i++){
		for(ll j=1;j<m;j++){
			if(a[i][j]==1){
				if(a[i-1][j]!=0 && a[i][j-1]!=0)
				dp[i][j]=(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
				else
				if(a[i-1][j]!=0 && a[i][j-1]==0)
				dp[i][j]=dp[i-1][j]%mod;
				else
				if(a[i-1][j]==0 && a[i][j-1]!=0)
				dp[i][j]=dp[i][j-1]%mod;
			}
			else
			dp[i][j]=0;
		}
	}

	cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 15872
def odd():
    for i in range(M):
        print(order[i], reverse[i])

def multipule4():
    d = 0
    for i in range(M):
        if reverse[i] - order[i] == N//2:
            d = 1
        print(order[i+d], reverse[i])

def even():
    d = 0
    for i in range(M):
        if i == (N//2-1) //2:
            d = 1
        print(order[i+d], reverse[i])
    

N, M = map(int, input().split())
order = [i for i in range(2, N+1)]
reverse = order[::-1]

if N%2 != 0:
    odd()
elif N%4 == 0:
    multipule4()
else:
    even()

Measured memory_bytes: 79968
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define PI acos(-1)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 


int main()
{
	string a,b;

	cin>>a>>b;

	cout<<b<<a<<"\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	static final long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		
		long ans = modPow(10, n);
		ans -= modPow(9, n) * 2;
		ans += modPow(8, n);
		ans %= MOD;
		ans = (ans + MOD) % MOD;
		
		System.out.println(ans);
		
		sc.close();
	}
	
	static long modPow(long base, long n) {
		long re = 1;
		for (int i = 0; i < n; i++) {
			re = re * base % MOD;
		}
		return re;
	}
}



Measured memory_bytes: 27140
#include <iostream>

using namespace std;

int main()
{
    int n,m,sum=0;
    cin >> n;
    m=n;
    while(m/10!=0){
        sum=sum+(m%10);
        m/=10;
    }
    sum+=m;
    if(n%sum==0){
        cout << "Yes" ;
    }else{
        cout << "No" ;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = [[int(i) for i in input().split()] for i in range(n)]
flag = True
x, y = 0, 0
time = 0

for i in range(n):
    if not i == 0:
        x, y = ls[i-1][1], ls[i-1][2]
        time = ls[i-1][0]
    d = abs(ls[i][1]-x) + abs(ls[i][2]-y)

    if d > ls[i][0]-time:
        flag = False
        break
    if not (ls[i][0]-time-d) % 2 == 0:
        flag = False
        break

print('Yes' if flag else 'No')


Measured memory_bytes: 62552
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll N;
  cin >> N;
  vector<ll> x(5);
  REP(i, 5) cin >> x[i];
  ll mi = LLINF, mii = -1;
  REP(i, 5) {
    if (x[i] < mi) {
      mi = x[i];
      mii = i;
    }
  }
  ll num = N / mi;
  if (N % mi > 0) num++;
  cout << (num + 4) << endl;
  return 0;
}

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

int s;
const int N = 1000000;

int main(void){
	vector<int> a(N, 0);
	cin >> s;
	int i = 1;
	int ans;
	while(true){
		if(a[s] != 0){
			ans = i;
			break;
		}
		a[s] = i++;
		if(s%2 == 0) s/=2;
		else s = 3*s+1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	int[] a = new int[100010];
    	for (int i = 0; i < n; i++)
    	{
    		int x = sc.NextInt() + 1;
    		for (int j = 0; j < 3; j++) a[x + j - 1]++;
    	}
    	int max = a[0];
    	int res = 0;
    	for (int i = 0; i < 100010; i++)
    	{
    		if (a[i] <= max) continue;
    		max = a[i];
    		res = i;
    	}
    	Console.WriteLine(max);
    }
    
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 16864
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  double ans = 0;
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N)cin >> A[i];
  rep(i, N) {
	ans += (double)1 / A[i];
  }

  cout << (double)1 / ans;

  return 0;
}

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

#define pi acos(-1)
int main() {
  string s;cin >> s;
  int res = 0;
  bool flag = false;
  if (s=="RSR"||s=="SRS"||s=="RSS"||s=="SSR") {
    cout << 1 << endl;
  } else if (s=="RRS"||s=="SRR") {
    cout << 2 << endl;
  } else if (s=="SSS") {
    cout << 0 << endl;
  } else {
    cout << 3 << endl;
  }
  return 0;
}



Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.Math;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int t = fs.nextInt();
        String[] ar = new String[t];
        for (int TT=0;TT<t;TT++) {
            ar[TT] = fs.next();
        }
        HashMap<String,Integer> x = new HashMap<>();
        x.put("AC", 0);
        x.put("WA",0);
        x.put("TLE",0);
        x.put("RE",0);

        for (int i = 0; i<t; i++) {
            x.put(ar[i],x.get(ar[i])+1);
        }

        System.out.println("AC x " + x.get("AC"));
        System.out.println("WA x " + x.get("WA"));
        System.out.println("TLE x " + x.get("TLE"));
        System.out.println("RE x " + x.get("RE"));




    }





    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

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

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

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

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

    v_ll a(n);
    cin >> a;
    
    sort(a.begin(), a.end());

    v_ll b(n+1);
    b[0] = a[0];

    irep2(i, 1, n-1) {
        b[i] = b[i-1] + a[i];
    }
    int ans = 1;
    
    irrep2(i, 0, n-2) {
        if(b[i]*2 < a[i+1]) {
            break;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 4836
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int n;
string s1, s2;

void solve() {
    ll ans = 1;
    int first = 0;
    bool is_pre_stands = false;

    if (s1[0] == s2[0]) {
        is_pre_stands = true;
        first = 1;
        ans *= 3;
    } else {
        first = 2;
        ans *= 6;
    }

    FOR(i, first, n) {
        if (s1[i] == s2[i]) {
            if (is_pre_stands) {
                ans *= 2;
            } else {

            }
            is_pre_stands = true;

        } else {
            if (is_pre_stands) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            i++;
            is_pre_stands = false;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    cin >> s1 >> s2;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

const int MAX = 510000;
const LL MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL sub(LL N, LL M, LL K)
{
	LL tmp = 0;
	int s1 = max(1LL, K - (N - 1) * M), e1 = min(M + 1, K);
	FOR(j, s1, e1){
		int s2 = max(1LL, K - (N - 2) * M - j), e2 = min(M + 1, K - j + 1);
		LL c = COM(M, j);
		FOR(k, s1, e2){
			tmp += ((c * COM(M, k)) % MOD) * ((((2 < N) ? COM((N - 2) * M, K - (j + k)) : 1) * j * k) % MOD);
			tmp %= MOD;
		}
	}
	LL tmp2 = 0;
	REP(i, N - 1){
		tmp2 += (N - 1 - i) * (i + 1);
		tmp2 %= MOD;
	}
	return tmp * tmp2;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N, M, K;
	cin >> N >> M >> K;

	LL ret = 0;
	COMinit();

	ret += sub(N, M, K);
	ret %= MOD;
	ret += sub(M, N, K);
	ret %= MOD;

	cout << ret << endl;

	return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  string a[N];
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int M;
  scanf("%d", &M);
  string b[M];
  for (int i = 0; i < M; ++i) {
    cin >> b[i];
  }


  map<string,int> mp;
  for (int i = 0; i < N; ++i) mp[a[i]]++;
  for (int i = 0; i < M; ++i) mp[b[i]]--;


  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (ans < itr->second) ans = itr->second;
  }

  cout << ans << endl;



}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stdlib.h>

using namespace std;
#define N_MAX 100001
#define INF (2<<21)

struct edge{int to,cost;};
int N;
vector<struct edge> E[N_MAX];

int G[N_MAX];
bool used[N_MAX];

void dijkstra(int s){
	auto comp = [](pair<int,int> l, pair<int,int> r) { return l.second > r.second;}; 
    

	priority_queue<pair<int,int>, vector <pair<int,int>>, decltype(comp) > q(comp);

	for (int i=0; i<N_MAX;i++){
		used[i] = false;
	}
	used[s] = true;
	q.push((pair<int,int>){s,G[s]});

	for (int t=1; t<N; t++){
		pair<int, int> min;
		for(;!q.empty();){
			min = q.top(); q.pop();
			if (!used[min.first]) break;
		}
		used[min.first] = true;
		for (int i=0; i<E[min.first].size(); i++){
			if (used[E[min.first][i].to]) continue;
			if (G[min.first] + E[min.first][i].cost < G[E[min.first][i].to]){
				G[E[min.first][i].to] = G[min.first] + E[min.first][i].cost;
				q.push((pair<int,int>){E[min.first][i].to,G[E[min.first][i].to]});
			}
		}
	}
}

int main(){
	cin >> N;
	for (int i=0; i<N_MAX; i++){
		G[i] = INF;
	}
	for (int i=0; i<N; i++){
		E[i].push_back((struct edge){(i+1)%N,1});
		E[i].push_back((struct edge){(i*10)%N,0});
	}
	G[1] = 1;

	dijkstra(1);

	cout << G[0] << endl;
	
	return 0;
}

Measured memory_bytes: 6904
s=input()
if 1<=int(s[:2])<=12 and 1<=int(s[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(s[:2])<=12:
  print("MMYY")
elif 1<=int(s[2:])<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 8996
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
     dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;tsort(s);
    lint l=s.length();
    for(char c='a'; c<='z'; c++){
        rep(i, l){
            if(s[i]==c)goto L_break1;
        }
        co(c);
        return 0;
L_break1:;
    }
    co("None");
}

Measured memory_bytes: 512
n = int(input())

t0 = 0
x0 = 0
y0 = 0

for i in range(n):
  t, x, y = map(int, input().split())
  if (x-x0)+(y-y0) <= t-t0 and(t-t0)%2 == ((x-x0)+(y-y0))%2:
    t0 = t
    x0 = x
    y0 = y
  else:
    print('No')
    exit()
else:
  print('Yes')
  

Measured memory_bytes: 44904
#include <stdio.h>

const long long mod = 1000000007;

struct mat {
	long long a[3][3];

	mat operator -(mat t) {
		mat r;
		for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){
			r.a[i][j] = (a[i][j] + mod - t.a[i][j]) % mod;
		}
		return r;
	}

	mat operator *(mat t){
		mat r;
		for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){
			r.a[i][j] = 0;
			for (int k = 0; k < 3; k++) {
				r.a[i][j] = (r.a[i][j] + a[i][k] * t.a[k][j]) % mod;
			}
		}
		return r;
	}

	long long get(){
		return (a[2][0] * 5 + a[2][1]) % mod;
	}
};

int N, M, X[100100];
long long D[100100];

int main()
{
	mat base[32];
	base[0] = mat{ 4,mod - 2,1,1,0,0,0,1,0 };
	for (int i=1;i<32;i++) base[i] = base[i-1] * base[i-1];

	scanf("%d %d", &N, &M);
	for (int t = 1; t <= M; t++) scanf("%d", &X[t]);
	X[M + 1] = N;

	mat sum = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	mat idt = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
	mat all = idt;

	for (int i = 1; i <= M + 1; i++) {
		mat now = idt;
		for (int j=0,x=X[i]-X[i-1];x;j++,x/=2) if (x & 1) now = now * base[j];
		sum = sum * now;
		all = all * now;
		D[i] = (all - sum).get();
		for (int k = 0; k < 3; k++) sum.a[k][k] = (sum.a[k][k] + D[i]) % mod;
	}

	printf("%lld\n", D[M+1]);
	return 0;
}


Measured memory_bytes: 1280
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    
    string s;
    while(cin >> s){
        if(s == "0") break;
        int sum = 0;
        for(int i = 0; i < s.length(); i++){
            sum += s[i]-48;
        }
        cout << sum << endl;
    }
}



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

int ctoi(char c){
  if(c >= '0' && c <= '9'){
    return c - '0';
  }
  return 0;
}

int main() {
  string S;
  cin >> S;
  int t = 0;
  for(int i = 0; i < S.size(); i++){
    t += ctoi(S.at(i));
  }
  
  if(t % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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(){
  int N, R; cin >> N >> R;
  int ans;
  if(N>=10) ans = R;
  else ans = R+100*(10-N);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

bool is_odd_eight(int x){
    if(x%2==0) return false;

    unordered_map<int, int> m;
    for(int i=3; i<x; i+=2){
        if(x%i==0){
            while(x%i==0 && x!=1){
                m[i]++;
                x /= i;
            }
        }
    }

    if(x!=1) m[x]++;

    int k = 1;
    for(auto p: m){
        k *= 1+p.second;
    }

    if(k==8) return true;
    else return false;
}

int main()
{
    int n; cin >> n;
    int ans = 0;
    FOR(i, 1, n+1) ans += is_odd_eight(i);
    pr(ans);
    return 0;}

Measured memory_bytes: 3552
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int n = Readint()[0];
    int[] d = Readint();
    long res=0;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
        res += (long)(d[i]*d[j]);
    
    WriteLine(res.ToString());
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}


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

int main()
{
  ll n,k,q;
  cin >> n >> k >> q;
  
  ll a[q];
  rep(i,q) cin >> a[i];
  
  ll ans[n];
  rep(i,n) ans[i] = 0;
  
  rep(i,q)
  {
    ans[a[i]-1]++;
  }
  
  rep(i,n)
  {
    if(k + ans[i] > q)
    {
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 5056