akhauriyash/Code-Regression huggingface dataset:
implicit none
integer :: a,b,c,d
character(4) :: s
character(1) :: op1,op2,op3
read *,s
read(s(1:1),*) a
read(s(2:2),*) b
read(s(3:3),*) c
read(s(4:4),*) d

if      (a+b+c+d==7) then
  op1 = '+'
  op2 = '+'
  op3 = '+'
else if (a+b+c-d==7) then
  op1 = '+'
  op2 = '+'
  op3 = '-'
else if (a+b-c+d==7) then
  op1 = '+'
  op2 = '-'
  op3 = '+'
else if (a+b-c-d==7) then
  op1 = '+'
  op2 = '-'
  op3 = '-'
else if (a-b+c+d==7) then
  op1 = '-'
  op2 = '+'
  op3 = '+'
else if (a-b+c-d==7) then
  op1 = '-'
  op2 = '+'
  op3 = '-'
else if (a-b-c+d==7) then
  op1 = '-'
  op2 = '-'
  op3 = '+'
else if (a-b-c-d==7) then
  op1 = '-'
  op2 = '-'
  op3 = '-'
endif

print '(i0,1a,i0,1a,i0,1a,i0,a)', a,op1,b,op2,c,op3,d,'=7'
end

Measured memory_bytes: 256
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int n;
	cin >> n;
	int v[22];
	int c[22];

	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}

	int ans = 0;
	rep(i, n) {
		int dif = v[i] - c[i];
		if (dif >= 0) {
			ans += dif;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
lst = [int(i) for i in input().split(" ")]

flag = 1

for i in lst:
  if i%2 == 0 and i%3 != 0 and i%5 != 0:
    flag = 0
    
if flag == 1:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )



int D, N;

int main() {
    cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    }else{
        cout <<  2*N << endl;
    }
}

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

string A, B;

int main() {
    cin >> A >> B;

    if (A.length() > B.length()) {
        cout << "GREATER" << endl;
    }
    else if (A.length() < B.length()) {
        cout << "LESS" << endl;
    }
    else {
        bool f = true;
        for (int i = 0; i < A.length(); i++) {
            if (A[0] - '0' > B[0] - '0') {
                cout << "GREATER" << endl;
                f = false;
                break;
            }
            else if (A[0] - '0' < B[0] - '0') {
                cout << "LESS" << endl;
                f = false;
                break;
            }
        }

        if (f) cout << "EQUAL" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf = 2147483647;
const long long int My_LInf = 9223372036854775807;

struct plant {
	double fertrate;

	double lovewater;
	double vital;
};
double pw;
vector<plant>plants;

double getmon(const double water) {
	double ans = water*pw;
	for (auto p:plants) {
		double rest = p.vital - water*p.lovewater;
		if (rest < 0) {
			ans += 0;
		}
		else {
			ans += rest / p.fertrate;
		}
	}
	return ans;
}

int main() {
	while (1) {
		plants.clear();
		int N; cin >> N; if (!N)break;
		cin >> pw;
		for (int i = 0; i < N; ++i) {
			double vw, pf, vf, t; cin >> vw >> pf >> vf >> t;
			double fertrate = vf / pf;
			double water= vw;
			plants.push_back(plant{ fertrate,water,t });

		}
		double amin = 0;
		double amax = 100;
		while (amin < amax - 1e-10) {
			double amid1 = (amin * 2 + amax) / 3;
			double amid2 = (amin + amax * 2) / 3;
			double mon1 = getmon(amid1);
			double mon2 = getmon(amid2);
			if (mon1 < mon2) {
				amax = amid2;
			}
			else {
				amin = amid1;
			}
		}
		double ans = getmon((amin+amax)/2);
		cout <<setprecision(22)<<fixed<< ans << endl;
	}
	return 0;
}

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

const int N=300;

struct EDGE{int to,len;};

vector<EDGE> lnk[N+3];
int n,m,ful,Q;
int Eans[N+3][N+3],Emx[N+3][N+3];
bool Ifx[N+3][N+3];
bool Ique[N+3];

void BFS(int S){
	queue<int> que;
	que.push(S);
	Eans[S][S]=0;Emx[S][S]=ful;
	while(!que.empty()){
		int u=que.front(),ut=Eans[S][u],ur=Emx[S][u];
		que.pop();
		Ique[u]=false;
		for(auto it : lnk[u]){
			int v=it.to,len=it.len;
			int vt,vr;
			if(len>ful) continue;
			if(len>ur) vt=ut+1,vr=ful-len;
			else vt=ut,vr=ur-len;
			if(Eans[S][v]<vt || (Eans[S][v]==vt && Emx[S][v]>=vr)) continue;
			Eans[S][v]=vt;Emx[S][v]=vr;
			if(!Ique[v]){
				que.push(v);
				Ique[v]=true;
			}
		}
	}
}
int main(){
//	freopen("output.txt","w",stdout);
	scanf("%d%d%d",&n,&m,&ful);
	for(int i=1;i<=m;i++){
		int u,v,len;
		scanf("%d%d%d",&u,&v,&len);
		lnk[u].push_back((EDGE){v,len});
		lnk[v].push_back((EDGE){u,len});
		if(len<=ful) Ifx[u][v]=Ifx[v][u]=true;
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				Ifx[i][j]|=(Ifx[i][k] && Ifx[k][j]);
	memset(Eans,0x3f,sizeof Eans);
	for(int i=1;i<=n;i++)
		BFS(i);
	scanf("%d",&Q);
	while(Q--){
		int u,v;
		scanf("%d%d",&u,&v);
		if(!Ifx[u][v]){
			printf("-1\n");
			continue;
		}
		printf("%d\n",Eans[u][v]);
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int l = s.size();

  vector<int> number(26, 0);
  for (int i = 0; i < l; i++) {
    number[s[i] - 'a']++;
  }
  
  for (int i = 0; i < 26; i++) {
    if (number.at(i) == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char inp[100005];

int main() {
	scanf("%s", inp + 1);
	int N = strlen(inp + 1);
	if (inp[N] == '1' || inp[1] == '0') return !printf("-1");
	for (int i = 1; i < N; i++) {
		if (inp[i] != inp[N - i]) return !printf("-1");
	}
	int used = 1;
	for (int i = 2; i < N; i++) {
		if (inp[i] == '1') {
			while (used < i) printf("%d %d\n", used++, i);
		}
	}
	printf("%d %d\n", N - 1, N);
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int max = a + b;
    if(a - b > max)
      max = a - b;
    if(a * b > max)
      max = a * b;
    System.out.println(max);
  }
}

Measured memory_bytes: 21972
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int n;

    cin >> n;
    switch(n % 10)
    {
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    default:
        cout << "hon" << endl;
        break;
    }

    return 0;
}


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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y % x, x);
}

ll powM(ll x, ll y, ll m) {
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}

map<long long, long long> factorize(long long n) {
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}
/* **********END OF TEMPLATE*********** */
int main() {
	FAST();

	ll n;
	cin >> n;
	n %= 10;
	if (n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon";
	else if (n == 3)
		cout << "bon";
	else
		cout << "hon";
	return 0;
}

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


#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

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

const int N = 100;

int n;

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

    cin >> n;
    for (int cur=1;cur<=n;cur++){
        int ans = 0;
        for (int i=1;i * i<cur;i++){
            for (int j=1;i * i + j * j + i * j<cur;j++){
                int sisa = cur - (i * i + j * j + i * j);
                int low = 1, high = N;
                while (low < high){
                    int mid = (low + high) / 2;
                    if ((i + j + mid) * mid >= sisa){
                        high = mid;
                    } else{
                        low = mid + 1;
                    }
                }
                if ((i + j + high) * high == sisa) ans++;
            }
        }
        cout << ans << el;
    }

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int k, x; cin >> k >> x;
	vi v;
	rep(i, k - 1) v.pb(x - k + i + 1);
	rep(i, k) v.pb(x + i);
	rep(i, v.size()) cout << v[i] << (i==v.size()-1?"\n":" ");
	return 0;
}

Measured memory_bytes: 256
def main():
    from bisect import bisect_left as bl

    def sosuu(n):
        p = [False]*2+[True]*(n-1)
        for i in range(2, int(n**0.5)+1):
            if not p[i]:
                continue
            for j in range(i*2, n+1, i):
                p[j] = False
        return [i for i in range(n+1) if p[i]]

    x = int(input())
    y = sosuu(100010)
    print(y[bl(y, x)])


main()

Measured memory_bytes: 4596
S = input() + 'x'
acgt = ('A','C','G','T')
curran = 0
longest = 0

def check1(l):
    for i in acgt:
        if l == i:
            return True
    return False

for i in S:
    if check1(i):
        curran += 1
    elif not check1(i):
        if curran > longest:
            longest = curran
        curran = 0
        
print(longest)

Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
s = list(map(int, input().split()))
N = s[0]
M = s[1]

s = np.array([list(map(int, input().split())) for i in range(M)])

print(max(np.min(s[:,1]) - np.max(s[:,0]) +1, 0))


Measured memory_bytes: 37880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  for(int i=0;i<H;i++){
    cin >> a.at(i);
  }
  vector<bool> h(H,false);
  vector<bool> w(W,false);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        h[i]=true;
        w[j]=true;
      }
    }
  }

  for(int i=0;i<H;i++){
    if(h[i]){
      for(int j=0;j<W;j++){
        if(w[j]){
          cout << a[i][j];
        }
      }
      cout<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ipair pair<ll,ll>
#define umap unordered_map<ll,ll>
#define map map<ll,ll>
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;
 
 
 
int main()
{
	booster;
	ll n=5,ans;
	eqrep(i,n)
	{
      	ll x;
		cin>>x;
		if(x==0) ans=i;
	}
	cout<<ans<<endl;

	
	return 0;
}

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

namespace ALDS1_6_A
{
    static class Algorithm
    {
        public static void CountingSort(this int[] a, int max)
        {
            int[] cnt = new int[max + 1];
            foreach (var e in a) cnt[e]++;
            for (int i = 1; i < max + 1; i++) cnt[i] += cnt[i - 1];
            var b = new int[a.Length];
            a.CopyTo(b, 0);
            foreach (var e in b) a[--cnt[e]] = e;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            a.CountingSort(a.Max());
            Console.WriteLine(string.Join(" ", Array.ConvertAll(a, (e) => e.ToString())));
        }
    }
}

Measured memory_bytes: 257916
# -*- coding: utf-8 -*-
n = int(input())
ab = []
for _ in range(n):
    a,b = map(int, input().split())
    ab.append((a,b))

res = 0
for i in range(n-1,-1,-1):
    a,b = ab[i]
    a += res
    if a%b==0:
        pass
    elif b>=a:
        res += b-a
    else:
        res += b-a%b
print(res)


Measured memory_bytes: 16668
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int d[101],f[101],t;

void dfs(vector<vi> a,int v){
    if(d[v])return;
    d[v]=++t;
    rep(i,a[v].size()){
        dfs(a,a[v][i]);
    }
    f[v]=++t;
}

void run(){
    int n;
    cin>>n;
    vector<vi> a(n+1);
    REP(i,1,n){
        int u,k;
        cin>>u>>k;
        rep(j,k){
            int v;
            cin>>v;
            a[u].pb(v);
        }
        sort(all(a[u]));
    }
    REP(i,1,n){
        dfs(a,i);
    }
    REP(i,1,n){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}


Measured memory_bytes: 3784
#include<iostream>
using namespace std;

int main(){
    int N,M,X;
    cin >> N >> M >> X;
    int m[N+1]={};
    for(int i=0;i<M;i++){
        int a;
        cin >> a;
        m[a]++;
    }
    for(int i=1;i<=N;i++){
        m[i]+=m[i-1];
    }
    int ans=min(m[X]-m[0],m[N]-m[X]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int getmax(int val1, int val2) {
	if (val1 > val2) {
		return val1;
	}
	else {
		return val2;
	}
}

typedef struct data {
	char c;
	int cnt;
} data;

char s[200010];
data datas[200010];
int dcnt;

int fnc2() {
	int p = geti();
	int q = geti();
	int r = geti();
	int sum = p + q + r;
	int max = getmax(p, q);
	max = getmax(max, r);

	return sum - max;
}

int fnc1() {
	int ret = fnc2();
	outi(ret);
	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc1();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc1();
#endif

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define FREE 0
#define NOT_FREE 1
#define EXIST 2
#define EMPTY -1
#define MAX 8
#define DMAX 15

void putQueen(int);
void print(void);

int row[MAX],col[MAX],dpos[DMAX],dneg[DMAX];
int res[MAX][MAX];
int main(){
  int i,j,k,r,c;
 
  for(i=0; i<MAX; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i=0; i<DMAX; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      res[i][j] = EMPTY;
    }
  }
  
  scanf("%d",&k);
  for(i=0; i<k; i++){
    scanf("%d%d",&r,&c);
    res[r][c] = EXIST;
  }
  
  putQueen(0);
  return 0;
}

void putQueen(int i){
  int j;

  if(i == MAX){
    print();
    return;
  }

  for(j=0; j<MAX; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+MAX-1] == NOT_FREE) continue;
    row[i] = j;
    col[j] = NOT_FREE;
    dpos[i+j] = NOT_FREE;
    dneg[i-j+MAX-1] = NOT_FREE;

    putQueen(i+1);

    col[j] = FREE;
    dpos[i+j] = FREE;
    dneg[i-j+MAX-1] = FREE;
  }
}

void print(){
  int i,j;
  
  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      if(res[i][j] == EXIST){
	if(row[i] != j) return;
      }
    }
  }

  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      if(row[i] == j) res[i][j] = EXIST;
    }
  }

   for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      if(res[i][j] == EXIST) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int N;

pair<int, int> find_repr(ll num) {
  int x = -9, y = -9;
  while(num % 2 == 0) {
    x++;
    num /= 2;
  }
  while(num % 5 == 0) {
    y++;
    num /= 5;
  }

  return {x, y};
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 map<pair<int,int>, int> ma;

 double abc; ll def;
 cin>>N;
 rep(i, N) {
   cin >> abc;
   def = llround(abc * 1e9);
   // cout << setprecision(10) << fixed << abc * 1e9 << endl;
   // debug(def)
   ma[find_repr(def)]++;
 }

 ll ans = 0;
 for(auto it = ma.begin();it != ma.end();it++) {
   auto x1 = it->first;
   auto y1 = it->second;
   for(auto it2 = ma.begin();it2 != it;it2++) {
     auto x2 = it2->first;
     auto y2 = it2->second;
     if((x1.F + x2.F) >= 0 && (x1.S + x2.S) >= 0) {
       ans += 1LL*y1*y2;
     }
   }

   if(x1.F >= 0 && x1.S >= 0) {
     ans += 1LL*(y1)*(y1-1)/2;
   }
 }
 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

//#define int long long

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) a[i]--;
	
	int cnt = 0;
	for (i = 0; i < n; i++) {
		if (a[a[i]] == i && a[i] > i) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
n=int(input())
dic={}
for i in range(n):
    q,*args=map(str,input().split())
    key=args[0]
    val=args[0]
    if q=="0":
        val=int(args[1])
        dic[key]=val
    elif q=="1":
        if key in dic.keys():
            print(dic[key])
        else:
            print(0)
    else:
        if key in dic:
            dic.pop(key)
        else :
            None


Measured memory_bytes: 37500
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

int main() {
	string s;
	cin >> s;
	for(int i=0; i<4;i++)
		cout << s[i];
		cout << " ";
	for(int i=4; i<12; i++)
		cout << s[i];
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int calc(int n, int a, int b, vector<int> v)
{
	int result = 0;
	rep(i, n)
	{
		if (i % 2 == 0)
		{
			if (v[i] != a)
				result += 1;
		}
		else if (i % 2 == 1)
		{
			if (v[i] != b)
				result += 1;
		}
	}

	return result;
}

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

	vector<int> x(N), y(N);

	rep(i, N)
	{
		int X, Y;
		cin >> X >> Y;
		x[i] = X;
		y[i] = Y;
	}

	int n = permutation(N, N);
	vector<int> b(N);
	rep(i, N)
	{
		b[i] = i;
	}

	double total = 0;
	do
	{
		rep(i, b.size() - 1)
		{
			int xi = x[ b[i] ];
			int xj = x[ b[i+1] ];
			int yi = y[ b[i] ];
			int yj = y[ b[i+1] ];
			
			total += sqrt((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj));
		}
		
	} while (next_permutation(b.begin(), b.end()));

	cout << setprecision(10) << (total / n) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a){
    int c[a],w=0;
    r(i,a)cin>>c[i];
    r(i,a-b){
      int cc=0;
      for(int j=i;j<i+b;j++)cc+=c[j];
      w=max(w,cc);
    }
    cout<<w<<endl;
  }
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int M=1e9+7,N=1e5;
int dp[101][N],p[101][N];
int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int> v={0};
    for(int down=1;down<=n;++down){
        int d=n/down;
        down=n/d;
        v.pb(down);
    }
    int m=sz(v);
    for(int i=1;i<m;++i)p[0][i]=v[i];
    for(int i=1;i<k;++i){
        for(int j=1;j<m;++j){
            int sym=m-j;
            dp[i][j]=p[i-1][sym]*(v[j]-v[j-1])%M;
            p[i][j]=p[i][j-1]+dp[i][j];
            if(p[i][j]>=M)p[i][j]-=M;
        }
    }
    cout<<p[k-1][m-1]<<'\n';
    return 0;
}


Measured memory_bytes: 102848
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;


vector<pair<int,ll>> m[N] ;

ll leng[N];

void dfs(int no,int p,ll le){
	leng[no]=le%2;
	for(auto &s:m[no]){
		if(s.first==p){
			continue;
		}else{
			dfs(s.first,no,s.second+leng[no]);
		}
	}
}
int main(){
	int n;
	cin>>n;
	REP(i,n-1){
		int u,v;
		ll w;
		cin>>u>>v>>w;
		u--;v--;
		m[u].push_back({v,w});
		m[v].push_back({u,w});
		
	}
	dfs(0,-1,0);
	REP(i,n){
		OUT(leng[i]);
	}
	return 0;
}

Measured memory_bytes: 10240
/*
    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);
    string s;
    cin >> s;
    if (s.size() != 26)
    {
        string t = s;
        sort(all(s));
        rep(i, 26)
        {
            if (!binary_search(all(s), (char)(i + 'a')))
            {
                cout << t + (char)(i + 'a') << endl;
                return 0;
            }
        }
    }else{
        if (s == "zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 << endl;
            return 0;
        }
        string t=s;
       // cout<<s<<endl;
        next_permutation(all(s));
        rep(i,s.size()){
            cout<<s[i];
            if(s[i]!=t[i])break;
        }
       // cout << s << endl;
    }
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
ans=0

if A%2!=0 or B%2!=0 or C%2!=0:
      pass
elif A==B and B==C:
  ans=-1
else:
  while True:
    if A%2!=0 or B%2!=0 or C%2!=0:
      break

    A,B,C=B/2+C/2,A/2+C/2,A/2+B/2
    ans+=1

print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

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

bool both=false;
if(A[0]<0 && A[N-1]>=0)both=true;

vector<pair<long long,long long>>ans(N-1);
if(both){
    for(int i=1;i<N-1;i++){
        if(A[i]<0){
            ans[i-1]=make_pair(A[N-1],A[i]);
            A[N-1]-=A[i];
        }
        else if(A[i]>=0){
            ans[i-1]=make_pair(A[0],A[i]);
            A[0]-=A[i];
        }
    }
    ans[N-2]=make_pair(A[N-1],A[0]);
    cout<<A[N-1]-A[0]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}
else if(A[0]>=0){
    for(int i=1;i<N-1;i++){
        ans[i-1]=make_pair(A[0],A[i]);
        A[0]-=A[i];
    }
    ans[N-2]=make_pair(A[N-1],A[0]);
    cout<<A[N-1]-A[0]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}
else if(A[0]<0){
    for(int i=N-2;i>=0;i--){
        ans[N-2-i]=make_pair(A[N-1],A[i]);
        A[N-1]-=A[i];
    }
    cout<<A[N-1]<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

 return 0;
}
/*
3
1 -1 2


4
-1 1
2 -2


3
1 1 1

1
1 1
1 0
*/

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
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;
  }
}
void wt_L(int x){
  char f[10];
  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 S, class T> inline void chmax(S &a, T b){
  if(a<b){
    a=b;
  }
}
int N, W, gain[4][100], sum[4][101], sz[4], v[100], w[100];
int main(){
  int a, b, c, d, res=0, tmp;
  long long minw, r;
  rd(N);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(w[Lj4PdHRW]);
      rd(v[Lj4PdHRW]);
    }
  }
  minw = w[0];
  {
    int KL2GvlyY;
    for(KL2GvlyY= 0;KL2GvlyY< (N-1) + 1;KL2GvlyY++){
      w[KL2GvlyY] -= minw;
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS= 0;Q5VJL1cS< (N-1) + 1;Q5VJL1cS++){
      gain[w[Q5VJL1cS]][sz[w[Q5VJL1cS]]++] = v[Q5VJL1cS];
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY= 0;e98WHCEY< (3) + 1;e98WHCEY++){
      sort(gain[e98WHCEY], gain[e98WHCEY]+sz[e98WHCEY], greater<int>());
    }
  }
  {
    int cTE1_r3A;
    for(cTE1_r3A= 0;cTE1_r3A< (3) + 1;cTE1_r3A++){
      {
        int RZTsC2BF;
        for(RZTsC2BF= 1;RZTsC2BF< (sz[cTE1_r3A]) + 1;RZTsC2BF++){
          sum[cTE1_r3A][RZTsC2BF] += sum[cTE1_r3A][RZTsC2BF - (1) + (0)] + gain[cTE1_r3A][RZTsC2BF - (1) + (0)];
        }
      }
    }
  }
  for(a=0;a<sz[0]+1;a++){
    for(b=0;b<sz[1]+1;b++){
      for(c=0;c<sz[2]+1;c++){
        r = W - minw*a - (minw+1)*b - (minw+2)*c;
        if(r < 0){
          break;
        }
        d = min(r / (minw+3), (long long)sz[3]);
        chmax(res, sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d]);
      }
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170429-1

// --- original code ---
// int N, W, w[100], v[100];
// int gain[4][100], sum[4][101], sz[4];
// {
//   int res = 0, tmp;
//   int a, b, c, d;
//   ll r, minw;
//   rd(N, W, (w,v)(N));
//   minw = w[0];
//   w[0..N-1] -= minw;
//   gain[w[0..N-1]][sz[w[0..]]++] = v[0..];
//   sort(gain[0..3], gain[0..]+sz[0..], greater<int>());
// 
//   sum[0...3][1..sz[0...]] += sum[0...][0..] + gain[0...][0..];
// 
//   rep(a,sz[0]+1) rep(b,sz[1]+1) rep(c,sz[2]+1){
//     r = W - minw*a - (minw+1)*b - (minw+2)*c;
//     if(r < 0) break;
//     d = min(r / (minw+3), (ll)sz[3]);
//     res >?= sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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


using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = s.length();
    string prev,cur;

    rep(i,n){
        if(i == 0){
            prev = s[0];
            ans ++;
        }else{
            cur += s[i];
            if(cur != prev){
                prev = cur;
                cur = "";
                ans ++;
            }
        }
    }

    cout << ans;
    return 0;
}











Measured memory_bytes: 3752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        // ひなあられの色定数
        final String PINK = "P";
        final String WHITE = "W";
        final String GREEN = "G";
        final String YELLOW = "Y";
        
        boolean hasFourColors = false;
        
        Scanner sc = new Scanner(System.in);
        
        // ひなあられの数
        int arareNum = sc.nextInt();

        while(sc.hasNext()) {
            String color = sc.next();
                        
            if(color.equals(YELLOW)) {
                hasFourColors = true;
                break;
            }
        }
        
        String result = null;
        
        if(hasFourColors) {
            result = "Four";
        } else {
            result = "Three";
        }
        
        System.out.println(result);
        
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  //cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
ll gcd(ll p, ll q){
if(p % q == 0)return q;
return gcd(q, p % q);
}
ll getSumofdigit(ll n) {

    ll sum = 0; 
    while (n != 0) 
    { 
     sum = sum + n % 10; 
     n = n/10; 
    }  
    return sum; 
} 
ll countDigit(ll n) 
{ 
    return floor(log10(n) + 1); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////


void solve()
{

    ll n;

    cin>>n;

    ll cnt = 0;
    ll flag = 0;

    loop(i,0,n)
    {
        ll a,b;
        cin>>a>>b;

        if(a==b)
        {
            cnt++;
        }
        else
            cnt=0;

        if(cnt==3)
            flag = 1;
    }
    
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";


    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 



Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int tmp=1;
		for(int i=1;i<X;i++) {
			for(int j=2;j<=100;j++) {
				if(Math.pow(i, j)>tmp&&Math.pow(i, j)<=X) {

					tmp = (int) Math.pow(i, j);
								}
				if(Math.pow(i, j)>X) {
						break;
				}

			}

		}
		System.out.println(tmp);
	}

}





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

int main(void){
    // Your code here!
    long long N;
    cin>>N;
    vector<long long>A(N);
    vector<bool>B(1000000);
    for(long long i=0;i<N;i++){
        cin>>A[i];
    }
    for(long long i=0;i<1000000;i++){
        B[i]=true;
    }
    sort(A.begin(),A.end());
    long long count=0;
    for(long long i=0;i<N;i++){
        if(i>0&&A[i]==A[i-1]){
            B[A[i]]=false;
        }
        if(B[A[i]]==true){
            for(long long j=2*A[i];j<=1000000;j+=A[i]){
                B[j]=false;
            }
        }
    }
    for(long long i=0;i<N;i++){
        if(B[A[i]]==true){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 4772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string s;

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

  int ans = 0;
  for (int i = s.length() - 2; i >= 0; i--) {
    int S = i + 1;
    if (S % 2 != 0) continue;
    int cnt = 0;
    for (int j = 0; j < S / 2; j++) {
      if (s[j] == s[S / 2 + j]) {
        cnt++;
      }
      else {
        cnt = 0;
        break;
      }
    }
    ans = max(ans, 2 * cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  int r = 0;
  int b = 0;
  
  for(int i=0;i<N;i++){
    if(s[i] == 'R')
      r++;
    else
      b++;
  }
  
  if(r > b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a--;
        A.at(a)++;
    }
    sort(ALL(A));
    int ans = 0;
    for (int i = 0; i < N - K; i++) {
        ans += A.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
sum1,sum2=[a1[0]],[a2[0]]
for i in range(1,n):
    sum1.append(sum1[i-1]+a1[i])
    sum2.append(sum2[i-1]+a2[i])
ans=0
sum2.insert(0,0)
for i in range(n):
    now=sum1[i]+(sum2[-1]-sum2[i])
    if ans<now:
        ans=now
print(ans)

Measured memory_bytes: 3064
// Problem : C - Traveling Salesman around Lake
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <cstdio>
#include <algorithm>
using namespace std;
int a[200005];
int main()
{
 int k,n,ans=0;
 scanf("%d%d",&k,&n);
 for(int i=1;i<=n;i++)
  scanf("%d",&a[i]);
 a[n+1]=a[1]+k;
 for(int i=1;i<=n;i++)
  ans=max(ans,a[i+1]-a[i]);
 printf("%d\n",k-ans);
 return 0;
}

Measured memory_bytes: 1024
N,C = map(int,input().split())
ST = []
for _ in range(N):
  s,t,c = map(int,input().split())
  ST.append([s,0,c])
  ST.append([t,1,c])
ST.sort(key=lambda x:x[0])
ST.sort(key=lambda x:x[2])
for i in range(len(ST)-1):
  if ST[i][2]==ST[i+1][2] and ST[i][0]==ST[i+1][0]:
    ST[i][1]=2
    ST[i+1][1]=2

ST.sort(key=lambda x:x[1])
ST.sort(key=lambda x:x[0])

ans =[0]
for st in ST:
  if st[1]==0:
    ans.append(ans[-1]+1)
  elif st[1]==1:
    ans.append(ans[-1]-1)
print(max(ans))



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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のランク

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] =rx;
           //if(rnk[rx] == rnk[ry]) {
               //rnk[rx]++;
            rnk[rx] += rnk[ry];
           //}
       }
   }
   long long int size(long long int x){
       return rnk[root(x)];
   }

};

int main(){
    
    int n, m, k, a, b;
    cin >> n >> m >> k;
    vector<set<int> > s(n);
    int ans[n];
    UnionFind uf(n);
    
    for(int i=0;i<m;i++){
        cin >> a >> b;
        s[a-1].insert(b-1);
        s[b-1].insert(a-1);        
        uf.unite(a-1, b-1);
        //cout << uf.same(0, i) << endl;
    }

    for(int i=0;i<k;i++){
        cin >> a >> b;
        if(!uf.same(a-1, b-1)) continue;
        s[a-1].insert(b-1);
        s[b-1].insert(a-1);
        
    }
    
    for(int i=0;i<n;i++){
        int size = uf.size(i);
        int ssize = s[i].size();
        cout << size-1-ssize;
        if(i==(n-1)) cout << endl;
        else cout << " ";
        
        
    }

}   


Measured memory_bytes: 28348