akhauriyash/Code-Regression huggingface dataset:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l,m):
	f = 1
	n = len(l)
	tot = sum(l)
	k = tot/(4*m)
	l = sorted(l)[::-1][:m]
	for i in l:
		if(i < k):
			f = 0
			break
	if(f):
		return 'Yes'
	else:
		return 'No'

N,M = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,M)
print(ans)




Measured memory_bytes: 39664
use proconio::{input, fastout};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input!{
        (n, m): (usize, usize),
        xyz: [(usize, usize, usize); m]
    };

    let mut links: Vec<Vec<usize>> = vec![Vec::new(); n];
    for (a, b, c) in xyz {
        links[a-1].push(b-1);
        links[b-1].push(a-1);
    }

    let mut ans = 0;
    let mut used = vec![false; n];
    for i in 0..n {
        if !used[i] {
            ans += 1;
            let mut que: VecDeque<usize> = VecDeque::new();
            que.push_back(i);
            while !que.is_empty() {
                let from = match que.back() {
                    Some(x) => *x,
                    None => 0 as usize,
                };
                que.pop_back();
                if used[from] {
                    continue;
                }
                used[from] = true;
                for to in links[from].iter() {
                    if !used[*to] {
                        que.push_back(*to);
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


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

int gcd(int a, int b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
   

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

	int k = 360/(gcd(360,x));
	cout<< k;

	return 0;
	
}

Measured memory_bytes: 3608
#!/usr/bin/ruby
# encoding: utf-8

N,K = gets.split.map(&:to_i)
S = gets.chomp

str = Array.new(N,"")

(0..N-1).each do |i|
  if i == K-1
    str[i] += S[i].downcase
  elsif
    str[i] += S[i]
  end
end

puts str.join


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;
const int MaxM = 1000;

int n, k;
int M;
struct Point {
	int x, y;
	char c;
	Point () {}
	Point (int _x, int _y, char _c) {
		x = _x; y = _y; c = _c;
	}
}PP[MaxN + 5];
int sum[4 * MaxM + 5][4 * MaxM + 5];

void init() {
	M = 2 * k;
	memset(sum, 0, sizeof(sum));
	for(int i = 1; i <= n; i++)
		scanf("%d %d %c", &PP[i].x, &PP[i].y, &PP[i].c);
}

int cal(int lx, int ly, int ux, int uy) {
	int Sa = sum[ux][uy];
	int Sb, Sc, Sd;
	if(lx == 0 && ly != 0) {
		Sc = 0; Sd = 0;
		Sb = sum[ux][ly - 1];
	}
	else if(lx != 0 && ly == 0) {
		Sc = sum[lx - 1][uy];
		Sb = 0; Sd = 0;
	}
	else if(lx == 0 && ly == 0) {
		Sb = 0; Sc = 0; Sd = 0;
	}
	else {
		Sb = sum[ux][ly - 1];
		Sc = sum[lx - 1][uy];
		Sd = sum[lx - 1][ly - 1];
	}
	return Sa - Sb - Sc + Sd;
}

void debug() {
	printf("cal1 == %d\n", cal(0, 0, 1, 1));
	printf("cal2 == %d\n", cal(4, 4, 6, 6));
	for(int i = 0; i < 2 * M; i++) {
		for(int j = 0; j < 2 * M; j++)
			printf("%d ", sum[i][j]);
		printf("\n");
	}
}

void change() {
	for(int i = 1; i <= n; i++) {
		if(PP[i].c == 'B') {
			int tx = PP[i].x % M;
			int ty = PP[i].y % M;
			sum[tx][ty]++;
		}
		else if(PP[i].c == 'W') {
			int tx = (PP[i].x) % M;
			int ty = (PP[i].y + k) % M;
			sum[tx][ty]++;
		}
	}
	for(int i = 0; i < M; i++) {
		for(int j = 0; j < M; j++) {
			sum[i + M][j] = sum[i][j];
			sum[i][j + M] = sum[i][j];
			sum[i + M][j + M] = sum[i][j];
		}
	}
	for(int i = 0; i < 2 * M; i++) {
		for(int j = 0; j < 2 * M; j++) {
			//sum[i][j] = sum[i][j] + sum[i - 1][j] + 
			//		   sum[i][j - 1] - sum[i - 1][j - 1];
			if(i != 0 & j != 0)
				sum[i][j] = sum[i][j] + sum[i - 1][j] + 
			               sum[i][j - 1] - sum[i - 1][j - 1];
			else if(i == 0 && j != 0)
				sum[i][j] = sum[i][j] + sum[i][j - 1];
			else if(i != 0 && j == 0)
				sum[i][j] = sum[i][j] + sum[i - 1][j];
			else if(i == 0 && j == 0) 
				sum[i][j] = sum[i][j];
		}
	}
	//debug();
}

void solve() {
	int best = 0;
	for(int i = 0; i < M; i++) {
		for(int j = 0; j < M; j++) {
			int tmp = cal(i, j, i + k - 1, j + k - 1)
		                 + cal(i + k, j + k, i + M - 1, j + M - 1);
		    //printf("A = %d\n", cal(i, j, i + k - 1, j + k - 1));
		    //printf("B = %d\n", cal(i + k, j + k, i + M - 1, j + M - 1));
			//printf("tmp = %d\n", tmp);
			best = max(best, tmp);
		}
	}
	printf("%d\n", best);
}

int main()
{
	while(scanf("%d %d", &n, &k) != EOF)
	{
		init();
		change();
		solve();
	}
	return 0;
}

Measured memory_bytes: 64000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int L;
  while (cin >> L, L) {
    int M[12], N[12];
    for (int i = 0; i < 12; i++) {
      cin >> M[i] >> N[i];
    }
    int sum = 0, ans = -1;
    for (int i = 0; i < 12; i++) {
      sum += M[i] - N[i];
      if (sum >= L) {
        ans = i + 1;
        break;
      }
    }
    if (ans < 0) cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}


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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> dams(N); //0 からn-1まで
    ll allWater = 0;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        dams.at(i) = a;
        allWater += a;
    }
    vector<ll> mountains(N);
    mountains.at(0) = allWater;
    for (int i = 2; i < N; i = i + 2)
    {
        mountains.at(0) -= 2 * (dams.at(i - 1));
    }

    for (int i = 1; i < N; i++)
    {
        mountains.at(i) = 2 * (dams.at(i - 1) - (mountains.at(i - 1) / 2));
    }

    bool isFirst = true;
    for (int i = 0; i < N; i++)
    {
        if (isFirst)
        {
            isFirst = false;
        }
        else
        {
            cout << " ";
        }
        cout << mountains.at(i);
    }
    return 0;
}

Measured memory_bytes: 2816
##入力
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]
##一致個所の確認
for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
ans = 'No'
##横ラインビンゴ確認
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
  ans = 'Yes'
#縦ラインビンゴ確認
elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
  ans = 'Yes'
#斜めビンゴ確認
elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 0):
  ans = 'Yes'
#結果
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int selectionsort(int a[],int n){
  int i,j,minj,cnt=0,tmp;
  int flag=0;
  for(i=0;i<n;i++){
    minj = i;
    flag = 0;
    for(j=i;j<n;j++){
      if(a[j] < a[minj]){
        minj = j;
        flag++;
      }
    }
      if(flag >= 1){
        tmp = a[i];
        a[i] = a[minj];
        a[minj] = tmp;
        cnt++;
      }
    }
  return cnt;
}

int main(){
  int a[110];
  int i,n,cnt;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  cnt = selectionsort(a,n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}
template<typename T1,typename T2> inline T1 gmax(T1 &a,T2 b){return a=a<b?b:a;}
template<typename T1,typename T2> inline T1 gmin(T1 &a,T2 b){return a=a<b?a:b;}


namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1;

vector<int> e[_];
inline void adde(int a,int b){e[a].emplace_back(b);}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,dep[_]={0},mxdep;

void dfs(int x,int ff)
{
	dep[x]=1;
	for(auto b:e[x])
		if(b!=ff)
		{
			dfs(b,x);
			gmax(mxdep,dep[x]+dep[b]);
			gmax(dep[x],dep[b]+1);
		}
	gmax(mxdep,dep[x]);
}

int main()
{
	n=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	mxdep=0,dfs(1,0);
	puts(mxdep%3==2?"Second":"First");

	return 0;
}


Measured memory_bytes: 23936
#include<iostream>
using namespace std;
int main(){
    int n, ct; cin >> n >> ct;
    int t = 0;
    for(int i=0; i<ct; i++){
        int x; cin >> x;
        t += x;
    }
    if( n-t <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

using Graph = vector<vector<pair<ll, ll>>>;
using Pi = pair<ll, ll>;

//準備...Graph g;
//入力...g[Node].push_back(make_pair(nextNode, weight));
const ll MOD = 1000000007;

vector<ll> djkstra(Graph &g, ll s) {
	vector<ll> dist(g.size(), MOD);
	dist[s] = 0;
	priority_queue<Pi, vector<Pi>, greater<Pi>> que;
	que.emplace(dist[s], s);
	while ( !que.empty() ) {
		ll cost; ll u; tie(cost, u) = que.top(); que.pop();
		if (dist[u] < cost) continue;
		for (auto &x : g[u]) {
			ll v; ll nc; tie(v, nc) = x;
			if (chmin(dist[v], dist[u] + nc)) que.emplace(dist[v], v);
		}
	}

	return dist;
}

Graph gd(100005);

int main() {
	int n;
	cin >> n;
	rep (i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		gd[a].eb(b, 1);
		gd[b].eb(a, 1);
	}

	vector<ll> distF = djkstra(gd, 0);	
	vector<ll> distS = djkstra(gd, n - 1);

	int cntF = 0, cntS = 0;
	rep (i, n) if (distF[i] <= distS[i]) cntF++;
	else cntS++;

	cout << (cntF > cntS ? "Fennec" : "Snuke") << endl;
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(b >= c){
    cout << "delicious" << endl;
  }
  
  else if(c - b > a){
    cout << "dangerous" << endl;
  }
  
  else{
    cout << "safe" << endl;
  }
  
  
}


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

int main () {
  int n, m;
  cin >> n >> m;
  long long cnt = 0;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    cnt += tmp;
  }
  
  if (n >= cnt) cout << n - cnt;
  else cout << -1;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N, M, C;
  cin >> N >> M >> C;

  int B[M];
  for (int i = 0; i < M; ++i)
    cin >> B[i];

  int res = 0;
  for (int i = 0; i < N; ++i) {
    int total = C;
    for (int j = 0; j < M; ++j) {
      int tmp;
      cin >> tmp;
      total += tmp * B[j];
    }
    if (total > 0)
      ++res;
  }

  cout << res << endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;

    int t = s.size();
    //cout << t << endl;
    REP(i, t){
        int k = ((s[i] - 'A')  + n ) % 26;
        printf("%c", 'A' + k);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
a2 = x // 500
if a <= a2:
  a2 = a
abcs = []
for i in range(int(a2) + 1):
  xi = x - 500*i
  b2 = xi // 100
  if b <= b2:
    b2 = b
  for j in range(int(b2)+1):
    xj = xi - 100*j
    k = int(xj / 50)
    if k <= c:
      abc = []
      abc.append(i)
      abc.append(j)
      abc.append(k)
      abcs.append(abc)
print(len(abcs))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/


int a,b;

int main(void){
	cin>>a>>b;
	if(a>9 || b>9){
		cout<<-1<<endl;
		return 0;
	}
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
s = 0
sb = sum(B)
sc = 0
for i in range(N-1):
  if A[i+1] == A[i] + 1:
    sc += C[A[i]-1]
s = sb + sc
print(s)

Measured memory_bytes: 3064
#081 shift only
N =int(input())

A=list(map(int,input().split()))
ans = 0
for i in range(5*10**8):
    tmp=0
    for j,k in enumerate(A):
        if k%2 ==0:
            A[j] =k/2
            tmp+=1
    if tmp ==len(A):
        ans+=1
    else:
        print(ans)
        exit()


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

#define MAX 1000
#define INFTY (1 << 29)


class Edge {
public:
    int source, target, cost;
    Edge(int source=0, int target = 0, int cost = 0) : source(source), target(target), cost(cost) { }
};

int d[MAX];

void printArr(const int &N)
{
    for (int i = 0; i < N; ++i)
        (d[i] == INFTY) ? std::printf("INF\n") : std::printf("%d\n", d[i]);
}


void BellmanFord(std::vector<Edge> &edges, const int &V, const int &E, const int &src) {

    for (int i = 0; i < V; i++) d[i] = INFTY;
    d[src] = 0;
    int chg = 0;

    for (int i = 1; i < V-1; i++) {
        chg = 0;
        for (int j = 0; j < E; j++) {
            int u = edges[j].source;
            int v = edges[j].target;
            int cost = edges[j].cost;

            if (d[u] != INFTY && d[u] + cost < d[v]) {
                d[v] = d[u] + cost;
                chg++;
            }
        }
        if (chg == 0) break;
    }

    if (chg != 0) {

        //detect if graph contains negative cycle
        for (int i = 0; i < E; i++) {
            int u = edges[i].source;
            int v = edges[i].target;
            int cost = edges[i].cost;

            if (d[u] != INFTY && d[u] + cost < d[v]) {
                std::printf("NEGATIVE CYCLE\n");
                return;
            }
        }
    }

    printArr(V);
}


int main()
{
    int V, E, src;
    std::scanf("%d %d %d", &V, &E, &src);
    int source, target, cost;
    std::vector<Edge> edges;
    edges.reserve(E);

    for (int i = 0; i < E; i++) {
        std::scanf("%d %d %d", &source, &target, &cost);
        edges.push_back(Edge(source, target, cost));
    }

    BellmanFord(edges, V, E, src);

    return 0;
}



Measured memory_bytes: 3244
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

bool ls(const char &a, const char &b) { return a < b; }
bool gr(const char &a, const char &b) { return a > b; }

int main() {
  vector<int> a;
  while (true) {
    int a0, L;
    scanf("%d %d", &a0, &L);
    if (a0 == 0 && L == 0) break;
    char fmt[10];
    sprintf(fmt, "%%0%dd", L);
    a.clear();
    a.push_back(a0);
    for (int i=0;i<=21;i++) {
      char ai[10];
      sprintf(ai, fmt, a[i]);
      sort(ai, ai+L, ls);
      const int amin = atoi(ai);
      sort(ai, ai+L, gr);
      const int amax = atoi(ai);
      const int nexta = amax-amin;
      vector<int>::iterator p = find(a.begin(), a.end(), nexta);
      if (p != a.end()) {
        int j = p-a.begin();
        printf("%d %d %d\n", j, nexta, i-j+1);
        break;
      }
      a.push_back(nexta);
    }
  }
  return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <limits>
#include <algorithm>

int main()
{
    int n;
    int count[9] = { 0 };
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int rate;
        std::cin >> rate;
        int rank = std::min(8, rate / 400);
        count[rank] ++;
    }

    int colors = 0;
    for (int i = 0; i < 8; i++) {
        if (count[i]) {
            colors++;
        }
    }

    if (colors == 0) {
        std::cout << 1 << ' ' << count[8] << std::endl;
    } else {
        std::cout << colors << ' ' << colors + count[8] << std::endl;
    }

    return 0;

}


Measured memory_bytes: 256
from sys import stdin
sin = stdin.readline().rstrip()
q = int(stdin.readline().rstrip())
li = [list(stdin.readline().rstrip().split()) for _ in range(q)]
point = 0
omote = ""
ura = ""
for i in li:
    if i[0] == "1":
        point += 1
    elif i[0] == "2":
        if i[1] == "1":
            if point%2 == 0:
                omote += i[2]
            else:
                ura += i[2]
        else:
            if point%2 == 0:
                ura += i[2]
            else:
                omote += i[2]
if point%2 == 0:
    omote = omote[::-1]
    sin = omote + sin + ura
    print(sin)
else:
    sin = sin[::-1]
    ura = ura[::-1]
    sin = ura + sin + omote
    print(sin)

Measured memory_bytes: 31080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>

int main(void){
	int s,t,ret=0;
	cin>>s;
	vi sv(s);
	rep(i,s)cin>>sv[i];
	cin>>t;
	vi tv(t);
	rep(i,t){
		cin>>tv[i];
		int l = 0 , r = sv.size() ; 
		while(l<r){
			int mid = (l + r) / 2;
			if(sv[mid] == tv[i]){
				ret ++; break;
			}else if(tv[i] < sv[mid]){
				r = mid;
			}else{
				l = mid + 1;
			}
		}
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 1560
l = [int(input()) for i in range(5)]
l_d = []
for i in l:
  if i % 10 == 0:
    l_d.append(0)
  else:
    n = (i//10+1)*10 - i
    l_d.append(n)
c = []
for i, j in zip(l_d, l):
  c.append([i, j])
  
from operator import itemgetter
c.sort(key=itemgetter(0))
a, b = zip(*c)
d = list(b)
for n, i in enumerate(list(d[:-1])):
  if i % 10 == 0:
    continue
  else:
    d[n] = (i//10+1)*10    
print(sum(d))

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int r,d,x;
   cin>>r>>d>>x;
   for(int i=0;i<10;i++)
   {
       x=r*x-d;
       cout<<x<<endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 2000

int search(int, int);

int A[N] ,anum;

int main(){
  int Q[N];
  int i, qnum;

  scanf("%d", &anum);
  for(i = 0; i < anum; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &qnum);
  
  for(i = 0; i < qnum; i++){
    scanf("%d", &Q[i]);
  }
  
  for(i = 0; i < qnum; i++){
    if(search(0,Q[i]) == 1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}

int search(int i, int num){
  int res;
  
  if(num == 0){
    return 1;
  }
  if(i >= anum){
    return 0;
  }

  res = search(i+1,num) || search(i+1 ,num - A[i]);
  return res;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    string a,b;
    cin >>a >> b;
    int c = 0;
    for (int i = 0; i < a.length(); i++) {
        if(a[i] !=b[i])c++;
    }
    cout << c;
    return 0;
}


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

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<bool> vec (N+1,false);
	for(int i = 0;i < M;i++){
		int d;
		cin >> d;
		vec.at(d) = true;
	}
	int low = 0;
	int high = 0;
	int p = X;
	while(p != 0){
		p--;
		if(vec.at(p) == true){
			low++;
		}
	}
	p = X;
	while(p != N){
		p++;
		if(vec.at(p) == true){
			high++;
		}
	}
	cout << min(low,high) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    x -= z;
    while (true) {
        if (x - y >= z) {
            x -= y;
            x -= z;
            ans++;
        }
        else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    S = [s for s in input()]
    num_a = num_b = num_c = 0
    for s in S:
        if s == 'a':
            num_a += 1
        elif s == 'b':
            num_b += 1
        elif s == 'c':
            num_c += 1
    num = [num_a, num_b, num_c]
    num.sort(reverse=True)
    for i in range(len(S)):
        index = i % 3
        if num[index] == 0:
            print('NO')
            return
        num[index] -= 1
    print('YES')
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x, y;
int main () {
  cin >> x >> y;
  ll c = x;
  int ret = 1;
  while(y / 2 >= c) {
    ret++;
    c *= 2;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n=input()
min = None
max = None
cand=None

for x in xrange(n):
    v = input()
   
    # print "#### %s %s %s %s" % (str(max), str(min), str(cand), str(v))

    if min is None:
        min = v
        # print "min is None"
        continue

    if min > v:
        # print "min > v"
        if (cand is None) or (cand < v-min):
            # print "cand None"
            cand = v-min
        min = v
        max = None
        continue

    elif (max is None) or (max < v):
        # print "max is None"
        max = v
        if cand < max - min:
            cand = max - min
        continue

print cand

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

long long N=0,K=0,M=0,A=0,ans=0,p=0;
string S;
int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    } while(next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}


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


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

    vector<int> c;
    vector<int> t;
    
    for(int i=0; i<N; i++)
    {
    	int x,y;
    	cin >> x >> y;
    	c.push_back(x);
    	t.push_back(y);  	
    }
    
    int ans = 1001;

    for(int i=0; i<N; i++)
    { 
       if(t[i]<=T)
       {
           ans = min(ans, c[i]);
       }  
    }
    
    if(ans==1001) cout << "TLE" << endl;
    else cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] b = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		int[] a = new int[n];
		a[0] = b[0];
		for (int i = 1; i < n - 1; i++) {
			a[i] = Math.min(b[i - 1], b[i]);
		}
		a[n - 1] = b[n - 2];

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
		System.out.println(ans);
	}
}


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

int main(){

    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = b / x - a / x;
    if(a % x == 0) ans += 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int N,K;
    cin >> N >> K;
    
    int x,ans=0;
    for(int i=0;i<N;i++){
        cin >> x;
        if(K-x>=x){
            ans += x*2;
        }else{
            ans += (K-x)*2;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, m, tarosum, hanasum,taro[100],hana[100],diff,min,input1,input2;
  int i, j;

  while(1){

    tarosum=0;
    hanasum=0;
    min=201;
    input1=0;
    input2=0;

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

    if(n==0 && m==0)break;
    
    for(i=0;i<n;i++){
      scanf("%d",&taro[i]);
      tarosum+=taro[i];
    }
    
    for(j=0;j<m;j++){
      scanf("%d",&hana[j]);
      hanasum+=hana[j];
    }
    
    diff = tarosum-hanasum;

    //  printf("%d\n",diff);
    
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	if( 2*(taro[i]-hana[j]) == diff){
	  if( min > taro[i]+hana[j]){
	    min=taro[i]+hana[j];
	    input1=taro[i];
	    input2=hana[j];
	  }
	}
      }
    }
    
    if(input1==0 && input2==0){
      printf("-1\n");
    }else{
      printf("%d %d\n",input1,input2);
    }
    
    
  }
  return 0;
}

Measured memory_bytes: 612
a,b,c = map(int, input().split())

if a == b and b == c:
    print(str(1))
elif (a == b and a != c) or (a == c and a != b) or (a != b and b == c):
    print(str(2))
elif a != b and b != c and a != c:
    print(str(3))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll Mod=998244353;

int main(){
  int i,j;
  int n;
  cin>>n;
  int ans=0;
  int sum=0;
  for(i=0;i<n;i++){
      int d;
      cin>>d;
      sum+=d;
      ans-=d*d;
  }
  ans+=sum*sum;
  cout<<ans/2<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int dp[100005];
int frog(int a[],int n,int k)
{
 for(int i=2;i<=n;i++)
 {
     dp[i]=1e9;
     for(int j=i-1;j>=1 && (i-j)<=k;j--)
     dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
 }
 return dp[n];
}
int main(){
    int n,k; 
    cin>>n>>k;
    int a[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
     memset(dp,sizeof dp,0);
   cout<<frog(a,n,k)<<"\n";
return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll solve(ll n, int mod, int rem){
  ll ret = n/mod + 1;
  if(n%mod < rem) ret--;
  return ret;
}

int main() {
  ll n, k;
  cin >> n >> k;
  int l;
  REP(i, 11){
    if(i*9%11 == k) l = i;
  }
  k = l;
  (k += 3) %= 11;
  n = n*7-15;
  int l1, l2;
  REP(i, 77){
    if((i%7 == 0) && (i%11 == k)) l1 = i;
    if((i%7 == 6) && (i%11 == k)) l2 = i;
  }
  cout << solve(n, 11, k) - solve(n, 77, l1) - solve(n, 77, l2) << endl;;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    while (cin >> a >> b){
      while (a != b){
		  a > b ? a -= b : b -= a;  
		}
	cout << a << endl;
   }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

using namespace std;

int main()
{
	int n;cin >> n;
	int a=n%10;n/=10;
	int b=n%10;n/=10;
	int c=n%10;n/=10;
	int d=n;
	
	if((a==b && b==c) || (b==c && c==d)) cout << "Yes";
	else cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
h, w = gets.split().map(&:to_i)

s = h.times.inject([]) {|acc|
  acc << gets.chomp.split(//)
}

di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]

max = 0

h.times.each do |si|
  w.times.each do |sj|
    # スタート位置を決める
    next if s[si][sj] == '#'
    dd = {}

    queue = []
    queue << [si, sj]
    dd[[si, sj]] = 0

    while(!queue.empty?)
      d = queue.shift
      4.times do |x|
        ni = d[0] + di[x]
        nj = d[1] + dj[x]

        if ((0 <= ni && ni < h) && (0 <= nj && nj < w)) && s[ni][nj] != '#'
          unless dd[[ni, nj]]
            dd[[ni, nj]] = dd[d] + 1
            queue <<[ni, nj]
          end
        end
      end
    end
    max = [dd.values.max, max].max
  end
end

puts max

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define ll           long long
#define pll          pair<ll,ll>
#define pb           push_back
#define eb           emplace_back
#define F            first
#define S            second
#define vll(v)       v.begin(),v.end()
#define bug(a)       cerr << #a << " : " << a << endl;
#define fastread()     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int Max = 1e4+10;


int main()
{
       fastread();

       ll n,i;

          cin>>n;


        ll dp[4][n+2];

        dp[1][0]=dp[2][0]=dp[3][0]=0;


       for(i=1; i<=n; i++)
       {
           cin>>dp[1][i]>>dp[2][i]>>dp[3][i];

           dp[1][i]+=max(dp[2][i-1],dp[3][i-1]);

           dp[2][i]+=max(dp[1][i-1],dp[3][i-1]);

           dp[3][i]+=max(dp[1][i-1],dp[2][i-1]);
       }

       cout<<max3(dp[1][n],dp[2][n],dp[3][n])<<endl;




}


Measured memory_bytes: 6012
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int n, y;
  cin >> n >> y;
  
  for (int i = 0; i <= n; i++) {
    for (int j = 0; (i + j) <= n; j++) {
      int k = (n - (i + j) < 0) ? 0 : n - (i + j);
      if (10000 * i + 5000 * j + 1000 * k == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);

  auto t = "";
  foreach (si; s) {
    if (si == 'B') {
      if (!t.empty) t = t[0..$-1];
    } else {
      t ~= si;
    }
  }

  writeln(t);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//2019 B
int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n)cin >> a[i];
	vector<ll> aB = vector<ll>(n,0);
	vector<ll> aA = vector<ll>(n, 0);
	rep(i, 0, n) {
		rep(j, 0, i) {
			if (a[j] < a[i]) aB[i]++;
		}
		rep(j, i + 1, n) {
			if (a[i] > a[j]) aA[i]++;
		}
	}
	ll ans = 0;
	const ll MOD = 1000000007;
	rep(i, 0, n) {
		ans += ((aA[i] * (((k + 1) * k / 2) % MOD)) % MOD + (aB[i] * (((k - 1) * k / 2) % MOD)) % MOD) % MOD;
		ans = ans % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    A, B, C = map(int, input().split())
    if A == B and A != C:
        print('Yes')
    elif A == C and A != B:
        print('Yes')
    elif B == C and A != B:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();

 	string s;
 	cin>>n>>s;
 	int mina=0;
 	 c=0;
 for (int i = 0; i < n; ++i)
 {
 	if(s[i]=='I') c++;
 	else c--;
 	mina=max(c,mina);
 }
 	cout<<mina<<endl;



 	return 0;

   }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> D(N), E(N);
    rep(i,N){
        cin >> D[i] >> E[i];
    }
    ll cnt = 0;
    rep(i,N){
        if(D[i] == E[i]){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt >= 3){
            cout << "Yes" << endl;
            return 0;
        }        
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll X, K, D;

int main() {

	cin >> X >> K >> D;
	X = abs(X);

	ll T = X / D;
	if (K <= T) {
		cout << X - K * D << endl;
		return 0;
	}

	if (T % 2 == K % 2) {
		cout << X - T * D << endl;
		return 0;
	}
	else {
		cout << (T + 1) * D - X << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

char b[9][9], c[9][9];
int h, w;

void dfs(int y = 0, int x = 0){
	c[y][x] = '#';
	if(x == w - 1 && y == h - 1){
		return ;
	}
	if(x < w - 1 && b[y][x + 1] == '#'){
		dfs(y, x + 1);
	}else if(y < h - 1 && b[y + 1][x] == '#'){
		dfs(y + 1, x);
	}
}

int main(){
	cin >> h >> w;
	for(int i = 0; i <= h; i++){
		for(int j = 0; j <= w; j++){
			c[i][j] = '.';
			if(i == h || j == w){
				b[i][j] = '.';
			}else{
				cin >> b[i][j];
			}
		}
	}
	bool ans = true;
	dfs();
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(b[i][j] != c[i][j]){
				ans = false;
				break;
			}
		}
		if(!ans) break;
	}
	if(ans){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

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

int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double c=d/s;
    //cout<<d/s<<endl;
    if(c<=t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3724
#include<stdio.h>

int main()
{
    int n,k,i,j,sum,max;
    int a[100000];

    while(1){
        scanf("%d%d",&n,&k);
        if(n==0&&k==0) break;
        max=0;
        for(i=0;i<n;i++) scanf("%d",&a[i]);

        for(i=0,sum=0;i<k;i++) sum+=a[i];

        for(i=k;i<n;i++){
            sum-=a[i-k];
            sum+=a[i];
            if(max<sum) max=sum;
        }   

        printf("%d\n",max);
    }   
    return 0;
}

Measured memory_bytes: 988
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cassert>
#include <ctime>
#include <list>
#include <numeric>
#include <iomanip>


using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};


ll ans;


int un[200000];
ll ch[200000];

int find(int x){
  if(x==un[x])
    return x;
  return un[x]=find(un[x]);
}

void unit(int a,int b){
  int ap=find(a);
  int bp=find(b);
  un[ap]=bp;
  ch[bp] += ch[ap];
}


main(){
  int n;
  cin >> n;
  vector<pair<ll,PI > > ed;
  un[0]=0;
  ch[0]=1;
  rep(i,n-1){
    un[i+1]=i+1;
    ch[i+1]=1;
    int a,b,c;
    cin >> a >> b >> c;
    ed.pb(mp(c,mp(a,b)));
  }
  sort(ALL(ed));

  ll ans = 0;
  FOR(it,ed){
    int ap=find(it->S.F);
    int bp=find(it->S.S);
    ans += it->F * ch[ap] * ch[bp];
    unit(it->S.F,it->S.S);
  }

  cout << ans << endl;
}

Measured memory_bytes: 8800
#include <stdio.h>

int main(void)
{
    int d, sum;
    int step;
    int i;
	
    while(scanf("%d", &d) != EOF){
        sum = 0;
        step = 600 / d;
		
        for(i = 0; i < step; i++){
			 sum = sum + d * (i * d) * (i * d);
        }
        printf("%d\n", sum);
    }
	
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
	int N;
	int a[1000+10];
	while(scanf("%d",&N)!=EOF)
	{
		int i=0;
		
		for(i=0;i<N;i++)
		scanf("%d\n",&a[i]);
		int max=a[0];
		int min=a[0];
		for(i=0;i<N;i++)
		{
			if(max<a[i])
				max=a[i];
			if(min>a[i])
				min=a[i];			
		}
		printf("%d\n",max-min);
	}
	return 0;
}

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

int main(){
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    string s;
    cin >> s;
    string ans = "";
    if (s == "ABC") ans = "ARC";
    if (s == "ARC") ans = "ABC";
    cout << ans << endl;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

bool check(long long a, long long b, long long x, long long y)
{
    if(a <= x)
        ++ x;
    if(b <= y)
        ++ y;
    return x * y < a * b;
}

long long solve(long long a, long long b)
{
    long long left = 0;
    long long right = 2000000000;
    while(left < right){
        long long mid = (left + right + 1) / 2;
        long long x = (mid + 1) / 2;
        long long y = (mid + 2) / 2;
        bool ok = check(a, b, x, y);
        if(mid % 2 == 0){
            ++ x;
            -- y;
            ok &= check(a, b, x, y);
        }

        if(ok)
            left = mid;
        else
            right = mid - 1;
    }
    return left;
}

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

    while(--q >= 0){
        long long a, b;
        cin >> a >> b;
        cout << solve(a, b) << endl;
    }

    return 0;
}


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

int main(){
	int tail;
	int top;
	int n;
	int sum;
	int count;
	
	while(cin >> n,n!=0){
		
		tail = 1;
		top = 2;
		sum = 3;
		count =0;
		
		while(top<=(int)(n/2.0+0.5)){
			
			if(sum==n){
			//	cout << tail <<" "<<top <<endl;
				count++;
			}
			
			
			if(tail == top || sum<=n){
				top++;
				sum+=top;
			}else{
				tail++;
				sum-=tail-1;
			}
			
		}
		
		cout << count <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	_, m, x := scanInt(sc), scanInt(sc), scanInt(sc)
	as := nextIntSlice(sc, m)
	sort.Sort(sort.IntSlice(as))
	lc := 0
	for i := 0; i < len(as); i++ {
		if as[i] >= x {
			break
		}
		lc++
	}
	fmt.Println(min(lc, m-lc))
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

Measured memory_bytes: 1788