akhauriyash/Code-Regression huggingface dataset:
import bisect
A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]
inf = [10**13, -10**13]
s = sorted(s+inf)
t = sorted(t+inf)

for i in range(Q):
    s_r = s[bisect.bisect_right(s, x[i])]
    s_l = s[bisect.bisect_left(s, x[i])-1]
    t_r = t[bisect.bisect_right(t, x[i])]
    t_l = t[bisect.bisect_left(t, x[i])-1]
    long = sorted([abs(t_r-s_r)+s_r-x[i], abs(t_l-s_r)+s_r-x[i], abs(t_l-s_l)+x[i]-s_l, abs(t_r-s_l)+x[i]-s_l,
     abs(s_r-t_r)+t_r-x[i], abs(s_l-t_r)+t_r-x[i], abs(s_r-t_l)+x[i]-t_l, abs(s_l-t_l)+x[i]-t_l])
    print(long[0])

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++) ans = (ans+v[i])/2;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int eq = 0;
		int min = Integer.MAX_VALUE;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt(), b = sc.nextInt();
			if (a > b)
				min = Math.min(min, b);
			if (a == b)
				eq++;
			sum += a;
		}
		System.out.println(eq == n ? 0 : sum - min);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 34512
import itertools

n = int(input())
town = [list(map(int, input().split())) for _ in range(n)]
x = 1
for i in range(1, n+1):
    x *= i
l = []
for j in range(n):
    l.append(j)
ans = 0
for a in itertools.permutations(l, n):
    newl = a
    length = 0
    for b in range(n-1):
        length += ((town[newl[b]][0] - town[newl[b+1]][0])**2 + (town[newl[b]][1] - town[newl[b+1]][1])**2)**(1/2) 
    ans += length
print(ans/x)

Measured memory_bytes: 9448
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define mian() main()
#define greater greater<int>()
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
using Graph=vector<vector<P> >;
int main(){
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){cout<<"OK"<<endl;return 0;}
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3584
K = int(input()) # 数字を変数に格納

L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[K-1])

Measured memory_bytes: 3060
#include <iostream>

int main() {
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;
  if ((r > x) // overlap left
      || (r > y) // overlap bottom
      || (r + x > W) // overlap right
      || (r + y > H) // overlap top
     )
    std::cout << "No\n";
  else std::cout << "Yes\n";
  return 0;
}


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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string pin;
  cin >> n;
  cin >> pin;
  int l = pin.length();
  int digits[l];
  int digits_mem[l];
  int appear_check[10];
  for(int i = 0; i < 10; i++) {
    appear_check[i] = -1;
  }
  for(int i = 0; i < l; i++) {
    int digit = (int) (pin[i] - '0');
    digits[i] = digit;
    if(appear_check[digit] >= 0) {
      digits_mem[i] = appear_check[digit];
    } else {
      digits_mem[i] = -1;
    }
    appear_check[digit] = i;
  }


  int table[3][l];
  table[0][0] = 1;
  for(int i = 1; i < l; i++) {
    if(digits_mem[i] < 0) {
      table[0][i] = table[0][i - 1] + 1;
    } else {
      table[0][i] = table[0][i - 1];
    }
  }
  table[1][0] = 0;
  table[1][1] = 1;
  table[2][0] = 0;
  table[2][1] = 0;
  table[2][2] = 1;
  for(int j = 1; j <= 2; j++) {
    for(int i = (j + 1); i < l; i++) {
      if(digits_mem[i] < j) {
        table[j][i] = table[j][i - 1] + table[j - 1][i - 1];
      } else {
        int last_index = digits_mem[i];
        table[j][i] = table[j][i - 1] + table[j - 1][i - 1] - table[j - 1][last_index - 1];
      }
    }
  }
  cout << table[2][l - 1] << "\n";

  return 0;
}


Measured memory_bytes: 896
import math
a, b, h, m = map(int, input().split())
x = 360*(h/12)+30*(m/60)
y = 360*(m/60)
d = math.cos(math.radians(abs(x-y)))
z = a**2 + b**2 -2*a*b*d
print (math.sqrt(z))


Measured memory_bytes: 9572
#include<bits/stdc++.h>
#define ll int
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(i,x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 233333333
using namespace std;
/*---------------------------------------*/
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/
#define N 300011
ll n,a[N],ans=23333333;
char ch[N];
inline ll work(ll x){return (x-1)-a[x-1]+a[n]-a[x];}
int main(){
	in(n);
	scanf("%s",ch+1);
	Fur(i,1,n)a[i]=a[i-1]+(ch[i]=='E');
	Fur(i,1,n)ans=min(ans,work(i));
	outn(ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MAX 100005
#define endl "\n"
using namespace std;

vector<int> adj[MAX];
int dp[MAX];

int DFS(int u)
{
    if(~dp[u]) return dp[u];
    int mx=0;
    for(auto v: adj[u])
    {
        mx=max(mx, 1+DFS(v));
    }
    return dp[u]=mx;
}

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

    int n,m,i,ans=0;
    cin>>n>>m;

    for(i=0; i<m; ++i)
    {
        int xx,yy;
        cin>>xx>>yy;
        adj[xx].push_back(yy);
        //adj[yy].push_back(xx);
    }

    memset(dp, -1, sizeof dp);
    for(i=1; i<=n; i++)
        ans = max(ans, DFS(i));
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	ll ans = 0;
	ll now = 0;
	REP(i, n - 1){
		if(v[i+1] <= v[i])now++;
		else {
			ans = max(now, ans);
			now = 0;
		}
	}

	cout << max(ans, now) << endl;


	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int N,K,A=0; 
	
	scanf("%d %d",&N,&K);
	for (int i = 0; i < N; i++)
	{
		int h;
		scanf("%d", &h);
		if (h >= K) 
		{
			A++;
		}
	}
	printf("%d", A);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	reverse(all(a));
	int cnt = 0;
	ll ans = 0LL;
	rep(i, n){
		if(cnt == (n - 1)) break;
		if(!i) ans += a[i], cnt++;
		else{
			if(cnt == (n - 2)){
				cnt++;
				ans += a[i];
			}
			else cnt += 2, ans += 2 * a[i];
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4740
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	cnt := bsort(a)
	printarray(a)
	fmt.Println(cnt)
}
func printarray(a []int) {
	for i := 0; i < len(a); i++ {
		fmt.Printf("%d", a[i])
		if i != len(a)-1 {
			fmt.Printf(" ")
		}
	}
	fmt.Println()
}
func bsort(a []int) int {
	rcnt := 0
	for i := 0; i < len(a); i++ {
		for j := len(a) - 1; j > i; j-- {
			if a[j-1] > a[j] {
				a[j-1], a[j] = a[j], a[j-1]
				rcnt++
			}
		}
	}
	return rcnt
}



Measured memory_bytes: 1192
o = input()
e = input()
result = []
if len(o) == len(e):
    for i in range(len(o)):
        result.append(o[i]+e[i])
else:
    for i in range(len(o)-1):
        result.append(o[i]+e[i])
    result.append(o[-1])
print(''.join(result))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static List<int>[] v;
    static bool[] visited;
    static int n, ans;
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0];
	int m = tmp[1];

	v = new List<int>[n+1];
	for (int i = 1; i <= n; i++)
	{
	    v[i] = new List<int>();
	}
	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1];
	    v[a] .Add(b);
	    v[b] .Add(a);
	}

	ans = 0;
	visited = new bool[n+1];
	dfs(1, 1);
	WriteLine(ans);
    }

    static void dfs(int node, int depth)
    {
	if (depth == n){ ans++; return; }

	visited[node] = true;
	foreach (int next in v[node])
	{
	    if (!visited[next]){ dfs(next, depth+1); }
	}
	visited[node] = false;
	return;
    }
}


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

int x[100], y[100];
long h[int(1e2)];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, H, t = -1;
    bool ans;
    cin >> N;
    for(int n=0; n<N; n++){
        cin >> x[n] >> y[n] >> h[n];
        if(t == -1 && h[n] != 0)t = n;
    }
    for(int X=0; X<=100; X++){
        for(int Y=0; Y<=100; Y++){
            H = abs(X - x[t]) + abs(Y - y[t]) + h[t];
            //cout << X << " " << Y << " " << H << " ";
            ans = true;
            for(int n=0; n<N; n++){
                if(n == t)continue;
                else if(max(H - abs(X - x[n]) - abs(Y - y[n]), 0) != h[n]){
                    //cout << x[n] << y[n] << h[n] << "\n";
                    ans = false;
                    break;
                }
            }
            if(ans){
                cout << X << " " << Y << " " << H << "\n";
                return 0;
            }
        }
    }
    //return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define test(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	//test(t){}
		
	ll n,d;
	cin>>n>>d;
	ll x,y,sq;
	ll cnt=0;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		sq = x*x + y*y;
		if(d*d>=sq){
			cnt++;
		}
	}		
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3616
import itertools

n,m = map(int,input().split())

v = list(range(1,n+1))

edge = []
for i in range(m):
    a,b = map(int,input().split())
    edge.append((a,b))
    edge.append((b,a))
res = 0
for s in itertools.permutations(v):
    if s[0]!=1:
        continue
    flag = True
    for i in range(1,len(s)):
        if (s[i-1],s[i]) not in edge:
            flag =False
    if flag:
        res+=1   
print(res)


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

int main()
{
    string S; cin >> S;
    if (S[S.length()-1] == 's') {
        cout << S << "es" << endl;
    }
    else cout << S << "s" << endl;


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int n, T;
  cin >> n >> T;
  vi t(n);
  rep(i, n) cin >> t[i];
  int64_t x = 0;
  rep(i, n-1) {
    if (t[i+1] - t[i] <= T) {
      x += t[i+1] - t[i];
    }
    else {
      x += T;
    }
  }
  x += T;
  cout << x << endl;
}


Measured memory_bytes: 4048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            // 文字列の入力
            string s = Console.ReadLine();

            if(s == inputStrArray[0]) {
                inputLongArray[0]--;
            } else {
                inputLongArray[1]--;
            }

            Console.WriteLine($"{inputLongArray[0]} {inputLongArray[1]}");

            Console.Out.Flush();
        }
    }
}


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

ll com[51][51];

void init(){
  for (int i = 0; i < 51; i++) {
    com[i][0] = 1;
    com[i][i] = 1;
  }
  for (int j = 1; j < 51; j++) {
    for (int k = 1; k < j; k++) {
      com[j][k] = (com[j-1][k-1] + com[j-1][k]);
    }
  }
}

int main(){
  init();
  int n, a, b;
  cin >> n >> a >> b;
  ll v[n];
  rep(i,n){
    ll c;
    cin >> c;
    v[i] = -c;
  }
  sort(v,v+n);
  double ave = 0;
  rep(i,a) ave += -v[i];
  ave /= a;
  int s = upper_bound(v, v+n, v[a-1]) - lower_bound(v, v+n, v[a-1]);
  int u =  a - (lower_bound(v, v+n, v[a-1]) - v);
  ll ans = 0;
  if(v[0] != v[a-1]) ans = com[s][u];
  else {
    for(int i = a; i <= min(b,a+s-u); i++) ans += com[s][u+i-a];
  }
  printf("%.8f\n",ave);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int, input().split())
T,F=[[]for i in range(N)],[[]for i in range(N)]
for i in range(N-1+M):
  a,b=map(int, input().split())
  a-=1
  b-=1
  T[a].append(b)
  F[b].append(a)
  
for i in range(N):
  if len(F[i])==0:
    R=i
    break
    
ans=[-1]*N
ans[R]=0

from collections import deque
q=deque([])
q.append(R)
s=set()
while q:
  now=q.popleft()
  s.add(now)
  for i in T[now]:
    if ans[i]==-1:
      c=0
      for j in F[i]:
        if j not in s:
          c=1
          break
      if c==0:
        ans[i]=now+1
        q.append(i)
        
for i in ans:
  print(i)

Measured memory_bytes: 111968
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 10500;

int h, n;
int a[MAXN], b[MAXN];
long long dp[MAXN];

int main() { 

  scanf("%d %d", &h, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }

  dp[0] = 0;
  for (int i = 1; i <= h; i++) {
    dp[i] = -1;
    for (int j = 0; j < n; j++) {
      long long go = b[j];
      if (i - a[j] > 0) {
        go += dp[i - a[j]];
      }
      if (dp[i] == -1 || dp[i] > go) {
        dp[i] = go;
      }
    }
  }

  cout << dp[h] << endl;

  return 0;
}


Measured memory_bytes: 384
import bisect

n = int(input())
a = list(map(int, input().split()))
x = [i + 1 + a[i] for i in range(n)]
y = [i + 1 - a[i] for i in range(n)]
x.sort()
ans = 0
for i in y:
    ans += (bisect.bisect_right(x, i) - bisect.bisect_left(x, i))
print(ans)

Measured memory_bytes: 33752
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int answer = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int x = 0;
            int a = scan.nextInt();
            while (a % 2 == 0) {
                x += 1;
                a /= 2;
            }
            answer = Math.min(answer, x);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn line_to_vec_i32(line: &str) -> Vec<i32> {
  line
    .trim()
    .split_whitespace()
    .map(|s| { s.parse::<i32>().unwrap_or(0) })
    .collect()
}

fn main() {
  loop {
    let line = get_line();
    let mut v = line_to_vec_i32(&line);
    v.sort();
    if v[0] == 0 && v[1] == 0 {
      break;
    }
    else {
      println!("{} {}", v[0], v[1]);
    }
  }
}



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


//#define int long long 


struct DSU{
	vector <int> p, sz;
	DSU(int n) {
		p.resize(n + 1); sz.resize(n + 1, 1);
		for(int i = 1; i <= n; i++) {
			p[i] = i;
		}
	}
	int find(int x) {
		return p[x] = (p[x] == x) ? p[x] : find(p[x]);
	}
	int merge(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) {
			return 0;
		}
		p[x] = y;
		sz[y] += sz[x];
		return 1;
	}
};

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m; DSU d(n);
	for(int i = 1; i <= m; i++) {
		int u, v; cin >> u >> v;
		d.merge(u, v);
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) cnt += d.find(i) == i;

	cout << cnt - 1 << endl;
}

Measured memory_bytes: 3972
num = gets.chomp.to_i
count = 0
max_count = 0
max_num = 0

(num+1).times do |i|
  current_num = i
  while i!=0 && i%2==0 do
    i /= 2
    count += 1
  end
  if count >= max_count 
    max_count = count
    max_num = current_num
  end
  count = 0
end

puts max_num

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

int main(){
  int n;
  cin >> n;
  vector<int>b(n-1);
  for(int i=0;i<n-1;i++)cin >> b[i];
  long long ans =b[0]+b[n-2];
  for(int i=0;i<n-2;i++){
      ans += min(b[i],b[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = list(input())
n = len(s) + 1
left = [0]*n
right = [0]*n
for i in range(n-1):
    if s[i] == '<':
        left[i+1] = left[i] + 1
for i in range(n-2, -1, -1):
    if s[i] == '>':
        right[i] = right[i+1] + 1
a = [0]*n
for i in range(n):
    a[i] = max(left[i], right[i])
ans = sum(a)
print(ans)

Measured memory_bytes: 36656
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int x; cin>>x;
	int N = 1200;
	vector<ll> con(N);
	for(ll i = 0; i<=N; ++i){
		ll t = i*i*i*i*i;
		con[i] = t;
	}
	rep(i,N+1){
		rep(j,N+1){
			ll a = con[i];
			ll b = con[j];
			if(-a+b == (ll)x){cout<<-(i)<<' '<<-(j)<<endl; return 0;}
			if(a-b == (ll)x){cout<<(i)<<' '<<(j)<<endl; return 0;}
			if(a+b == (ll)x){cout<<(i)<<' '<<-(j)<<endl; return 0;}
			if(-a-b == (ll)x){cout<<-(i)<<' '<<(j)<<endl; return 0;}
		}
	}
	return 0;
}

Measured memory_bytes: 3604
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
D = 40
# dp[i][smaller]
# Xの上からi[0, 40]桁（2進数）目までの数を確定させたときのスコアの最大値
# smaller=1 Xの桁がKの当該桁より小さい
# smaller=0 Xの桁がKの当該桁と一致
dp = Array.new(D + 1) { Array.new(2, -1) }
dp[0][0] = 0
(0...D).each do |d|
  mask = 1 << (D - d - 1)
  # d桁目が1のAの個数
  num = as.count { |a| a & mask > 0 }
  # Xのd桁目を0,1にした時のスコア
  cost0 = mask * num
  cost1 = mask * (N - num)

  # 遷移
  # 1. smaller=1 -> smaller=1
  if dp[d][1] != -1 # ?
    dp[d+1][1] = [
      dp[d+1][1],
      dp[d][1] + [cost0, cost1].max
    ].max
  end

  # 2. smaller=0 -> smaller=1
  # Kのd桁目が1だったらXのd桁目は0にする
  if K & mask > 0
    dp[d + 1][1] = dp[d][0] + cost0 if dp[d + 1][1] < dp[d][0] + cost0
  end

  # 3. smaller=0 -> smaller=0
  dp[d + 1][0] = dp[d][0] + (K & mask > 0 ? cost1 : cost0)
end
p [dp[D][0], dp[D][1]].max

Measured memory_bytes: 8844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

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

	cin >> N;
	vector<long long int>v(N);
	map<long long int, int>mp;
	long long int ans = 0;
	for (auto &i : v) {
		cin >> i;
		mp[i]++;
		ans += mp[i] - 1;
	}
	for (auto i: v) {
		cout << ans - mp[i] + 1 << endl;
	}
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N,M;
  cin>>N>>M;
  
  if(N%2==1){
    for(int i=0; i<M; ++i){
      cout<<i+1;
      cout<<" ";
      cout<<N-i<<endl;
    }
    return 0;
  }
  
  vector<pair<int,int>> L;
  if(N%2==0){
    for(int i=1; i<N/2; ++i){
      if(i%2==1){
        L.push_back(make_pair(N/2-i/2,N/2+1+i/2));
      }
      else{
        L.push_back(make_pair(i/2,N-i/2));
      }
    }
  }
  
  for(int i=0; i<M; ++i){
    cout<<L[i].first<<" "<<L[i].second<<endl;
  }
  return 0;
}

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

string s;

int main()
{
    cin >> s;
    for(auto x : s)
    {
        if(x == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
	int a,b,uncov;
	scanf("%d %d",&a,&b);
	if((a-2*b)<=0)
	{
		uncov=0;
	}
	else 
	{
		uncov=a-2*b;
	}
	printf("%d\n",uncov);
	
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int solve(int d[100], const int n)
{
  int counter = 1;
  sort(d, d + n, greater<int>());
  REP(i, n - 1) {
    if (d[i] > d[i + 1]) counter++;
  }
  return counter;
}

int main()
{
  int n;
  int d[100];
  cin >> n;
  REP(i, n) cin >> d[i];
  cout << solve(d, n) << endl;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

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

int main() {
	int a, b; cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())

mod = 10**9+7

niko = 0
zero = 1
kyu = 1
nai = 8


for _ in range(N-1):
    niko = niko*10 + (zero+kyu)
    zero = nai+zero*9
    kyu = nai+kyu*9
    nai *= 8
    
    niko %= mod
    zero %= mod
    kyu %= mod
    nai %= mod
    ##print(niko,zero,kyu,nai,niko+zero+kyu+nai)

print(niko)

Measured memory_bytes: 9184
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b = list(map(int, readline().split()))
    if a + b == 15:
        print("+")
    elif a * b == 15:
        print("*")
    else:
        print("x")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string S;

int main() {
  cin >> S;
  if (S[0] == S[2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3568
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner scanner = new Scanner(System.in);
        int tree = scanner.nextInt();
        int patrol_width = scanner.nextInt();
      
        int max_patrol = patrol_width * 2 + 1;
      
        for(int i = 1; i <= 20; i++){
            if(tree <= max_patrol * i){
			    System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 21844
'use strict';
const main = arg => {
  const input = arg.trim().split(' ');
  const target = parseInt(input[0], 10);

  let value = 100;
  let n = 0;
  while(value < target) {
    value = Math.floor(value * 1.01);
    n++
  }
  console.log(n);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29724
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int m = ni();
		int[] aa = new int[m];
		int[] ba = new int[m];
		UnionFind uf = new UnionFind(n + 1);

		long result = (long)n*(n-1)/2;
		Deque<Long> resultq = new ArrayDeque<>();
		resultq.push(result);

		for(int i = 0; i < m; i++){
			aa[i] = ni();
			ba[i] = ni();
		}

		for(int i = m - 1; i > 0; i--){

			if(!uf.sameGroup(aa[i], ba[i])) {
				result -= (long)uf.size[uf.find(aa[i])] * uf.size[uf.find(ba[i])];
			}
			uf.unite(aa[i], ba[i]);
			resultq.push(result);			
		}

		while(!resultq.isEmpty()){
			System.out.println(resultq.pop());
		}
	}

	static class UnionFind{
		//Union find tree.
		private int[] par;
		private int[] rank;
		public int g;
		public int[] size;

		public UnionFind(int size) {
			this.par = new int[size];
			this.rank = new int[size];
			this.size = new int[size];
			for(int i = 0; i < size; i++) {
				par[i] = i;
				rank[i] = 0;
				this.size[i] = 1;
			}
			this.g = size;

			Arrays.fill(this.size, 1);
		}

		public int find(int x) {
			if(par[x] == x) {
				return x;
			} else {
				return find(par[x]);
			}
		}

		public void unite(int x, int y) {
			int xpar = find(x);
			int ypar = find(y);
			if(xpar == ypar) {
				return;
			}else {
				int sum = size[xpar] + size[ypar];
				size[xpar] = sum;
				size[ypar] = sum;
				
				if(rank[xpar] < rank[ypar]) {
					par[xpar] = ypar;
				} else {
					par[ypar] = xpar;
					if(rank[xpar] == rank[ypar]) rank[xpar] ++;
				}
			}
		}

		public boolean sameGroup(int x, int y) {
			return find(x) == find(y);
		}		
	}


	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const ll inf = LLONG_MAX;

ll power_mod(int a, int n, int mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll power(ll a,ll n){if(n==0){return 1;}ll p=power(a,n/2);p = (p * p);if (n%2==1){p=(p*a);}return p;}
int gcd(int a,int b){ return __gcd(a,b);}
int lcm(int a,int b){return a*b/__gcd(a,b);}
vector<vector<int>> adj;
bool vis[mxn];

void run(ll test){

    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    ll mod = 1e9+7;
    fr(i,0,n,1){
        cin >> a[i];
        sum += a[i];
        sum%=mod;
    }

    ll ans = 0;

    fr(i,0,n,1) {
        sum-=a[i];
        if(sum<0)sum+=mod;
        ans += sum*a[i];
        ans%=mod;
    }

    cout << ans;
}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        run(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5136
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int a, b, c;
	cin >> a >> b >> c;

	cout << a * b / 2 << endl;

	return 0;
}

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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    int q; cin >> q;
    map<string, int> m;
    while (q--) {
        int a; cin >> a;
        if (a == 0) {
            string k;
            int x; cin >> k >> x;
            m[k] = x;
        } else if (a == 1) {
            string k; cin >> k;
            cout << m[k] << endl;
        }
    }
}


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

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

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

    while(a[i] % 2 == 0){
      a[i] /= 2;
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())

renzoku = 0
flag = 0
for i in range(n):
  d = list(map(int, input().split()))
  if d[0] == d[1]:
    renzoku += 1
    if renzoku == 3:
      flag = 1
      break
  else:
    renzoku = 0
  
if flag == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define maxn 264000
#define ll long long
using namespace std;
int x[maxn];
ll seg[2][maxn<<1];
void modify(int l,int r,int pos,int p,ll val,ll *seg) {
	if(l == r)
		seg[p] = min(seg[p],val);
	else {
		int mid = (l+r)>>1 , lch = p<<1 , rch = p<<1|1;
		if(pos <= mid)
			modify(l,mid,pos,lch,val,seg);
		else
			modify(mid+1,r,pos,rch,val,seg);
		seg[p] = min(seg[lch],seg[rch]);
	}
}
ll query(int l,int r,int ql,int qr,int p,ll *seg) {
	if(l == ql && r == qr)
		return seg[p];
	else {
		int mid = (l+r)>>1 , lch = p<<1 , rch = p<<1|1;
		if(qr <= mid)
			return query(l,mid,ql,qr,lch,seg);
		else if(ql > mid)
			return query(mid+1,r,ql,qr,rch,seg);
		else
			return min(query(l,mid,ql,mid,lch,seg),query(mid+1,r,mid+1,qr,rch,seg));
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,q;
	cin >> n >> q;
	int a,b;
	cin >> a >> b;
	for(int i=1;i<=q;i++)
		cin >> x[i];
	memset(seg,0x3f,sizeof seg);
	ll sum = 0;
	for(int i=0,coe=1;i<2;i++,coe*=-1) {
		modify(1,n,a,1,-sum + coe * a + abs(b - x[1]),seg[i]);
		modify(1,n,b,1,-sum + coe * b + abs(a - x[1]),seg[i]);
	}
	x[0] = x[1];
	ll ans = -1;
	for(int i=1;i<=q;i++) {
		sum += abs(x[i] - x[i-1]);
		if(i == q) {
			for(int j=0,coe=1;j<2;j++,coe*=-1)
				for(int k=1;k<=n;k++) {
					ll now = sum + query(1,n,k,k,1,seg[j]) - coe * k;
					if(ans == -1 || ans > now)
						ans = now;
				}
		}
		else {
			ll dp = sum + min(query(1,n,x[i+1],n,1,seg[0]) - x[i+1],query(1,n,1,x[i+1],1,seg[1]) + x[i+1]);
			for(int j=0,coe=1;j<2;j++,coe*=-1)
				modify(1,n,x[i],1,-(sum + abs(x[i+1] - x[i])) + coe * x[i] + dp,seg[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9344
/*

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

#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fo(i,s,n) for(int i=s;i<n;i++)
#define pb(x) push_back(x);
#define mod 1000000007


int main()
{
    Fast
    string s,t;
    cin>>s;
    cin>>t;
    ll ls=s.length();
    ll lt=t.length();
    ll dp[ls+1][lt+1];
    //cout<<"ls"<<ls<<" lt"<<lt<<endl;
    fo(i,0,ls+1)
        dp[i][0]=0;
    fo(i,0,lt+1)
        dp[0][i]=0;
    for(ll i=1;i<=ls;i++)
    {

        for(ll j=1;j<=lt;j++)
        {
            if(t[j-1]==s[i-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            
        }
    }
    
   /* fo(i,0,ls+1)
    {
       
        fo(j,0,lt+1)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    //cout<<dp[ls][lt];
cout<<endl;*/
string res;
ll i=ls,j=lt;
while(i!=0&&j!=0)
        {
            if(s[i-1]==t[j-1])
            {
                res+=s[i-1];  //res is string
                j--;
                i--;
            }
            else if(dp[i-1][j]==dp[i][j])
            i--;
            else
            j--;
        }
        reverse(res.begin(),res.end());
    cout<<res<<endl;
/*
while(i>0&&j>0)
{
    if(dp[i][j]==dp[i-1][j-1]+1)
    {
        ans.push(t[j-1]);
        i--;
        j--;

    }
    else
    {
        j--;
    }
    
}

while(!ans.empty())
{
    cout<<ans.top();
    ans.pop();
}
cout<<endl;*/


    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a+b<24)
cout<<a+b;
else
cout<<a+b-24;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<cstdio>

const int mod=1000000007;

long long power(long long a,int k){

    long long ans=1,y=a;

    while(k){

        if(k%2)

            ans=ans*y%mod;

        y=y*y%mod;

        k=k/2;

    }

    return ans;

}

long long fun[1<<17],ans=1;

int main(){

    long long n,m;

    scanf("%lld%lld",&n,&m);

    fun[0]=1;

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

        fun[i]=fun[i-1]*i%mod;

    }

    for(int i=2;i*i<=m;i++){

        if(m%i==0){

            long long s=0;

            while (m%i==0) {

                m=m/i;

                s++;

            }

            ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;

        }

    }

    if(m>1)

        ans=ans*n%mod;

    printf("%lld\n",ans);

    return 0;

}



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

int64_t solve2(int h, int w)
{
   if (0 == (h&1) || 0 == (w&1))
   {
      auto ret1 = (static_cast<int64_t>(w)*h)>>1;
      return ret1;
   }

   int64_t ans = 0;
   auto ar1 = static_cast<int64_t>(w)*(h >> 1);
   ans = max(ar1, ans);

   auto ar2 = static_cast<int64_t>(w >> 1)*h;
   ans = max(ar2, ans);
   return ans;
}
int64_t solve(int h, int w)
{
   int64_t ans = numeric_limits<int64_t>::max();
   for (int i = 1; i < h; i++)
   {
      auto ar1 = static_cast<int64_t>(w)*i;
      auto ar2 = solve2(w, h-i);
      auto ar3 = static_cast<int64_t>(w)*(h-i) - ar2;

      auto mi = min(ar3,min(ar1, ar2));
      auto ma = max(ar3,max(ar1, ar2));
      auto cand = ma - mi;
      ans = min(cand, ans);
   }

   return ans;
}
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);

   int h, w;
   while (cin >> h >> w)
   {
      int64_t ans = numeric_limits<int64_t>::max();
      if (0 == (h % 3) || 0 == (w % 3))
         ans = 0;
      else{
         auto c1 = solve(h, w);
         ans = min(ans, c1);

         auto c2 = solve(w, h);
         ans = min(ans, c2);
      }
      cout << ans << '\n';
   }
   return 0;
}

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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var data = new int[1000001];
                int f, s, b, l = f = s = b = 0;
                for(int m = 0; m < i; ++m) {
                    var value = Console.ReadLine().Split();
                    var input = new int[9];
                    for(int n = 0; n < 9; ++n) {
                        input[n] = int.Parse(value[n]);
                    }
                    var time = 0;
                    for(int n = 1; n <= 8; ++n) {
                        time += input[n] * ((n & 1) == 1 ? 60 : 1);
                    }
                    data[input[0]] = time;
                    if(m <= 1) {
                        if(m == 0) {
                            f = s = b = l = input[0];
                        }
                        else { 
                            if (data[f] > time) {
                                f = b = input[0];
                            }
                            else {
                                s = l = input[0];
                            }
                        }
                    }
                    else {
                        if(time < data[s]) {
                            s = input[0];
                        }
                        if(time < data[f]) {
                            s = f;
                            f = input[0];
                        }
                        if(time > data[b]) {
                            b = input[0];
                        }
                        if(time > data[l]) {
                            b = l;
                            l = input[0];
                        }
                    }
                }
                Console.WriteLine("{0}{3}{1}{3}{2}", f, s, b, System.Environment.NewLine);
            }
        }
    }
}

Measured memory_bytes: 29308
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		int card[20] = { 0 };
		int pos = 0;
		int field = 0;
		for (int i = 1; i <= 100; i++) 
		{
			char c; cin >> c;
			if (c == 'M') { card[pos]++; pos++; }
			if (c == 'S') {
				field += card[pos] + 1;
				card[pos] = 0;
				pos++;
			}
			if (c == 'L') {
				card[pos] += field + 1;
				field = 0;
				pos++;
			}
			if (pos >= n )pos = 0;
		}
		sort(card, card + n);
		for (int i = 0; i < n; i++) {
			cout << card[i] << " ";
		}
		cout << field << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
N = int(input())
A = list(map(int, input().split()))
count, check = 0, 0
for i in A:
    if i%2 == 0:
        count += 1
        if i%3 == 0 or i%5 == 0:
            check += 1
if count == check:
	print('APPROVED')
else:
	print('DENIED')

Measured memory_bytes: 3060