akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll base = 1ll << 58;
const int LOG = 60;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    x[i] += base;
    y[i] += base;
  }
  auto calc = [&] (ll sum, int r) {
    vector<bool> F(3), G(3), F2(3), G2(3);
    bool res = false;
    for (int i = 0; i < n; i++) {
      if (y[i] < sum) {
        ll limit = sum - y[i];
        fill(F.begin(), F.end(), false);
        fill(G.begin(), G.end(), false);
        F[0] = true;
        for (int j = LOG; j >= 0; j--) {
          fill(F2.begin(), F2.end(), false);
          fill(G2.begin(), G2.end(), false);
          for (int k = 0; k < 3; k++) {
            if (F[k]) {
              for (int v = 0; v <= min(limit >> j & 1, x[i] >> j & 1); v++) {
                int nxt = (k + v * (j & 1) + v) % 3;
                if (v != (limit >> j & 1)) {
                  G2[nxt].flip();
                } else {
                  F2[nxt].flip();
                }
              }
            }
            if (G[k]) {
              for (int v = 0; v <= (x[i] >> j & 1); v++) {
                int nxt = (k + v * (j & 1) + v) % 3;
                G2[nxt].flip();
              }
            }
          }
          F.swap(F2);
          G.swap(G2);
        }
        res ^= G[(r - y[i] % 3 + 3) % 3];
      }
    }
    return res;
  };
  int r = 0;
  while (!calc(1ll << LOG, r)) {
    r++;
  }
  ll start = 0;
  for (int i = LOG; i >= 0; i--) {
    if (calc(start, r) == calc(start + (1ll << i), r)) {
      start |= 1ll << i;
    }
  }
  auto check = [&] (ll pos) {
    bool res = false;
    for (int i = 0; i < n; i++) {
      if (y[i] <= pos && pos <= x[i] + y[i] && (x[i] & (pos - y[i])) == pos - y[i]) {
        res ^= 1;
      }
    }
    return res;
  };
  ll L = start, R = start;
  for (int i = LOG; i >= 0; i--) {
    if (check(L - (1ll << i))) {
      L -= 1ll << i;
    }
    if (check(R + (1ll << i))) {
      R += 1ll << i;
    }
  }
  cout << R - L - base << " " << L - base << endl;
  return 0;
}


Measured memory_bytes: 384
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5;

int n,npas;
int nsonA[N+3],nsonB[N+3],pas[N*2+10],ans[N+3];
bool vis[3*N+3];

struct EDGE{
	int to,id;
	EDGE *nxt;
};
struct GRAPH{
	EDGE edg[N*6+3],*head[2*N+3],*ncnt;
	int nedg;
	GRAPH(){ncnt=edg;nedg=0;}
	void AddEdge(int u,int v){
		EDGE *p=++ncnt,*q=++ncnt;nedg++;
		*p=(EDGE){v,nedg,head[u]};head[u]=p;
		*q=(EDGE){u,nedg,head[v]};head[v]=q;
	}
	EDGE *&operator [](int id){return head[id];}
};
GRAPH Gr;

void DFS(int u){
	for(;Gr[u];Gr[u]=Gr[u]->nxt){
		EDGE *now=Gr[u];
		int v=now->to;
		if(vis[now->id]) continue;
		vis[now->id]=true;
		DFS(v);
		if(!Gr[u]) break;
	}
	pas[++npas]=u;
}
int main(){
	scanf("%d",&n);
	for(int i=1,fa;i<=n;i++){
		scanf("%d",&fa);
		if(fa==-1) Gr.AddEdge(2*n+1,i);
		else nsonA[fa]++,Gr.AddEdge(fa,i);
	}
	for(int i=1,fa;i<=n;i++){
		scanf("%d",&fa);
		if(fa==-1) Gr.AddEdge(2*n+1,i+n);
		else nsonB[fa]++,Gr.AddEdge(fa+n,i+n);
	}
	for(int i=1;i<=n;i++){
		if((nsonA[i]&1)^(nsonB[i]&1)){
			printf("IMPOSSIBLE\n");
			return 0;
		}
		if(!(nsonA[i]&1)) Gr.AddEdge(i,i+n);
	}
	DFS(2*n+1);
	// printf("%d",pas[1]);
	for(int i=2;i<=npas;i++){
		if(pas[i-1]==pas[i]+n) ans[pas[i]]=-1;
		if(pas[i-1]+n==pas[i]) ans[pas[i-1]]=1;
		// printf(" -> %d",pas[i]);
	}
	printf("\n");
	printf("POSSIBLE\n");
	for(int i=1;i<=n;i++){
		printf("%d",ans[i]);
		if(i==n) putchar('\n');
		else putchar(' ');
	}
	return 0;
}


Measured memory_bytes: 22528
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

int a[205];
void solve()
{
    int x, n;
    cin >> x >> n;
    for (int i = 1; i <= n; i++)
    {
        int res;
        cin >> res;
        a[res]++;
    }
    for (int d = 0; d <= 100; d++)
    {
        int l = x - d;
        if (l == 0)
        {
            cout << l << endl;
            return;
        }
        if (!a[l])
        {
            cout << l << endl;
            return;
        }
        int r = x + d;
        if (!a[r])
        {
            cout << r << endl;
            return;
        }
    }
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){

  int n,s,ans;
  vector<int> list;
  while(1){
    cin >>n;
    list.resize(n);
    if(n==0)return 0;
    rep(i,n)
      cin>>list[i];
    sort(list.begin(),list.end());
    ans=0;
    for(int i=1;i<n-1;i++)
      ans+=list[i];
    ans/=n-2;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int x[4],y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];

	x[2] = x[1]-(y[1]-y[0]); y[2] = y[1]+(x[1]-x[0]);
	x[3] = x[2]-(y[2]-y[1]); y[3] = y[2]+(x[2]-x[1]);

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << "\n";


	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  ll n; cin >> n;
  vector<ll> a(n), b(n);
  ll maxa=-1, minb;
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if(maxa < a[i]) {
      maxa = a[i];
      minb = b[i];
    }
  }
  cout << maxa + minb << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5 + 2;
int n, arr[100010], ans, dp[100010];

int calc(int x){
	if (x == n - 1)return 0;
	if (dp[x] != -1)return dp[x];
	int a, b;
	a = calc(x + 1);
	b = x + 2 <= n - 1 ? calc(x + 2) : -1;
	if (b == -1)return dp[x] = a + abs(arr[x + 1] - arr[x]);
	return dp[x] = min(a + abs(arr[x + 1] - arr[x]), b + abs(arr[x + 2] - arr[x])); 
}

int main(){
	speed
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	memset(dp, -1, sizeof(dp));
	cout<<calc(0);

}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = 600003;

int n, m;
int tot, head[N], ver[M], nxt[M], edge[M];
int dist[N], cnt[N];
bool st[N], used[N], ok = false;

inline void add(int u, int v, int w)
{
    ver[++tot] = v, edge[tot] = w, nxt[tot] = head[u], head[u] = tot;
}

inline bool SPFA(int u)
{
    st[u] = used[u] = true;
    for (int i = head[u]; i; i = nxt[i])
    {
        int v = ver[i], w = edge[i];
        if (dist[v] > dist[u] + w)
        {
            if (st[v]) return true;
            dist[v] = dist[u] + w;
            if (SPFA(v)) return true;
        }
    }
    return false;
}

int main()
{
	//File("");
    n = gi(), m = gi();
    for (int i = 1; i <= m; i+=1)
    {
        int u = gi(), v = gi(), w = gi();
        add(u, v, w), add(v, u, -w);
    }
    memset(dist, 0x3f, sizeof dist);
    dist[0] = 0;
    for (int i = 1; i <= n; i+=1) 
        if (!used[i])
        {
            used[i] = true;
            dist[i] = 0;
            if (SPFA(i)) {ok = true; break;}
        }
    if (ok) puts("No");
    else puts("Yes");
	return 0;
}


Measured memory_bytes: 9600
import Data.List

main = interact $ unwords . map show . sol . map read . words

sol (n:as)
  | even n    = es ++ reverse os
  | otherwise = os ++ reverse es
  where
  (i,es,os) = foldl' f (0,[],[]) as

f (i,es,os) a
  | even i    = (i+1,es,a:os)
  | otherwise = (i+1,a:es,os)

Measured memory_bytes: 178876
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long K, long long X){
  for(int i = -(K-1); i <= K-1; i++) cout << X+i << (i==K-1 ? "\n" : " ");
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long K;
  scanf("%lld",&K);
  long long X;
  scanf("%lld",&X);
  solve(K, X);
  return 0;
}


Measured memory_bytes: 256
import math
A, B = map(int, input().split())

for i in range(1, 1011):
    n_a = math.floor(i * 0.08)
    n_b = math.floor(i * 0.1)
    if n_a == A and n_b == B:
        ans = i
        break
    ans = -1

print(ans)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
  int x,y,s,i,j,k,o,a,b,sum;
  cin >> x >> y >> s;
  while(x!=0){
    o=0;
    for(i=1;i<s/2+1;i++){
      a=i*(100+x)/100;
      b=(s-a)*100/(100+x);
      while((b+1)*(100+x)/100+a<=s) b++;
      sum = i*(100+y)/100+b*(100+y)/100;
      if(b*(100+x)/100+a==s&&sum>o) {
	o=sum;
	//cout << a << endl;
      }
    }
    cout << o << endl;
    cin >> x >> y >> s;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0; i < n; i++)
ll N,A[100010];

int main(void)
{
    ll sum;
    cin >> N;
    REP(i,N) cin >> A[i];
    REP(i,N) {
        if(i == 0) {
            sum = A[i];
            for(ll j = 1; j < N; j += 2) {
                sum += -A[(i+j)%N]+A[(i+j+1)%N];
            }
        } else {
            sum = -sum + A[(i+N-1)%N]*2;
        }
        cout << sum << " ";
    }
    cout << endl;

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int hp,n;
int main() {
	scanf("%d%d",&hp,&n);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		hp-=a;
	}
	if(hp<=0)
	puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower)
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper)
//#define min(a) *min_element(a.begin(),a.end())
//#define max(a) *max_element(a.begin(),a.end())
#define pdd pair<long double,long double>
#define prnt(a) for(auto x:a) cout<<x<<" ";
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
#define PI 3.1415926535897932385
#define INF 1000000000000000
#define M 1000000007
#define ve  vector<ll>;


 
 
int main()
{
ll n;
cin>>n;
vector<ll> a(n);
for(ll i=0;i<n;i++)
{
    cin>>a[i];
}
ll temp=a[0];
ll s=0;
for(ll i=1;i<n;i++)
{
	if(temp>a[i])
	{
		s+=temp-a[i];

	}
	else
	{
		temp=a[i];
	}
}
cout<<s<<endl;



  
return 0;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	ll S; cin >> S;
	if (S == 1e18){
		printf("0 0 1000000000 0 1000000000 1000000000");
		return 0;
	}

	ll Q = S / 1000000000;
	ll r = (S % (1000000000));

	ll Y3 = Q+1;
	ll X3 = 1000000000 - r;

	cout << "0 0 1000000000 " << 1 << " " << X3 << " " << Y3 << endl;
}


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

using namespace std;

#define fo(i, n) for(int i = 0; i < n; i++)

int main()
{
    long n;
    cin>> n;
    long arr[n], count = 0, temp[n], ans = 0;
    fo(i, n)
    {
        cin>> arr[i];
        if(arr[i] < 0)
        {
            count++;
            temp[i] = -arr[i];
            ans += temp[i];
        }
        if(arr[i] >= 0)
        {
            ans += arr[i];
            temp[i] = arr[i];
        }
    }
    sort(temp, temp+n);
    if(count % 2 == 0)
        cout<< ans;
    else
        cout<<ans-2*temp[0];
    return 0;
}

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

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

bool solve(ll A, ll B, ll C, ll D) {
    if ( A < B ) return false;
    if ( B > D ) return false;
    if ( C >= B - 1 ) return true;
    ll g = gcd(B,D);
    ll x = B - (g - (A-B)%g);
    if ( x > C ) return false;
    return true;
}

int main() {
    ll T;
    cin >> T;
    ll A,B,C,D;
    vector<string> ans;
    for ( int i = 0; i < T; i++ ) {
        cin >> A >> B >> C >> D;
        string ans = solve(A,B,C,D) ? "Yes" : "No";
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc084

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int N ;
    vector<int> C;
    vector<int> S;
    vector<int> F;
#ifdef SUBMIT
    cin >> N;
    C.resize(N - 1);
    S.resize(N - 1);
    F.resize(N - 1);
    for (int k = 0; k < N - 1; ++k) {
        cin >> C[k] >> S[k] >> F[k];
    }
#else
    N = 4;
    C = {12, 44, 66};
    S = {13, 17, 4096};
    F = {1, 17, 64};
#endif

    for (int i = 0; i < N; ++i) {
        int t = 0;
        for (int j = i; j < N - 1; ++j) {
            if (t <= S[j]) t = S[j];
            else {
                auto diff = t - S[j];
                auto wait = F[j] * ((diff + (F[j] - 1)) / F[j]);
                t = S[j] + wait;
            }

            t += C[j];
        }

        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//失敗するからこそそこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

const int MAX_N = 1e5 + 100;

int main() {
	FIO

	int n, k;cin >> n >> k;
	int ans = 0;
	while(n > 0){
		n /= k;
		ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = [0 for i in range(200000+1)]
B = [0 for i in range(200000+1)]
ans = 'IMPOSSIBLE'

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A[b] = 1
        if A[b] and B[b]:
            ans = 'POSSIBLE'
            break
    elif b == N:
        B[a] = 1
        if A[a] and B[a]:
            ans = 'POSSIBLE'
            break
print(ans)

Measured memory_bytes: 6320
#include <stdio.h>
int main(void){
	int A, B;

	scanf("%d %d", &A, &B);

	if(A == B)
		printf("Draw\n");
	else if(A == 1)
		printf("Alice\n");
	else if(B == 1)
		printf("Bob\n");
	else if(A > B)
		printf("Alice\n");
	else if(B > A)
		printf("Bob\n");


	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	// 4/N = 1/h+1/n+1/w
	// 4 = N/h + N/n + N/w
	// w = N/(4-N/h-N/n)
	//
	// 1/w = 4/N-1/h-1/n = (4*n*h-N*n-N*h)/(n*h*N)
	for h := 1; h <= 3500; h++ {
		for n := 1; n <= 3500; n++ {
			if 4*n*h-N*n-N*h > 0 && (n*h*N)%(4*n*h-N*n-N*h) == 0 {
				w := (n * h * N) / (4*n*h - N*n - N*h)
				fmt.Println(h, w, n)
				return
			}
		}
	}
}


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

int n,q;
vector<int> v[MAX];
int marked[MAX]={};

void dfs(int now,int a){
  if(marked[now]==a || marked[now]==now)return;
  marked[now]=a;
  for(int i=0;i<v[now].size();i++){
    dfs(v[now][i],a);
  }
}

int main()
{
  char c;
  int a;

  while(1){
    cin>>n>>q;
    if(n+q==0)break;
    for(int i=0;i<MAX;i++){
      marked[i]=0;
      v[i].clear();
    }
    for(int i=1;i<n;i++){
      cin>>a;
      v[a-1].push_back(i);
    }
    long long ans=0;
    for(int i=0;i<q;i++){
      cin>>c>>a;
      if(c=='Q'){
	ans+=marked[a-1]+1;
      }
      else {
	dfs(a-1,a-1);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 10060
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, w, n float64
	fmt.Scanf("%f", &h)
	fmt.Scanf("%f", &w)
	fmt.Scanf("%f", &n)
	max := math.Max(h, w)
	fmt.Printf("%d\n", int(math.Ceil(n / max)))
}


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

using namespace std;

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

typedef modint<1000000007> mint;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  if (n == 1) {
    cout << 3 << endl;
    return 0;
  }
  mint ans;
  int i;
  bool tate = false;
  if (s[0] == t[0]) {
    ans = 3;
    i = 1;
    tate = true;
  } else {
    ans = 6;
    i = 2;
    tate = false;
  }
  while (i < n) {
    if (s[i] == t[i]) {
      if (tate) {
        ans *= 2;
        i += 1;
        tate = true;
      } else {
        ans *= 1;
        i += 1;
        tate = true;
      }
    } else {
      if (tate) {
        ans *= 2;
        i += 2;
        tate = false;
      } else {
        ans *= 3;
        i += 2;
        tate = false;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math

if sys.platform =='ios':
    sys.stdin=open('input133b.txt')

#+++++

count = 0
n, d = map(int, input().split())
anums = []
for i in range(n):
	anums.append( list(map(int, input().split())))

for i in range(n):
	for k in range(i+1,n):
		num = 0
		for j in range(d):
			num += pow(abs(anums[i][j] - anums[k][j]),2)

		sq = math.sqrt(num)
		if sq.is_integer():
			count += 1

print(count)

Measured memory_bytes: 12480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<40)
#define mod 1000000007
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	ll n;cin>>n;
	
	ll dp[110][5][5][5]={0};//1->a 2->c 3->g 4->tに対応させる　　i文字目まで見ているとき　2文字前j　1文字前k　今見る文字nowのときの　条件を満たす文字列の個数
	dp[0][0][0][0]=1;

	rep(i,n+1){
		if(i==0) continue;
		rep(j,5){//三つ前
			rep(k,5){//二つ前
				rep(l,5){//一つ前
					rep(now,5){//今見ているところ
						if(i>=2 && l==0) continue;//0をカウントしないとき(0は3文字に満たないときにのみ添え字として使う)
						if(i>=3 && k==0) continue;
						if(i>=4 && j==0) continue;
						
						if(k==1 && l==3 && now==2) continue;//agc
						if(k==1 && l==2 && now==3) continue;//acg
						if(k==3 && l==1 && now==2) continue;//gac
						if(j==1 && l==3 && now==2) continue;//a.gc
						if(j==1 && k==3 && now==2) continue;//ag.c
					
						dp[i][k][l][now]+=dp[i-1][j][k][l];
						dp[i][k][l][now]%=mod;
					}
				}
			}
		}
	}

	ll ans=0;
	rep(i,5)rep(j,5)rep(k,5){
		if(!(i==0 || j==0 || k==0)){
			ans+=dp[n][i][j][k];
			ans%=mod;
		}
	}

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

Measured memory_bytes: 384
s = input()
count = 0
a = 0
for name in s:
    if name == 'A' or name == 'C' or name == 'G' or name == 'T':
        count += 1
    else:
        if count > a:
            a = count
            count = 0
if count > a:
    a = count
print(a)

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=2e5+1, mod= 1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max(0,a-2*b);
	
    yogeshk972();
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int W = nint();
        
        // 品物i
        int[] v = new int[N+1];
        int[] w = new int[N+1];
        
        for (int i = 1; i <= N; i++) {
            v[i] = nint();
            w[i] = nint();
        }
        
        int[][] sumV = new int[N+1][W+1];
        
        for (int i = 1; i <= N; i++) {
            for (int i_sum = 0; i_sum < w[i]; i_sum++) {
                sumV[i][i_sum] = sumV[i-1][i_sum];
            }
            
            for (int i_sum = w[i]; i_sum <= W; i_sum++) {
                sumV[i][i_sum] = Math.max(sumV[i-1][i_sum], sumV[i-1][i_sum-w[i]] + v[i]);
            }
        }
        
        so.println(sumV[N][W]);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}



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

signed
main(){
	 ll M;
	 cin >> M;
	 vector<ll> a(M), p,m;
	 for(int i=0;i<M;i++){
			cin >> a[i];
			if(a[i]>=0) p.push_back(a[i]);
			else m.push_back(a[i]);
	 }
	 sort(a.begin(),a.end());

	 if(a[0]<0){
			ll ans = 0;
			ll mi = 0,pl = 0;
			for(int i=0;i<M;i++){
					if(a[i]<0) mi++;
					else pl++;
			}

			if(mi==1 && pl>=1){
				for(int i=0;i<M;i++){
					ans += llabs(a[i]);
				}
				cout << ans << endl;
				ll key = a[0];
				for(int i=1;i<M-1;i++){
					cout << key << " " << a[i] << endl;
					key = key - a[i];
				}
				cout << a[M-1] << " " << key << endl;
			}else if(pl==0){ //すべてマイナス
				ans = a[M-1];
				for(int i=0;i<=M-2;i++){
					ans += llabs(a[i]);
				}
				cout << ans << endl;
				ll key = a[M-1];
				for(int i=M-2;i>=0;i--){
					cout << key << " " << a[i] << endl;
					key = key - a[i];
				}
			}else if(mi>=2 && pl==1){
				ans = 0;
				for(int i=0;i<M;i++){
					ans += llabs(a[i]);
				}
				cout << ans << endl;
				ll key = a[M-1];
				for(int i=0;i<M-1;i++){
					cout << key << " " << a[i] << endl;
					key = key - a[i];
				}
			}else{//mi>=2 && pl>=2
				ans = 0;
				for(int i=0;i<M;i++){
					ans += llabs(a[i]);
				}
				cout << ans << endl;
				ll mkey = m[0], pkey = p[0];
				for(int i=1;i<p.size();i++){
					cout << mkey << " " << p[i] << endl;
					mkey = mkey - p[i];
				}
				for(int i=1;i<m.size();i++){
					cout << pkey << " " << m[i] << endl;
					pkey = pkey - m[i];
				}
				cout << pkey << " " << mkey << endl;
			}

	 }else{ //すべてプラス
			ll ans = -a[0];
			for(int i=1;i<M;i++){
					ans += a[i];
			}
			cout << ans << endl;
			ll key = a[0];
			for(int i=1;i<M-1;i++){
					cout << key << " " << a[i] << endl;
					key = key - a[i];
			}
			cout << a[M-1] << " " << key << endl;
	 }
}

Measured memory_bytes: 3572
import java.util.*;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int t=1;;t++) {
			int n = sc.nextInt();
			if(n == 0) break;
			double[] x = new double[n], y = new double[n];
			for(int i=0;i<n;i++) {
				x[i] = sc.nextDouble(); y[i] = sc.nextDouble();
			}
			double area = 0;
			for(int i=0;i<n;i++) area += (x[i]-x[(i+1)%n]) * (y[i]+y[(i+1)%n]);
			System.out.println(t + " " + Math.abs( area / 2 ) );
		}
	}
}

Measured memory_bytes: 23080
#include <bits/stdc++.h>
using namespace std;
const int maxn = 600300;
int c[maxn], pos[maxn], pr[maxn], ans[maxn];
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		c[x]++;
	}
	vector<int> occ;
	for(int i = 0; i < maxn; i++){
		if(c[i]){
			occ.push_back(c[i]);
		}
	}
	sort(occ.begin(), occ.end());
	int len = occ.size();
	for(int i = 1; i <= 2 * n; i++){
		pos[i] = lower_bound(occ.begin(), occ.end(), i) - occ.begin();
	}
	pr[0] = occ[0];
	for(int i = 1; i < len; i++) pr[i] = pr[i - 1] + occ[i];
	for(int k = 1; k <= n; k++){
		int p = lower_bound(occ.begin(), occ.end(), k) - occ.begin();
		int s = 0;
		if(p) s += pr[p - 1] / k;
		s += len - p;
		ans[s] = max(ans[s], k);
	}
	for(int i = n; i >= 1; i--){
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for(int i = 1; i <= n; i++){
		ans[i + 1] = min(ans[i], ans[i + 1]);
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 9328
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    string w;
    cin >> w;
    ll n=w.length();
    vector<ll> a(26);
    rep(i,n){
        a[(int)(w[i]-'a')]++;
    }
    bool ok=true;
    rep(i,26){
        if(a[i]%2==1){
            ok=false;
            break;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

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

		int n = stdIn.nextInt();
		Map<String,String> map = new HashMap<String,String>();

		for (int i=0; i<n; i++) {
			String s = stdIn.next();
			String str = stdIn.next();
			if (s.equals("insert")) {
				map.put(str,str);
			}else {
				if(map.containsKey(str))
					System.out.println("yes");
				else
					System.out.println("no");
			}
		}
	}
}

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

int main(){
	string s;
    cin >> s;
    vector <char> ls(s.size());

    for (int i=0;i < s.size(); i++ ){
            ls.at(i) = s.at(i);
        }
    sort(ls.begin(),ls.end());
    for (int i = 0; i < s.size()-1; i++){
            if (ls.at(i) == ls.at(i+1)){
                cout << "no" << endl;
                exit(0);
            }
        }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

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

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  string w;
  cin>>w;
  vector <int> a(28,0);
  for(int i = 0; i < w.length(); i++){
    a[w[i]-'a']++;
  }
  bool flg = true;
  for(int i = 0; i < 30; i++){
    if(a[i]%2!=0) flg = false;
  }
  if(flg)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

if N == 2:
	print(A[0], A[1])
else:
	q = max(A)
	B = list(map(lambda x : abs(q // 2 - x),  A))
	print(q, A[B.index(min(B))])

Measured memory_bytes: 63084
import itertools
N = int(input())
num = int(N**0.5)+1

ans = [0]*(N+1)

# for x in range(1,num+1):
#     for y in range(1,num+1):
#         for z in range(1,num+1):

for x,y,z in itertools.product(range(1, num+1), repeat=3):
    fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if fn > N:
        continue
    else:
        ans[fn] += 1

for i in range(1,len(ans)):
    print(ans[i])

Measured memory_bytes: 9516
#include <stdio.h>
#define MAX 2000
#define TRUE 1
#define FALSE 0
int n, A[MAX];
int solve(int ,int );

int main( ){
  int i, q, m[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);

    if(solve(0,m[i])==TRUE) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(i,m){
  if(i >= n) return FALSE;
  else if(m - A[i] == 0) return TRUE;
  else{
    if( solve(i + 1, m) || solve(i + 1, m - A[i])) return TRUE;
	else return FALSE;
  }
}

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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int n,m,k,ii;

void solve()
{
  string s,t;
  cin>>s>>t;
  int re=0;
  for(int i=0;i<s.size();i++)re+=(s[i]!=t[i]);
  cout<<re<<endl;
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
  // scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 3920
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    int(input())
    nums = list(map(int, input().split()))

    counter = Counter()
    ret = 0
    for num in nums:
        counter[num] += 1
        ret += (counter[num] - 1)

    for num in nums:
        ret -= (counter[num] - 1)
        print(ret)
        ret += (counter[num] - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25916
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
cnt1 = cnt2 = 0
for i in range(len(S)):
    if ((S[i] == '0') + (i % 2 == 0)) % 2:
        cnt1 += 1
    else:
        cnt2 += 1
print min(cnt1, cnt2)

Measured memory_bytes: 6008
//============================================================================
// Name        : BeginnerContest072-A-Sandglass2.cpp
// Author      : tt
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int X = 0;
int t = 0;

void solve(){
	cin >> X >> t;

	int ans = (X-t);
	if(ans<0) ans = 0;
	cout << ans;
}

int main() {
	solve();
	return 0;
}


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

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

	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; ++i){
		if(i % d == 0)
			ans++;
	}
	
	cout << ans;

	return 0;
	
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a=0;


		try(Scanner scanner=new Scanner(System.in)){
			a=scanner.nextInt();
		//	b=scanner.nextInt();
		}


		//Date date =new Date();

		int b=a/3600;
		int c=(a%3600)/60;
		int d=(a%3600%60);
		if(a<10&&a>=0&&a<86400) {
		System.out.println(b+":"+c+":"+d);

		}else {
		System.out.println(b+":"+c+":"+d);
		}

	}

}

Measured memory_bytes: 26072
//
// Created on 2020/01/10.
//

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int K;
    int X;
    cin>>K>>X;
    if (K*500 >= X){
        cout<<"Yes"<<endl;
        return 0;
    }


    cout<<"No"<<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    sort(a.begin(), a.end());

    int res = 0;
    int i = 0;
    while (i < N) {
        int now = a[i];
        int cnt = 0;
        while (i < N && a[i] == now) {
            cnt++;
            i++;
        }
        if (cnt < now)
            res += cnt;
        else
            res += cnt - now;

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

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	vector<int> xs { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1 };

	int posa = 0, posb = 0;
	for(int i = 0; i < xs.size(); i++) {
		if(xs[i] == a) posa = i;
		if(xs[i] == b) posb = i;
	}
	cout << (posa < posb ? "Bob" : (posa > posb ? "Alice" : "Draw")) << "\n";
    return 0;
}



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

int main(){
  int n;
  double xl[110],xr[110],yd[110],yu[110],x,y,r;
  vector<double> h,w;
  bool use[1000][1000];
  int test = 1;

  while(scanf("%d",&n),n){
    h.clear(); w.clear();

    for(int i=0;i<n;i++){
      scanf("%lf%lf%lf",&x,&y,&r);
      xl[i] = x-r; xr[i] = x+r;
      yd[i] = y-r; yu[i] = y+r;
      w.push_back(xl[i]); w.push_back(xr[i]);
      h.push_back(yd[i]); h.push_back(yu[i]);
    }

    sort(h.begin(),h.end());
    h.erase(unique(h.begin(),h.end()),h.end());
    sort(w.begin(),w.end());
    w.erase(unique(w.begin(),w.end()),w.end());

    for(int i=0;i<n;i++){
      xl[i] = lower_bound(w.begin(),w.end(),xl[i]) - w.begin();
      xr[i] = lower_bound(w.begin(),w.end(),xr[i]) - w.begin();
      yd[i] = lower_bound(h.begin(),h.end(),yd[i]) - h.begin();
      yu[i] = lower_bound(h.begin(),h.end(),yu[i]) - h.begin();
    }

    for(int i=0;i<h.size();i++)
      for(int j=0;j<w.size();j++)use[i][j] = false;

    for(int i=0;i<n;i++){
      for(int j=yd[i];j<yu[i];j++){
	for(int k=xl[i];k<xr[i];k++){
	  use[j][k] = true;
	}
      }
    }
    double ans = 0;
    for(int i=0;i<h.size();i++){
      for(int j=0;j<w.size();j++){
	if(use[i][j])ans += (h[i+1]-h[i])*(w[j+1]-w[j]);
      }
    }
    printf("%d %.2lf\n",test++,ans);

  }
}
    

    
      

Measured memory_bytes: 1212
"""
右におけるのが同じやつなら同一で扱う
普通なら√N * √Nになっちゃう


"""

N,K = map(int,input().split())
mod = 10 ** 9 + 7

lis = []
lis2 = []

i = 1
while i ** 2 <= N:

    if N // i != i:
        lis.append(i)
        lis2.append(N // i)
    else:
        lis.append(i)

    i += 1

lis2.reverse()
lis += lis2


dp = [0] * len(lis)

for i in range(len(lis)):
    if i == 0:
        dp[i] = 1
    else:
        dp[i] = lis[i]-lis[i-1]

#print (dp)

for loop in range(K):

    ndp = [0] * len(lis)
    nsum = 0
    
    for i in range((len(lis))):

        nsum += dp[i]
        nsum %= mod

        if i != len(lis)-1:
            ndp[-1-i] += ((lis[-1-i] - lis[-2-i]) * nsum) % mod
        else:
            ndp[-1-i] += nsum % mod

    dp = ndp

print (dp[0])

Measured memory_bytes: 61084
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var pp = input.ReadLine().Trim();//ToIntArray(input.ReadLine(), n);
        var qq = input.ReadLine().Trim();//ToIntArray(input.ReadLine(), n);

        var ary = new int[n];
        for (int i = 0; i < n; i++) ary[i] = i+1;

        var list = AllPattern(ary);
        var slist = new List<string>();
        foreach(var x in list) {
            var b = new StringBuilder(n * 2);
            foreach(var y in x) {
                b.Append(y);
                b.Append(' ');
            }
            slist.Add(b.ToString().Trim());
        }

        slist.Sort();
        var pn = 0;
        var qn = 0;
        for(int i=0; i<slist.Count; i++) {
            if (slist[i] == pp) pn = i;
            if (slist[i] == qq) qn = i; 
        }

        return Math.Abs(pn-qn);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

    static List<T[]> AllPattern<T>(T[] input) {
        return AllPattern(input, new HashSet<int>());
    }
    static List<T[]> AllPattern<T>(T[] input, HashSet<int>usedidx) {
        var ret = new List<T[]>();

        for(int i=0; i<input.Length; i++) {
            if (usedidx.Contains(i)) continue;

            if (usedidx.Count == input.Length-1) {
                var ary = new T[input.Length];
                ary[usedidx.Count] = input[i];
                ret.Add(ary);
            } else {
                usedidx.Add(i);
                var sublist = AllPattern(input, usedidx);
                usedidx.Remove(i);

                foreach (var sub in sublist) {
                    var ary = new T[input.Length];
                    Array.Copy(sub, ary, ary.Length);
                    ary[usedidx.Count] = input[i];
                    ret.Add(ary);
                }
            }
        }

        return ret;
    }
}


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

int n, cnt = 0, d;

int main() {
  cin >> n >> d;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    if (sqrt((long long)x * (long long)x + (long long)y * y) <= d) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

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

int main()
{
  int64_t N, ans = 0;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for (int i = 0; i < N - 1; i++)
  {
    ans += A[i] / 2;
    if (A[i] % 2 && A[i + 1] >= 1)
    {
      ans++;
      A[i + 1]--;
    }
  }
  ans += A[N - 1] / 2;
  cout << ans << endl;
}

Measured memory_bytes: 4040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

ll K;

int main(){
    cin >> K;
    ll N = 50;

    cout << N << endl;
    ll x = K / N;
    ll y = K % N;
    for(int i = 0; i < N; i++){
        if(i < y)
            cout << N + x << " ";
        else
            cout << max(N + x - y - 1, 0ll) << " ";
    }
    cout << 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 all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

int mergecount(vector<int> &A) {
// int mergecount(vector<int> &a) {
    // int count = 0;
    // int n = a.size();
    // rep(i,n) rep(j,i) if(a[j]>a[i]) ++count;
    // return count;
      int c = 0;
  for(size_t i = 0; i < A.size(); ++i){
    for(size_t j = 1; j < A.size(); ++j){
      if(A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        ++c;
      }
    }
  }
  return c;
}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    int res = INF;
    rep(mask, 1<<n){
        using P = pair<int,int>;
        vector<P> even, odd;
        rep(i,n){
            bool is_back = mask & bit(i);
            if ((i&1)^is_back) {
                odd.push_back({is_back ? b[i] : a[i], i});
            } else {
                even.push_back({is_back ? b[i] : a[i], i});
            }
        }
        if ((int)odd.size() != n/2) continue;
        if(__builtin_popcount(mask) & 1) continue;

        sort(all(even));
        sort(all(odd));
        {
            bool ng = false;
            rep(i,n-1){
                if (i % 2 == 0) {
                    if (even[i/2].first > odd[i/2].first) ng = true;
                } else {
                    if (odd[i/2].first > even[(i+1)/2].first) ng = true;
                }
            }
            if (ng) continue;
        }

        vector<int> v;
        rep(i,n){
            v.push_back((i&1) ? odd[i/2].second : even[i/2].second);
        }
        res = min(res, mergecount(v));
    }
    cout << (res == INF ? -1 : res) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	long long k;
	cin>>n>>k;
	int arr[200001];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int cur=1;
	int arr2[200001];
	while(k>0){
		if(k&1){cur=arr[cur];}
		k=k>>1;
		
		for(int i=1;i<=n;i++)arr2[i]=arr[i];
		for(int i=1;i<=n;i++){arr[i]=arr2[arr2[i]];}
	}
	cout<<cur<<endl;
  return 0;
}

Measured memory_bytes: 5168