akhauriyash/Code-Regression huggingface dataset:
import java.util.*;class Main{public static void main(String[]a){int i=0;Scanner s=new Scanner(System.in);for(;;){String t=s.nextLine(),r="";if(t.equals("."))break;for(char c:t.toCharArray()){i="()[]".indexOf(c);r+=i<0?"":i;}for(;i<99;i++)r=r.replace("01","").replace("23","");System.out.println(r.equals("")?"yes":"no");}}}

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

  //input
  long long N;
  cin >> N;
  string Ans = "";
  
  //setup
  //bool first = true;
  int A=1;
  long long chk = 26;
  while(N > chk){
    A++;
    N -= chk;
    chk *= 26;
  }
  N--;
  
  int ct=0;
  while(A > ct){
    int tmp = N % 26;
    char mj = 'a';
    //if(!first) mj--;
    //first=false;
    mj += tmp;
    Ans += mj;
    N /= 26;
    ct++;
  }
  reverse(Ans.begin(), Ans.end());
  
  //output
  cout << Ans << endl;

}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>

int main(){
	int i,j,flag=0;
	char s[256];
	while(fgets(s,sizeof(s),stdin)!=NULL){
		flag=0;
		for(i=1;i<=26;i++){
			for(j=0;j<strlen(s);j++){
				if(97<=s[j]&&s[j]<=122) {
						if(s[j]+1>122) s[j]=(s[j]+1)%122+96;
						else s[j]=s[j]+1;
				}
			}
			for(j=0;j<strlen(s);j++){
				if(s[j]=='t'){
					if(!strncmp(s+j,"the",3)||!strncmp(s+j,"this",4)||!strncmp(s+j,"that",4)){
						flag=1;
					}
				}
			}
			if(flag) break;
		}
		printf("%s",s);
		memset(s,'\0',sizeof(s));
	}
	return 0;
}
	

Measured memory_bytes: 524
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	cin >> a >> b;
	if (a > 12)
		cout << b << endl;
	else if (a < 6)
		cout << 0 << endl;
	else
		cout << b / 2 << endl;
	return 0;
}

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

using namespace std;
using namespace atcoder;

typedef long long ll;

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

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

	int n, q;
	cin >> n >> q;

	dsu dsu(n);
	rep(i, q){
		int t, u, v;
		cin >> t >> u >> v;

		if(t == 0){
			dsu.merge(u, v);
		}else{
			cout << dsu.same(u, v) << endl;
		}
	}

	
}


Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

// 手cに対し勝てる手を返す
char win(char c) {
    if (c == 'r') return 'p';
    if (c == 's') return 'r';
    if (c == 'p') return 's';
}
int main() {
    int n,k; cin >> n >> k;
    int r,s,p; cin >> r >> s >> p;
    string t; cin >> t;
    vector<char> te(n); // te[i] := i回目の勝負で出した手

    // mod k = {0,1,...,k-1} のグループに分ける
    // 各グループで連続で同じ手を出さなければよし
    for (int mod = 0; mod < k; mod++)
    {
        // 初手は必ず勝利
        te[mod] = win(t[mod]);

        // 第2手以降の処理
        // 前回自分が出した手と被らない => 勝てる手を出す
        // 前回自分が出した手と被る => 次の手の邪魔にならない手(x)を出す
        for (int i = mod+k; i < n; i += k)
        {
            char tmpte = win(t[i]);
            if (te[i-k] != tmpte) {
                te[i] = tmpte;
            } else {
                te[i] = 'x';
            }
        }
    }
    int ans = 0;
    rep(i,n) {
        if (te[i] == 'r') ans += r;
        if (te[i] == 's') ans += s;
        if (te[i] == 'p') ans += p;
    }
    cout << ans << endl;
    return 0;
}

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


signed main(){
	int a,b,c;
	cin>>a;
	b=a;c=a;int ans=0;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			for(int k=1;k<=c;k++){
				ans+=__gcd(__gcd(i,j),k);
			}
		}
	}cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <climits>
using namespace std;
void solve()
{
	int n,k;
	cin >> n >> k;
	int h[n];
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	int dp[n];
	for(int i=1;i<n;i++)
	{
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=min(i,k);j++)
		{
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n-1] << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
const int P=998244353;
const int N=2e4+5;
int n,m,k,len,r[N];
long long ans,Inv,f[N],g[N],h[N],fac[N],inv[N];
long long fsp(long long x,int y){
	long long ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		y>>=1,x=x*x%P;
	}
	return ans;
}
void NTT(long long *d,int f){
	for(int i=1;i<n;i++)	if(i<r[i])	swap(d[i],d[r[i]]);
	for(int i=1;i<n;i<<=1){
		int wn=fsp(3,(P-1)/(i<<1));
		if(f)	wn=fsp(wn,P-2);
		for(int j=0;j<n;j+=i<<1){
			long long w=1;
			for(int k=0;k<i;k++,w=w*wn%P){
				int x=d[j+k],y=w*d[i+j+k]%P;
				d[j+k]=(x+y)%P,d[i+j+k]=(x-y+P)%P;
			}
		}
	}
	if(f)	for(int i=0;i<n;i++)	d[i]=d[i]*Inv%P;
}
long long C(int n,int m){
	return fac[n]*inv[m]%P*inv[n-m]%P;
}
int main(){
	scanf("%d%d",&k,&m),fac[0]=inv[0]=1;
	for(int i=1;i<=k+2;i++){
		fac[i]=fac[i-1]*i%P;
		inv[i]=fsp(fac[i],P-2);
	}
	for(;(1<<len)<=k*2;++len);
	n=1<<len,Inv=fsp(n,P-2),g[0]=1;
	for(int i=1;i<=k;i++)	h[i]=inv[i+2];
	for(int i=1;i<n;i++)	r[i]=(r[i>>1]>>1)|((i&1)<<(len-1));
	NTT(h,0);

	while(m--){
		for(int i=0;i<=k;i++)	f[i]=(1LL*i*(i-1)/2+i+1)*g[i]%P;
		for(int i=0;i<=k;i++)	g[i]=g[i]*inv[i]%P;
		NTT(g,0);

		for(int i=0;i<n;i++)	g[i]=g[i]*h[i]%P;

		NTT(g,1);
		for(int i=k+1;i<n;i++)	f[i]=0;
		for(int i=0;i<=k;i++)	f[i]=(f[i]+g[i]*fac[i+2])%P;
		swap(f,g);
	}
	for(int i=0;i<=k;i++)	ans=(ans+g[i]*C(k,i))%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,c=gsmi
puts a+b+c>=22 ? 'bust' : 'win'

Measured memory_bytes: 1788
s = input()
t = input()
ans = "UNRESTORABLE"

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != "?":
            break
        if j == len(t) - 1:
            mazai = (s[:i] + t + s[i+len(t):]).replace("?","a")
            if True or mazai < "UNRESTORABLE":
                ans = mazai
print(ans)

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


 
int main()
{
    int n;
    cin>>n;
    
    int a[n],b[n],c[n];
    
    for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    
    long long int dp[3][n+1];
    
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    
    
    for(int i=1;i<n;i++)
    {
        dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c[i]+max(dp[1][i-1],dp[0][i-1]);
        //cout<<dp[0][i]<<" "<<dp[1][i]<<" "<<dp[2][i]<<endl;
    }
    
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    
    

    
   


    
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    REP(i, N) {
        if (x >= a[i]) {
            ans++;
            x-= a[i];
        }
    }
    if (ans == N && x > 0) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, (s.size()+1)/2){
        if(s[i] != s[s.size()-i-1])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define ld long double
int const M=2e5+10,inf=1e9+10,mod=1e9+7,M2=1e6+10,sq=447;
int sa(int x,int y)
{
	if(x%y==0)return x/y;
	return x/y+1;
}
int32_t main()
{
	int n,k;
	cin>>n>>k;
	int ind,tmp;
	for(int i=1;i<=n;i++)
	{
		cin>>tmp;
		if(tmp==1)ind=i;
	}
	int mn=inf;
	for(int i=ind;i<=min(ind+k-1,n);i++)
	{
		int l=i-k+1;
		int ans=1+sa(l-1,k-1)+sa(n-i,k-1);
		mn=min(mn,ans);
	}
	cout<<mn;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  ll A,B,C;
  cin>>A>>B>>C;
  ll ans = 0;
  ans+=B;
  ans+=min(A+B+1,C);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  ll n, p;
  cin >> n >> p;

  ll ans = 1;
  for (ll i = 2; i * i <= p; i++) {
    int cnt = 0;
    while (p % i == 0) {
      cnt++;
      p /= i;
    }

    int tmp = cnt / n;
    for (int j = 0; j < tmp; j++) {
      ans *= i;
    }
  }
  if (n == 1) ans *= p;
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 01:19:32 2020

@author: shinba
"""
import collections

n = int(input())

A = list(map(int,input().split()))

data = collections.Counter(A)

I = sorted(data.items(),reverse = True)
#print(I)
s1 = 0
s2 = 1
cnt1 = 0
cnt2 = 0 

for i,j in I:
    if cnt1 == 0 and j >= 4:
        s1 = i**2
        cnt1 = 1
    if j >= 2:
        s2 *= i
        cnt2 += 1
    if cnt2 == 2:
        print(max(s1,s2))
        break
else:
    if s1 != 0:
        print(s1)
    else:
        print(0)

Measured memory_bytes: 25848
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999

int so[100000];

int hen(int i){
	if(i%2==0) return ((int)(i/2))*7 + 1;
	else return ((int)(i/2))*7 + 6;
}

void erato(){
	so[0] = 0;
	so[1] = 1;
	for(int j=2;j<100000;j++){
		so[j] = 1;
		int m = hen(j);
		//cout << m << endl;
		for(int k=1;hen(k)*hen(k)<=m;k++){
			if(m%hen(k)==0){
				so[j] = 0;
				break;
			}
		}
	}
}

int main(){
	int i, j, n;
	erato();
	while(1){
		cin >> n;
		if(n==1) break;
		cout << n << ":";
		for(j=0;hen(j)<=n;j++){
			if(so[j]==1 && n%hen(j)==0){
				cout << " " << hen(j);
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class sg_tree : public vector<T>{
private:
    lli n;
    T default_value;
    T _query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return default_value;
        if(a <= l && r <= b) return (*this)[k];
        else {
            T vl = _query(a,b,k*2+1,l,(l+r)/2);
            T vr = _query(a,b,k*2+2,(l+r)/2,r);
            return func(vl,vr);
        }
    }
public:
    sg_tree():vector<T>(){

    }
    sg_tree(lli n,T d = 'O'):vector<T>(n*4,d){
		this->n = 1;
        while(n > this->n) this->n <<= 1;
        this->default_value = d;
    }
    void update(lli i,T x){
        i += n - 1;
        (*this)[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            (*this)[i] = func((*this)[i * 2 + 1],(*this)[i * 2 + 2]);
        }

    }
    T query(lli a,lli b){
        return _query(a,b,0,0,n);
    }
    T func(T a,T b){
        if(a == 'A' && b == 'A') return 'B';
        if(a == 'A' && b == 'B') return 'O';
        if(a == 'A' && b == 'O') return 'A';
        if(a == 'B' && b == 'A') return 'O';
        if(a == 'B' && b == 'B') return 'A';
        if(a == 'B' && b == 'O') return 'B';
        if(a == 'O' && b == 'A') return 'A';
        if(a == 'O' && b == 'B') return 'B';
        if(a == 'O' && b == 'O') return 'O';
        return 0;
    }
};

sg_tree<char> sgs;
sg_tree<char> sgt;

string s,t;
lli q;


void solve(){
    sgs = sg_tree<char> (s.size());
    sgt = sg_tree<char> (t.size());
    for(lli i = 0;i < s.size();i++){
        sgs.update(i,s[i]);
    }
    for(lli i = 0;i < t.size();i++){
        sgt.update(i,t[i]);
    }
    for(lli i = 0;i < q;i++){
        lli a,b,c,d;
        cin >> a >> b >> c >> d;
        //cout << sgs.query(a-1,b) << " " << sgt.query(c-1,d) << endl;
        if(sgs.query(a-1,b) == sgt.query(c-1,d)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}
void input(){
    cin >> s >> t;
    cin >> q;

}


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

}

Measured memory_bytes: 1664
n,m=map(int,input().split())
a=[]
for _ in range(m):
   a.append(input())

def fb(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    if num==-1:
        b=0
    return b 

if m==0:
    print(fb(n+1) % (10**9+7))
    
else:
    sum=fb(int(a[0]))

    for i in range(m-1):
        sum=sum*fb(int(a[i+1])-int(a[i])-1)

    sum=sum*fb(n-int(a[m-1]))

    print(sum % (10**9+7))

Measured memory_bytes: 9388
import java.util.Scanner;

public class Main {

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

		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();

		if(a==b && a!=c) {
			System.out.println(2);

		}else if(a==c && b!=a) {
			System.out.println(2);

		}else if(b==c && a!=b) {
			System.out.println(2);

		}else if(a==b && b==c) {
			System.out.println(1);

		}else {
			System.out.println(3);
		}

	}

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int n;

void kock(double lpx, double lpy, double rpx, double rpy, int n){
	if(n==0)return;
	double sx, sy, tx, ty, ux, uy;
	double ag = M_PI/180;
	
	sx = (2*lpx + rpx)/3, sy = (2*lpy + rpy)/3;
	tx = (lpx + 2*rpx)/3, ty = (lpy + 2*rpy)/3;
	ux = (tx-sx)*cos(60*ag) - (ty-sy)*sin(60*ag) + sx;
	uy = (tx-sx)*sin(60*ag) + (ty-sy)*cos(60*ag) + sy;
	
	kock(lpx, lpy, sx, sy, n-1);
	printf("%f %f\n", sx, sy);
	kock(sx, sy, ux, uy, n-1);
	printf("%f %f\n", ux, uy);
	kock(ux, uy, tx, ty, n-1);
	printf("%f %f\n", tx, ty);
	kock(tx, ty, rpx, rpy, n-1);
	
}

int main(){
	double p1x = 0, p1y = 0;
	double p2x = 100, p2y = 0;
	
	scanf("%d", &n);
	printf("%f %f\n", p1x, p1y);
	kock(p1x, p1y, p2x, p2y, n);
	printf("%f %f\n", p2x, p2y);
	
	return 0;
}


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

using namespace std;

int main() {
  int n; cin >> n;
  vector<string> u(n);
  for(int i=0;i<n;++i) cin >> u[i];
  int m,now=0; cin >> m;
  string t;
  for(int i=0;i<m;++i){
    cin >> t;
    int j;
    for(j=0;j<n;++j){
      if(u[j]==t) break;
    }
    if(j!=n){
      if(now) cout << "Closed by " << t;
      else cout << "Opened by " << t;
      now=1-now;
    } else cout << "Unknown " << t;
    cout << endl;
  }
  
  return 0;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    set<long long> st(A.begin(),A.end());
    if(A.size() == st.size()){
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<int> G[MAX_N];
int f[MAX_N];

int main() {
    ll n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i,n)f[i] = -1;

    queue<int> que;
    que.push(0);
    f[0] = 0;

    int flag = 0;
    while(que.size() > 0){
        int x = que.front();
        que.pop();
        rep(i,G[x].size()){
            if(f[G[x][i]] == -1){
                f[G[x][i]] = (f[x] + 1) % 2;
                que.push(G[x][i]);
            }else{
                if(f[G[x][i]] == f[x]){
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 1)break;
    }

    /*
    rep(i,n){
        cout << f[i] << ' ';
    }
    cout << endl;
    */

    ll ans = 0;

    if(flag == 1){
        ans = n * (n - 1) / 2 - m;
    }else{
        ll c[2] = {};
        rep(i,n){
            c[f[i]]++;
        }
        ans = c[0] * c[1] - m;
    }

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


Measured memory_bytes: 8576
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int Aa = 0, Ba = 0, Ca = 0, Da = 0
    , Ab = 0, Bb = 0, Cb = 0, Db = 0;
  double a, b;

  while ( scanf ( "%lf%lf", &a, &b ) == 2 )
  {
    Aa += !!( a >= 1.1            );
    Ab += !!( b >= 1.1            );
    Ba += !!( a >= 0.6 && a < 1.1 );
    Bb += !!( b >= 0.6 && b < 1.1 );
    Ca += !!( a >= 0.2 && a < 0.6 );
    Cb += !!( b >= 0.2 && b < 0.6 );
    Da += !!(             a < 0.2 );
    Db += !!(             b < 0.2 );
  }

  printf ( "%d %d\n%d %d\n%d %d\n%d %d\n"
         , Aa, Ab, Ba, Bb, Ca, Cb, Da, Db );

  return ( 0 );
}

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

using namespace std;

#define int long long

int q;
int a, b;

bool solve(int v){
    int pos = v / 2;
    for(int i = max(1ll, pos - 10); i <= min(v, pos + 10); i++){
        int diff = v - i;
        int u = 1 + diff;
        int v = i;
        if(v <= b) v--;
        if(u >= a) u++;
        if(u * v >= a * b) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> a >> b;
        if(a > b) swap(a, b);
        int lo = 0, hi = 2000000000;
        while(lo != hi){
            int mi = (lo + hi + 1) >> 1;
            if(solve(mi)) lo = mi;
            else hi = mi - 1;
        }
        cout << lo-1 << endl;
    }
}


Measured memory_bytes: 256
from decimal import Decimal

n,m = map(int, input().split())
A = list(map(int, input().split()))
line = Decimal(sum(A) / (4 * m))
cnt = 0
for a in A:
    if a >= line:
        cnt += 1
    if cnt >= m:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 77144
#include <bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long ll;

int a[2005], cop[2005];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cop[i] = a[i];
    }
    sort(cop + 1, cop + n + 1);

    int ans = (int) 2e9;
    for (int i = 1; i <= n; i++)
    {
        multiset <int> opa;
        vector <int> glob;
        for (int j = 1; j <= n; j++)
        {
            if (a[j] >= cop[i]) opa.insert(a[j]);
            else
            {
                while ((int) opa.size() >= k)
                {
                    glob.pb(*opa.begin());
                    opa.erase(opa.begin());
                }
                opa.clear();
            }
        }
        while ((int) opa.size() >= k)
        {
            glob.pb(*opa.begin());
            opa.erase(opa.begin());
        }
        opa.clear();

        sort(glob.begin(), glob.end());
        if ((int) glob.size() >= q) ans = min(ans, glob[q - 1] - glob[0]);
        glob.clear();
    }
    cout << ans;
    return 0;
}



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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
bool can[11][11][11];

// solve
int main(){

    int N;
    cin >> N;
    can[0][0][0] = true;
    rep(i, N){
        char c;
        cin >> c;
        int t = c - '0' + 1;
        rep(j, 1, 10)rep(k, 1, 10){
            if(can[j][k][0])can[j][k][t] = true;
        }
        rep(j, 1, 10){
            if(can[j][0][0])can[j][t][0] = true;
        }
        can[t][0][0] = true;
    }

    int ans = 0;
    rep(i, 1, 10)rep(j, 1, 10)rep(k, 1, 10)if(can[i][j][k])ans++;
    cout << ans << '\n';

}


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

const int INF = 1e9;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = INF;
    for (int i = 0; i < (1<<n); i++) {
        vector<int> lvl(m);
        int cost = 0;
        rep(j,n) {
            if(i>>j&1) {
                cost += c[j];
                rep(k,m) lvl[k] += a[j][k];
            }
        }
        bool ok = true;
        rep(i,m) {
            if(lvl[i] < x) ok = false;
        }
        if(ok) ans = min(ans, cost);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	a, b := sc.getInt2()

	ans := -1
	for i := 1; i <= 11111; i++ {
		if x := i * 8 / 100; x != a {
			continue
		}
		if x := i * 10 / 100; x != b {
			continue
		}
		ans = i
		break
	}

	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1780
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let n_odd = List.length @@ List.filter (fun n -> n mod 2 = 1) as_ in
  let n_4n2 = List.length @@ List.filter (fun n -> n mod 2 = 0 && n mod 4 <> 0) as_ in
  let n_4n = List.length @@ List.filter (fun n -> n mod 4 = 0) as_ in
  print_endline @@ if n_odd <= n_4n || n_4n2 = 0 && n_odd <= n_4n + 1 then "Yes" else "No"


Measured memory_bytes: 8064
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,c
    
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    allocate(y(n))
    read(*,*)x
    read(*,*)y
    a=0 !aは上の道の差
    c=X(1)
    do i=1,n-1
    
    if (x(i+1)+a >y(i) )then
        b=i+1
        c=c+a+x(i+1)
        a=0
    else
        a=x(i+1)-y(i) +a
        c=c+y(i)
    end if
    
    end do
    c=c+y(n)
    write(*,*) c
    deallocate(x)
    deallocate(y)
    stop
end program sample
  



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int main()
{
	LL co=2;
	LL n;scanf("%lld",&n);
	for(LL k=2;k<=n/k;++k)
	{
		LL now=n;
		while(now>=k&&now%k==0)now/=k;
		if(now%k==1)co++;
		if(n%k==1&&k*k!=n-1)co++;
	}
	if(n==2)co=1;
	printf("%lld\n",co);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T popLast(multiset<T> &a){
  T res;
  typename multiset<T>::iterator it;
  it = a.end();
  it--;
  res = *it;
  a.erase(it);
  return res;
}
template<class T> inline T popLast(set<T> &a){
  T res;
  typename set<T>::iterator it;
  it = a.end();
  it--;
  res = *it;
  a.erase(it);
  return res;
}
int X;
int Y;
int Z;
int K;
long long A[1000];
long long B[1000];
long long C[1000];
set< tuple<long long,int,int,int> > val;
void pus(int i, int j, int k){
  if(i < 0 || j < 0 || k < 0){
    return;
  }
  val.insert(make_tuple(A[i]+B[j]+C[k],i,j,k));
}
void pul(int &i, int &j, int &k){
  long long v;
  tuple<long long,int,int,int> t;
  t = popLast(val);
  tie(v,i,j,k) = t;
  wt_L(v);
  wt_L('\n');
}
int main(){
  int e98WHCEY, i, j, k;
  long long res;
  rd(X);
  rd(Y);
  rd(Z);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<X;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<Y;KL2GvlyY++){
      rd(B[KL2GvlyY]);
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=0;Q5VJL1cS<Z;Q5VJL1cS++){
      rd(C[Q5VJL1cS]);
    }
  }
  sort(A,A+X);
  sort(B,B+Y);
  sort(C,C+Z);
  pus(X-1,Y-1,Z-1);
  for(e98WHCEY=0;e98WHCEY<K;e98WHCEY++){
    pul(i,j,k);
    pus(i-1,j,k);
    pus(i,j-1,k);
    pus(i,j,k-1);
  }
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// int X, Y, Z, K;
// ll A[1000], B[1000], C[1000];
// 
// set< tuple<ll,int,int,int> > val;
// 
// void pus(int i, int j, int k){
//   if(i < 0 || j < 0 || k < 0) return;
//   val.insert(make_tuple(A[i]+B[j]+C[k],i,j,k));
// }
// 
// void pul(int &i, int &j, int &k){
//   ll v;
//   tuple<ll,int,int,int> t;
//   t = popLast(val);
//   tie(v,i,j,k) = t;
//   wt(v);
// }
// 
// {
//   int i, j, k;
//   ll res;
//   rd(X,Y,Z,K,A(X),B(Y),C(Z));
//   sort(A,A+X);
//   sort(B,B+Y);
//   sort(C,C+Z);
// 
//   pus(X-1,Y-1,Z-1);
//   rep(K){
//     pul(i,j,k);
//     pus(i-1,j,k);
//     pus(i,j-1,k);
//     pus(i,j,k-1);
//   }
// }


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, int> PDI;

struct Edge{
    int to; double cost;
    Edge(int t, double c): to(t), cost(c) { }
};
using Graph = vector<vector<Edge>>;

struct Point{
    int x; int y; int r;
    Point(int x, int y, int r): x(x), y(y), r(r) { }
};


double getDist(int x1, int y1, int r1, int x2, int y2, int r2) {
    double dist = sqrt(ll(x2 - x1) * ll(x2 - x1) + ll(y2 - y1) * ll(y2 - y1));
    if (r1 + r2 >= dist) return 0;
    else return dist - (r1 + r2);
}

int n;
vector<double> dijkstra(int s, Graph& g) {
    vector<double> dist(n+2, 1e18);
    dist[s] = 0;
    priority_queue<PDI, vector<PDI>, greater<PDI>> pq;
    pq.push(PDI(0, s));
    while (!pq.empty()) {
        PDI q = pq.top(); pq.pop();
        double d = q.first;
        int v = q.second;
        if (dist[v] + 1e-9 < d) continue;
        for (auto ne: g[v]) {
            double nd = ne.cost;
            int nv = ne.to;
            if (dist[v] + nd < dist[nv]) {
                dist[nv] = dist[v] + nd;
                pq.push(PDI(dist[nv], nv));
            }
        }
    }
    return dist;
}

int main() {
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    cin >> n;

    Graph g(n+2);
    vector<Point> p;


    rep(i, n) {
        int x, y, r;
        cin >> x >> y >> r;
        p.push_back(Point(x, y, r));
    }

    p.push_back(Point(xs, ys, 0));
    p.push_back(Point(xt, yt, 0));

    rep(i, n+2) {
        for (int j = i+1; j < n+2; j++) {
            g[i].push_back(Edge(j, getDist(p[i].x, p[i].y, p[i].r, p[j].x, p[j].y, p[j].r)));
            g[j].push_back(Edge(i, getDist(p[i].x, p[i].y, p[i].r, p[j].x, p[j].y, p[j].r)));
        }
    }

    vector<double> d = dijkstra(n, g);

    cout << fixed;
    cout << setprecision(10) << d[n+1] << endl;
}

Measured memory_bytes: 22640
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define LL long long
#define swap(x,y) (x^=y^=x^=y)
#define min(x,y) ((x)<(y)?(x):(y))
using namespace std;
LL n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);if(a>b&&swap(a,b),(a&1)==(b&1)) return printf("%lld",b-a>>1),0;
	return printf("%lld",(b-a-1>>1)+min(a,n-b+1)),0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m = 0;
  cin >> n;
  vector<bool> cnt(13,false);
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    int b = a/400;
    cnt[b] = true;
    if(b >= 8){
      m++;
    }
  }
  REP(i,8){
    if(cnt[i] == true) ans++;
  }
  if(n == m){
    cout << 1 << " ";
  }
  else{
    cout << ans << " ";
  }
  REP(i,m){
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
}

Measured memory_bytes: 764
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function ds(c, a, val, cost, checked, x, l=0, s=length(c))
    if l == s
        return (sum(map(y -> y >= x, val)) == length(val), checked, cost)
    end
    bc = typemax(Int)
    br = nothing
    tmp = ds(c, a, val, cost, checked, x, l+1)
    if tmp[1]
        if bc > tmp[3]
            bc = tmp[3]
            br = tmp
        end
    end
    checked[l+1] = true
    val += a[l+1,:]
    cost += c[l+1]
    tmp = ds(c, a, val, cost, checked, x, l+1)
    if tmp[1]
        if bc > tmp[3]
            bc = tmp[3]
            br = tmp
        end
    end
    checked[l+1] = false
    if isnothing(br)
        return (false, checked, bc)
    else
        return br
    end
end

function main()
    N,M,X = reads(Int,Int,Int)
    c = zeros(Int, N)
    a = zeros(Int, N,M)
    for i in 1:N
        c[i] = pread(Int)
        a[i,:] = readvec(Int, M)
    end
    ans = ds(c, a, zeros(Int, M), 0, zeros(Int, N), X)
    if !ans[1]
        println(-1)
    else
        println(ans[3])
    end
end

main()


Measured memory_bytes: 216344
#include <iostream>
#include <numeric>
#include <cstdio>
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)
using namespace std;

int N,M,a,L;
int main(void){
    cin >> N >> M;
    int wall[N];
    fill(wall,wall+N,0);
    rep(i,M) {
        cin >> a >> L;
        REP(j,a,a+L) wall[j%N] = 1;
    }

    int mn = 1;
    rep(i,N) mn = min(mn, wall[i]);
    if (mn == 1) {
        printf("%d %d\n", N, 1);
        return 0;
    }
    
    while (wall[0] != 0) {
        int nwall[N];
        rep(i,N-1) nwall[i] = wall[i+1];
        nwall[N-1] = wall[0];
        rep(i,N) wall[i] = nwall[i];
    }
    
    int ans[N+1];
    fill(ans,ans+N+1,0);
    int l = 0;
    rep(i,N) {
        if (wall[i]) ++l;
        else {
            ++ans[l];
            l = 0;
        }
    }
    ++ans[l];

    for(int i = N; i > 0; --i) {
        if (ans[i] > 0)
            printf("%d %d\n", i, ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> H >> W;
   Vec(Graph,string,H,"");
   rep(i,0,H)cin >> Graph[i];
   DV(dist,lli,H,W,-1);
   queue<pair<int,int>> que;
   rep(i,0,H)rep(j,0,W){
      if(Graph[i][j]=='#'){
         dist[i][j]=0;
         que.push(pair<int,int>(i,j));
      }
   }
   while(!que.empty()){
      auto Xq = que.front();
      que.pop();
      rep(i,0,4){
         auto nx=Xq.first+dx[i];
         auto ny=Xq.second+dy[i];
         if(nx<0||nx>=H||ny<0||ny>=W)continue;
         if(dist[nx][ny]==-1){
            dist[nx][ny]=dist[Xq.first][Xq.second]+1;
            que.push(pair<int,int>(nx,ny));
         }
      }
   }
   rep(i,0,H)rep(j,0,W)sum=max(sum,dist[i][j]);
   Out(sum);
}

Measured memory_bytes: 17296
package main

import (
	"fmt"
)

func main() {
	var a int64
	var b1, b2 int64
	fmt.Scanf("%d %d.%d", &a, &b1, &b2)

	var sum = a * b1
	sum = sum + a * b2 / 100

	fmt.Printf("%d", sum)
}


Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;
	int ans=0;
	if(X<4) ans += 100000*(4-X);
	if(Y<4) ans += 100000*(4-Y);
	if(X*Y==1) ans += 400000;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include"math.h"
#include<iostream>
using namespace std;
int main()
{
	int n, d, x[10][10], i, j, k, cnt = 0, t;
	cin >> n >> d;
	for (i = 0; i < n; i++) for (j = 0; j < d; j++) cin >> x[i][j];
	for (i = 0; i < n; i++)for (j = i + 1; j < n; j++) {
		t = 0;
		for (k = 0; k < d; k++)t += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
		if (int(sqrt(t)) == sqrt(t)) cnt++;
	}
	cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int blk;
struct node{
    int left,right;
    int index;
};
static bool compare(node& p1,node& p2){
    if(p1.left/blk==p2.left/blk)
    return p1.right<p2.right;
    return p1.left<p2.left;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    blk=sqrt(n);
    vector<int> a(n,0);
    for(int i=0;i<n;i++)
    cin>>a[i];
    vector<node> q;
    q.resize(m);
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        node p;
        p.left=l,p.right=r,p.index=i;
        q[i]=p;
    }
    sort(q.begin(),q.end(),compare);
    vector<int> freq(500001,0);
    vector<int> ans(m,0);
    int ml=0,mr=-1,count=0;
    for(int i=0;i<m;i++){
        int l=q[i].left-1,r=q[i].right-1;
        int ind=q[i].index;
        while(ml>l)
        if(++freq[a[--ml]]==1)
        count++;
        while(mr<r)
        if(++freq[a[++mr]]==1)
        count++;
        while(ml<l)
        if(--freq[a[ml++]]==0)
        count--;
        while(mr>r)
        if(--freq[a[mr--]]==0)
        count--;
        ans[ind]=count;
    }
    for(auto &i:ans)
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 15484
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 200010;
char s[N];
ll ans;
int o[2];
int main(){
	scanf("\n%s", s + 1);
	int l = strlen(s + 1);
	for (int i = 1; i <= l; i++)
		if (s[i] == '1'){
			o[i % 2]++;
			ans = ans + i / 2 + i % 2;
		}
		else {
			ans = ans + max(o[0], o[1]);
			o[0] = max(o[0], o[1]);
			o[1] = max(o[0], o[1]);
		}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3952
//****** @author mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}



void solve() {
   ll a,b;cin>>a>>b;
   ll tempa=a;
   ll tempb=b;
   a=min(tempa,tempb);
   b=max(tempa,tempb);
   if(a==1 && b==2)cout<<3<<endl;
   if(a==2 && b==3)cout<<1<<endl;
   if(a==1 && b==3)cout<<2<<endl;

}
int main()
{
    IOS;
    ll t=1;
   //   cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
N, M = map(int, input().split())
e = dd(list)
inf = 10 ** 9
pos = [inf] * (N + 1)
for i in range(M):
  a, b, d = map(int, input().split())
  e[a].append((b, d))
  e[b].append((a, -d))
visited = [0] * (N + 1)
s = []
for i in range(1, N + 1):
  if visited[i] == 0:
    s.append(i)
    pos[i] = 0
  while len(s):
    p = s.pop()
    for q in e[p]:
      if pos[q[0]] == inf:
        pos[q[0]] = pos[p] + q[1]
        visited[q[0]] = 1
        s.append(q[0])
      else:
        if pos[q[0]] - pos[p] != q[1]:
          print("No")
          exit(0)
print("Yes")

Measured memory_bytes: 95064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(m);
  vb e(m, false);
  rep(i, n) {
    int k, l0;
    cin >> k >> l0;
    l0--;
    e[l0] = true;
    rep(j, k - 1) {
      int l;
      cin >> l;
      l--;
      e[l] = true;
      uf.unite(l0, l);
    }
  }
  set<int> st;
  rep(i, m) if(e[i]) st.insert(uf.root(i));
  cout << (st.size() == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 640
n, l, t = [int(x) for x in raw_input().split()]


def inp():
    x, w = [int(x) for x in raw_input().split()]
    return x, (1 if w == 1 else -1)

ants = [inp() for _ in xrange(n)]
ad = {
    1: [],
    -1: []
}
for i, (x, w) in enumerate(ants):
    ad[w].append(i)

m, r = divmod(t, l)

a0x, a0w = ants[0]
n_d = len(ad[-a0w]) * m * 2
n_e = 0
for anti in ad[-a0w]:
    aix, aiw = ants[anti]
    r2 = r * 2
    m1 = ((aix - a0x) * a0w) % (2 * l)
    if m1 < r2:
        n_d += 1
    elif m1 == r2:
        n_e += 1
    m2 = ((aix + l - a0x) * a0w) % (2 * l)
    if m2 < r2:
        n_d += 1
    elif m2 == r2:
        n_e += 1

nantsx = [(x + w * r) % l for x, w in ants]
andfx = nantsx[0]
nantsx.sort()

lb = 0
ub = n - 1
while ub != lb:
    mid = (lb + ub) / 2
    if nantsx[mid] == andfx:
        lb = ub = mid
        break
    elif nantsx[mid] < andfx:
        lb = mid + 1
    else:
        ub = mid - 1

while lb >= 1 and nantsx[lb - 1] == andfx:
    lb -= 1
while ub < n - 1 and nantsx[ub + 1] == andfx:
    ub += 1

if a0w == 1:
    di = lb - n_d
else:
    di = ub + n_d

for i in xrange(di, di + n):
    print(nantsx[i % n])


Measured memory_bytes: 20280
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = input()
for i in range(len(n)):
  count += int(n[i])
if count % 9 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 68572
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;


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

  int n = 0;

  for(int i=0; i<s.size(); i++){
    if(s[i] == '+'){
      n += 1;
    }else{
      n -= 1;
    }
  }

  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256