akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 15
#define rep(i,n) for(int i=0;i<int(n);i++)
int nn,m;
vector<int> g[MAX],r[MAX];
//bool used[1<<MAX][MAX];
struct Q{
  bool is_move;
  bool is_on;
  int s;
  Q(){}
  Q(bool i,bool o,int s_):is_move(i),is_on(o),s(s_){}
};
struct P{
  int u,n;
  vector<Q> v;
  P(int u_,int n_,const vector<Q>& v_):u(u_),n(n_),v(v_){}
};
void solve(int u)
{
  //memset(used,0,sizeof(used));
  vector<vector<bool> >used(1<<nn,vector<bool>(nn,false));
  queue<P> q;
  vector<Q> v;
  q.push( P(u,0,vector<Q>()) );
  used[u][0]=true;
  bool can=false,all=false;
  if( !(u&1) )goto END;
  while( !q.empty() ){
    P p=q.front(); q.pop();
    int n=p.n;
    u=p.u;
    if( n==nn-1 ){
      can=true;
      if( u==(1<<(nn-1)) ){
        all=true;
        v=p.v;
        goto END;
      }
    }
    //move
    rep(i,g[n].size()){
      //printf("%d -> %d %d\n",n,g[n][i],i);
      if( u&(1<<g[n][i]) && !used[u][g[n][i]] ){
        used[u][g[n][i]]=true;
        v=p.v;
        v.push_back( Q(true,false,g[n][i]) );
        q.push( P(u,g[n][i],v) );
      }
    }
    //switch
    rep(i,r[n].size()){
      bool is_on=!(u&(1<<r[n][i]));
      int uu=u^(1<<r[n][i]);
      if( !used[uu][n] ){
        used[uu][n]=true;
        v=p.v;
        v.push_back( Q(false,is_on,r[n][i]) );
        q.push( P(uu,n,v) );
      }
    }
  }
END:;
  if( !can ){
    puts("Help me!");
  } else if( !all ){
    puts("You can not switch off all lights.");
  } else {
    printf("You can go home in %d steps.\n",v.size());
    rep(i,v.size()){
      Q& q=v[i];
      if(q.is_move){
        printf("Move to room %d.\n",q.s+1);
      } else {
        printf("Switch %s room %d.\n",q.is_on?"on":"off",q.s+1);
      }
    }
  }
}
int main(void)
{
  for(;;){
    scanf("%d%d",&nn,&m); if(!nn)break;
    int s,t;
    rep(i,m){
      scanf("%d%d",&s,&t);
      s--; t--;
      g[s].push_back(t);
      g[t].push_back(s);
    }
    int a,u=0;
    rep(i,nn){
      scanf("%d",&a);
      u|=a<<i;
    }
    int k,l;
    rep(i,nn){
      scanf("%d",&k);
      rep(j,k){
        scanf("%d",&l); l--;
        if(l==i)continue;
        r[i].push_back(l);
      }
      sort(r[i].begin(),r[i].end());
    }
    solve(u);
    rep(i,nn)g[i].clear();
    rep(i,nn)r[i].clear();
  }
}

Measured memory_bytes: 3968
#include <iostream>

using namespace std;

#define MAXN 100005

int a[MAXN],b[MAXN],c[MAXN],dp[MAXN][3];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    int n;cin>>n;

    for(int i=1;i<=n;i++){
        
        cin>>a[i]>>b[i]>>c[i];

    }

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

        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
    
    }

    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

}


Measured memory_bytes: 2560
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(n);
    rep(i, n) cin >> vec[i];
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    ll log = 0;
    ll res =1 ;
    rep(i,n-1){
        if(log==0){
            if(vec[i+1]>vec[i]){
                log = 1;
            }else if(vec[i+1]<vec[i]){
                log = -1;
            }
        }else if(log==1){
            if(vec[i+1]<vec[i]){
                log = 0;
                res++;
            }
        }else{
            if(vec[i+1]>vec[i]){
                log=0;
                res++;
            }
        }
      //  cout<<i<<" "<<res<<endl;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nmx = readln.split.to!(int[]);
    auto N = nmx[0];
    auto M = nmx[1];
    auto X = nmx[2];

    int[][] cas;
    foreach (_; 0..N) {
        cas ~= readln.split.to!(int[]);
    }

    auto ms = new int[](M);
    long solve(int i) {
        if (i == N) {
            foreach (m; ms) if (m < X) {
                return int.max/3;
            }
            return 0;
        } else {
            auto r1 = solve(i+1);
            foreach (j, a; cas[i][1..$]) {
                ms[j] += a;
            }
            auto r2 = solve(i+1) + cas[i][0];
            foreach (j, a; cas[i][1..$]) {
                ms[j] -= a;
            }
            return min(r1, r2);
        }
    }
    auto r = solve(0);
    writeln(r >= int.max/3 ? -1 : r);
}

Measured memory_bytes: 2716
using System;
using System.Linq;
using System.Collections.Generic;

public static class Hello{
    static Scanner sc = new Scanner();
    public static void Main(){
        var l = new List<string> {"A", "B", "C", "D", "E", "F"};
        var X = l.IndexOf(sc.Next());
        var Y = l.IndexOf(sc.Next());
        if(X<Y){
            Console.WriteLine("<");
        }else if (X==Y){
            Console.WriteLine("=");
        }else{
            Console.WriteLine(">");
        }
    }
}
public class Scanner{
    private string line;
    private string[] token;
    private int cursole = 0;
    
    public string ReadLine(){
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;    
    }
    
    public string Next(){
        if(token == null) ReadLine();
        if(token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList(){
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt(){return Int32.Parse(Next());}
    
    public long NextLong(){return Int64.Parse(Next());}

    public double NextDouble(){return Double.Parse(Next());}

    public IEnumerable<string> NextList(){
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }
    
    public IEnumerable<int> NextIntList(){
        return NextList().Select(s => Int32.Parse(s));
    }
}

Measured memory_bytes: 13024
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

using namespace std;

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

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

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n;
LL ans;

signed main()
{
    //File("");
    n = gi <int> ();
    for (int i = 1; i <= n; i+=1)
    {
    	for (int j = 1; j * i < n; j+=1)
    		++ans;
    }
    cout << ans << endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S;
    cin >> S;
    if(S <= 1e9) {
        cout << "0 0 1 0 0 " << S << endl;
    } else if(S == 1e18) {
        cout << "0 0 " << (ll)1e9 << " 0 0 " << (ll)1e9 << endl;
    } else {
        cout << "0 0 " << (ll)1e9 << " " << 1 << " "
             << (ll)1e9 * ((ll)(S / 1e9) + 1) - S << " " << (ll)(S / 1e9) + 1
             << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans;
int main()
{
	cin>>n>>m;
	if(m==0&&n==0)
		ans=0;
	else if(n==0)
	{
		if(m<0)
			ans=abs(m)+1;
		else 
			ans=m;
	}
	else if(m==0)
	{
		if(n<0)
			ans=abs(n);
		else
			ans=n+1;
	}
	else if((n>0&&m>0)||(n<0&&m<0))
	{
		if(n>m)
			ans=(n-m)+2;
		else
			ans=m-n;	
	}
	else
		ans=abs(abs(m)-abs(n))+1;
	cout<<ans;
	return 0;
}

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


        signed main() {
         int n;
         cin>>n;
         long double x[n],y[n],ans=0,r,a,b,c;
        for(int i=0;i<n;i++)cin>>x[i]>>y[i];
        if(n==2){
            cout<< std::setprecision(20)<<sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]))/2;
            return 0;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<i;j++){
                for(int k=0;k<j;k++){
                   a=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
                   b=sqrt((x[k]-x[j])*(x[k]-x[j])+(y[k]-y[j])*(y[k]-y[j]));
                   c=sqrt((x[k]-x[i])*(x[k]-x[i])+(y[k]-y[i])*(y[k]-y[i]));
                   if(a*a<b*b+c*c&&b*b<a*a+c*c&&c*c<a*a+b*b)r=2*a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
                   else r=max(a,max(b,c));
                   //r=min(max(a,max(b,c)),2*a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)));
                   ans=max(ans,r/2);
                }
            }
        }
        cout << std::setprecision(20) <<ans;
          
            
         return 0;

        }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int si(const void* a,const void* b)
{
	if(*(int*)a > *(int*)b)
		return -1;
	if(*(int*)a < *(int*)b)
		return 1;
	return 0;
}

int main()
{
	int ary[5];
	scanf("%d %d %d %d %d",ary,ary+1,ary+2,ary+3,ary+4);
	qsort(ary,5,sizeof(int),si);
	int i;
	printf("%d %d %d %d %d\n",ary[0],ary[1],ary[2],ary[3],ary[4]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int input;
    cin >> input ;
    
    vector<int> ans(10001);

        for(int j = 1; j * j <= input; j++){
            for(int k = j; k * k <= input; k++){
                for(int l = k; l * l <= input; l++){
                    if(j * j + k * k + l * l + j * k + k * l + l * j < 10001){
                        if(j == k && k == l){
                            ans.at(j * j + k * k + l * l + j * k + k * l + l * j)++;
                        } else if( j != k && k != l ){
                            ans.at(j * j + k * k + l * l + j * k + k * l + l * j) += 6;
                        } else {
                            ans.at(j * j + k * k + l * l + j * k + k * l + l * j) += 3;
                        }
                        
                    } else {
                        break;
                    }
                }
            }
        }

    for(int i = 1; i <= input; i++){

        cout << ans.at(i) << endl;
        
    
    }
    
}


Measured memory_bytes: 3664
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  static long long A[401];
  copy_n(istream_iterator<int>(cin), N, A + 1);
  partial_sum(A + 1, A + N + 1, A + 1);
  static long long F[401][401];
  for (auto i = 2; i <= N; ++i)
    for (auto j = 0; j <= N - i; ++j) {
      auto f = LLONG_MAX;
      for (auto k = 1; k < i; ++k)
        f = min(f, F[k][j] + F[i - k][j + k]);
      F[i][j] = f + A[j + i] - A[j];
    }
  cout << F[N][0] << endl;
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


ll ma=1e15;




int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,w;
cin>>n>>w;
ll v[n],a[n];
int x=0;
for(int i=0;i<n;i++){
    cin>>a[i]>>v[i];
    x+=v[i];
}
vector<ll> dp(x+1,ma);
dp[0]=0;
for(int i=0;i<n;i++){
    for(int j=x;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+a[i]);

    }
}
for(int i=x;i>=0;i--){
    if(dp[i]<=w){
        cout<<i<<endl;
        return 0;
    }
}





}


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

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

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

A, B = map(int, raw_input().split())
if A > 9 or B > 9:
    print -1
else:
    print A * B

Measured memory_bytes: 4268
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint hani(vector<int>&in,int L,int R){return UBI(in,R)-LBI(in,L);}
//直径%3が1ならSecondをお祈りします
vector<vector<int>>go;
vector<int>dis;
pair<int,int> dfs(int ter,int per,int fka=0){
	pair<int,int>a=mp(fka,ter);
	for(auto it:go[ter]){
		if(it==per){continue;}
		maxeq(a,dfs(it,ter,fka+1));
	}
	return a;
}
int main(void){
	int n,i;cin>>n;
	go.res(n);
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);
		go[b].pub(a);
	}
	//cerr<<dfs(dfs(0,-1).sec,-1).fir<<endl;
	cout<<(dfs(dfs(0,-1).sec,-1).fir%3==1?"Second":"First")<<endl;
}

Measured memory_bytes: 26752
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

LL a,b,c,d;

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		LL x=a%b,y=d%b;
		if (a<b) puts("No");
		else if (c>=b&&d>=b) puts("Yes");
		else if (d<b) puts("No");
		else if (x>c) puts("No");
		else
		{
			LL l=(b-x)%b,r=(c+b-x)%b,d=gcd(y,b);
			if (l<=r)
			{
				if (l-1>=d||r/d<(b-1)/d) puts("No");
				else puts("Yes");
				continue;
			}
			std::swap(l,r);
			l++;r--;
			if (l<=r&&(l/d!=r/d||l%d==0)) puts("No");
			else puts("Yes");
		}
	}
	return 0;
}

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    if(n>=65 && n<=90){
        cout << 1 << endl;
    }
    else if(n>=97 && n<=122)cout << 2 << endl;
    else cout << 0 << endl;
    
}


Measured memory_bytes: 3164
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;


bool operator < (const P &p,const P &q){
  if(p.F != q.F)return p.F < q.F;
  return p.S < q.S;
}

P operator - (const P &p,const P &q){
  return P(p.F-q.F,p.S-q.S);
}

P operator + (const P &p,const P &q){
  return P(p.F+q.F,p.S+q.S);
}



int main(){
  int m,n;

  while(cin >> m && m){
    vector<P> M,N;
    P p;
    for(int i=0;i<m;i++){
      cin >> p.F >> p.S;
      M.push_back(p);
    }
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> p.F >> p.S;
      N.push_back(p);
    }
    P dif;
    bool AorB;
    for(int i=0;i<N.size();i++){
      
      if(M[0] < N[i]){
	//dif = P(N[0].F-M[0].F,N[0].S-M[0].S);
	dif = M[0]-N[i];
	AorB = true;
      }
      else{
	//dif = P(M[0].F-N[0].F,M[0].S-N[0].S);
	dif = N[i]-M[0];
	AorB = false;
      }      

     
      //cout << "dif = " << dif.F << " " << dif.S << endl;

      bool found = true;
      for(int j=1;j<M.size();j++){

	bool it = false;
	//	cout << "M = " << M[j].F << " " << M[j].S << endl;
	for(int k=0;k<N.size();k++){
	  if(k == i)continue;
	  //cout << "N = " << N[k].F << " " << N[k].S << endl;
	  if(AorB &&M[j].F-dif.F == N[k].F && M[j].S-dif.S == N[k].S){
	    it = true;
	  }
	  else if(!AorB &&M[j].F+dif.F == N[k].F && M[j].S+dif.S == N[k].S){
	    it = true;
	  }
	}
	if(!it){
	  found = false;
	  break;
	}
      }
      if(found){
	if(AorB)cout << -dif.F << " " << -dif.S << endl;
	else cout << dif.F << " " << dif.S << endl;
	break;
      }

    }
   
  }
  return 0;
}

Measured memory_bytes: 1216
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

string rotateStr(string str){ 
    char n=str[str.size()-1];
    str.insert(0,1,n);
    str.erase(str.size()-1,1); 
             
    return str;
}

int main() { 
    string S,T;
    cin>>S>>T; 
    bool found=false;
    int compIteration=0;
    do{
        if(S==T){
            found=true;
        }else{
           S= rotateStr(S);
        } 
        compIteration++;
    }while(compIteration<S.size());
   
   
    if(found){
        cout<<"Yes";
    }else{ 
        cout<<"No";
    }
} 


Measured memory_bytes: 256
n=list(map(int, input().split()))
if n[0]==n[1]:
    if n[0]==n[2]:
        print('No')
    else:
        print('Yes')
elif n[0]==n[2]:
    if n[0]==n[1]:
        print('No')
    else:
        print('Yes')
elif n[1]==n[2]:
    if n[0]==n[1]:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
#define bp __builtin_popcount
typedef long long ll;
const ll MAX_N = 18;
const ll MOD = 1e9+7;
using namespace std;

ll a[MAX_N][MAX_N];
ll cost[1 << MAX_N];
int d[1 << MAX_N];
ll dp[1 << MAX_N];
int n;

bool cmp(int a,int b)
{
    return bp(a) < bp(b);
}

int main()
{
    cin >> n;
    for(int i = 1;i<=n;++i)
        for(int j = 1;j<=n;++j)
            cin >> a[i][j];
    vector<int> vc;
    for(int i = 1;i<(1<<n);++i)
        vc.push_back(i);
    sort(vc.begin(),vc.end(),cmp);
    for(auto mask:vc)
    {
        for(int i = 1;i<=n;++i)
        {
            if (!(mask & (1<<(i-1))))
                continue;
            for(int j = i;j<=n;++j)
            {
                if (!(mask & (1<<(j-1))))
                    continue;
                cost[mask] += a[i][j];
            }
        }
    }
    for(auto mask:vc)
    {
        dp[mask] = -1e18;
        vector<int> v;
        for(int i = 0;i<n;++i)
        {
            if (mask & (1<<i))
                v.push_back(i);
        }
        for(int j = 1;j<(1 << (v.size()));++j)
        {
            int lowbit = j&-j;
            d[j] = d[j-lowbit]+(1 << v[(int)log2(lowbit)]);
            dp[mask] = max(dp[mask],dp[mask-d[j]]+cost[d[j]]);
        }
    }
    cout << dp[(1 << n)-1];
    return 0;
}


Measured memory_bytes: 3196
// デバッグ実行：Ctrl+F5

using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int H = int.Parse(words[0]); //Xの最大値
        int W = int.Parse(words[1]); //Yの最大値
        int N = int.Parse(words[2]);
        int MAX = H;
        int X, Y;
        var dict = new Dictionary<int, List<int>>();
        for(int i = 0; i < N; i++)
        {
            line = Console.ReadLine();
            words = line.Split(' ');
            X = int.Parse(words[0]);
            Y = int.Parse(words[1]);
            if (dict.ContainsKey(Y))
            {
                dict[Y].Add(X);
            }
            else
            {
                dict[Y] = new List<int>();
                dict[Y].Add(X);
            }

        }
        // 各リストはいったんソートされるべき
        foreach(KeyValuePair<int, List<int>> kvp in dict)
        {
            kvp.Value.Sort();
        }
        int beforeX = 1;
        // 各行の最大Xをチェック
        for (int i = 1; i <= W; i++) // i:Y座標
        {
            if (dict.ContainsKey(i))
            {
                foreach(int value in dict[i])
                {
                    // 現在地より後ろにある障害物だけ見る
                    if (value > beforeX )
                    {
                        // 最小値の場合のみ更新する
                        if (MAX > value-1) MAX = value-1;
                        break;
                    }
                }
            }
            // 次の行に移る前に"仕込み"（上に移動するときに邪魔になる障害物がないかチェック）
            if (i == W) break; //最終行は次をチェックしない
            beforeX++;
            if (dict.ContainsKey(i+1))
            {
                foreach (int value in dict[i+1])
                {
                    // 1マス横に移動した後、上の場所にある場合、beforeXを1マスずらす（移動できないため）
                    if (beforeX == value)
                    {
                        beforeX++;
                    }
                }
            }
        }
        Console.WriteLine(MAX);
    }
}

Measured memory_bytes: 37308
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define UN unsigned int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
#define BS binary_search

int main()
{
	int n;
	cin>>n;
	int a[n];
	double doo=0.0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];

		doo+=(double)(1.0/a[i]);
	}
	doo=1.0/doo;
	printf("%.12lf\n",doo);
}

Measured memory_bytes: 256
{
  const main = (input: string) => {
    const r = reader(input);
    const [a, b] = r.ns();
    
    console.log(Math.max(0, (a - 2 * b)));
  };

  const reader = (str: string) => {
    const lines = str.trim().split("\n");
    const s = () => lines.shift() || "";
    const n = () => Number(s());

    const ss = () => s().split(" ");
    const ns = () => ss().map(Number);
    const nls = () => lines.map(Number);

    return { lines, s, n, ss, ns, nls }
  };

  const getInput = () => require("fs").readFileSync("/dev/stdin", "utf8");

  main(getInput());
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
	for (unsigned i = 0; i < v.size(); i++)
		in >> v[i];
	return in;
}


void solve(){
		lo N,ac=0,wa=0,tle=0,re=0; cin>>N;
		while(N--){
			string s;
			cin>>s;
			if(s=="AC")ac++;
			else if(s=="WA")wa++;
			else if(s=="TLE")tle++;
			else if(s=="RE")re++;
		}
cout<<"AC"<<" x "<<ac<<endl<<"WA"<<" x "<<wa<<endl<<"TLE"<<" x "<<tle<<endl<<"RE"<<" x "<<re<<endl;

}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(20);
	solve();
	return 0;
}

Measured memory_bytes: 3656
n = int(input())
hs = [int(x) for x in input().split()]

curr_height = 0
max_stepnum = 0
start_point = 0

while start_point < n-1:
  stepnum = 0
  curr_height = hs[start_point]
  for i in range(start_point+1, n):
    if curr_height >= hs[i]:
      stepnum += 1
      curr_height = hs[i]
    else:
      start_point = i
      break
  else:
     start_point = n-1

  if stepnum > max_stepnum:
    max_stepnum = stepnum

print(max_stepnum)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n; cin >> n;
  vi p(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }

  vi q(n);
  rep(i,n) q[p[i]] = i;

  int ans = 1e6;
  int cnt = 1;
  rep(i,n-1) {
    if(q[i] < q[i+1]){
      cnt++;
    }
    else{
      chmin(ans, n-cnt);
      cnt = 1;
    }
  }
  chmin(ans,n-cnt);

  cout << ans << endl;
}

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

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

int main(){
    int k; cin >> k;
    ll sum = 0;
    for(ll i=1; i<=k; ++i){
        for(ll j=1; j<=k; ++j){
            for(ll n=1; n<=k; ++n){
                ll l = gcd(j, n); 
                ll m = gcd(l, i);
                sum += m;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3608
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8");
const toInt = (i: string) => parseInt(i, 10);
 
const [kindsData, priceData] = input.split("\n");
const [, kindsToBuy] = kindsData.split(" ").map(toInt);
const prices = priceData.split(" ").map(toInt);
const lowestPrices = prices.sort((a, b) => a >= b ? 1 : -1).slice(0, kindsToBuy);
const totalPrice = lowestPrices.reduce((acc, crr) => acc+crr, 0);
console.log(totalPrice);


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

using namespace std;

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b&&b!=c){
		cout << "Yes" << endl;
	}else if(b==c&&c!=a){
		cout << "Yes" << endl;
	}else if(c==a&&a!=b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  size_t N;
  std::cin >> N;

  std::vector<long> A(N);
  for (size_t i=0; i<N; i++) {
    std::cin >> A[i];
  }

  size_t ans = 0;
  size_t inc = 0;
  size_t l = 0;
  size_t r = 0;
  long s = 0;
  long x = 0;

  for (; r<N; r++) {
    s += A[r];
    x ^= A[r];
    if (s != x)
      while (s != x) {
        s -= A[l];
        x ^= A[l];
        l++;
        inc--;
      }
    inc++;
    ans+=inc;
    // std::cout << l << ' ' << r << ' ' << inc << ' ' << ans << std::endl;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1792
def main():
    s = input()
    rem = [0] * 2019  # the count of the each remainder: 0 ~ 2018
    rem[0] = 1  # why? can't understand.

    temp = 0
    for i, c in enumerate(s[::-1]):
        temp += pow(10, i, 2019) * int(c)
        rem[temp % 2019] += 1

    return sum(c * (c - 1) // 2 for c in rem)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9364
implicit none
integer :: n,k
integer,allocatable :: x(:)
integer :: i,j,d,t,tmin

read *,n,k
allocate(x(n))
read *,(x(i),i=1,n)

tmin = 1000000000
j = k
do i = 1,n-k+1
   d = abs(x(j) - x(i))
   t = min(abs(x(i)) + d, abs(x(j)) + d)
   if (t < tmin) then
      tmin = t
   endif
   j = j + 1
enddo

print '(i0)',tmin
end

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    int q; cin >> q;
    map<string,int> mp;
    for(int i = 0; i < q; i++){
        int n; string s; cin >> n >> s;
        if (n == 0){
            int k; cin >> k;
            mp[s] = k;
        } else if (n == 1){
            if (mp[s] > 0) cout << mp[s] << endl;
            else cout << 0 << endl;
        } else {
            mp[s] = 0;
        }
    }
}
  




Measured memory_bytes: 27896
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
B = defaultdict(int)
for i in A:
    B[min(8,i//400)]+=1
ans = 0
jiyuu = 0
for i in B:
    if i != 8:
        ans += 1
    else:
        jiyuu = B[i]
#print(B)
print(*[max(ans,1),ans+jiyuu])

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

int main() {
  int n, l;
  cin >> n >> l;
  vector<int> taste(n);
  for(int i = 0; i < n; i++) {
    taste.at(i) = i + l;
  }
  
  int answer = 0;
  if(l >= 0) {
    for(int i = 1; i < n; i++) {
      answer += taste.at(i);
    }
  } else if(n + l - 1 >= 0) {
    for(int i = 0; i < n; i++) {
      answer += taste.at(i);
    }
  } else {
    for(int i = 0; i < n - 1; i++) {
      answer += taste.at(i);
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int n;



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

    string S, T, U;
    int A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S==U){
        A--;
    }else{
        B--;
    }

    cout << A << " " << B << endl;


    return 0;
}


Measured memory_bytes: 256
r,g,b,n=map(int,input().split())
ans=0
r,g,b=max(r,g,b),r+g+b-max(r,g,b)-min(r,g,b),min(r,g,b)
for i in range(n//r+1):
  for j in range(n//g+1):
    if (n-i*r-j*g)%b or (n-i*r-j*g)<0:
      continue
    ans+=1
print(ans)


Measured memory_bytes: 41232
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

count = 0
tmp = 10
tmp1 = 124
ABCDE = []
for i in [A,B,C,D,E]:
  if tmp >= i%10 and i%10 != 0:
    tmp = i%10
    tmp1 = i

for i in [A,B,C,D,E]:
  if tmp1 == i and count == 0:
    ABCDE.append(i)
    count = 1
  elif i%10 != 0:
    ABCDE.append(10-(i%10) + i)
  elif i%10 == 0:
    ABCDE.append(i)
print(sum(ABCDE))

Measured memory_bytes: 3064
def num_handler(cards)
  yamato = 0
  suzu = 0
  new_nums = cards.sort.reverse
  for i in 0..(new_nums.size - 1)
    if i % 2 == 0
      yamato += new_nums[i]
    else
      suzu += new_nums[i]
    end
  end
  return (yamato - suzu)
end

count = gets.to_i
cards = gets.chop.split.map(&:to_i)

p num_handler(cards)

Measured memory_bytes: 1788
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    as <- fmap ((\[a, b] -> ((readi a, readi b), True)) . B.words) . B.lines <$> B.getContents
    let hs = M.fromList as
    let f i = all isJust [M.lookup (1, i) hs, M.lookup (i, n) hs]
    if any f [2 .. n - 1]
        then putStrLn "POSSIBLE"
        else putStrLn "IMPOSSIBLE"

Measured memory_bytes: 70140
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  double p;
  while(cin>>p&&p){
    for(i=1;;i++){
      if(p>M_PI-(double)((int)(M_PI*i))/i){
	cout<<(int)(M_PI*i)<<"/"<<i<<endl;
	break;
      }
      if(p>(double)((int)(M_PI*i)+1)/i-M_PI){
	cout<<(int)(M_PI*i)+1<<"/"<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    if (accumulate(A.begin(), A.end(), 0) < H) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  int max_idx = 0;
  int total = l[0];
  for (int i = 1; i < n; i++) {
    if (l[i] > l[max_idx]) max_idx = i;
    total += l[i];
  }
  if (l[max_idx] < total - l[max_idx])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// date: 11.06.20
// author: Tibbarnit

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
before = -10
result = 0
for i in range(N):
  result += B[A[i] - 1]
  if before + 1 == A[i] - 1:
    result += C[before]
  before = A[i] - 1
print(result)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
    int n, info[4][3][10];
    int i, j, k, b, f, r, v;
    
    for (i=0; i<4; i++) {
        for (j=0; j<3; j++) {
	    for (k=0; k<10; k++) info[i][j][k] = 0;
	}
    }
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
	info[b-1][f-1][r-1] += v;
    }
    for (i=0; i<4; i++) {
	for (j=0; j<3; j++) {
	    for (k=0; k<10; k++) {
	       printf(" %d", info[i][j][k]);
	       if (k==9) printf("\n");
	    }
	}
        if (i==3) break;
	printf("####################\n");
    }

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e16;
typedef long long ll;
ll mod = 1e9+7;
ll fast_exp(ll a, ll b)
{
    if(b == 0)
        return 1;
    else
    {
        ll res = 1;
        res = fast_exp(a,b/2);
        res = (res*res)%mod;
        if(b%2 == 1)
            res = (res*a)%mod;
        return res;
 
    }
}

 
int main()
{
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
   long double n,x[10],y[10],ans=0;
   cin>>n;
   for(int i=0; i<n ; i++)
   {
      cin>>x[i]>>y[i];
   }
   for(int i=0; i<n ; i++)
    for(int j=i+1; j<n ; j++)
    {
      ans+= sqrt((x[i]-x[j])*(x[i]-x[j])+ (y[i]-y[j])*(y[i]-y[j]));
    }
    ans = 2*ans/(n);
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;


 return 0;
}

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

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
#define ll long long

using namespace std;

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

int main(void){
	char a,b,c,d,e,f;
	scanf("%c%c%c\n%c%c%c",&a,&b,&c,&d,&e,&f);

	if(a==f && b==e && c==d){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

	return 0;
}
	


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> us(m), vs(m);
  vector<int> deg(n);
  rep(i, m) {
    cin >> us[i] >> vs[i];
    us[i]--; vs[i]--;
    g[us[i]].push_back(i);
    g[vs[i]].push_back(i);
    deg[us[i]]++;
  }
  if (m % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> vis(n);
  auto dfs = [&](auto dfs, int u) -> int {
    vis[u] = true;
    int cnt = 0;
    for (int i : g[u]) {
      if (us[i] == u) {
        if (!vis[vs[i]]) {
          int d = dfs(dfs, vs[i]);
          if (d % 2 == 1) {
            swap(us[i], vs[i]);
          }
          cnt += d;
        }
      } else {
        if (!vis[us[i]]) {
          int d = dfs(dfs, us[i]);
          if (d % 2 == 1) {
            swap(us[i], vs[i]);
          }
          cnt += d;
        }
      }
    }
    if (deg[u] % 2 == 1) cnt++;
    return cnt;
  };
  dfs(dfs, 0);
  rep(i, m) {
    cout << us[i]+1 << ' ' << vs[i]+1 << endl;
  }
}



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

int main() {
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n)cin >> a[i];

        int ans = 0;
        for(int i = 0; i<n; i+=2){
                if (a[i]%2==1)ans++;
        }
        cout << ans <<endl;
        return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i+1<s.size();i++)
    {
        if(s[i]==s[i+1])
        {
            ++ans;
            if(s[i+1]=='0')
              s[i+1] = '1';
            else
              s[i+1] = '0';
        }
    }
    cout<<ans;
    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {

    int  H,W;
    cin >> H >> W;
    vector<vector<char> > S(H,vector<char>(W));

    REP(i,H){
        REP(j,W){
            cin >> S[i][j];
        }
    }

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


        int max_dist = 0;

REP(i,H){
    REP(j,W){
        if(S[i][j]=='#')continue;

        queue<pair<int, int> > q;
        vector<vector<int> > dist(H, vector<int>(W, -1));  //二次元ベクターを定義
        dist[i][j] = 0;
        q.emplace(i,j);

        while (!q.empty()) {
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            for (int k = 0; k < 4; k++) {
            int yy = y + dy[k];
            int xx = x + dx[k];
            if (yy < 0 || xx < 0 || yy >= H || xx >= W) continue;  //はみ出た場合
            if (S[yy][xx] == '#') continue;    //塗りつぶされている場合
            if (dist[yy][xx] != -1) continue;  //訪問済みの場合
            dist[yy][xx] = dist[y][x] + 1;     //初期位置からの移動距離
            max_dist = max(max_dist,dist[yy][xx]);
            q.emplace(yy, xx);
            }
        }

        queue<pair<int,int> > empty;
        swap( q, empty );
    }
}
cout << max_dist << endl;

}



Measured memory_bytes: 256
import math
a,b = map(int, input().split())
A = int(math.floor(a * (100/8)))
A1 = int(math.ceil((a+1)*(100/8)))
B = int(math.floor(b * (100/10)))
B1 = int(math.ceil((b+1) * (100/10)))
X = []
Y = []
for i in range(A,A1+1):
  if int(math.floor(i*(8/100))) == a:
    X.append(i)
  else:
    pass
  
for i in range(B,B1+1):
  if int(math.floor(i*(10/100))) == b:
    Y.append(i)
  else:
    pass
    
if set(X)&set(Y) == set():
  print(-1)
else:
  Z = list(set(X)&set(Y))
  Z.sort()
  print(Z[0])


Measured memory_bytes: 3064
#include<cstdio>
#include<cctype>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

#define REP(i, N) for(int i=0;i<(int)(N);++i)

int unit[20];
int need[20];

int nextInt() {int r = 0, ch; while( isspace(ch = getchar())); do {r = r * 10 + ch - '0';}while( isdigit( ch = getchar() ) ); return r;}

char visited[1 << 20];

struct State {
  int one, mask, have;
};

int solve(int N, int U, int tno) {
  queue<State> up;
  static State s;
  s.one = s.mask = s.have = 0;
  visited[s.mask] = tno;
  up.push(s);
  while( !up.empty() ) {
    s = up.front(); up.pop();

    if( s.have >= U ) return s.one;

    for(int i = 0; i < N; i++)
      if ( visited[s.mask | (1 << i)] != tno && (s.mask | need[i]) == s.mask )
      {
        static State next;
        next.mask = s.mask | (1 << i);
        next.one = s.one + 1;
        next.have = s.have + unit[i];
        visited[next.mask] = tno;
        up.push(next);
      }
  }
  return -1;
}

int main() {
  for(int tno = 1;; tno++) {
    int N, U;
    N = nextInt();
    U = nextInt();
    if( N == 0 && U == 0 ) break;
    REP(i, N) need[i] = 0;

    int all = 0;
    REP(i, N) {
      unit[i] = nextInt();
      all += unit[i];
      int K = nextInt();
      REP(k, K) {
        int x = nextInt();
        need[i] |= (1 << x);
      }
    }
    if( all == U ) {
      printf("%d\n", N);
      continue;
    }
    int best = solve(N, U, tno);
    printf("%d\n", best);
  }
}

Measured memory_bytes: 4124
from collections import deque
N, K, C = map(int, input().split())
S = input()

fastest = deque([])
latest = deque([])


date = 1

for work_days in range(K):
    while S[date - 1] == 'x':
        date += 1
    fastest.append(date)
    date += C + 1

date = 1

for work_days in range(K):
    while S[- date] == 'x':
        date += 1
    latest.append(N - (date - 1))
    date += C + 1

fastest = list(fastest)
latest = list(latest)

for i in range(K):
    if fastest[i] == latest[- (i + 1)]:
        print(fastest[i])

Measured memory_bytes: 22688
class UnionFindTree():
    def __init__(self, N):
        self.N = N
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(self.N):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    X = sorted(zip(B, A))
    A = list(map(lambda x: x[1], X))
    B = list(map(lambda x: x[0], X))
    sortedA = sorted(A)
    for i in range(N):
        if sortedA[i] > B[i]:
            print("No")
            return
    for i in range(N-1):
        if sortedA[i+1] <= B[i]:
            print("Yes")
            return
    uft = UnionFindTree(N)
    desired_pos = {sortedA[i]: i for i in range(N)}
    for i in range(N):
        uft.unite(i, desired_pos[A[i]])
    if len(uft.groups()) == 1:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 118760
N, Y= gets.split(" ").map(&:to_i)

(0..N).each do |mi|
  (0..N-mi).each do |gi|
    si = N - mi - gi
    if Y == 10000*mi + 5000*gi + 1000*si
      puts "#{mi} #{gi} #{si}"
      exit
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 1788