akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans, d[100][100];
char a[100][100];
struct Edge { Pll to; LL cost; };
bool f=1;
vector<Edge>vec[100][100];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL bfs() {
	rep(i, 100)rep(j, 100)d[i][j] = INF;
	d[0][0] = 1;
	priority_queue<Ppll, vector<Ppll>, greater<Ppll>>pq;
	pq.push(Ppll(1, Pll(0, 0)));
	while (!pq.empty()) {
		Ppll p = pq.top();
		pq.pop();
		LL cost = p.first, x = p.second.first, y = p.second.second;
		if (d[x][y] < cost)
			continue;
		rep(i, 4) {
			LL X = x + dx[i], Y = y + dy[i];
			if(a[X][Y]!='#')
				if (X >= 0 && X < n&&Y >= 0 && Y < m&&d[x][y] + 1 < d[X][Y]) {
					d[X][Y] = d[x][y] + 1;
					pq.push(Ppll(d[X][Y], Pll(X, Y)));
				}
		}
	}
	return d[n - 1][m - 1];
}
int main() {
	cin >> n >> m;
	rep(i, n)rep(j, m) {
		cin >> a[i][j];
		if (a[i][j] != '#')
			ans++;
	}
	LL A=bfs();
	cout << (A != INF ? ans - A : -1)<< endl;	
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

const int A = 0;
const int B = 1;
const int C = 2;

int main() {
  string w;cin>>w;
  ll bit = 0;
  rep(i,w.size()) bit ^= 1<<(w[i]-'a');
  bool ans = bit == 0;
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat &A, mat &B, ll MOD){ // A*B
  mat C(A.size(), vec(B[0].size()));
  rep(i,A.size()) rep(k,B.size()){
    rep(j,B[0].size()){      
      C[i][j] = (C[i][j]+(A[i][k]%MOD)*(B[k][j]%MOD))%MOD;
    }
  }
  return C;
}
mat pow(mat A, ll n, ll MOD){ // A^n
  mat B(A.size(), vec(A.size()));
  rep(i,A.size()) B[i][i] = 1;
  while(n>0){
    if(n&1) B=mul(B,A,MOD);
    A=mul(A,A,MOD);
    n>>=1;
  }
  return B;
}
 
ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}
 
int get_keta(ll x){
  int keta = 0;
  while(x>0){ keta++; x/=10; }
  return keta;
}
 
 
int main(){
  ll L, A, B, M;
  cin >> L >> A >> B >> M;
 
  ll ret = 0;
 
  ll base = 0;
  vec mvec{0,A%M,1};
  for(ll k=1; k<19; k++){
    ll st = -1, ed = -1;
    {
      ll lb = -1, ub = L;
      while(ub-lb>1){
        ll mid = (lb+ub)/2;
 
        ll s = A + B*mid;
        if(get_keta(s) < k) lb = mid;
        else ub = mid;
      }
      if(0<=ub && ub<L){
        if(get_keta(A+B*ub) == k) st = ub;
      }
    }
    {
      ll lb = -1, ub = L;
      while(ub-lb>1){
        ll mid = (lb+ub)/2;
 
        ll s = A + B*mid;
        if(get_keta(s) <= k) lb = mid;
        else ub = mid;
      }
      if(0<=lb && lb<L){
        if(get_keta(A+B*lb) == k) ed = lb;
      }
    }
    if(st != -1 && ed != -1){
      ll n = ed-st+1;
      ll kk = 1;
      rep(i,k) kk *= 10;
      mat smat{{kk%M,0,0},{1,1,0},{0,B%M,1}};
      mat dmat = pow(smat,n,M);
      //cout << " " << dmat[0][0] << " " << dmat[0][1] << " " << dmat[0][2] << endl;
      //cout << " " << dmat[1][0] << " " << dmat[1][1] << " " << dmat[1][2] << endl;
      //cout << " " << dmat[2][0] << " " << dmat[2][1] << " " << dmat[2][2] << endl;
      vec nvec{0,0,0};
      nvec[0] += (dmat[0][0] * mvec[0])%M;
      nvec[0] %= M;
      nvec[0] += (dmat[1][0] * mvec[1])%M;
      nvec[0] %= M;
      nvec[0] += (dmat[2][0] * mvec[2])%M;
      nvec[0] %= M;
      nvec[1] += (dmat[0][1] * mvec[0])%M;
      nvec[1] %= M;
      nvec[1] += (dmat[1][1] * mvec[1])%M;
      nvec[1] %= M;
      nvec[1] += (dmat[2][1] * mvec[2])%M;
      nvec[1] %= M;
      nvec[2] += (dmat[0][2] * mvec[0])%M;
      nvec[2] %= M;
      nvec[2] += (dmat[1][2] * mvec[1])%M;
      nvec[2] %= M;
      nvec[2] += (dmat[2][2] * mvec[2])%M;
      nvec[2] %= M;
      mvec = nvec;
      //cout << mvec[0] << endl;
    }
  }
  
  cout << mvec[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long A, long long B, long long C){
    ll ans = INF;

    ans = min(ans, abs((A-A/2)-A/2)*B*C);
    ans = min(ans, abs((B-B/2)-B/2)*A*C);
    ans = min(ans, abs((C-C/2)-C/2)*A*B);
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		if(2*i+4*(n-i)==m)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int md = (int)1e9+7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	int n,c;
	cin >>n >>c;
	vector<VI> cs(c, VI(c)), rct(3, VI(c));

	rep(i,c) rep(j,c) cin >> cs[i][j];
	rep(i,n) rep(j,n){
		int aa; cin >> aa;
		rct[(i+j)%3][aa-1]++;
	}
	
	vector<vector<ll>> sm(3, vector<ll>(c));
	rep(g,3) rep(i,c) rep(j,c) sm[g][i] += (ll)cs[j][i] * rct[g][j];
	
	//for(auto xl: sm){for(auto x :xl) printf("%lld, ",x); puts("");}
	ll ans = 1LL<<60;
	rep(i,c) rep(j,c) if(i !=j) rep(k,c){
		if(i ==k || j==k) continue;
		ans = min(ans, sm[0][i] + sm[1][j] + sm[2][k]);
	}
	
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 384
N=int(input())
list=[0 for i in range(10**4+1)]
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      f=i**2+j**2+k**2+i*j+i*k+j*k
      if f<10**4+1:
        list[f]+=1
for i in range(1,N+1):
      print(list[i])
      
      
  

Measured memory_bytes: 9244
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        HashSet<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.ns());
        }
        out.println(set.size());
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}


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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
int n;
long long a[maxi];


void dfs(int x, int pred)
{
    a[x]+=a[pred];

    for (int i:v[x])
        if (i!=pred) dfs(i,x);
}
int main()
{
     cin>>n;
     cin>>s;

     if (n<3200) cout<<"red"<<endl; else
        cout<<s<<endl;

    return 0;
}
//pisacu joj pisma duga
//iz Zagore iz Drnisa
//razglednice tople s juga
//z Banata poslije Nisa

//ti si sunce moga neba
//tebi mogu reci
//ti si jedina od svih
//koja tajne moje cuva
//ti si moja ljubav prva <3


Measured memory_bytes: 25344
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end()); 昇順
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;



int main() {
  int n; cin>>n;
  vector<int> v(n);
  rep (i,n) cin>>v[i];
  sort(v.begin(), v.end());
  debug(v);
  debug(v.size());
  int cnt = 0;
  for(int i=0; i<n; ++i){
    for(int j=0; j<i; ++j) {
      for(int k=0; k<j; ++k) {
        if (v[k] != v[j] && v[i] != v[j] && (v[k] + v[j] > v[i])) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}


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

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    int i;
    char pic[h][w+1];
    for(i=0;i<h;i++){
        scanf("%s",&pic[i]);
    }
    for(i=0;i<w+2;i++){
        if(i!=w+1) printf("#");
        else printf("#\n");
    }
    for(i=0;i<h;i++){
        printf("#%s#\n",pic[i]);
    }
    for(i=0;i<w+2;i++){
        if(i!=w+1) printf("#");
        else printf("#\n");
    }
    return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	LL x;
	cin>>x;
	cout<<3*x*x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> hs;
    for (ll i = 0; i < n; ++i)
    {
        ll h;
        cin >> h;
        hs.push_back(h);
    }
    vector<ll> dais(n, true);
    for (ll i = 0; i < m; ++i)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        if (hs[a] < hs[b])
        {
            dais[a] = false;
        }
        else if (hs[a] > hs[b])
        {
            dais[b] = false;
        }
        else
        {
            dais[a] = false;
            dais[b] = false;
        }
    }
    ll count = 0;
    for (ll dai : dais)
    {
        if (dai)
        {
            ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n,cnt=0;
	cin>>n;
	for(int i=0;i<1000000000;i++){
		cnt+=i;
		if(cnt>=n){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct SCC{
  int V;
  vector<vector<int> > G,rG,T;
  vector<int> vs,used,cmp;
  SCC(){}
  SCC(int V):V(V){init();}
  void init(){
    G.clear();
    rG.clear();
    vs.clear();
    used.clear();
    cmp.clear();
    T.clear();
    
    G.resize(V);
    rG.resize(V);
    used.resize(V);
    cmp.resize(V);
  }
  void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }
  void dfs(int v){
    used[v]=1;
    for(int i=0;i<(int)G[v].size();i++){
      if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }
  void rdfs(int v,int k){
    used[v]=1;
    cmp[v]=k;
    T[k].push_back(v);
    for(int i=0;i<(int)rG[v].size();i++){
      if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }
  }
  
  int scc(){
    fill(used.begin(),used.end(),0);
    vs.clear();
    for(int v=0;v<V;v++){
      if(!used[v]) dfs(v);
    }
    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
	T.push_back(vector<int>());
	rdfs(vs[i],k++);
      }
    }
    return k;
  }
};

#define MAX 114514
int dp[111][MAX];
void knapsak(int v,int p,int t,int k){
  //cout<<k<<":"<<endl;
  for(int i=1;i<=k;k-=i,i*=2){
    //cout<<i<<endl;
    for(int j=MAX-1;j>=0;j--){
      if(dp[v][j]<0) continue;
      if(j+t*i>=MAX) continue;
      dp[v][j+t*i]=max(dp[v][j+t*i],dp[v][j]+p*i);
    }
  }
  //cout<<k<<endl;
  if(!k) return;
  for(int j=MAX-1;j>=0;j--){
    if(dp[v][j]<0) continue;
    if(j+t*k>=MAX) continue;
    dp[v][j+t*k]=max(dp[v][j+t*k],dp[v][j]+p*k);
  }
}

int N,M,T,V;
int p[111],t[111],k[111];
bool used[111],self[111];

int ans;
void dfs(int v,SCC &scc){
  if(used[v]) return;
  used[v]=1;
  memset(dp[v],-1,sizeof(dp[v]));
  dp[v][0]=0;
  vector<int> &g=scc.T[v];
  for(int i=0;i<(int)g.size();i++){
    vector<int> &h=scc.G[g[i]];
    for(int j=0;j<(int)h.size();j++){
      int u=scc.cmp[h[j]];
      dfs(u,scc);
      for(int k=0;k<MAX;k++)
	dp[v][k]=max(dp[v][k],dp[u][k]);
    }
  }
  if((int)scc.T[v].size()==1&&!self[g[0]]){
    knapsak(v,p[g[0]],t[g[0]],1);
  }else{
    for(int i=0;i<(int)g.size();i++){
      knapsak(v,p[g[i]],t[g[i]],k[g[i]]);
    }
  }
  for(int i=0;i<=T;i++) ans=max(ans,dp[v][i]);
}

signed main(){
  while(cin>>N>>M>>T,N){
    //cout<<N<<" "<<M<<" "<<T<<endl;
    for(int i=0;i<N;i++) cin>>p[i]>>t[i]>>k[i];
    SCC scc(N);
    memset(self,0,sizeof(self));
    for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      if(a==b) self[a]=1;
      else scc.add_edge(a,b);
    }
    ans=0;
    memset(used,0,sizeof(used));
    V=scc.scc();
    for(int i=0;i<V;i++)
      if(!used[i]) dfs(i,scc);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 47928
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;


int main(){
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    vector<int> a(n);
    rep(i,m){
        scanf("%d%d",&x,&y);
        a[y-1]=max(x,a[y-1]);
    }
    int cnt=0;
    int pos=0;
    rep(i,n){
        if(a[i]>pos){
            cnt++;
            pos=i;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long m1,d1,m2,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if (m2>m1)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x[n],y[n],h[n];
	for (int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
	}
	int ans[3]={0};
	for (int i=0;i<=100;i++){
		for (int j=0;j<=100;j++){
			int H,flag=0;
			for (int z=0;z<n;z++){
				if (h[z]==0){
					continue;
				}
				H=h[z]+abs(i-x[z])+abs(j-y[z]);
				break;
			}
			for (int z=0;z<n;z++){
				if(h[z]!=max(0,(H-abs(i-x[z])-abs(j-y[z])))) {
					flag=1;
				}
			}
			if (flag==0){
				ans[0]=i;
				ans[1]=j;
				ans[2]=H;
			}
		}
	}
	cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2];
	return 0;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [False] * (k + 1)

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]
            else:
                break

    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()


Measured memory_bytes: 79136
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007
const long INF = 1e15 + 5;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    
    const int MAX_VALUE = 100 * 1000 + 1; // n * max_value + 1
    vector<long> dp(MAX_VALUE, INF);
    dp[0] = 0;

    int answer = 0;
    for (int i = 0; i < n; i++) 
    {
        for (int j = MAX_VALUE - 1; j >= value[i]; j--) 
        {
            if (dp[j - value[i]] + weight[i] <= W) 
            {
                dp[j] = min(dp[j], dp[j - value[i]] + weight[i]);
                answer = max(answer, j);
            }
        }
    }
    printf("%d\n", answer);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define vl          vector<ll>
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323


void solve()
{
       ll n,d; cin>>n>>d;
       ll m=2*d+1;
       ll ans=(n+m-1)/m;
       cout<<ans<<endl;
}

int main(){
	int T = 1;
       //pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
 
      if(A<10 && B<10){
    System.out.println(A*B);
      }else{
	System.out.println("-1");
      }
      }
}




Measured memory_bytes: 22612
N,M = map(int,input().split())
ad = [[0]*N for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1; b -= 1
    ad[a][b] = 1
    ad[b][a] = 1

ans = 0

def dfs(v=0,d=0,visited=[1]+[0]*(N-1)):
    if d == N-1:
        global ans
        ans += 1
        return
    for nv, bit in enumerate(ad[v]):
        if bit == 0: continue
        if visited[nv] == 1: continue
        visited[nv] = 1
        dfs(nv,d+1)
        visited[nv] = 0

dfs()
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#define INF 1000000000
using namespace std;

int V, cost[100][100], K;
int main()
{
loop:
  for(int i = 0; i < 100; i++)
    for(int j = 0; j < 100; j++)
      cost[i][j] = i == j ? 0 : INF;
  cin >> V >> K;
  if(!V)
    return 0;
  for(int i = 0; i < K; i++)
  {
    int x;
    cin >> x;
    if(x)
    {
      int c, d, e;
      cin >> c >> d >> e;
      c--; d--;
      cost[c][d] = min(cost[c][d], e);
      cost[d][c] = min(cost[d][c], e);
      for(int i = 0; i < V; i++)
      {
        for(int j = 0; j < V; j++)
        {
          cost[i][j] = min(cost[i][j], cost[i][c] + cost[c][d] + cost[d][j]);
          cost[i][j] = min(cost[i][j], cost[i][d] + cost[d][c] + cost[c][j]);
        }
      }
    }
    else
    {
      int a, b;
      cin >> a >> b;
      a--; b--;
      cout << (cost[a][b] == INF ? -1 : cost[a][b]) << endl;
    }
  }
  goto loop;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    string s, x;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if ((i + 1) % 2 == 1) x += s[i];
    }
    cout << x << endl;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << (x) << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<pair<long double, long double>> xy;
    for (int i = 0; i < n; i++) {
        long double x, y;
        cin >> x >> y;
        xy.push_back({x, y});
    }
    vector<int> town(n);
    iota(town.begin(), town.end(), 0);
    long double ans = 0;

    do {
        for (int i = 0; i < n - 1; i++) {
            ans += sqrt(((xy[town[i]].first - xy[town[i + 1]].first) * (xy[town[i]].first - xy[town[i + 1]].first)) + ((xy[town[i]].second - xy[town[i + 1]].second) * (xy[town[i]].second - xy[town[i + 1]].second)));
        }
    } while (next_permutation(town.begin(), town.end()));

    int tem = 1;
    for (int i = 1; i <= n; i++) {
        tem *= i;
    }
    ans = ans / (long double)tem;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

struct QueueItem
{
  uint64_t x;
  bool f;

  QueueItem(uint64_t x, bool f) : x(x), f(f) {}
  bool operator<(const QueueItem &rhs) const { return x < rhs.x; }
};

int main()
{
  uint64_t N, H;
  cin >> N >> H;

  vector<uint64_t> a(N), b(N);
  N_TIMES(n, N) { cin >> a[n] >> b[n]; }

  uint64_t S = 0, C = 0;
  priority_queue<QueueItem> pq;
  N_TIMES(n, N) {
    pq.emplace(a[n], true);
    pq.emplace(b[n], false);
  }

  while(S < H) {
    QueueItem item = pq.top(); pq.pop();
    S += item.x;
    ++C;
    if (item.f) { pq.push(item); break; }
  }

  if (H > S) {
    QueueItem top_item = pq.top();
    C += (H - S) / top_item.x;
    if ((H - S) % top_item.x > 0) { ++C; }
  }

  cout << C << endl;

  return 0;
}

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

#define MAXN 2010
#define ll long long
#define mod 1000000007

using namespace std;

int n, x, y, tot;

int ans[MAXN], head[MAXN], dis[MAXN], vis[MAXN];

priority_queue<pair<int, int> > q, kong;

struct edge {
	int to, next;
}e[MAXN * 2];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

void dijkstra(int s) {
	memset(dis, 63, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	q = kong;
	dis[s] = 0;
	q.push(make_pair(0, s));
	
	while (q.size()) {
		int u = q.top().second;
		q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		for (int i = head[u]; i; i = e[i].next) {
			int v = e[i].to;
			if (dis[u] + 1 < dis[v]) {
				dis[v] = dis[u] + 1;
				q.push(make_pair(-dis[v], v));
			}
		}
	}
	
	for (int i = 1; i <= n; i++) {
		ans[dis[i]]++;
	}
	return;
}

int main() {
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i < n; i++) {
		add_edge(i, i + 1);
		add_edge(i + 1, i);
	}
	add_edge(x, y);
	add_edge(y, x);
	
	for (int i = 1; i <= n; i++) {
		dijkstra(i);
	}
	
	for (int i = 1; i < n; i++) {
		cout << ans[i] / 2 << endl;
	}
	return 0;
} 
 

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

ll modpow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b%2)
			ans *= a;
		b /= 2;
		a *= a;
		ans %= MOD;
		a %= MOD;
	}
	return ans;
}

int main() {
	string S;
	cin >> S;
	ll sz = S.size();
	reverse(S.begin(), S.end());
	ll ans = 1;
	for (ll i = 0;i < sz;i++) {
		if (S[i] == '1') {
			ans *= 2;
			ans %= MOD;
			ans += modpow(3, i);
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main () {
	int n, m;
	scanf("%d %d", &n, &m);
	char s[n];
	scanf("%s", s);
	if(s[m-1] >= 'A' && s[m-1] <= 'Z') {
		s[m-1] += 32;
	} else {
		s[m-1] -= 32;
	}
	printf("%s", s);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,n) cin >> a[i] >> b[i];
  
  ll ans=0;
  for(int i=n-1;i>=0;i--){
    a[i]+=ans;
    if(a[i]%b[i]!=0){
      ll num=((a[i]/b[i])+1)*b[i];
      ans += num-a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
n,m,c,=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
cnt=0
n.times do
  a=gets.split.map(&:to_i)
  sum=0
  m.times do |i|
    sum+=a[i]*b[i]
  end
  cnt+=1 if sum+c>0
end

puts cnt

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int n;
    ll l, t;
    cin >> n >> l >> t;

    ll x[n];
    int w[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> w[i];

    vector <ll> vec(n);
    for (int i = 0; i < n; i++) {
        if (w[i] == 1) {
            vec[i] = (x[i] + t) % l;
        } else {
            vec[i] = (x[i] - t % l + l) % l;
        }
    }

    ll pos = vec[0];
    sort(vec.begin(), vec.end());

    int idx = 0;
    for (int i = 1; i < n; i++) {
        if (w[0] == 1 && w[i] == 2) {
            ll cnt = t / l * 2;
            if (t%l > (x[i] - x[0]) / 2) cnt++;
            if (t%l > x[i] - x[0] + (l + x[0] - x[i]) / 2) cnt++;
            idx = (idx + cnt) % n;
        } else if (w[0] == 2 && w[i] == 1) {
            ll cnt = t / l * 2;
            if (t%l > l + x[0] - x[i] + (x[i] - x[0]) / 2) cnt++;
            if (t%l > (l + x[0] - x[i]) / 2) cnt++;
            idx = (idx - cnt % n + n) % n;
        }
    }

    int start = 0;
    if (w[0] == 1) {
        for (int i = 0; i < n; i++) {
            if (vec[i] == pos) {
                start = (i - idx + n) % n;
                break;
            }
        }
    } else {
        for (int i = n-1; i >= 0; i--) {
            if (vec[i] == pos) {
                start = (i - idx + n) % n;
                break;
            }
        }
    }

    for (int i = 0; i < n; i++) cout << vec[(start + i) % n] << '\n';
    return 0;
}

Measured memory_bytes: 3200
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heappush(edgelist,e)
    while len(edgelist):
        minedge = heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x-1].append([z,y-1])
for i in range(n-1):
    edge[i+1].append([0,i])
res = dijkstra_heap(0)
if res[-1] == float('inf'):
    print(-1)
else:
    print(res[-1])

Measured memory_bytes: 95776
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1], ans = new int[N+1];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            ans[A[i]] = i+1;
        }
        for (int i=1; i<=N; i++) {
            System.out.print(ans[i] + " ");
        }
    }
}

Measured memory_bytes: 56884
a, b, c, d = map(int, input().split())
import fractions
 
def num_divide(p, q, r):
    if p % r == 0:
        rmin = p
    else:
        rmin = p + (r-p%r)
    rmax = q - q%r
    return (rmax-rmin)//r + 1
 
print(b - a + 1 - (num_divide(a, b, c) + num_divide(a, b, d) - num_divide(a, b, c * d // fractions.gcd(c, d))))

Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
const int MN = 500010;
int s[MN];
int dp[MN];
int nx0[MN];
int main(){
	string str;
	cin>>N>>str;
	rep(i,N) s[i] = str[i]-'0';

	nx0[N] = N;
	for(int i=N-1;i>=0;i--){
		if(!s[i]) nx0[i] = i;
		else nx0[i] = nx0[i+1];
	}
	rep(i,N){
		chmax(dp[i+1],dp[i]);
		if(i+2<N && s[i]&&!s[i+1]&&s[i+2]){
			for(int j=i+3;j<=N;j++){
				chmax(dp[j],dp[i]+j-i-2);
				if(!s[j]) break;
			}
		}
		if(s[i]){
			int z = nx0[i];
			if(z+1<N && s[z+1]){
				chmax(dp[z+2],dp[i]+z-i);
			}
		}
	}
	cout<<dp[N]<<endl;
}


Measured memory_bytes: 6788
import collections

s=input()
t=collections.deque()
t.append(s)
q=int(input())
flag=False
for _ in range(q):
  query=list(map(str,input().split()))
  if query[0]=='1':
    if flag==False:
      flag=True
    else:
      flag=False
  elif query[0]=='2':
    if query[1]=='1':
      if flag==False:
        t.appendleft(query[2])
      else:
        t.append(query[2])
    else:
      if flag==False:
        t.append(query[2])
      else:
        t.appendleft(query[2])
t=''.join(map(str,t))
if flag==False:
  print(t)
else:
  print(t[::-1])

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

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

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

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

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

const int MAX = 200*1000+47;


int main()
{
    int n;
    scanf("%d", &n);
    LL s = 0;
    FOR(i, 0, n)
    {
        int x;
        scanf("%d", &x);
        s += x;
    }
    if (s & 1)printf("NO\n");
    else printf("YES");
    
    
    
    
}











Measured memory_bytes: 256
def main():
    N, D = list(map(int, input().split()))
    c = 0
    for _ in range(N):
        x, y = list(map(int, input().split()))
        if x * x + y * y <= D * D:
            c += 1


    return c

print(main())
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')


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

ll gcd(ll a, ll b){
    return b? gcd(b, a%b): a; 
}


int main() {
    ll N, ans=0, tmp;
    cin >> N;

    for(ll i=1; i<=N; i++){
	for(ll j=1; j<=N; j++){
	    for(ll k=1; k<=N; k++){
		tmp = gcd(i, j);
		tmp = gcd(tmp, k);
		ans += tmp;
	    }
	}
    }


    cout << ans << endl;
} 




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=2e5+11;
int n;
int fa[N],q[N],d[N],col[N];
vector<int> v[N];
int had[N],Tim;
int main(){
	int h=0,t=0;
	n=rd();
	rep(i,1,n){
		d[fa[i]=rd()]++;
	}
	rep(i,1,n)if(!d[i])q[t++]=i;
	while(h<t){
		int x=q[h++];
		Tim++;
		for(auto u:v[x])had[u]=Tim;
		int j;for(j=0;had[j]==Tim;j++);
		v[fa[x]].pb(col[x]=j);
		if(!(--d[fa[x]]))q[t++]=fa[x];
	}
	
	int x,lst=0,now=0;
	rep(i,1,n)if(d[i]){
		x=i;break;
	}
	Tim++;
	for(auto u:v[x])had[u]=Tim;
	int j;for(j=0;had[j]==Tim;j++);
	now=lst=j;
	//calc(x),lst=col[x];
	for(int i=fa[x];i!=x;i=fa[i]){
		had[lst]=++Tim;
		for(auto u:v[i])had[u]=Tim;
		int j;for(j=0;had[j]==Tim;j++);
		lst=j;
		//calc(i,lst);
		
		//v[fa[x]].pb(col[i]);
		//lst=col[i];
	}
	bool flag=0;
	if(lst!=now){
		flag=1;
	}
	//debug(flag); 
	if(!flag){
		Tim++;
		for(auto u:v[x])had[u]=Tim;
		int j;for(j=0;had[j]==Tim;j++);
		now=j;for(j++;had[j]==Tim;j++);lst=j;
		for(int i=fa[x];i!=x;i=fa[i]){
			had[lst]=++Tim;
			for(auto u:v[i])had[u]=Tim;
			int j;for(j=0;had[j]==Tim;j++);
			lst=j;
		}
		//cout<<lst<<endl;
		if(lst==now)flag=1;
	}
	puts(flag?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 11264
dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(int(input())):
    s = input()
    dic[s] += 1
print("AC x {}".format(dic["AC"]))
print("WA x {}".format(dic["WA"]))
print("TLE x {}".format(dic["TLE"]))
print("RE x {}".format(dic["RE"]))


Measured memory_bytes: 9188
a=raw_input();
lt=a.split(' ')
n=int(lt[0])
x=int(lt[1])
b=raw_input()
lt=b.split(' ')
ar=[]
for i in range(0,n):
	ar.append(int(lt[i]))

ar.sort()
v=0
for i in range(0,n):
	if x<=0:
		break
	else:
		x-=ar[i]
		v+=1

if x!=0:
	v-=1
print(v)

Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max  100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}
int int_sort( const void * a , const void * b ) {
  return strcmp(( char * )a , ( char * )b );
}

int main()
{
    int x, a, b;
    int i, j, cnt=0;
    
    scanf("%d", &x);
    
    for (b=-1000; b<=1000; b++) {
        for (a=-1000; a<=1000; a++) {
            if (pow(a, 5)-pow(b, 5)==x) {
                printf("%d %d", a, b);
                return 0;
            }
        }
    }
    
    return 0;
} 



Measured memory_bytes: 2600
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int ans[300];
int q[1000][3],qtop;
bool vis[1000];
int main(){
	int n,s,a,b,z,c[3];
	while(true){
	cin>>s>>a>>b;
	s+=a+b;
	if(!s)break;
	cin>>n;
	rep(i,s)ans[i]=2;
	qtop=0;
	rep(i,n){
		rep(j,3){cin>>c[j];c[j]--;}
		cin>>z;
		if(z)rep(j,3)ans[c[j]]=1;
		else{
			rep(j,3)q[qtop][j]=c[j];
			vis[qtop]=false;
			qtop++;
		}
	}
	rep(i,qtop){
		bool f[3]={false};
		rep(j,3)if(ans[q[i][j]]==1)f[j]=true;
		if(f[0]+f[1]+f[2]==2)rep(j,3)if(!f[j])ans[q[i][j]]=0;
	}
	rep(i,s)cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)//半開区間[a, b)
#define rep(i,n) for(int i=0;i<n;i++)//半開区間[0, n)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)//半開区間[a, b)を上から
#define reprev(i,n) reprrev(i,0,n)//半開区間[0, n]を上から
typedef long long ll;//intは[-2147483648, 2147483647]の範囲 
typedef unsigned long long ull;//非負整数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
                     
const ll mod = 1e9+7;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
                     
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll W, H, x, y; cin >> W >> H >> x >> y;
 double ans = (double)W/2*H;
  cout << fixed << setprecision(9) << ans << endl;

  
  if(((double)2*x == (double)W) && ((double)2*y == (double)H)) cout << 1 << endl;
  else cout << 0 << endl;


 return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int n,m;
    cin>>n>>m;
    if(n==m){ cout<<"Yes"<<endl;} else {cout<<"No"<<endl; }

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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int monsterHealth, attacksDone, specialAttack;
	int attackPower = 0;
	int specialAttacks[100000];
	scanf("%d %d", &monsterHealth, &attacksDone);

	// Reads from input specialAttack and creates an array of specialAttacks
	for (int i = 0; i < attacksDone; i++)
	{
		scanf("%d", &specialAttack);
		specialAttacks[i] = specialAttack;
		// Adds 'power' of specialAttacks to basic attackPower of the monster
		attackPower += specialAttacks[i];
	}

	if (attackPower >= monsterHealth)
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//cout.setf(ios::fixed); cout.precision(18)



int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    string s;
    cin>>s;
    rep(i,0,s.size()-1){
        if(s[i]=='A' && s[i+1]=='C'){
            preturn("Yes");
        }
    }
    preturn("No");
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;

    cin >> n;

    if(400 <= n && n <= 599)
    {
        cout << 8 << endl;
    }
    else if(600 <= n && n <= 799)
    {
        cout << 7 << endl;
    }
    else if(800 <= n && n <= 999)
    {
        cout << 6 << endl;
    }
    else if(1000 <= n && n <= 1199)
    {
        cout << 5 << endl;
    }
    else if(1200 <= n && n <= 1399)
    {
        cout << 4 << endl;
    }
    else if(1400 <= n && n <= 1599)
    {
        cout << 3 << endl;
    }
    else if(1600 <= n && n <= 1799)
    {
        cout << 2 << endl;
    }
    else if(1800 <= n && n <= 1999)
    {
        cout << 1 << endl;
    }

	return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
map<string,int>mm;
string s;

int main()
{
    int n;
    cin >> n;
    while(n--){
        cin >> s;
        mm[s]++;
    }
    int num=0;
    vector<string>v;
    for(auto i:mm){
        if(i.second>num){
            num=i.second;
            v.clear();
            v.push_back(i.first);
        }
        else if(i.second==num){
            //cout << i.first <<endl;
            v.push_back(i.first);
        }
    }
    //cout << endl;
    sort(v.begin(),v.end());
    for(auto s:v){
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 27888
#include<stdio.h>
int gcd(int a, int b)
{
    int r;
    while (b != 0){
    	r = a % b;
    	a = b;
    	b = r;
    }
    return a;
}

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",1+x+y-gcd(x,y));
    return 0;
}

Measured memory_bytes: 2740