akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll n,m;cin>>n>>m;
	ll out;
	if (n==1 && m==1) {
		out=1;
	} else if (n==1) {
		out=max(0,(int)m-2);
	} else if (m==1) {
		out=max(0,(int)n-2);
	} else {
		out=(m-2)*(n-2);
	}

	cout<<out;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			TreeMap<String, List<Integer>> m = new TreeMap<>();
			for(int i = 0; i < q; i++) {
				int query = sc.nextInt();
				Iterator<Integer> valueItr;
				switch(query) {
				case 0:
					String key = sc.next();
					if(!m.containsKey(key)) {
						m.put(key, new ArrayList<Integer>());
					}
					m.get(key).add(sc.nextInt());
					break;
				case 1:
					valueItr = m.getOrDefault(sc.next(), new ArrayList<Integer>()).iterator();
					if(valueItr.hasNext()) {
						System.out.println(valueItr.next());
						while(valueItr.hasNext()) {
							System.out.println(valueItr.next());
						}
					}
					break;
				case 2:
					m.remove(sc.next());
					break;
				case 3:
					Map<String, List<Integer>> sub = m.subMap(sc.next(), true, sc.next(), true);
					for(Map.Entry<String, List<Integer>> entry: sub.entrySet()) {
						valueItr = entry.getValue().iterator();
						if(valueItr.hasNext()) {
							System.out.println(String.format("%s %d", entry.getKey(), valueItr.next()));
							while(valueItr.hasNext()) {
								System.out.println(String.format("%s %d", entry.getKey(), valueItr.next()));
							}
						}
					}
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 331420
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    bool jud = true;
    ll ans = 0;
    ll modifier = 1002003004;

    rep(i,n){
        ll a, b; cin >> a >> b;
        if(a != b) jud = false;
        ans += a;

        if(a > b){
            modifier = min(modifier, b);
        }
        
    }

    if(jud) cout << 0 << endl;

    else{
        cout << ans - modifier << endl;
    }
    
}

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

#define INF 1e9
using namespace std;

int main() {

    int N, K; cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }

    int ans = INF;
    int t = INF;
    for (int i = 0; i < N-K+1; ++i) { //N-K+1通りで全探索
        t = min(abs(x[i+K-1] - x[i]) + abs(x[i+K-1]), abs(x[i+K-1] - x[i]) + abs(x[i]));
        ans = min(t, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
N, M, C = map(int, input().split())
R = 10**18
X = []
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(2**N):
    c = 0
    Y = [0] * M
    ct = 0
    for _ in range(N):
        if i%2:
            cc, y = X[c][0], X[c][1:]
            for j in range(M):
                Y[j] += y[j]
            ct += cc
        c += 1
        i = i//2
        for j in range(M):
            if Y[j] < C:
                break
        else:
            R = min(ct, R)
if R < 10**18:
    print(R)
else:
    print(-1)


Measured memory_bytes: 68840
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int n;
    cin >> n;
    vei a(n+1);
    a[0] = 0;
    a[1] = 0;
    for(int i=2;i<=n;i++){
        cin >> a[i];
    }

    vei num(n,0);
    for(int i = 2; i<=n;i++){
        num[a[i]-1]++;
    }
    REP(i,n){
        cout << num[i] << endl;
    }

}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int main() {
  
  int n, a, b, passed = 0, bc = 0; cin >> n >> a >> b;
  string s; cin >> s;
  
  for(int i = 0; i < n; i++) {
    if(s.at(i) == 'a') {
      if(passed < a + b) {
        cout << "Yes" << endl;
        passed++;
      }
      else {
        cout << "No" << endl;
      }
    }
    if(s.at(i) == 'b') {
      bc++;
      if(passed < a + b && bc <= b) {
        cout << "Yes" << endl;
        passed++;
      }
      else {
        cout << "No" << endl;
      }
    }
    if(s.at(i) == 'c') {
      cout << "No" << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

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

  for (int i = 0; i < 5; i++) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3600
n,m,l=map(int,input().split())
a=list()
b=list()
for i in range(n):
    x=list(map(int,input().split()))
    a.append(x)
for i in range(m):
    y=list(map(int,input().split()))
    b.append(y)
for i in range(n):
    line=list()
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=a[i][k]*b[k][j]
        line.append(sum)
    print(" ".join(list(map(str,line))))



Measured memory_bytes: 6248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

int main(){
    int H,W;
    cin>>H>>W;
    char maze[H][W];
    rep(i,H){
        rep(j,W){
            cin>>maze[i][j];
        }
    }

    queue<pair<int,int>> que;
    rep(i,H){
        rep(j,W){
            d[i][j]=INF;
            if(maze[i][j]=='#'){
                que.push(make_pair(i,j));
                d[i][j]=0;
            }
        }
    }
    
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            ans=max(ans,d[i][j]);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 16108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int now = 1;
  int cnt = 0;
  vector<int> streak;
  for (int i=0; i<n; i++) {
    if (s[i] == (char)('0' + now)) cnt++;
    else {
      streak.push_back(cnt);
      now = 1-now;
      cnt = 1;
    }
  }
  if (cnt != 0) streak.push_back(cnt);
  if (streak.size()%2 == 0) streak.push_back(0);
  vector<int> sum(streak.size()+1);
  for (int i=0; i<streak.size(); i++) {
    sum[i+1] = sum[i]+streak[i];
  }
  int width = 2*k +1;
  int ans = 0;
  for (int i=0; i<sum.size(); i+=2) {
    int left = i;
    int right = min(left+width, (int)(sum.size())-1);
    ans = max(ans, sum[right]-sum[left]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x;
  cin>>a>>b>>x;
  bool ok=false;
  if(x>=a){
    if(x-a<=b){
      ok=true;
    }
  }
  if(ok){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}
      


Measured memory_bytes: 256
n, k = map(int, input().split())

"""
a+b = K i
b+c = K j
c+a = K k
2(a+b+c) = K(i+j+k)

k%2=0ならば,
a+b+cはk//2の倍数でなければならない、かつ、差を取ると結局a,b,cがそれぞれk//2の倍数
でなければならい。それでa+b,b+c,c+dはｋの倍数だから、a,b,cはすべて偶数またはすべて奇数
でなければならない。

それ以外の場合、
a+b+cがkの倍数である必要があり、かつ差を取ると結局a,b,cがすべてkの倍数でなければ
ならない。
"""

if k%2==0:
    k//=2
    a = n//k
    even = a//2
    if a%2==0:
        odd = even
    else:
        odd = even+1
    ans = even**3 + odd**3
else:
    ans = (n//k)**3
print(ans)



Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000000001

using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

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


int main(){
	int i[100];
	int p=-1;
	int in;
	while(cin >> in){
		if(in==0){
			cout << i[p] << endl;
			p--;
		}
		else{
			p++;
			i[p]=in;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int x = Integer.parseInt(in.next());
            int y = Integer.parseInt(in.next());
            long ans = 0;

            if (n > k) {
                ans = (n - k) * y;
                ans += k * x;
            } else {
                ans += n * x;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
struct activity{
	int A;
	int B;
	int C;
};
int maxhap(vector<activity>v,int n){
	int dp[n+1][3];
	dp[1][0]=v[1].A;
	dp[1][1]=v[1].B;
	dp[1][2]=v[1].C;
	
	for(int i=2;i<=n;i++){
		dp[i][0]=v[i].A +max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=v[i].B +max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=v[i].C +max(dp[i-1][0],dp[i-1][1]);
		
	}
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
	
}
int main(){
	int n;
	cin>>n;
	vector<activity>v(n+1);
	for(int i=1;i<=n;i++){
		cin>>v[i].A;
		cin>>v[i].B;
		cin>>v[i].C;
	}
//		for(int i=1;i<=n;i++){
//		cout<<v[i].A;
//		cout<<v[i].B;
//		cout<<v[i].C;
//		cout<<endl;
//	}
	cout<<maxhap(v,n)<<endl;
	return 0;
}

Measured memory_bytes: 3712
import collections
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for _ in range(k):a,b=map(int,input().split());u(d,a-1,b-1)
for _ in range(l):a,b=map(int,input().split());u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in range(n)];c=collections.Counter(p);print(*[c[p[i]]for i in range(n)])

Measured memory_bytes: 44392
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long c=sc.nextLong();
		long x[] = new long[n];
		long v[] = new long[n];
		for(int i=0; i<n; i++) {
			x[i]=sc.nextLong();
			v[i]=sc.nextLong();
		}

		long left[]=new long[n+1];
		long leftback[] = new long[n+1];
		long lsum=0;
		for(int i=0; i<n; i++) {
			left[i+1]= Math.max(left[i], lsum+v[n-1-i]-(c-x[n-1-i])) ;
			leftback[i+1]= Math.max(leftback[i], lsum+v[n-1-i]-2*(c-x[n-1-i])) ;
			lsum += v[n-1-i];
		}

		long right[]=new long[n+1];
		long rightback[]=new long[n+1];
		long rsum=0;
		for(int i=0; i<n; i++) {
			right[i+1]= Math.max(right[i],rsum+v[i]-x[i]) ;
			rightback[i+1]= Math.max(rightback[i], rsum+v[i]-2*x[i]) ;
			rsum += v[i];
		}

		long max = 0;
		for(int i=0; i<=n; i++) {
			max = Math.max(max, Math.max(leftback[i]+right[n-i], rightback[i]+left[n-i])) ;
		}
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 87532
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


const int mx = 1e5+123;
int cnt[mx];
bool vis[mx];

int main()
{
    optimize();

    int n, m, pa = 0, sol = 0;
    cin >> n >> m;

    for ( int i = 1; i <= m; i++ ) {
        int p;
        string ver;
        cin >> p >> ver;
        if ( ver == "AC" ) vis[p] = 1;
        if ( !vis[p] ) cnt[p]++;
    }

    for ( int i = 1; i <= n; i++ ) {
        sol += vis[i];
        if ( vis[i] ) pa += cnt[i];
    }

    cout << sol << " " << pa << endl;


    return 0;
}



















Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2018/09/09/015414
int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> x(M), y(M);
    // 1番目の箱には赤いボールが1 個入っています。 また、 2 ～ N
    ///番目の箱には白いボールが 1 個ずつ入っています。
    REP(i, M) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    vector<ll> cnt(N, 1);
    vector<bool> flag(N, false);
    flag[0] = true;
    REP(i, M) {
        cnt[x[i]]--;
        cnt[y[i]]++;
        if(flag[x[i]]) {
            flag[y[i]] = true;
        }
        if(cnt[x[i]] == 0) {
            flag[x[i]] = false;
        }
    }
    ll res = 0;
    REP(i, N) {
        if(flag[i]) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end

h,a=get_i
puts (h%a).zero? ? h/a : h/a+1

Measured memory_bytes: 3836
n, m = [ int(v) for v in input().split() ]
ball_list = [1 for i in range(n)]
ball_list_2 = [1 for i in range(n)]
ball_list[0] = 2

for i in range(m):
    x, y = [ int(v)-1 for v in input().split() ]
    
    if ball_list[x] == 1:
        if ball_list[y] in [0,1]:
            ball_list[y] = 1
        else:
            ball_list[y] = 3
    elif ball_list[x] == 2:
        if ball_list[y] in [0,2]:
            ball_list[y] = 2
        else:
            ball_list[y] = 3
    elif ball_list[x] == 3:
        ball_list[y] = 3
    
    ball_list_2[y] += 1
    ball_list_2[x] -= 1
    if ball_list_2[x] == 0:
        ball_list[x] = 0
    
print(sum([ 1 for i in ball_list if i > 1]))

Measured memory_bytes: 55384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;

int main(){
    int i,tmp,res;
    int n,k,q;
    vector<int> a,np;
    cin >> n >> k >> q;
    pb(int,a,q);
    np = vector<int>(n);
    forN(i,q){
        np[a[i]-1]++;
    }
    tmp = q-k+1;
    forN(i,n){
        cout << (tmp<=np[i]?"Yes":"No") << endl;
    }
}

Measured memory_bytes: 1528
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

struct Edge{
	int to;
	int weight;
	
	Edge(int _to, int _w) : to(_to), weight(_w){}
	Edge() : to(-1), weight(-1){}
};

const int MAXN = 10;
const int INF = 0x3f3f3f3f;
int dist[MAXN];
bool isVis[MAXN];
int E, N;
vector<Edge> graph[MAXN];
vector<pair<int ,int> > dists;

struct cmp{
	bool operator() (int a, int b){
		return dist[a] > dist[b];
	}
};

void clearV(){
	for(int i = 0; i < MAXN; ++i){
		graph[i].clear();
	}
}

void init(){
	clearV();
	dists.clear();
	N = 0;
	for(int i = 0; i < E; ++i){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		graph[a].push_back(Edge(b, c));
		graph[b].push_back(Edge(a, c));
		if(a > N) N = a;
		if(b > N) N = b;
	}
}

int dijkstra(int s){
	
	fill(isVis, isVis + MAXN, false);
	fill(dist, dist + MAXN, INF);
	dist[s] = 0;
	
	for(int i = 0; i <= N; ++i){
		
		int u = -1, MIN = INF;
		for(int j = 0; j <= N; ++j){
			if(dist[j] < MIN && isVis[j] == false){
				u = j;
				MIN = dist[j];
			}
		}
		isVis[u] = true;
		if(u == -1) break;
		
		for(int j = 0; j < graph[u].size(); ++j){
			Edge nowEdge = graph[u][j];
			if(dist[nowEdge.to] > dist[u] + nowEdge.weight){
				dist[nowEdge.to] = dist[u] + nowEdge.weight;	
			}
		}
	}
	
	int sum = 0;
	for(int i = 0; i <= N; ++i){
		if(dist[i] != INF){
			sum += dist[i];
		}
	}
	
	return sum;
}

int main(){
	while(scanf("%d", &E) && E){
		init();
		int optimum = INF;
		int index = 0;
		for(int i = 0; i <= N; ++i){
			int sum = dijkstra(i);
			if(sum < optimum){
				optimum = sum;
			}
			dists.push_back(pair<int, int>(i, sum));
		}
		
		int ans = INF;
		for(int i = 0; i <= N; ++i){
			if(dists[i].second == optimum && i < ans){
				ans = i;
			}
		}
		printf("%d %d\n", ans, optimum);
	}
}


Measured memory_bytes: 2712
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e5 + 123;
const int M = 1e5 + 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
int mod = 1e9 + 7;
const ld eps = 1e-12;
const int Sz = 350;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N];

int main() {
 // srand(time(0));
  #ifdef wws
    freopen("in", "r", stdin);
  //  freopen("out", "w", stdout); 
  #endif 
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0;i < n;i++) {
    cin >> a[i];
    a[i]--;
  }
  sort(a, a + n);
  reverse(a, a + n);
  int c = 0;
  while(c + 1 < n && a[c + 1] >= c + 1) c++;
  int x = a[c] - c;
  int y = 0;
  for (int i = c + 1;i < n;i++) if (a[i] >= c) y++;
  if (x % 2 || y % 2) cout << "First\n";
  else cout << "Second\n"; 
  return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    s[ 5] = ' ';
    s[13] = ' ';

    cout << s << endl;

    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 16050, M = 8010;

int n, x, y;
char s[M];
set<int> fx[2], fy[2];
vector<int> X, Y;

int main()
{
	scanf("%s%d%d", s, &x, &y);
	n = strlen(s);
	
	for (int i = 0, t = 0; i < n; i ++ , t ^= 1)
	{
		int j = i;
		while (j < n && s[j] != 'T') j ++ ;
		
		if (!t) X.push_back(j - i);
		else Y.push_back(j - i);
		i = j;
	}
	
	int tx = 0;
	if (X.size()) fx[tx].insert(X[0] + M);
	else fx[tx].insert(M);
	for (int i = 1; i < X.size(); i ++ )
	{
		tx ^= 1, fx[tx].clear();
		for (auto u : fx[tx ^ 1])
		{
			fx[tx].insert(u + X[i]);
			fx[tx].insert(u - X[i]);
		}
	}
	
	int ty = 0;
	fy[ty].insert(M);
	for (int i = 0; i < Y.size(); i ++ )
	{
		ty ^= 1, fy[ty].clear();
		for (auto u : fy[ty ^ 1])
		{
			fy[ty].insert(u + Y[i]);
			fy[ty].insert(u - Y[i]);
		}
	}
	
	if (fx[tx].count(x + M) && fy[ty].count(y + M)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s string
	var K int
	fmt.Scan(&s, &K)

	N := len(s)

	L := make([]string, 5*N)

	for i := 1; i <= K; i++ {
		for j := 0; j <= N-i; j++ {
			L = append(L, s[j:j+i])
		}
	}
	sort.Strings(L)

	index, cnt := 0, 0
	for cnt < K {
		if L[index+1] != L[index] {
			cnt++
		}
		index++
	}
	fmt.Println(L[index])
}


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

int	main() {
	int N, x;
	cin >>N;
	cin >>x;
	int a;
	long S=0;
	cin >>a;
	for (int i=1; i<N; i++) {
		int b;
		cin >>b;
		if (a>=x) {
			S +=a+b-x;
			a=0;
		} else if (a+b>x) {
			S +=a+b-x;
			a=x-a;
		} else {
			a=b;
		}
	}
	cout <<S <<endl;
	return 0;
};


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

int main () {
    int n;
    string ans = "Three";
    cin >> n;
    for (int i=0; i<n; i++) {
        string k;
        cin >> k;
        if (k=="Y") {
            ans = "Four";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = []
for i in range(h):
    a = str(input())
    if a == '.'*w:
        continue
    else:
        A.append(a)

non_use = set()
for i in range(w):
    flag = True
    for j in range(len(A)):
        if A[j][i] == '#':
            flag = False
            break
    if flag:
        non_use.add(i)

ans = []
for i in range(len(A)):
    temp = ''
    for j in range(w):
        if j in non_use:
            continue
        else:
            temp += A[i][j]
    ans.append(temp)

for s in ans:
    print(s)


Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};



void solve(){

    ll n,W;
    cin>>n>>W;

    ll weight[n];
    ll value[n];

    rep(i,n){
        cin>>weight[i]>>value[i];
    }

    ll dp[2][W+1];
    dp[0][0]=0;
    dp[1][0]=0;

    repA(i,1,W)
    dp[0][i]=0;
    ll row = 0;
    repA(i,1,n){
        repA(j,1,W){
            dp[row^1][j] = dp[row][j];
            if(weight[i-1]<=j){
                dp[row^1][j]=max(dp[row^1][j],dp[row][j-weight[i-1]]+value[i-1]);
            }
        }
        row=row^1;
    }
    ll ans = dp[row][W];
    db1(ans);
}
int main(){ 



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





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

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct edge {
    int u;
    int v;
    int w;
};

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

    map<int, vector<pair<int, int>>> uv;
    //    map<int, vector<pair<int, int>>> vu;

    int E = N - 1;
    for (int i = 0; i < E; i++) {
        int u, v, w;
        cin >> u;
        cin >> v;
        cin >> w;
        u--;
        v--;
        w = (w % 2 == 0) ? 2 : 1;
        uv[u].push_back(pair<int, int>(v, w));
        uv[v].push_back(pair<int, int>(u, w));
        //        vu[v].push_back(pair<int, int>(u, w));
    }

    vector<int> colors(N);
    for (int i = 0; i < N; i++) {
        colors[i] = -1;
    }
    colors[0] = 1;

    stack<int> nodeids;
    nodeids.push(0);
    while (!nodeids.empty()) {
        int nod = nodeids.top();
        nodeids.pop();
        for (auto e : uv[nod]) {
            int v = e.first;
            int w = e.second;
            if (colors[v] == -1) {
                if (w == 2) {
                    colors[v] = colors[nod];
                } else {
                    colors[v] = 1 - colors[nod];
                }
                nodeids.push(v);
            }
        }
        // for (auto e : vu[nod]) {
        //     int u = e.first;
        //     int w = e.second;
        //     if (colors[u] == -1) {
        //         if (w == 2) {
        //             colors[u] = colors[nod];
        //         } else {
        //             colors[u] = 1 - colors[nod];
        //         }
        //         nodeids.push(u);
        //     }
        // }
    }
    for (int i = 0; i < N; i++) {
        cout << colors[i] << endl;
    }
}


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

using namespace std;

struct Edge {
	int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
	int k = 1;
	for (int i = 0; i < g[v].size(); i++) {
		int u = g[v][i].to, ei = g[v][i].id;
		if (u == p) {
			continue;
		}
		if (k == c) {
			k++;
		}
		ans[ei] = k;
		k++;
		dfs(u, ans[ei], v);
	}
}

int main(int argc, char *argv[])
{
	int N;

	cin >> N;

	g.resize(N);
	ans.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back((Edge) {b, i});
		g[b].push_back((Edge) {a, i});
	}
	dfs(0);

	int mx = 0;
	for (int i = 0; i < N; i++) {
		mx = max(mx, int(g[i].size()));
	}
	cout << mx << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 8320
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
ll a[N];
map<ll,ll>m;
map<ll,ll>::iterator it;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll i,j,x,y,n,ans=-1;
	sc(n);
	for(i=1;i<=n;i++){
		sc(a[i]);
		m[a[i]]++;
	}
	it=m.end();
	it--;
	j=-1;
	x=-1;
	for(;it!=m.begin();it--){
		j=it->second;
		//cout<<j<<" \n";
		if(j>=2){
			x=it->first;
			//cout<<x<<" \n";
			break;
		}
	}
	if(x==-1){
		printf("0\n");
		return 0;
	}
	if(j>=4){
		ans=x*x;
		pr(ans);
		return 0;
	}
	it--;
	j=-1;
	y=-1;
	//cout<<" \n\n";
	for(;;it--){
		j=it->second;
		//cout<<j<<" \n";
		if(j>=2){
			y=it->first;
			break;
		}
		if(it==m.begin())break;
	}
	if(y==-1){
		printf("0\n");
		return 0;
	}
	ans=x*y;
	pr(ans);

}

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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var dict = new Dictionary<char, int>();

        for (int i = 0; i < n; i++)
        {
            var c = Console.ReadLine()[0];
            switch (c)
            {
                case 'M':
                case 'A':
                case 'R':
                case 'C':
                case 'H':
                    if (dict.ContainsKey(c))
                    {
                        dict[c]++;
                    }
                    else
                    {
                        dict[c] = 1;
                    }
                    break;
            }
        }

        var d = dict.Values.ToArray();
        var ans = dfs(0, 3, d);
        Console.WriteLine(ans);
    }

    static long dfs(int i, int n, int[] d)
    {
        if (n == 0)
        {
            return 1;
        }
        var ans = 0L;
        for (; i <= d.Length - n; i++)
        {
            ans += d[i] * dfs(i + 1, n - 1, d);
        }
        return ans;
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int a,b,h;
    cin >> a >> b >> h;

    cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int x,a,b;
  cin >> x >> a >> b;
  int ans = 0;
  cout << (x-a)%b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP1(u) for(int i=hd[u],v,c;v=e[i].v,c=e[i].c,i;i=e[i].n)  
#define REP2(u) for(int&i=cr[u],v,c;v=e[i].v,c=e[i].c,i;i=e[i].n)  
using namespace std;
const int N=200200,M=1000100,INF=1000010000;
int n,m,x,S,T,mxf,fl=1;
int hd[N],cr[N],lk[N],vi[N],fa[N],X[N],Y[N],dep[N];
queue<int>q;
vector<int>ve[N];
struct edge{int n,v,c;}e[M];
void add_(int u,int v,int c){e[++fl]=(edge){hd[u],v,c};hd[u]=fl;}
void adde(int u,int v){add_(u,v,1),add_(v,u,0);}
bool bfs(){
	FOR(i,S,T) dep[i]=-1,cr[i]=hd[i];
	q.push(S);dep[S]=0;
	while(q.size()){
		int u=q.front();q.pop();
		REP1(u)if(c && dep[v]<0)
			dep[v]=dep[u]+1,q.push(v);
	}
	return dep[T]>0;
}
int dfs(int u,int E){
	if(u==T) return E;
	int F=0;
	REP2(u)if(c && dep[v]==dep[u]+1){
		int t=dfs(v,min(E,c));
		F+=t,e[i^1].c+=t;
		E-=t,e[i^0].c-=t;
		if(!E) break;
	}
	return F;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,2,n){
		scanf("%d",&m);
		while(m--){
			scanf("%d",&x);
			ve[x].push_back(i+n-1);
			if(x>1) adde(x,i+n-1);
		}
	}
	S=1;T=n<<1;
	FOR(i,2,n) adde(S,i),adde(i+n-1,T);
	while(bfs()) mxf+=dfs(S,INF);
	if(mxf<n-1) return puts("-1"),0;
	FOR(x,2,n)REP1(x)if(v>S && !c) lk[v]=x;
	q.push(1);
	while(q.size()){
		int u=q.front(),w;q.pop();
		for(int v:ve[u])if(!vi[w=lk[v]])
			vi[w]=1,fa[w]=u,X[v]=u,Y[v]=w,q.push(w);
	}
	FOR(i,2,n)if(!fa[i]) return puts("-1"),0;
	FOR(i,2,n) cout<<X[i+n-1]<<' '<<Y[i+n-1]<<'\n';
} 

Measured memory_bytes: 30592
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second                                                                                                                                                                                                                                                                                                                
#define f first
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a,b;
    cin>>a>>b;
    cout<<6-(a+b)<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc114_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int years = int.Parse(Console.ReadLine());
            if (years == 3 || years == 5 || years == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
const int MAXN = 2e5+5 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
int a[MAXN] ;
int dist[MAXN] ;
bool visited[MAXN] ;
int loopPoint ;
vector<int> steps ;
void dfs(int node,int parent)
{
    if(visited[node]) 
    {
        loopPoint = dist[node] ;
        return ;
    }
    visited[node] = true ;
    steps.pb(node) ;
    dist[node] = dist[parent]+1 ;
    dfs(a[node],node) ;
}
int main()
{
    fio ;
    /* ======================Start of code ================ */
    ll n,k;cin>>n>>k ;
    f(i,1,n+1) cin>>a[i] ;
    dist[0] = -1 ;
    dfs(1,0); 
    int basePos = loopPoint ;
    if(k<=basePos) return cout<<steps[k]<<"\n",0 ;
    k-=basePos ;
    int loopSize = steps.size()-basePos ;

    cout<<steps[(int)(k%loopSize)+basePos]<<"\n" ;
    /* ======================End of code ================== */
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int x;cin >>x;
   int ans=10-x/200;
   cout <<ans <<endl;
}


Measured memory_bytes: 3632
X,N = map(int,input().split())
p = list(map(int, input().split())) 

ans = X

for i in range(N+1):
    a = X+i
    b = X-i
    if b not in p:
        ans = b
        break
    elif a not in p:
        ans = a
        break

print(ans)


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
struct node{int s[6],len;}a[5000*5+1];
int n,k,cnt;
char ch[5005];
bool cmp(node a,node b)
{
	int x=min(a.len,b.len);
	for(int i=0;i<x;i++)
	if(a.s[i]<b.s[i])return 1;
	else if(a.s[i]>b.s[i])return 0;
	return a.len<b.len;
}
bool bdy(node a,node b)
{
	if(a.len!=b.len)return 1;
	for(int i=0;i<a.len;i++)
	if(a.s[i]!=b.s[i])return 1;
	return 0;
}
int main()
{
	scanf("%s",ch);
	n=strlen(ch);
	for(int i=0;i<n;i++)
	for(int j=i;j<min(n,i+5);j++)
	{
		a[++cnt].len=j-i+1;
		for(int k=i;k<=j;k++)a[cnt].s[k-i]=ch[k]-'a';
	}
	sort(a+1,a+cnt+1,cmp);
	scanf("%d",&k);
	int cnt=1,p=1;
	while(cnt!=k)
	{
		p++;
		if(bdy(a[p],a[p-1]))cnt++;
	}
	for(int i=0;i<a[p].len;i++)printf("%c",(char)(a[p].s[i]+'a'));
	printf("\n");
}

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

int main(){
    int x;
    cin >> x;
    double ans=0;
    for(int i=1;i*i<=x;i++){
       for(int j=2;j<=10;j++){
           if(pow(i,j)<=x){
               ans=max(ans,pow(i,j));
           }
       }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;cin>>k;
  ll rem=k%50;
  lvector ans(50,0);rep(i,50) ans[i]+=i+(k-rem)/50;
  rep(i,rem) {
    ans[i]+=50;
    rep(j,50) if(j!=i) ans[j]-=1;
  }
  print(50);
  rep(i,49) cout<<ans[i]<<' ';print(ans[49]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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;}
int const INF = 1 << 30;


int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    string res = "No";
    rep(i,n) {
        int x,y;
        cin >> x >> y;
        if(x == y) cnt++;
        else cnt = 0;

        if(cnt == 3) {
            res = "Yes";
        }
    }

    cout << res << endl;
    return 0;
}

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

int main(){
    ll N; cin>>N;
    ll t=N,dig=0;
    while(t!=0){
        dig+=t%10;
        t/=10;
    }
    //cout<<dig<<endl;
    if(N%dig==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

    

Measured memory_bytes: 256
N = int(input())
Carry = []
for i in range(5):
    Carry.append(int(input()))
min_num = min(Carry)
if N < min_num:
    print(5)
elif min_num == 1:
    print((N//min_num)+4)
elif N % min_num == 0:
    print((N//min_num))
else:
    print((N//min_num)+5)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//








int main(){


        string s;
        cin >> s;

        if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
        else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes" << endl;
        else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;














}

























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

int main() {
  int n;
  cin >> n;
  double sum = 0;
  
  for(int i = 0; i < n; i++){
    double a;
    cin >> a;
    sum += 1 / a;
  }

  cout << 1 / sum << endl;
}

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int a[26] = {0};
	for (int i = 0; i < S.length(); ++i){
		++a[(int)(S[i] - 'a')];
	} // end for

	int sum = 0;
	for (int i = 0; i < 26; ++i){
		sum += a[i] % 2;
	} // end for
	cout << sum / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 3208
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# grobalにmdを設定すること
class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10**9+7

def main():
    n,k=MI()
    dp=[mint(0) for _ in range(k+1)]
    for a in range(k,0,-1):
        dp[a]+=pow(k//a,n,md)
        for b in range(2*a,k+1,a):
            dp[a]-=dp[b]
    ans=0
    for a in range(1,k+1):
        ans+=dp[a]*a
    print(ans)

main()

Measured memory_bytes: 82388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A == 1 || B == 1 | C == 1 || D == 1)
        if(A == 9 || B == 9 | C == 9 || D == 9)
            if(A == 7 || B == 7 | C == 7 || D == 7)
                if(A == 4 || B == 4 | C == 4 || D == 4){
                    cout << "YES" << "\n";
                    return 0;
                }
    cout << "NO" << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<s.size();i++)ans += s[i]-'0';
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC165
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
//#define __DBG__

using Graph = vector<vector<int>>;


void solve(void){
  
  int N, M;
  
  cin >> N >> M;
  
  vector<int> H(N,0);
  
  Graph G(N);
  
  REP(i,N){
    cin >> H[i];
  }
  
  REP(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int ans=0;
  REP(i,N){
    bool flag=1;
    REP(j,G[i].size()){
      if(H[G[i][j]]>=H[i]){
        flag=0;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  
  cout << ans << endl;
  return;
}



#define TESTCASES 1

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




Measured memory_bytes: 8744
from itertools import permutations as pm
n = int(input())
p = [tuple(map(int,input().split())) for _ in range(n)]
def dist(i,j):
    return ((p[i][0]-p[j][0])**2 + (p[i][1]-p[j][1])**2)**(0.5)
ans = 0
m = 0
for l in pm(range(n),n):
    m += 1
    s = 0
    for i in range(n-1):
        s += dist(l[i],l[i+1])
    ans += s
print(ans/m)

Measured memory_bytes: 3064
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0

for i in range(N):
    for k in range(1, min(K+1, N-i)):
        if i + k <= N - 1:
            dp[i + k] = min(dp[i + k], dp[i] + abs(h_list[i + k] - h_list[i]))
print(dp[N - 1])


Measured memory_bytes: 55136