akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;

int main() {
	int n;
	cin >> n;
	bool flag = false;

	for(int i = 0; i < n; i++) {
		int board[16][16];
		char mark[16][16];
		memset(mark, ' ', sizeof(mark));
		for(int j = 0; j < 9; j++)
			for(int k = 0; k < 9; k++)
				cin >> board[j][k];

		// row & comlumn
		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				for(int l = k + 1; l < 9; l++) {
					if(board[j][k] == board[j][l])
						mark[j][k] = mark[j][l] = '*';
					if(board[k][j] == board[l][j])
						mark[k][j] = mark[l][j] = '*';
				}
			}
		}

		// block
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				for(int l = 0; l < 3; l++) {
					for(int m = 0; m < 3; m++) {
						for(int n = l + (m + 1) / 3; n < 3; n++) {
							for(int o = (m + 1) % 3; o < 3; o++) {
								if(board[j * 3 + l][k * 3 + m] == board[j * 3 + n][k * 3 + o])
									mark[j * 3 + l][k * 3 + m] = mark[j * 3 + n][k * 3 + o] = '*';
							}
						}
					}
				}
			}
		}

		if(flag)
			cout << endl;

		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				cout << mark[j][k] << board[j][k];
			}
			cout << endl;
		}

		flag = true;
	}

	return 0;
}

Measured memory_bytes: 1156
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
dp = [INF]*(N+1)
dp[0] = 0

for i in range(0, N):
    j = 1
    while j == 1:
        dp[i+1**j] = min(dp[i+1**j], dp[i] + 1)
        j += 1
    j = 1
    while i+6**j < N+1:
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        j += 1
    j = 1
    while i+9**j < N+1:
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
        j += 1
print(dp[N])


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

template<class T>
class Dinic {
private:
    const T INF;

    struct edge {
        T to, cap, rev;
        edge(T to, T cap, T rev) :to(to), cap(cap), rev(rev) {}
    };

    T V;
    vector<vector<edge>> g;
    vector<T> level;      // sourceからの距離
    vector<T> itr;       // どこまで調べ終わったか

public:
    Dinic(T V) :INF(1e9+7), V(V), g(V, vector<edge>()) {}

    void add_edge(T from, T to, T cap) {
        g[from].emplace_back(to, cap, g[to].size());
        g[to].emplace_back(from, 0, g[from].size()-1);
    }

    // sourceからの最短路を幅優先で探索
    void bfs(T s) {
        level = vector<T>(V, -1);
        queue<T> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front(); que.pop();
            for (edge &e : g[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    // v->tの増加路を探す
    T dfs(T v, T t, T f) {
        if (v == t) return f;
        for (T& i = itr[v]; i < g[v].size(); ++i) {
            edge& e = g[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(T s, T t) {
        T flow = 0, f;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            itr = vector<T>(V, 0);
            while ((f = dfs(s, t, numeric_limits<T>::max())) > 0) {
                flow += f;
            }
        }
    }
};

string board[101];



int main() {
    int H, W, cnt = 0;
    cin >> H >> W;
    Dinic<int> flow(H+W+2);
    rep(r, H) {
        cin >> board[r];
    }
    int s = 0, t = 1;
    int inf = 1e9+7;
    rep(r, H) rep(c, W) {
        if (board[r][c] == 'S') {
            flow.add_edge(s, r+2, inf);
            flow.add_edge(s, H+c+2, inf);
        }
        else if (board[r][c] == 'T') {
            flow.add_edge(r+2, t, inf);
            flow.add_edge(H+c+2, t, inf);
        }
        else if (board[r][c] == 'o') {
            flow.add_edge(r+2, H+c+2, 1);
            flow.add_edge(H+c+2, r+2, 1);
        }
    }
    int f = flow.max_flow(s, t);
    cout << (f < inf ? f : -1) << endl;
    return 0;
}


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

/* */


int main(){
    // 入力スタンダード
    int x;
    cin >> x;

    int i,j;
    for(i=-200; i<200; i++){
        for(j=-200; j<200; j++){
            if( pow(i,5) - pow(j,5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3984
def main(argv)
  n = gets.chomp.to_i
  d = gets.chomp.split(' ').map(&:to_i)
  m = gets.chomp.to_i
  t = gets.chomp.split(' ').map(&:to_i)

  md = {}
  d.each{|x| if md[x] == nil then md[x] = 1 else md[x] += 1 end}

  flag = true
  t.each do |x|
    if ((md[x] == nil) or (md[x] == 0)) then
      flag = false
      break
    end

    md[x] -= 1
  end

  puts (flag ? 'YES' : 'NO')
end

if self.to_s == 'main' then
  main(ARGV)
end

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


int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      int su,ei,ko;
      cin >> su >> ei >> ko;

      if(su == 100 || ei == 100 || ko == 100){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei)/2.0 >= 90.0){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 80.0){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 70.0){
	cout << "B\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 50.0 && (su >=80 || ei >= 80) ){
	cout << "B\n";
	continue; 
      }
      cout << "C\n";
    }


  }



}

Measured memory_bytes: 1124
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean ans = true;
		StringBuffer sb = new StringBuffer();
		sb.append(S);
		
		//all
		StringBuffer reverce = sb.reverse();
		if(!S.equals(reverce.toString())) {
			ans = false;
		}
		
		//former
		String former = S.substring(0, (S.length() - 1) / 2);
		StringBuffer formerSb = new StringBuffer();
		formerSb.append(former);
		StringBuffer reverceFormer = formerSb.reverse();
		if(!former.equals(reverceFormer.toString())) {
			ans = false;
		}
		
		
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
	
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K,M;
ll mo=1000000007;
vector<ll> V;
ll dp[2020];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

vector<ll> enumdiv(ll n) {
	vector<ll> S;
	for(ll i=1;i*i<=n;i++) if(n%i==0) {S.push_back(i); if(i*i!=n) S.push_back(n/i); }
	sort(S.begin(),S.end());
	return S;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	
	V=enumdiv(N);
	M=V.size();
	
	ll ret=0;
	FOR(x,M) {
		dp[x] = modpow(K,(V[x]+1)/2);
		FOR(y,x) if(V[x]%V[y]==0) dp[x] += mo - dp[y];
		dp[x] %= mo;
		
		if(V[x]%2==0) {
			ret += dp[x]*V[x]/2;
		}
		else {
			ret += dp[x]*V[x];
		}
	}
	cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,q;
  cin >> N >> q;
  vi s(N),t(N),x(N);
  rep(i,N) {
    cin >> s[i] >> t[i] >> x[i];
  }
  vi l(N),r(N);
  rep(i,N) {
    l[i]=s[i]-x[i];
    r[i]=t[i]-x[i];
  }
  vi d(q);
  rep(i,q) {
    cin >> d[i];
  }
  vvi event;
  rep(i,N) {
    event.push_back(vi{l[i],0,x[i]});
    event.push_back(vi{r[i],-1,x[i]});
  }
  rep(i,q) {
    event.push_back(vi{d[i],i});
  }
  sort(rng(event));
  set<int> xs;
  vi ans(q,-1);
  rep(i,sz(event)) {
    vi e = event[i];
    if(sz(e)==3) {
      if(e[1]<0) {
        xs.erase(e[2]);
      } else {
        xs.insert(e[2]);
      }
      continue;
    }
    auto itr = xs.begin();
    if(itr==xs.end()) continue;
    ans[e[1]] = *itr;
  }
  rep(i,q) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 50468
mod = 10**9+7
n, m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
sum_x = 0
sum_y = 0
for i in range(1, n):
    x0 = X[i-1]
    x1 = X[i]
    sum_x += (x1-x0)*i*(n-i)
    sum_x%=mod
for i in range(1, m):
    y0 = Y[i-1]
    y1 = Y[i]
    sum_y += (y1-y0)*i*(m-i)
    sum_y%=mod
print((sum_x*sum_y)%mod)    


Measured memory_bytes: 83044
#include <iostream>
#include <cstring>

using namespace std;

void bomb(int map[14][14], int x, int y){ 
        map[x][y] = 0;
        for(int i = -3; i <= 3; i++){
                if(map[x+i][y]){
                        bomb(map, x+i, y); 
                }   
                if(map[x][y+i]){
                        bomb(map, x, y+i);
                }   
        }   
}
int main(){
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++){
                int map[14][14];
                memset(map,0,sizeof(map));
                int in; 
                for(int j = 3; j <= 10; j++){
                        cin >> in; 
                        for(int k = 10; k >2; k--){
                                map[j][k] = in%10;
                                in /= 10; 
                        }   
                }   
                int x,y;
                cin >> x >> y;
                bomb(map,y+2,x+2);
                cout << "Data " << i << ":" << endl;
                for(int j = 3; j <= 10; j++){
                        for(int k = 3; k <= 10; k++){
                                cout << map[j][k];
                        }   
                        cout << endl;
                }   
        }   
}

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

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

    string s, t;
    cin >> s >> t;
    int n = s.length();
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if (s[i] == t[i]) ++ans;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n,c,k;
    cin >> n >> c >> k;
    vector<int> t(n);
    int num=1,bus=0;
    long limit = 0;

    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    sort(t.begin(), t.end());

    limit = t[0] + k;

    for(int i=1; i<n; i++){
        if(num == 0){
            limit = t[i]+k;
        }
        if(t[i] <= limit){
            num++;
        }else{
            bus++;
            num = 1;
            limit = t[i]+k;
        }
        if(num==c){
            num=0;
            bus++;
        }
    }
    if(num>0){
        bus++;
    }
    cout << bus << endl;
}

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

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;cin>>t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	
	int l = 1, r = n-2;
	ll cl = a[0], cr = a[n-1];
	ll sum = cr - cl;

	while (l <= r) {
		if (cl > cr)
			swap(cl, cr);
	
		if (abs(cl - a[r]) < abs(cr - a[l])) {
			sum += abs(cr- a[l]);
			cr = a[l];
			l++;
		} else {
			sum += abs(cl - a[r]);
			cl = a[r];
			r--;
		}
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 892
package main

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

type ByValue []float64

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i] < s[j] }

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	strA := sc.Text()
	strAList := strings.Split(strA, " ")
	aList := []float64{}
	for _, v := range strAList {
		intV, _ := strconv.Atoi(v)
		aList = append(aList, float64(intV))
	}
	sort.Sort(ByValue(aList))
	res := aList[0]
	for i := 1; i < n; i++ {
		res += aList[i]
		res = res / 2
	}
	fmt.Println(res)
}


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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if((a==5&&b==7&&c==5)||(b==5&&c==7&&a==5)||(c==5&&a==7&&b==5))
  {
    cout << "YES";
  }
  else
  {
    cout << "NO";
  }
  cout << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func main() {
	A := oneInt()
	B := oneInt()

	if 13 <= A {
		fmt.Print(B)
	} else if 6 <= A && A <= 12 {
		fmt.Print(B / 2)
	} else {
		fmt.Print(0)
	}
}

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

using namespace std;

const long long INF = 1LL << 60;

int main (void) {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A.at(i);

    sort(A.begin(), A.end());


    long long l = -INF, r = INF;

    while ( l+1 < r ) {
        long long m = (l + r) / 2;

        bool ok = [&] {
            long long sum = 0;

            for ( int i = 0; i < N; i++ ) {
                if ( A.at(i) < 0 ) {
                    /* 負の場合 */
                    int l = -1, r = N;
                    while ( l+1 < r ) {
                        int c = (l + r) / 2;
                        if ( A.at(c) * A.at(i) < m ) r = c;
                        else l = c;
                    }
                    sum += N - r;
                }
                else {
                    /* 0 以上の場合 */
                    int l = -1, r = N;
                    while ( l+1 < r ) {
                        int c = (l + r) / 2;
                        if ( A.at(c) * A.at(i) < m ) l = c;
                        else r = c;
                    }
                    sum += r;
                }
                if ( A.at(i) * A.at(i) < m ) sum--;
            }
            sum /= 2;
            return sum < K;
        }();

        if ( ok ) l = m;
        else r = m;
    }

    cout << l << endl;
    return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

struct node {
	int key;
	node *p, *lc, *rc;
	node(int key){
		this->p = this->lc = this->rc = NULL;
		this->key = key;
	}
	void push(node *nod){
		if(this->key == INT_MAX){
			this->key = nod->key;
			return;
		}
		
		if(this->key > nod->key){
			if(this->lc == NULL){
				nod->p = this;
				this->lc = nod;
			}else this->lc->push(nod);
		}else{
			if(this->rc == NULL){
				nod->p = this;
				this->rc = nod;
			}else this->rc->push(nod);
		}
	}
	bool find(int fkey){
		if(this->key > fkey){
			if(this->lc == NULL) return false;
			else return this->lc->find(fkey);
		}else if(this->key < fkey){
			if(this->rc == NULL) return false;
			else return this->rc->find(fkey);
		}else return true;
	}
	int getMinKey(){
		if(this->lc != NULL) return this->lc->getMinKey();
		else return this->key;
	}
	bool del(int dk){
		if(this->key > dk){
			if(this->lc == NULL) return false;
			else return this->lc->del(dk);
		}else if(this->key < dk){
			if(this->rc == NULL) return false;
			else return this->rc->del(dk);
		}
		
		if(this->lc == NULL && this->rc == NULL){
			if(this->p->lc == this) this->p->lc = NULL;
			else this->p->rc = NULL;
		}else if(this->lc != NULL && this->rc != NULL){
			this->key = this->rc->getMinKey();
			this->rc->del(this->key);
		}else if(this->lc == NULL){
			this->rc->p = this->p;
			if(this->p->lc == this) this->p->lc = this->rc;
			else this->p->rc = this->rc;
		}else{
			this->lc->p = this->p;
			if(this->p->lc == this) this->p->lc = this->lc;
			else this->p->rc = this->lc;
		}
		
		return true;
	}
	void inprint(){
		if(this->lc != NULL) this->lc->inprint();
		cout << " " << this->key;
		if(this->rc != NULL) this->rc->inprint();
	}
	void preprint(){
		cout << " " << this->key;
		if(this->lc != NULL) this->lc->preprint();
		if(this->rc != NULL) this->rc->preprint();
	}
};

int main() {
	int n;
	cin >> n;
	
	node top(INT_MAX);
	while(n--){
		string com;
		cin >> com;
		
		if(com[0] == 'i'){
			int key;
			cin >> key;
			
			node *nod = new node(key);
			top.push(nod);
		}else if(com[0] == 'f'){
			int key;
			cin >> key;
			
			cout << (top.find(key) ? "yes" : "no") << endl;
		}else if(com[0] == 'd'){
			int key;
			cin >> key;
			
			top.del(key);
		}else{
			top.inprint();
			cout << endl;
			top.preprint();
			cout << endl;
		}
	}
	
	return 0;
}

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

int main(){
    int n, a, b, cnt = 0;
    cin >> n;
    string ans = "No";

    for (int i = 0; i < n; i++){
        cin >> a >> b;
        if (a == b){
            cnt++;
            if(cnt == 3){
                ans = "Yes";
                break;
            }
        }else{
            cnt = 0;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3596
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    deq = collections.deque()
    for i in range(n):
        if i % 2 == 0:
            deq.append(str(a[i]))
        else:
            deq.appendleft(str(a[i]))
    if n % 2 == 1:
        deq.reverse()
    print(" ".join(deq))
    return 0

if __name__ == "__main__":
    solve()


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

int main() {
	int x, y;
	cin >> x >> y;
	int m = INT_MAX;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			int a = i ? -x : x, b = j ? -y : y;
			if (a <= b) {
				m = min(m, i + j + b - a);
			}
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
const long long int mod = 1e9+7;
long long int power(long long int x,long long int y){  
    long long int res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % mod;  
        y = y>>1;
        x = (x*x) % mod; 
    }  
    return res;
}  
long long int inv(long long int a){return power(a,mod-2);}
long long int add(long long int a,long long int b){return (a+b)%mod;}
long long int sub(long long int a,long long int b){return (a-b+mod)%mod;}
long long int mul(long long int a,long long int b){return (a*b)%mod;}
long long int divi(long long int a,long long int b){return (a*inv(b))%mod;}
ll fact[500001];
void pre(){
    fact[0]=1;
    for(int i=1;i<=500000;i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll ncr(ll n,ll r){
    return divi(fact[n],mul(fact[r],fact[n-r]));
}
void solve(){
    ll n,m;cin>>n>>m;
    ll ans = 0;
    for(int i=0;i<=n;i++){
        if(i%2==0)
            ans = add(ans,mul(ncr(n,i),fact[m-i]));
        else
            ans = sub(ans,mul(ncr(n,i),fact[m-i]));
    }
    cout<<mul(mul(ncr(m,n),fact[n]),divi(ans,fact[m-n]))<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 7556
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    string s;cin >> s;
    if(s.back() != 's')s += 's';
    else s += "es";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

bool ok(ll n){
   ll tmp = n;
   if(n<=10){
      return true;
   }

   while(tmp!=0){
      ll tmp3 = tmp%10;
      tmp/=10;
      if(tmp==0){
         return true;
      }
      ll tmp2 = tmp%10;
      if(abs(tmp3-tmp2)<=1){
         continue;
      }
      else{
         return false;
      }
   }

   return true;
}

int main() {
   int k; cin >> k;
   queue<ll> q;
   for(int i=1; i<10; i++){
      q.push(i);
   }

   int cnt = 0;
   ll tmp;
   while(cnt!=k){
      tmp = q.front();
      q.pop();
      if(tmp%10!=0){
         q.push(tmp*10+(tmp%10-1));
      }
      q.push(tmp*10+tmp%10);

      if(tmp%10!=9){
         q.push(tmp*10+(tmp%10+1));
      }
      
      cnt++;
   }

   cout << tmp << endl;
   return 0;
}


Measured memory_bytes: 1792
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i <= (n); i++)

int main() {
    int a, b, c, k,ans = 0;
    cin >> a >> b >> c >> k;

    rep(i, k) {
        int a2, b2, c2,a3,b3,c3;
        a2 = a, b2 = b, c2 = c;
        rep(j, k - i) {
            a3 = a2 * pow(2, i);
            b3 = b2 * pow(2, j);
            c3 = c2 * pow(2, k - i - j);
            if (a3 < b3 && b3 < c3) {
                ans = 1;
               
            }
        }
    }
    if (ans == 1)cout << "Yes" << endl;
    else cout << "No" << endl;
   
return 0;
}

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

//約数列挙 計算量O(sqrt(n))
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

ll f(ll a, ll b){
  ll a_count = 1;
  ll b_count = 1;
  while(a >= 10){
    a_count++;
    a /= 10;
  }
  while (b >= 10){
    b_count++;
    b /= 10;
  }
  return max(a_count, b_count);
}

int main() {
  ll n;
  cin >> n;
  ll ans = 1000000000000;
  vector<ll> divs = divisor(n);
  int left = 0;
  int right = divs.size() - 1;
  while(right - left >= 0){
    ll num = f(divs[left], divs[right]);
    ans = min(ans, num);
    left++;
    right--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n,p;
long long ans;
int main() {
    scanf("%d",&n);
    for(int c=1;c<=n;c++) {
        p=n-c;
        for(int a=1;a*a<=p;a++)
            if(p%a==0) {
                if(p/a==a) ans++;
                else ans+=2;
            }
    }
    printf("%d\n",ans);
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N-1);

    for(int i = 0; i < N-1 ; i++){
        cin >> B.at(i);
    }

    A.at(0) = B.at(0);
    for(int i = 0; i < N-1; i++){
        if(B.at(i) < A.at(i)){
            A.at(i) = B.at(i);
            A.at(i+1) = B.at(i);
        }else{
            A.at(i+1) = B.at(i);
        }
    }

    long long ans = 0;
    for(int num : A){
        ans += num;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>

using namespace std;
const int inf=1e8;

int main(){

   int N, M;
   cin>> N>> M;
   int g[N][N];
   for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
         if(i==j) g[i][j]=0;
         else g[i][j]=inf;
      }
   }
   int u[M], v[M], cost[M];
   for(int i=0; i<M; i++){
      int a, b, c;
      cin>> a>> b>> c;
      a--; b--;
      g[a][b]=g[b][a]=c;
      u[i]=a; v[i]=b, cost[i]=c;
   }

   for(int k=0; k<N; k++){
      for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
            g[i][j]=min(g[i][j], g[i][k]+g[k][j]);
         }
      }
   }

   int r=0;
   for(int i=0; i<M; i++){
      if(g[u[i]][v[i]]==cost[i]) r++;
   }

   cout<< M-r<< endl;



   return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CSlimes {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            int answer = 0;
            for (int i = 0, j = 0; i < n; i = j) {
                while (j < n && s[i] == s[j])
                    j++;

                answer++;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 25044
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
m = {}
total = 0
diff = [0]*N
for a in c.items():
    m[a[0]] = a[1]
    total += a[1]*(a[1]-1)//2
for i in range(N):
    com1 = (m[A[i]])*(m[A[i]]-1)//2
    com2 = (m[A[i]]-1)*(m[A[i]]-2)//2
    diff[i] = com1-com2
for i in range(N):
    print(total-diff[i])

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

int main() {
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(2));
    for (int i = N - 1; i >= 0; i--) {
        // 先手番
        dp[i][0] = -INF;
        ll Y = (i ? A[i - 1] : W); // 先手番がi番目以降の手札を取れる時、後手番はi-1番目の手札を取っている(i=0の時はW)
        chmax(dp[i][0], abs(Y - A[N - 1])); // すべての手札を取った場合
        for (int j = i + 1; j < N; j++) chmax(dp[i][0], dp[j][1]); //途中までの手札を取った場合

        // 後手番も先手番と同様の更新をする
        dp[i][1] = INF;
        ll X = (i ? A[i - 1] : Z);
        chmin(dp[i][1], abs(X - A[N - 1]));
        for (int j = i + 1; j < N; j++) chmin(dp[i][1], dp[j][0]);
    }

    cout << dp[0][0] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1000000000009
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
//#define int ll

signed main(){
    int H,W,K;
    char c[32][32];
    int d[32][32];
    int Ans=0;
    cin >> H >> W >> K;
    REP(i,H){REP(j,W){cin >> c[i][j];}}
    REP(i,H){
        REP(j,W){
            int num=0;
            REP(k,H){
                REP(l,W){
                    d[k][l] = (int)(c[k][l] - '0');
                }
            }
            d[i][j]=0;
            for(int k=i;k>=1;k--){
                d[k][j]=d[k-1][j];
            }
            d[0][j]=0;
            bool ch=0;
            int kai=1;
            while(ch==0){
               // if(i==3&&j==3){cout << endl << endl;REP(k,H){REP(l,W){cout << d[k][l] << " ";}cout << endl;}}
                int kam=0;
                ch=1;
                REP(k,H){
                    int y=1;
                    REP(l,W-1){
                        if(d[k][l]==d[k][l+1]){
                            y++;
                        }else{
                            if(K<=y && d[k][l]!=0){
                                ch=0;
                                for(int m=l-y+1;m<=l;m++){
                                    kam+=d[k][m];
                                    d[k][m]=0;
                                }
                            }
                            y=1;
                        }
                    }
                    if(K<=y && d[k][W-1]!=0){
                        ch=0;
                        for(int m=W-y;m<W;m++){
                            kam+=d[k][m];
                            d[k][m]=0;
                        }
                    }
                    y=1;
                }
               // if(i==3&&j==3){cout <<endl << endl << kai << " " << kam << " " << endl;}
                num += kai*kam;
                kam=0;
                kai*=2;
                
                REP(l,W){
                    REP(k,H){
                        if(d[k][l]==0){
                            for(int m=k;m>0;m--){
                                d[m][l]=d[m-1][l];
                            }
                            d[0][l]=0;
                        }
                    }
                }
            }
            Ans = max(Ans,num);
            //cout << i+1 << " " << j+1 << "  " << num << endl;
        }//cout << endl;
    }
    cout << Ans << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int x;
    cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>


void solve(int h, int w){
	int x,y=1;
	int tr=h*h+w*w;
	int min_x,min_y,min_tr=100000;
	while(1){
		x=y+1;
		if(tr<x*x+y*y){
			if(min_tr>x*x+y*y){
				min_tr=x*x+y*y;
				min_x=x;
				min_y=y;
			}
			break;
		}
		if(tr==x*x+y*y){
			if(y>h){
				printf("%d %d\n",y,x);
				return;
			}
		}
		while(1){
			if(tr==x*x+y*y){
				if(y>h){
					printf("%d %d\n",y,x);
					return;
				}
			}
			if(tr<x*x+y*y){
				if(min_tr>x*x+y*y){
					min_tr=x*x+y*y;
					min_x=x;
					min_y=y;
				}
				break;
			}
			x++;
		}
		y++;
	}
	printf("%d %d\n",min_y,min_x);
	return;
}

int main(void){
	int h,w;
	while(scanf("%d %d",&h,&w),h||w){
		solve(h,w);
	}
	return 0;
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int pyra[150000000];
int save[150000000];

int main(){
	double n[10];
	while (cin >> n[0]) {
	  long double ans = 0;
	  for (int i = 1; i < 10; i++) {
		  if (i % 2 == 0) {
			  n[i] = n[i - 1] / 3;
		  } else {
			  n[i] = n[i - 1] * 2;
		  }
	  }
	  for (int i = 0; i < 10; i++) {
		  ans += n[i];
		}
		cout.precision(10);
	  cout << ans << endl;
  }
	return 0;
}

Measured memory_bytes: 1284
using System;
class Program
 {
  static void Main(string[] args)
  {
    int a = int.Parse(Console.ReadLine()); //標準入力
    for (int i = 1; i < 10; i++)
    {
      int b = a / i;
      if (a % i > 0)
      {
        continue;
      }
      if (b < 10)
      {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
  }
 }

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cmath>
const int N=105;
using namespace std;
double a[N];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	int n,m; cin>>n>>m;
	double sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n,cmp);
	double min0=sum/(4*m);
	if(a[m-1]>=min0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
a = a.sort { |a, b| b <=> a }
s = 0
t = 0

(0..(n-1)).each do |i|
  if i.even?
    s += a[i]
  else
    t += a[i]
  end
end

p s - t



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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    auto itra = a.begin();
    auto itrb = b.begin();
    auto itrc = c.begin();
    const auto aend = a.end();
    const auto bend = b.end();
    const auto cend = c.end();

    auto itrptr = &itra;
    auto endptr = &aend;
    char next = **itrptr;
    while(*itrptr != *endptr)
    {
        next = **itrptr;
        ++*itrptr;
        if (next == 'a')
        {
            itrptr = &itra;
            endptr = &aend;
        }
        else if (next == 'b')
        {
            itrptr = &itrb;
            endptr = &bend;
        }
        else
        {
            itrptr = &itrc;
            endptr = &cend;
        }
    }
    cout << (char)toupper(next) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
  	if (i == 3) {
      cout << "8";
    } else {
      cout << (char)s[i];
    }
  }
  cout << endl;
}

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

using namespace std;
using swl = long long;

swl gcd(swl a, swl b) {
  return b ? gcd(b, a%b) : a;
}

int main(void) {  
  swl a, b; cin >> a >> b;
  swl c = a == b ? a : (a > b ? gcd(a, b) : gcd(b, a));

  if (c == 1) {
    cout << 1 << endl;
    return 0;
  }

  swl d = c;
  int ans = 1;
  
  if (d%2 == 0) {
    while (d%2 == 0) {
      d /= 2;
    }
    ans++;
  }

  for (swl i = 3; i*i <= c; i += 2) {
    if (d%i == 0) {
      while (d%i == 0) {
        d /= i;
      }
      ans++;
    }
  }
  
  if (d != 1) {
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int64> w(N + 1), v(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> w[i + 1] >> v[i + 1];
  }
  vector<vector<int64>> dp(N + 1, vector<int64>(W + 1));
  for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j >= w[i]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
    }
  }
  debug(dp);
  cout << dp[N][W] << endl;
  return 0;
  return 0;
}

Measured memory_bytes: 80256
//AOJ-GRL-1-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>> & G, /*vector<int> & prev,*/ const T INF = 1e9){
    using P = pair<T, int>;
    int V = G.size();
    vector<T> dist(V, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(0, s);
    //prev.assign(V, -1);
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < G[v].size(); i++){
            int to = G[v][i].first;
            T cost = G[v][i].second;
            if(dist[to] > dist[v] + cost){
                dist[to] = dist[v] + cost;
                //prev[to] = v;
                que.emplace(dist[to], to);
            }
        }
    }
    return dist;
}

signed main(){
    int v,e,r;
    cin >> v >> e >> r;
    using P = pair<int, ll>;
    vector<vector<P>> G(v);
    int s,t;
    ll d;
    REP(i,e){
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }
    vector<ll> dist = Dijkstra(r, G, LINF);
    REP(i,v){
        if(dist[i] == LINF){
            cout << "INF" << endl;
        }else{
            cout << dist[i] << endl;
        }
    }
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if(S.at(0) != S.at(1) && S.at(1) != S.at(2)) {
    if(S.at(0) != S.at(2)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
B = [[] for _ in range(m)]
for i in range(n):
    a,b = map(int,input().split())
    if 1 <= a <= m:
        B[a-1].append(b)
task = []
heapq.heapify(task)
ans = 0
for i in range(m):
    for t in B[i]:
        heapq.heappush(task,-t)
    if task:
        ans += heapq.heappop(task)
print(-ans)


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

int main(){
    int a,b,result;
    string op;
    while(1){
        cin >> a >> op >> b;
        if(op == "+"){
            result = a+b;
        }else if(op == "-"){
            result = a-b;
        }else if(op == "*"){
            result = a*b;
        }else if(op == "/"){
            result = a/b;
        }else if(op == "?"){
            break;
    }
    cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3020
// bubble sort バブルソート

#include <stdio.h>

// 標準出力にarrayを出力する関数
void printArray(int *A, int N){
    for(int i = 0; i < N; i++) {
        printf("%d", A[i]);
        if(i < N-1) printf(" ");  // 最後の要素以外は空白を挟む
    }
    printf("\n");
}

// 小さい順に並び替える バブルソート
int bubbleSort(int *A, int N) {
    int tmp;
    int count = 0;    // 交換した回数をカウントする変数
    int flag = 1; // 逆の隣接要素が存在する. L > R
    while(flag == 1) {
        flag = 0;
        for(int i = N - 1; i >= 1; i--) { // 最後のidx N-1 から idx 1 まで
            if(A[i - 1] > A[i]) {         // L > R なら入れ替える
                tmp = A[i];
                A[i] = A[i - 1];
                A[i - 1] = tmp;

                flag = 1;
                count++;
            }
        }
    }

    return count;
}

int main(int argc, char const *argv[]) {
    const int MAX = 100;
    int A[MAX];
    int N;
    int count;

    scanf("%d", &N);

    for(int i = 0; i < N; i++)
        scanf("%d", &A[i]);

    count = bubbleSort(A, N);

    printArray(A, N);
    printf("%d\n", count);

    return 0;
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;
  string ans;
  for(int i = 0; i < s.length(); i=i+2){
    ans = ans + s[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 656
def main():                                                                     
  data = raw_input()                                                            
  row = []                                                                      
  for c in data:                                                                
    if c == "B":                                                                
      if len(row):                                                              
        row.pop()                                                               
      continue                                                                  
    row.append(c)                                                               
  print(''.join(row))                                                           
                                                                                
main() 

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

int main(){
	int n;
	cin >> n;
	vector<int> num(200001, 0);
	vector<int> joushi(n + 1, 0);
	for (int i = 1; i < n; ++i)
	{
		cin >> joushi[i];
	}
	for (int i = 0; i < n; ++i)
	{
		if (joushi[i] > 0)
		{
			num[joushi[i]-1]++;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << num[i] << endl;
	}
}

Measured memory_bytes: 4844
#include <iostream>
using namespace std;
#define MAX_N 100010

bool is_like(int n) { 
    if (n == 1) return false;
    if (n == 3) return true;
    for (int i = 2; i * i <= n; i++) {
         if (n % i == 0) return false;
    }
    n = (n + 1) / 2;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int q; cin >> q;
    int ans[MAX_N] = {};
    for (int i = 1; i < MAX_N; i+=2) {
        ans[i] = is_like(i);
    }
    for (int i = 0; i < MAX_N - 1; i++) {
        ans[i + 1] += ans[i];
    }
    for (int i = 0; i < q; i++) {
        int l, r; cin >> l >> r;
        cout << ans[r] - ans[l - 1] << endl;
    }
}

Measured memory_bytes: 1024