akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,K;
    cin>>n>>K;
    vector<pair<ll,ll>> xs(n),ys(n);
    rep(i,n){
        int x,y;
        cin>>x>>y;
        xs[i]=make_pair(x,i);
        ys[i]=make_pair(y,i);
    }
    sort(all(xs));
    sort(all(ys));
    
    ll ans=9*LINF;
    vector<int> iscontained(n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            
            for(int k=0;k<n;k++){
                for(int l=k+1;l<n;l++){
                    int left=xs[i].first;
                    int right=xs[j].first;
                    int low=ys[k].first;
                    int high=ys[l].first;
                    
                    rep(p,n) iscontained[p]=0;
                    FOR(p,i,j){
                        iscontained[xs[p].second]++;
                    }
                    FOR(p,k,l){
                        iscontained[ys[p].second]++;
                    }
                    
                    int cnt=0;
                    rep(p,n) if(iscontained[p]==2) cnt++;
                    
                    if(cnt>=K){
                        ans=min(ans,(ll)(right-left)*(high-low));
                    }
                }
            }
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    double a;
    cin>>a;
    double b=ceil(a/1.08),c=floor(a/1.08);
    if(floor(b*1.08)!=a&&floor(c*1.08)!=a)cout<<":("<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    double te;
    vector< vector<double> > dp(2, vector<double>(n+1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i){
        scanf("%lf", &te);
        dp[i&1][0] = dp[i-1&1][0]*(1-te);
        for (int j = 1; j <= i; ++j){
            dp[i&1][j] = dp[i-1&1][j-1]*te + dp[i-1&1][j]*(1-te);
        }
    }
    te = 0;
    for (int i = (n>>1)+1; i <= n; ++i)
        te += dp[n&1][i];
    printf("%0.10lf", te);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


ll gcd(ll a, ll b){  if(b==0){  return a; }   return gcd(b , a%b); }


int main() {


int k,n;
cin>>k>>n;
int a[n];
for(int i=0;i<n;i++){

  cin>>a[i];

}

int dist = a[n-1]-a[0];

for(int i =1 ;i<n-1;i++){

int x = abs(a[i+1]-k) + a[i];
int y = k - a[i] + a[i-1];
dist = min(dist,min(x,y));
}

cout<<dist<<"\n";
  
  return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  string a = "", b = "";
  int cnt = 0;
  for (int i = 0; i < n; i ++) {
    if (s[i] == '(') cnt ++;
    else if (s[i] == ')' && cnt > 0) {
      cnt --;
    } else if (s[i] == ')' && cnt == 0) {
      a += '(';
    }
  }
  if (cnt > 0) {
    for (int i = 0; i < cnt; i ++) b += ')';
  }

  cout << a + s + b << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		var input = int.Parse(Console.ReadLine());
		var hour = input / 3600;
		input %= 3600;

		var minute = input / 60;
		input %= 60;

		System.Console.WriteLine(hour + ":" + minute + ":" + input);

	}
}


Measured memory_bytes: 17952
import java.util.* 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val b = sc.next()
    val res= if (b == "A") "T"
    else if (b == "T") "A"
    else if (b == "G") "C"
    else "G"
    println(res)
}


Measured memory_bytes: 29348
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	ll sum_c = 0;
    int q;cin>>q;
    multiset <ll> small,large;
    ll sum_small=0,sum_large=0;
    rep(i,0,q){
        int a;cin>>a;
        if (a==1){
            int b,c;cin>>b>>c;
            sum_c+=c;
            if (large.size()==small.size()){
                if (small.size()==0){
                    small.insert(b);
                    sum_small+=b;
                }else{
                    ll t = *large.begin();
                    if (t<=b){
                        large.erase(large.find(t));
                        sum_large-=t;
                        large.insert(b);
                        sum_large+=b;
                        small.insert(t);
                        sum_small+=t;
                    }else{
                        small.insert(b);
                        sum_small+=b;
                    }
                }
            }else{
                ll t = *small.rbegin();
                if (t<=b){
                    large.insert(b);
                    sum_large+=b;
                }else{
                    small.erase(small.find(t));
                    sum_small-=t;
                    small.insert(b);
                    sum_small+=b;
                    large.insert(t);
                    sum_large+=t;
                }
            }
        }else{
            int x = *small.rbegin();
            ll ans = 0;
            if (small.size()!=large.size()) ans+=x;
            cout<<x<<" "<<ans-sum_small+sum_large+sum_c<<endl;
        }
    }

}

Measured memory_bytes: 12972
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <cstring>

using namespace std;

namespace Icicle {
	static int N, L;
	static int A[100010];

	static int dp[100010];

	int rec(int i)
	{
		if (~dp[i]) return dp[i];
		int ma = 0;
		if (i - 1 >= 0 && A[i] < A[i - 1]) ma = max(ma, rec(i - 1));
		if (i + 1 < N && A[i] < A[i + 1]) ma = max(ma, rec(i + 1));
		return dp[i] = ma + (L - A[i]);
	}

	void MAIN()
	{
		memset(dp, -1, sizeof dp);

		cin >> N >> L;
		
		for (int i = 0; i < N; i++)
		{
			cin >> A[i];
		}

		int ans = -1;
		for (int i = 0; i < N; i++)
		{
			ans = max(ans, rec(i));
		}

		cout << ans << endl;
	}
}

int main()
{
#define solving Icicle
	solving::MAIN();
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;

ll N, X;
ll pCnt[50 + 1], pbCnt[50 + 1];

ll rec(ll l, ll r, int n) {
  if (X < l) return 0;
  if (1 <= l && r <= X) return pCnt[n];

  ll mid = (r - l) / 2 + l;
  ll res = 0;
  if (X < mid) res += rec(l + 1, mid - 1, n - 1);
  else res += rec(l + 1, mid - 1, n - 1) + rec(mid + 1, r - 1, n - 1) + 1;

  return res;
}

int main() {
  pCnt[0] = pbCnt[0] = 1;
  rep (i, 50) {
    pCnt[i + 1] = 2 * pCnt[i] + 1;
    pbCnt[i + 1] = 2 * pbCnt[i] + 3;
  }

  cin >> N >> X;
  cout << rec(1, pbCnt[N], N) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[1001];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d%d",&a[2*i],&a[2*i+1]);
	sort(a,a+2*n);
	int ans=0;
	for(int i=0;i<n;i++)
		ans+=a[2*i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; double D, X; 
	cin >> N >> D >> X; 
	double H[200010] = {}; 
	double HH[200010] = {}; 
	for(int i = 1; i < 200005; i++){
		H[i] = H[i-1] + (double) 1.0 / i; 
		HH[i] = H[i] + HH[i-1]; 
	}
	double ans1 = D + ((double) N - 0.5) * X; 
	double ans2 = HH[N]; 
	cout.precision(20); 
	cout << ans1 * ans2 << endl; 
}

Measured memory_bytes: 3328
s = input()
n = len (s)
def self(i,w):
    if i == n-1:
        return sum(list(map(int, w.split('+'))))
    return self(i+1,w+s[i+1])+self(i+1,w+'+'+s[i+1])
 
print(self(0,s[0]))


Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;

#define R 0
#define S 1
#define P 2
const map<char, int> transf{ {'r', R}, {'s', S}, { 'p', P}};
const map<int, int> iwin{ {R, P}, {S, R}, {P, S} };
const map<char,char> cwin{ {'r', 'p'}, {'s', 'r'}, {'p', 's'} };
map<int, int> points;

long long maximum(vector<int> & s) {
  if (s.size() == 0) return 0;

  vector<long long> score(3,0);
  vector<long long> prevscore(3,0);
  for (auto e:s) {
    for (int i=R; i<=P; i++) {
      if (i==iwin.at(e)) score.at(i) = max( prevscore.at((i+1)%3), prevscore.at((i+2)%3) ) + points.at(i);
      else score.at(i) = max( prevscore.at((i+1)%3), prevscore.at((i+2)%3) );
    }
    for (int i=R; i<=P; i++) {
      prevscore.at(i) = score.at(i);
    }
  }

  return max( max(score.at(R), score.at(S)), score.at(P) );

}


int main() {
  int n,k;
  cin >> n >> k;
  cin >> points[R]  >> points[S]  >> points[P];
  string temp;
  cin >> temp;
  vector<int> t(n);
  for (int i=0; i<n; i++) {
    t.at(i) = transf.at(temp.at(i));
  }

  long long ans=0;
  for (int i=0; i<k; i++) {
    vector<int> s;
    for (int j=i; j<n; j+=k) {
      s.push_back(t.at(j));
    }
    ans += maximum(s);
  }

  cout << ans << endl;



}

Measured memory_bytes: 1404
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_C: Breadth First Search

#include <algorithm>
#include <cstdio>
#include <queue>

using uint = unsigned int;

class Graph {
  const uint n_;
  uint* const g_;
  int* const depth_;
  
public:
  Graph(uint n) : n_(n),
                  g_(new uint[(n_*n_)]),
                  depth_(new int[n])
  {
    std::fill(g_, g_+(n_*n_), 0u);
  }

  ~Graph()
  {
    delete[] g_;
    delete[] depth_;
  }
  
  uint* operator [](uint i) const { return g_+(n_*i); }

  int* depth() const { return depth_; }

  void bfs()
  {
    init_depth();
    std::queue<uint> q;
    auto i = 0u;
    q.push(i);
    depth_[i] = 0;
    while (!q.empty()) {
      i = q.front();
      for (auto j = 0u; j < n_; ++j) {
        if ((*this)[i][j] && depth_[j] == -1) {
          q.push(j);
          depth_[j] = depth_[i]+1;
        }
      }
      q.pop();
    }
  }

private:
  void init_depth()
  {
    std::fill(depth_, depth_+(n_), -1);
  }
};

int main()
{
  uint n;
  std::scanf("%u", &n);

  Graph g(n);

  uint u, k, v;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u", &v);
      g[u-1][v-1] = 1;
    }
  }

  g.bfs();
  auto depth = g.depth();
  for (auto i = 0u; i < n; ++i) {
    std::printf("%u %d\n", i+1, depth[i]);
  }
}

// eof

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    unsigned long long tmp = 1;

    bool flag = false;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 0) {
            tmp = 0;
            flag = false;
            break;
        }
        if (A[i] < ULLONG_MAX / tmp) {
            tmp *= A[i];
        }
        else {
            flag = true;
        }
    }

    if (flag or tmp > 1000000000000000000ULL) {
        cout << -1 << endl;
    }
    else {
        cout << tmp << endl;
    }
}


Measured memory_bytes: 4052
# ABC125C - GCD on Blackboard
# Accumulative GCD
from fractions import gcd

def main():
    n = int(input())
    a = tuple(map(int, input().rstrip().split()))

    left = [0] * (n + 1)
    right = [0] * (n + 1)
    for i in range(n):
        left[i + 1] = gcd(left[i], a[i])
        right[n - i - 1] = gcd(right[n - i], a[n - i - 1])

    ans = 0
    for i in range(n):
        ans = max(ans, gcd(left[i], right[i + 1]))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16264
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2000 + 20;
#endif

//tg: @galebickosikasa
 
ostream& operator << (ostream& out, vector<int>& v) {
	for (auto& x: v) out << x << ' ';
	return out;
}

ostream& operator << (ostream& out, pii& v) {
	out << v.fi << ", " << v.se;
	return out;
}

istream& operator >> (istream& in, pii& a) {
	in >> a.fi >> a.se;
	return in;
}

const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vector<int> g[maxn], gr[maxn];
int n, k, s[maxn];

vector<int> bfs (int s) {
	vector<int> d (n, inf);
	d[s] = 0;
	queue<int> a;
	a.push (s);
	while (!a.empty ()) {
		int v = a.front ();
		a.pop ();
		for (auto& u: g[v]) {
			if (d[u] == inf) {
				d[u] = d[v] + 1;
				a.push (u);
			}
		}
	}
	return d;
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin >> n >> k;
	fr (i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		g[a].pb (b), g[b].pb (a);
	}
	fr (i, n) {
		auto d = bfs (i);
		fr (j, n) {
			if (d[j] > k) {
				gr[i].pb (j), gr[j].pb (i);
			}
		}
	}
	fr (i, n) s[i] = sz (gr[i]);
	fr (i, n) dbg (s[i]);
	int ans = 0;
	fr (i, n) {
		int mx = -1, t = 0;
		fr (j, n) {
			if (s[j] > t) {
				mx = j, t = s[j];
			}
		}
		if (mx == -1) break;
		dbg (mx);
		++ans;
		s[mx] = -1;
		for (auto& u: gr[mx]) {
			--s[u];
		}
	}
	cout << ans << '\n';






}

Measured memory_bytes: 70616
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
//#define mp make_pair
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const ll INF = 1e18 + 5;
const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
std::vector<ll> divi[1000004];

void divisor(int n)
{
   for(ll i=1;i<=n;i++)
   {
     for(ll j=i;j<=n;j+=i)
     {
       divi[j].pb(i);
     }
   }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2)
	{
		cout<<b-a<<endl;
	}    
	else {
		cout<<a-b<<endl;
	}

    
   	return 0;


}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N),indegree(N),vis(N); 
vector<int> adj[N];
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
vector<vector<int>>dp;
void solve()
{
    int n,w; cin>>n>>w;
    vector<int> val(n),weight(n);
    for(int i=0;i<n;i++)
    cin>>weight[i]>>val[i];
    int sum=accumulate(all(val),0ll);
    dp.assign(n+1,vector<int>(sum+1,INT_MAX)); int ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j-val[i-1]>=0)
            dp[i][j]=min(dp[i][j],dp[i-1][j-val[i-1]]+weight[i-1]);
            if(dp[i][j]<=w)
            ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 96640
//Areas on the Cross-Section Diagram
#if 0
    所 要 時 間 は 40 分 で あ っ た ． 方 針は
#endif // 0
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
#define MAX 100000
int main()
{
    pair<int,int> p[MAX];
    string s;
    int sum=0;int q=0;
    cin>>s;
    stack<int> a;
    for(int i=0;i<s.size();i++)
    {

       if(s[i]=='/'&&!a.empty())
       {
           p[q].first=a.top();
           p[q].second=i;
           a.pop();
          // cout<<p[q].first<<"     "<<p[q].second<<endl;
           q++;
       }
        else if(s[i]=='\\')
        {
            a.push(i);
            //cout<<a.top()<<endl;
        }
    }
    //stack<int> a;
    sort(p,p+q);

    int c[MAX];int flag=-1;int j=0;
    for(int i=0;i<q;i++)
    {
        sum+=p[i].second-p[i].first;
        if(flag>=0&&p[i].second<p[j].second)
        {
            c[flag]+=p[i].second-p[i].first;
            //cout<<c.top()<<endl;
        }
        else
        {
            c[++flag]=p[i].second-p[i].first;
            j=i;
        }
    }
    cout<<sum<<endl;
    if(flag>=0)
    {
        cout<<++flag<<' ';
    for(int i=0;i<flag;i++)
    {
        if(i==flag-1)
            cout<<c[i]<<endl;
        else
            cout<<c[i]<<' ';
        //c.pop();
    }
    }
    else cout<<++flag<<endl;
    //cout<<endl;
    return 0;
}



Measured memory_bytes: 3996
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;

typedef int flow_t;

const int MAX_N = 500;
const int MAX_E = 20000;
const int MAX_Q = 1000;

struct edge{
	int tar;
	flow_t cap;
	bool on;
};

struct query{
	int cmd;
	int x, y;
};

int V, E, Q;
vector<edge> graph[MAX_N];
int id_table[MAX_N][MAX_N];
query qs[MAX_Q];

void add_edge(int x, int y, flow_t cap, bool on){
	id_table[x][y] = graph[x].size();
	id_table[y][x] = graph[y].size();
	graph[x].push_back((edge){y, cap, on});
	graph[y].push_back((edge){x, cap, on});
}

void init(){
	scanf("%d%d%d", &V, &E, &Q);
	memset(id_table, -1, sizeof(id_table));
	for(int i=0; i<E; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		x--; y--;
		add_edge(x, y, 1, true);
	}

	for(int i=0; i<Q; i++){
		int c, x, y;
		scanf("%d%d%d", &c, &x, &y);
		x--; y--;
		qs[i] = (query){c, x, y};
		if(id_table[x][y] == -1){
			add_edge(x, y, 0, false);
		}
	}

}

bool visited[MAX_N];
int vis_time[MAX_N];

bool dfs(int v, int sink){
	if(v == sink){
		return true;
	}
	visited[v] = true;
	for(int i=0; i<(int)graph[v].size(); i++){
		edge& e = graph[v][i];
		if(e.on && e.cap > 0 && !visited[e.tar] && dfs(e.tar, sink)){
			e.cap--;
			graph[e.tar][id_table[e.tar][v]].cap++;
			return true;
		}
	}

	return false;
}

bool rem_dfs(int v){
	vis_time[v] = 2;
	for(int i=0; i<(int)graph[v].size(); i++){
		edge& e = graph[v][i];
		if(e.on && e.cap > 0){
			if(vis_time[e.tar] == 1 || (vis_time[e.tar] == 0 && rem_dfs(e.tar))){
				e.cap--;
				graph[e.tar][id_table[e.tar][v]].cap++;
				return true;
			}
		}
	}
	return false;
}

bool remove_cycle(int x, int y){
	memset(vis_time, 0, sizeof(vis_time));
	vis_time[y] = 1;
	return rem_dfs(x);
}

void solve(){
	const int source = 0, sink = V - 1;
	flow_t current = 0;

	for(;memset(visited, false, sizeof(visited)), dfs(source, sink); current++);

	for(int i=0; i<Q; i++){
		if(qs[i].cmd == 1){
			int x = qs[i].x, y = qs[i].y;
			graph[x][id_table[x][y]].on = true;
			graph[y][id_table[y][x]].on = true;
			graph[x][id_table[x][y]].cap = 1;
			graph[y][id_table[y][x]].cap = 1;
			memset(visited, false, sizeof(visited));
			if(dfs(source, sink)){
				current++;
			}
		}
		else{
			int x = qs[i].x, y = qs[i].y;
			if(graph[x][id_table[x][y]].cap != 1){
				// ツ個サツ催敖づ郊 -> yツづ猟ャツづェツづつ「ツづゥツづヲツつ、ツづ可暗ェツ氾環可サ
				if(graph[x][id_table[x][y]].cap == 2){
					swap(x, y);
				}
				if(!remove_cycle(x, y)){
					graph[x][id_table[x][y]].on = false;
					graph[y][id_table[y][x]].on = false;
					memset(visited, false, sizeof(visited));
					dfs(x, source);
					memset(visited, false, sizeof(visited));
					dfs(sink, y);
					current--;
				}
			}
			graph[x][id_table[x][y]].on = false;
			graph[y][id_table[y][x]].on = false;
			graph[x][id_table[x][y]].cap = 0;
			graph[y][id_table[y][x]].cap = 0;
		}
		printf("%d\n", current);
	}
}

int main(){
	init();
	solve();

	return 0;
}

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


int main(){
  int n,x,d=0; cin>>n>>x;
  int ans=1;
 
  for(int i=0;i<n;i++){
     int l;
    cin>>l;
    d+=l;
    if(d<=x)ans++;
  }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<utility>
using namespace std;

bool comp(pair <int, int> p1, pair <int, int> p2)
{
    return p1.second>p2.second;
}
int main()
{
    int n;
    cin>>n;
    int m=n/2;
    int a[n], b[m], c[m];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(i%2==0) b[i/2]=a[i];
        else c[i/2]=a[i];
    }
    
    sort(b, b+m);
    sort(c, c+m);
    
    vector <pair <int, int> > vecb;
    vector <pair <int, int> > vecc;
    vecb.push_back(make_pair(b[0],1));
    int idx=0;
    for(int i=1; i<m; i++)
    {
        if(b[i]==vecb[idx].first) vecb[idx].second++;
        else
        {
            idx++;
            vecb.push_back(make_pair(b[i],1));
        }
    }
    vecc.push_back(make_pair(c[0],1));
    idx=0;
    for(int i=1; i<m; i++)
    {
        if(c[i]==vecc[idx].first) vecc[idx].second++;
        else
        {
            idx++;
            vecc.push_back(make_pair(c[i],1));
        }
    }
    sort(vecb.begin(), vecb.end(), comp);
    sort(vecc.begin(), vecc.end(), comp);
    
    int ans=-1;
    if(vecb[0].first!= vecc[0].first) ans= n-vecb[0].second -vecc[0].second;
    else
    {
        if(vecb.end()-vecb.begin()==1 && vecc.end()-vecc.begin()==1) ans=m;
        else if(vecb.end()-vecb.begin()==1 && vecc.end()-vecc.begin()!=1)
        {
            ans= m-vecc[1].second;
        }
        else if(vecb.end()-vecb.begin()!=1 && vecc.end()-vecc.begin()==1)
        {
            ans= m-vecb[1].second;
        }
        else
        {
            
            if(vecb[1].second + vecc[0].second > vecb[0].second + vecc[1].second) 
            {
                //cout<<"tt";
                ans = n - vecb[1].second - vecc[0].second;
            }
            else
            {
                //cout<<"qq";
                ans = n - vecb[0].second - vecc[1].second;
            } 
                
            
        }
    }
    cout<<ans<<endl;
    
	return 0;
}


Measured memory_bytes: 2168
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/
pair<ll,ll> sx[100005];
pair<ll,ll> sy[100005];
ll px[100005];
ll py[100005];
set<pair<ll,pair<ll,ll > > > st;
ll par[100005];
ll find(ll x)
{
	return x==par[x]?x:par[x]=find(par[x]);
}
ll dis(ll a,ll b)
{
	return min(abs(px[a]-px[b]),abs(py[a]-py[b]));
}
ll un(ll x,ll y)
{
	x=find(x);
	y=find(y);
	if(x==y)
	{
		return 0;
	}
	par[x]=y;
	return 1;
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		par[i]=i;
		sx[i]=(mp(x,i));
		sy[i]=(mp(y,i));
		px[i]=x;
		py[i]=y;
	}
	sort(sx,sx+n);
	sort(sy,sy+n);
	for(ll i=0;i<n-1;i++)
	{
		st.insert(mp(dis(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second)));
		st.insert(mp(dis(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second)));
	}
	ll ans=0;
	while((int)st.size())
	{
		pair<ll,pair<ll,ll > > cur=*(st.begin());
		st.erase(cur);
		ll a=cur.second.first;
		ll b=cur.second.second;
		ans+=un(a,b)*dis(a,b);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18176
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: usize,
    }
    println!("{}", r * r);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N, K, Q;

int main() {
    cin >> N >> K >> Q;
    vector<int> A(N);
    int a;
    for (int i = 0; i < Q; i++) {
        cin >> a; a--;
        A[a]++;
    }
    int r;
    for (int i = 0; i < N; i++) {
        r = K - Q + A[i];
        cout << (r > 0? "Yes": "No") << endl;
    }
}



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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    int ma = *max_element(a.begin(), a.end());
    int nh = h+ma;
    imat dp(nh, ivec(n));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) dp[0][i] = 0;
    for (int i = 1; i < nh; i++) dp[i][0] = b[0] * ( 1 + (i)/a[0] - !((i) % a[0]));
    for (int i = 1; i < nh; i++){
        for (int j = 1; j < n; j++) dp[i][j] = fmin(dp[i][j-1], dp[fmax(i-a[j], 0)][j] + b[j]);
    }
    int ans = 100000001;
    for (int i = h; i < nh; i++) ans = fmin(ans, dp[i][n-1]);
    cout << ans << endl;
}


Measured memory_bytes: 44544
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <iomanip>

using namespace std;

int min(int x, int y) {
  return x < y ? x : y;
}

typedef pair<int, int> Key;

int main() {
  int n, m;
  cin >> n >> m;
  int N = 0x1 << n;

  vector<Key> keys(m);

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    int u = 0;
    for (int j = 0; j < b; ++j) {
      int c;
      cin >> c;
      int v = 0x1 << c-1;
      u |= v;
    }

    keys[i] = make_pair(a, u);
  }

  vector<vector<int>> table(m+1, vector<int>(N, 100000001));
  table[0][0] = 0;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j < N; ++j) {
      auto k = keys[i-1];
      int index = j | k.second;
      table[i][index] = min(table[i][index], table[i-1][j]+k.first);
      table[i][j] = min(table[i-1][j], table[i][j]);
    }
  }

  int ans;
  if (table[m][N-1] == 100000001) ans = -1;
  else ans = table[m][N-1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16384
import java.util.Scanner;

/**
 * Prime
 */
public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void taskA() {
        // long start = System.currentTimeMillis();
        int count = 0;
        for (int i = 0; i < this.size; i++) {
            boolean flg = false;
            int sqrt = (int) (Math.sqrt(this.mx[i]));
            for (int j = 2; j <= sqrt; j++) {
                if (mx[i] % j == 0) {
                    flg = true;
                    break;
                }
            }
            if (!flg) {
                count++;
            }
        }
        // long end = System.currentTimeMillis();
        System.out.println(count);
        // System.out.println((end - start) + "ms");
    }

    public void taskB() {
        long start = System.currentTimeMillis();
        boolean[] eratosthenes = new boolean[100000000];
        eratosthenes[0] = true;
        for (int i = 2; i <= 100000000; i++) {
            int j = i;
            while (j <= 100000000) {
                if (!eratosthenes[j - 1]) {
                    eratosthenes[j - 1] = true;
                }
                j += i;
            }
            System.out.println("end: " + i);
        }
        int count = 0;
        for (int i = 1; i < this.size; i++) {
            if (!eratosthenes[i]) {
                count++;
            }
        }
        long end = System.currentTimeMillis();
        System.out.println(count);
        System.out.println((end - start) + "ms");
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.taskA();
    }
}


Measured memory_bytes: 43656
n = gets.to_i
h = gets.split.map(&:to_i)

max = 0
cur = 0
(n - 1).times do |i|
  if h[i] >= h[i + 1]
    cur += 1
  else
    cur = 0
  end
  max = max > cur ? max : cur
end

puts max


Measured memory_bytes: 8580
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define F first
#define S second
using namespace std;
int n,m;
int p[111];
void init(){for(int i=0;i<n;i++)p[i]=i;}
int find(int x){return p[x]=(p[x]==x?x:find(p[x]));}
bool same(int x,int y){return find(x)==find(y);}
void merge(int x,int y){p[find(x)]=find(y);}
int main(void){
  while(true){
    scanf("%d",&n);
    if(!n) break;
    init();
    priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > que;
    scanf("%d",&m);
    for(int i = 0; i < m; i++){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      que.push(make_pair(c/100-1,make_pair(a,b)));
    }
    int res = 0;
    while(--n){
      while(same(que.top().S.F,que.top().S.S)) que.pop();
      res += que.top().F;
      merge(que.top().S.F,que.top().S.S);
      que.pop();
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1160
n = int(input())
h = list(map(int, input().split()))

for i in range(n - 1):
    if h[i] - h[i + 1] > 1:
        print('No')
        break

    elif h[i] - h[i + 1] == 1:
        if x == 1:
            print('No')
            break
        else:
            x = 1


    elif h[i] - h[i + 1] < 0:
        x = 0

else:
    print('Yes')


Measured memory_bytes: 63856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
typedef long double ld;
const ld PI = acos(-1);

typedef complex<ld> P;

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
};

P rot(P p, ld theta) {
    ld x = p.real(), y = p.imag();
    return P(x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta));
}

ld cross(P a, P b) {
    return imag(conj(a) * b);
}

P crosspointSS(L l1, L l2) {
    ld d1 = abs(cross(l2.v, l1.a - l2.a)); // <----????
    // ld d1 = abs(cross(l2.v, l1.a - l2.b)); // <----????
    // ld d1 = abs(cross(l2.v, l1.b - l2.a)); // <----????
    ld d2 = abs(cross(l2.v, l1.b - l2.a));
    ld t = d1 / (d1 + d2);
    return l1.a + t * l1.v;
}

ld distanceLP(L l, P p) {
    return abs(cross(l.v, p - l.a)) / abs(l.v);
}

ld area(P p0, P p1, P p2) {
    p1 -= p0, p2 -= p0;
    return abs(cross(p1, p2)) / 2;
}

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

    ld N, K;
    cin >> N >> K;

    ld theta = 2 * PI / N;
    P p0(1, 0);
    P p1 = rot(p0, K * theta);
    P q0 = rot(p0, theta);
    P q1 = rot(q0, - K * theta);

    L l(p0, p1);
    L m(q0, q1);
    P C = crosspointSS(l, m);

    const P O(0, 0);
    ld ans = N * (area(O, p0, q0) - area(C, p0, q0));
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;

    if(k == 0){
        cout << n * n << endl;
        return 0;
    }

    ll res = 0, tmp;
    for(int i = k + 1; i <= n; i++){
        if(n % i >= k) tmp = n % i - k + 1;
        else tmp = i - k;
        res += ((n - k) / i) * (i - k) + tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
mod = 1000000007
n = int(input())
nodes = [input() for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n - 1):
  s, t = map(int, input().split())
  s -= 1
  t -= 1
  edges[s].append(t)

def score(index):
  node = nodes[index]
  if node[0] == "E":
    ret = 1
    for to in edges[index]:
      ret *= score(to)

  if node[0] == "A":
    ret = 0
    for to in edges[index]:
      ret += score(to)

  if node[0] == "R":
    ret = 1
    for to in edges[index]:
      ret *= (score(to) + 1)
    ret -= 1

  if node[-1] == "?":
    ret += 1

  return ret % mod

print(score(0))  


Measured memory_bytes: 6512
#include<stdio.h>
int main(void)
{
	char s[10];
	scanf("%s", s);
	if(s[0]=='S'){
		printf("Cloudy\n");
	}
	if(s[0]=='R'){
		printf("Sunny\n");
	}
	if(s[0]=='C'){
		printf("Rainy\n");
	}
	return 0;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
typedef pair <int,int> pii;
 
const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50, INF=0x3f3f3f3f;
int n,bz=1,cnt;
int a[N],b[N],c[N],d[N],e[N],ans[N];
struct L {
	int l,r; 
	L(int l,int r) : l(l),r(r) {}
	friend inline bool operator <(const L &a,const L &b) {return a.l<b.l || (a.l==b.l && a.r>b.r);}
};
struct R {
	int l,r;
	R(int l,int r) : l(l),r(r) {}
	friend inline bool operator <(const R &a,const R &b) {return a.r<b.r || (a.r==b.r && a.l>b.l);}
};

multiset <int> lq[N];
multiset <int> rq[N];
multiset <L> ls; 
multiset <R> rs;

inline int kth(int x) {return lower_bound(c+1,c+n+2,x)-c;}
int main() {
	n=rd();
	for(int i=1;i<=n;i++) a[i]=rd(), b[i]=rd();
	for(int i=1;i<=n+1;i++) c[i]=rd(), d[i]=e[i]=1;
	sort(c+1,c+n+2);
	for(int i=1;i<=n && bz;i++) {
		if(a[i]>c[n+1] && b[i]>c[n+1]) bz=0;
		if(a[i]<=c[n+1]) {
			a[i]=kth(a[i]); b[i]=kth(b[i]);
			--d[a[i]]; --e[a[i]];
			if(b[i]<a[i]) rq[a[i]].insert(b[i]+1), lq[b[i]+1].insert(a[i]);
		} else --d[kth(b[i])], --e[kth(b[i])], ++cnt;
	}
	if(!bz) {for(int i=rd();i;i--) puts("-1"); return 0;}
	for(int i=n+1;i>=1 && bz;i--) {
		d[i]+=d[i+1];
		for(auto v:rq[i]) ls.insert(L(v,i));
		while(d[i]<0) {
			++cnt;
			if(!ls.size()) {bz=0; break;}
			L t=*ls.begin(); ls.erase(ls.begin());
			lq[t.l].erase(lq[t.l].find(t.r));
			++d[i]; --d[t.l-1];
			++e[t.r]; --e[t.l-1];
		}
	}
	if(!bz) {for(int i=rd();i;i--) puts("-1"); return 0;}
	for(int i=n;i>=1;i--) e[i]+=e[i+1];
	for(int i=1;i<=n+1;i++) {d[i]=e[i]-e[i-1];}
	for(int i=1;i<=n+1 && bz;i++) {
		d[i]+=d[i-1];
		for(auto v:lq[i]) rs.insert(R(i,v));
		while(d[i]<1) {
			++cnt;
			if(!rs.size()) {bz=0; cnt=INF; for(int j=i+1;j<=n+1;++j) ans[j]=cnt; break;}
			R t=*--rs.end(); rs.erase(--rs.end());
			++d[i]; --d[t.r+1];
		} ans[i]=cnt;
	}
	for(int i=rd();i;i--) {
		int x=rd(), y=rd();
		int w=INF;
		if(x<=c[n+1]) w=min(w,ans[kth(x)]);
		if(y<=c[n+1]) w=min(w,ans[kth(y)]+1);
		printf("%d\n",(w==INF) ? -1 : (n-w+1));
	}
}

Measured memory_bytes: 31488
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=100005;
int n,now,last,cnt,tot,ln,e[N][2];
char s[N];
void adde(int u,int v){
	e[++tot][0]=u;
	e[tot][1]=v;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1'){
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;i++){
		if(s[i]!=s[n-i]){
			puts("-1");
			return 0;
		}
	}
	now=1;
	for(int i=1;i<=n;i++){
		if(i==1){
			last=i;
			ln=1;
			continue;
		}
		if(s[i]=='1'){
			int tmp=i-last;
			adde(ln,now+1);
			now++;
			for(int i=1;i<tmp;i++){
				adde(now,now+i);
			}
			ln=now;
			now+=tmp-1;
			last=i;
		}
	}
	adde(ln,now+1);
	now++;
	int tmp=n-last;
	for(int i=1;i<tmp;i++){
		adde(now,now+i);
	}
	for(int i=1;i<=tot;i++){
		printf("%d %d\n",e[i][0],e[i][1]);
	}
	return 0;
}

Measured memory_bytes: 2176
N,M = map(int,input().split())
lis = []
path = ["1"]

for i in range(M):

    a,b = map(int,input().split())
    lis.append([a,b])

for i in range(N-1):

    i += 1

    npath = []

    for p in path:


        for j in lis:

            if j[0] == int(p[-1]) and str(j[1]) not in p:

                npath.append(p + str(j[1]))

            if j[1] == int(p[-1]) and str(j[0]) not in p:

                npath.append(p + str(j[0]))

    path = npath.copy()


print (len(path))


Measured memory_bytes: 3700
ans = ''
while True:
    n = int(input())
    if n == 0:
        break
    else:
        L = list(map(float, input().split(' ')))
        ave = 0
        for i in L:
            ave += i
        ave /= n
        sigma = 0
        for i in L:
            sigma += pow(i - ave, 2)
        sigma /= n
        sigma = pow(sigma, 0.5)
        ans += '{0:.8f}'.format(sigma) + '\n'
print(ans[:-1])


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

#define ll long long
#define ar array

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

    string s;
    cin >> s;
    cout << (s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
A = [0]*(n+1)
D = [-1]*(n+1)
DP = [0]*(n+1)
d = deque()
for i in range(n):
    A[i+1] = [int(i) for i in input().split()]
d.append(1)
D[1] = 0
DP[1] = 1
while(len(d)>0):
    tmp = d.pop()
    for i in A[tmp][2:]:
        if not DP[i]:
            D[i] = D[tmp]+1
            DP[i] = 1
            d.appendleft(i)
for i in range(1,n+1):
    tmp = "{} {}".format(i,D[i])
    print(tmp)


Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;int ans=0,ans2=0;
	cin>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(i%2==0&&s[i]!='0')ans++;
		if(i%2==1&&s[i]!='1')ans++;
		if(i%2==0&&s[i]!='1')ans2++;
		if(i%2==1&&s[i]!='0')ans2++;
	}
	printf("%d",min(ans,ans2));
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
    char str[10];
    int count=0;
    char a1[2];
    scanf("%s",str);
    for(int i=0;i<4;i++){
        if(i==3){
            printf("No\n");
            return 0;
        }
        for(int j=i+1;j<4;j++){
            if(str[i]==str[j]){
                a1[0]=str[i];
                count++;
                break;
            }
        }
        if(count==1) break;
    }

     for(int i=0;i<4;i++){
        if(i==3){
            printf("No\n");
            return 0;
        }
        for(int j=i+1;j<4;j++){
            if(str[i]==str[j]){
                if(a1[0]==str[i]){
                }
                else {
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
   

    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2000000000
#define PI 3.1415926535897932
using ll = long long;
using Graph = vector<vector<int>>;
//二項係数を求める。

int main(){
  int N; cin>>N;
  string S; cin>>S;
  set<char> m;
  rep(i,N){
    m.insert(S.at(i));
  }
  vector<char> v;
  for(auto c:m){
    v.push_back(c);
  }
  int l = v.size();
  ll res = 0;
  rep(i,l)rep(j,l)rep(k,l){
    vector<char> tmp = {v.at(i),v.at(j),v.at(k)};
    int index=0;
    rep(s,N){
      if(index==3)break;
      if(S.at(s)==tmp.at(index))index++;
    }
    if(index==3)res++;
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b;
  c=a-2*b;
  if(c<0)cout<<0<<endl;
  else cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int ans=0;
    vector<char> v;
    rep(i,0,26)v.pb('A'+i);
    int index=1;
    string s;cin>>s;
    rep(i,0,s.size()){
        while(v[index]!=s[i]){
            index++;
            if(index==26){
                index=0;
                ans++;
            }
        }
        index++;
        if(index==26&&i!=s.size()-1){
            index=0;
            ans++;
        }
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3180
def selection_sort(a)
  c = 0
  for i in 0..(a.length - 1)
    min = i
    for j in i ..(a.length - 1)
      if a[j] < a[min]
        min = j
      end
    end
    if i != min
      a[i], a[min] = a[min], a[i]
      c += 1
    end
  end
  [a,c]
end

gets
a,c = selection_sort(gets.split.map(&:to_i))
puts a.join(' ')
puts c

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int ok(vector<int> v){
	rep(i, 2){
		for(int j = i+1; j < 3; j++){
			if (v[i] != v[j])
				return 0;
		}
	}
	return 1;
}

int main() {
    Graph c(3, vector<int>(3));
	rep(j, 3)
		inv(3, c[j]);
	vector<int> v(3);
	rep(i, 2){
		for(int j = i+1; j < 3; j++){
			rep(k, 3){
				v[k] = c[k][i] - c[k][j];
			}
			if (!ok(v)){
				No;
				return 0;
			}
		}
	}
	rep(i, 2){
		for(int j = i+1; j < 3; j++){
			rep(k, 3){
				v[k] = c[i][k] - c[j][k];
			}
			if (!ok(v)){
				No;
				return 0;
			}
		}
	}
	Yes;
}


Measured memory_bytes: 3556
N=int(input())
A1 =  list(map(int,input().split()))
A2 =  list(map(int,input().split()))

A2.reverse()

# 累積和
A1_=[]
A2_=[]

a1_=0
a2_=0
for n in range(N):
    a1_ = a1_+A1[n]
    a2_ = a2_+A2[n]
    
    A1_.append(a1_)
    A2_.append(a2_)
    
A2_.reverse()

ans=0
for n in range(N):
    if ans < A1_[n]+A2_[n]:
        ans = A1_[n]+A2_[n]
print(ans)


Measured memory_bytes: 62044