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

int h,w;
int s[22][22];
int ans,sx,sy;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool dfs(int nh,int nw,int cnt){
    if(ans <= cnt) return false;
    for(int d=0;d<4;d++){
        int x=nh,y=nw;
        int nx = x+dx[d], ny = y+dy[d];
        if(nx<0 && nx>=h && ny<0 && ny>=w) continue;
        if(s[nx][ny]==1) continue;
        bool pos = false;
        for(int i = 0;i<20;i++){
            x += dx[d], y+=dy[d];
            if(s[x][y] == 3){
                ans = min(ans,cnt);
                pos = 1;
                break;
            }
            nx = x+dx[d], ny=y+dy[d];
            if(nx<0 || nx>=h || ny<0 || ny>=w) break;
            if(s[nx][ny]==1){
                s[nx][ny]=0;
                dfs(x,y,cnt+1);
                s[nx][ny]=1;
                break;
            }
        }
        if(pos) return true;
    }
    return true;
}

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

    while(cin>>w>>h){
        if(h==0) break;
        for(int i=0;i<h;i++)for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
        int sx,sy;
        for(int i=0;i<h;i++)for(int j=0;j<w;j++){
            if(s[i][j] == 2) sx=i,sy=j;
        }
        ans = 11;
        dfs(sx,sy,1);
        if(ans>10) ans = -1;
        cout << ans << "\n";
    }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int year,month,date;
    char c1,c2;
    cin>>year>>c1>>month>>c2>>date;
    if(month<=4)
    {
        cout<<"Heisei"<<endl;
    }
    else
    {
        cout<<"TBD"<<endl;
    }
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2] == S[3] && S[4] == S[5]) {
        cout << YES << endl;
    }else {
        cout << NO << endl;
    }
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  int n; cin >> n;
  int a[n];
  REP(i,n){
    cin >> a[i];
  }
  int b[n];
  REP(i,n){
    cin >> b[i];
  }
  int c[n-1];
  REP(i,n-1){
    cin >> c[i];
  }
  int sum = 0; 
  REP(i,n){
    if(i == 0){
      sum += b[a[i]-1];
      //cout << a[i] << b[a[i]-1] << sum <<"\n";
    }
    else{
      sum += b[a[i]-1]; 
      //cout <<a[i]<<b[a[i]-1]<< sum <<"\n";
      if(a[i-1]+1 == a[i]){
      	sum += c[a[i-1]-1]; 
        //cout << a[i-1] << a[i] << sum <<"\n";
      }
    }
  }
  cout << sum << "\n";
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	int h,n,x,sum=0;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		sum+=x;
	}
	if(sum>=h)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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


int main(){
    int maximum = 0;
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    int M;
    cin >> M;
    vector<string> T(M);
    for(int i = 0; i < M; i++){
        cin >> T.at(i);
    }

    for(int i = 0; i < N; i++){
        int base = count(S.begin(),S.end(),S.at(i)) - count(T.begin(),T.end(),S.at(i));
        maximum = max(maximum, base);
    }
    cout << maximum << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (s[i] != i+1)
                {
                    cnt++;
                }
            }
            if (cnt <= 2)
            {
                WriteLine("YES");
            }
            else WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13396
n=97
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):b(j+t-1);a(j+t,n,j+t);[b(s)for s in r(j+t,j+29)];a(j+29,x,i+t,1);b(j+t-1);a(j+t,i+t,j+t)
p(3933)
a(0,1,n)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):a(2,2,2);[(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)if t-30<s<30]

Measured memory_bytes: 9200
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map

#include <set> // set

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    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
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b, c,d,ans=0;
	cin >> a >> b >> c>>d;
	if (a > b)
		ans += b;
	else
		ans += a;
	if (c > d)
		ans += d;
	else
		ans += c;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int N, M, L;
vector<ll> A, B, C;
int Q;
vector<ll> s, t;

vector<vector<ll>> dist;

void WF(vector<vector<ll>> &dist){
  for(int i=0;i<dist.size();i++){
    for(int j=0;j<dist.size();j++){
      for(int k=0;k<dist.size();k++){
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
	}
  }
}

int main(){
  cin >> N >> M >> L;
  A = vector<ll>(M);
  B = vector<ll>(M);
  C = vector<ll>(M);
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i] >> C[i];
    A[i]--; B[i]--;
  }
  cin >> Q;
  s = vector<ll>(Q);
  t = vector<ll>(Q);
  for(int i=0;i<Q;i++){
    cin >> s[i] >> t[i];
    s[i]--; t[i]--;
  }
  
  ll INF = INT_MAX;
  dist = vector<vector<ll>>(N, vector<ll>(N, INF));
  for(int i=0;i<N;i++) dist[i][i] = 0;
  for(int i=0;i<M;i++){
    dist[A[i]][B[i]] = C[i];
    dist[B[i]][A[i]] = C[i];
  }
  WF(dist);
  for(int i=0;i<N;i++)for(int j=0;j<N;j++){
    if (i == j) {dist[i][j] = 0; continue;}
    if (dist[i][j] > L) dist[i][j] = INF;
    else dist[i][j] = 1;
  }
  WF(dist);
  for(int i=0;i<Q;i++){
    ll d = dist[s[i]][t[i]];
    cout << ((d < INT_MAX) ? d - 1 : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine().Trim().Split(' ');
            var (A, B) = (int.Parse(S[0]), int.Parse(S[2]));
            var op = S[1];
            var answer = op == "+" ? A + B : A - B;
            Console.WriteLine(answer);
        }
    }
}


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

int main(){
	//char c = 'c';
	//printf("%d", c-'a');
	char w[105];
	for(int i=0;i<105;i++){
	w[i]=0;
	}
	scanf("%s",w);

	int a[30];
	for(int i=0;i<30;i++){
	a[i]=0;
	}
	
	for(int i=0;i<105;i++){
	a[int(w[i])-97]++;
	}
	int flag=0;
	for(int i=0;i<30;i++){
	if(a[i]%2==1)flag=1;
	}
	if(flag==0)printf("Yes\n");
	if(flag==1)printf("No\n");
}

Measured memory_bytes: 256
import sys

import numpy as np
def sieve_of_eratosthenes(n=10 ** 7):
  sieve = np.ones(n + 1); sieve[:2] = 0
  for i in range(2, int(np.sqrt(n)) + 1):
    if sieve[i]: sieve[i*2::i] = 0
  return sieve, np.flatnonzero(sieve)

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = np.searchsorted(prime_numbers, x, side='left')
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 95756
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt(); // height
		int b = scan.nextInt(); // width
		System.out.println(a * b + " " + (a + b) * 2);
	}
}

Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

set<int> s;

signed main(){

	int N;
	cin >> N;

	for (int i = 0; i < N; i++){
		int a;
		cin >> a;
		if (s.find(a) == s.end()) s.insert(a);
		else s.erase(a);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 4864
from collections import Counter
import sys

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

def main():
    n=II()
    mx=10**6
    aa=LI()
    ac=Counter(aa)
    #print(aa)

    ok=[True]*(mx+1)
    ans=0
    for a,c in sorted(ac.items()):
        if ok[a]:
            if c==1:ans+=1
            for b in range(a*2,mx+1,a):
                ok[b]=False
    print(ans)

main()

Measured memory_bytes: 137640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  vector<pair<int,int>> ans;
  if(n%2){
    for(int i=1;i<n;i++){
      ans.push_back(make_pair(n,i));
    }
    for(int i=1;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(i+j==n) continue;
        ans.push_back(make_pair(i,j));
      }
    }
  }else{
    for(int i=2;i<n;i++){
      ans.push_back(make_pair(n,i));
    }
    for(int i=2;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(i+j==n+1) continue;
        ans.push_back(make_pair(i,j));
      }
    }
    for(int i=2;i<n;i++) ans.push_back(make_pair(1,i));
  }

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }

  return 0;
}


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

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

int main() {
  ll n;
  cin >> n;
  vector<ll> d1;
  vector<ll> d2;
  for(ll i = 1; i * i <= n; ++i){
    if(n % i == 0){
      d1.push_back(i);
      d1.push_back(n / i);
      d2.push_back(i);
      d2.push_back(n / i);
    }
  }

  reverse(d2.begin(), d2.end());
  
  int ans = 1000000;
  for(int i = 0; i < d1.size() / 2; ++i){
    string s1 = to_string(d1[i]);
    string s2 = to_string(d2[i]);
    int f = max(s1.size(), s2.size());
    ans = min(ans, f);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,ans = 0,tmp = 0;
	map<int,int> cnt;
	cin >> n >> m;
	cnt[0]++;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		tmp = (tmp + a) % m;
		ans += cnt[tmp]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn max (a: &i64, b:&i64) -> i64{
    if *a < *b {*b} else {*a}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: String
    }
    let mut ns = n.clone();
    let mut i = 0;
    let mut result = true;
    while result && i < n.len(){
        if (n.len()-i-5) as isize >= 0 && &ns[n.len()-i-5..n.len()-i] == "dream" {
            i += 5;
        }
        else if (n.len()-i-7) as isize >= 0 && &ns[n.len()-i-7..n.len()-i] == "dreamer" {
            i += 7;
        }
        else if (n.len()-i-5) as isize >= 0 && &ns[n.len()-i-5..n.len()-i] == "erase" {
            i += 5;
        }
        else if (n.len()-i-6) as isize >= 0 && &ns[n.len()-i-6..n.len()-i] == "eraser" {
            i += 6;
        }
        else { result = false; }
    }
    print!("{}", if result {"YES"} else {"NO"}.to_string());
}


Measured memory_bytes: 4352
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (k, x) = readListOfInt()
    val min = x-k+1
    val max = x + k - 1
    
    (min until max).map {print("$it ")}
    print("$max\n")
    
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37616
//B - Go to Jail
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define M 1000000007
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  ll n,a[10010], b[10010],ans=0;
  scanf("%lld", &n);
  for(ll i = 1; i <= n; i++) {
    scanf("%lld %lld", &a[i], &b[i]);
  }

  for(ll i = 1; i <= n-2; i++) {
    if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]){
      ans++;
    }
  }

  if(ans>=1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 1636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll MOD = 1e9 + 7;

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD;
		--b;
	}
	return ans;
}

ll n, k;
ll dp[10000];
vector<ll> vv;

int main() {
	cin >> n >> k;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0)
			continue;
		vv.push_back(i);
		if (i * i != n)
			vv.push_back(n / i);
	}
	sort(vv.begin(), vv.end());
	if (n % 2 == 0) {
		vector<ll> gg;
		for (ll i: vv)
			if ((n / i) % 2 == 0)
				gg.push_back(i);
		vv = gg;
		ll ans = 0;
		for (int i = 0; i < vv.size(); ++i)
			dp[i] = pw(k, vv[i]);
		for (int i = 0; i < vv.size(); ++i) {
			ans = (ans + dp[i] * vv[i]) % MOD;
			for (int j = i + 1; j < vv.size(); ++j)
				if (vv[j] % vv[i] == 0)
					dp[j] = (dp[j] - dp[i] + MOD) % MOD;
		}
		cout << ans << "\n";
	}
	else {
		ll ans = 0;
		for (int i = 0; i < vv.size(); ++i)
			dp[i] = pw(k, (vv[i] + 1) / 2);
		for (int i = 0; i < vv.size(); ++i) {
			ans = (ans + dp[i] * vv[i]) % MOD;
			for (int j = i + 1; j < vv.size(); ++j)
				if (vv[j] % vv[i] == 0)
					dp[j] = (dp[j] - dp[i] + MOD) % MOD;
		}
		cout << ans << "\n";
	}
	return 0;
}




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

using namespace std;

typedef long long ll;

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

    vector <int> a(n);
    for(int& x : a) scanf("%d", &x);

    int Ans = k - a.back() + a[0];

    for(int i = 0; i + 1 < n; i++)  Ans = max(Ans, a[i + 1] - a[i]);

    cout << k - Ans << endl;
}


Measured memory_bytes: 1024
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left >= n && right >= n) return;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String s = scan.next();
		String message = "No";
		try {
			Integer.parseInt(s.substring(0, a));
			Integer.parseInt(s.substring(a + 1));
			if(s.length() - a == b + 1) {
				if(s.charAt(a) == '-') {
					message = "Yes";
				} 
			}
		} catch(NumberFormatException e){
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
    int H,W,i,j,k,l;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    if(H%2 == 0 && W%2 == 0){
        for(i=0;i<H/2;i++){
            for(j=0;j<W/2;j++){
                printf("#.");              
            }
            printf("\n");
            for(k=0;k<W/2;k++){
                printf(".#");
            }
            printf("\n");
        }
        printf("\n");
     }
    if(H%2 == 0 && W%2 == 1){
        for(i=0;i<H/2;i++){
            for(j=0;j<(W-1)/2;j++){
                printf("#.");
            }
                printf("#\n");
            for(k=0;k<(W-1)/2;k++){
                printf(".#");
            }
                printf(".\n");
        }
        printf("\n");
    }
    if(H%2 == 1 && W%2 == 0){
         for(i=0;i<(H-1)/2;i++){
            for(j=0;j<W/2;j++){
                printf("#.");
            }
                printf("\n");
            for(k=0;k<W/2;k++){
                printf(".#");
            }
                printf("\n");
        }
        for(l=0;l<W/2;l++){
            printf("#.");
        }
        printf("\n\n");
    }
    if(H%2 == 1 && W%2 == 1){
        if(H==0 && W==0)printf("#");
         for(i=0;i<(H-1)/2;i++){
            for(j=0;j<(W-1)/2;j++){
                printf("#.");
            }
                printf("#\n");
            for(k=0;k<(W-1)/2;k++){
                printf(".#");
            }
                printf(".\n");
         }
        for(l=0;l<(W-1)/2;l++){
            printf("#.");
        }
        printf("#\n\n");
    }
    }
     return 0;
}
  

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;

int borrow[17];
char A[17],B[17],C[17];
void SYORI();
void INPUT(char a[],char tmp[]){
  for(int i=0;i<15;i++) tmp[i]='0';
  tmp[16]='\0';
  for(int i=15,j=strlen(a)-1;j>=0;i--,j--){
    tmp[i]=a[j];
  }
  return;
}

int main(){
  int K;
  char a[17],b[17],tmp[17];
  for(int i=0;i<16;i++)C[i]='0';
  C[16]='\0';borrow[15]=0;
  cin >> a >> b >> K;

  INPUT(a,tmp); strcpy(A,tmp);
  INPUT(b,tmp); strcpy(B,tmp);

  SYORI();

  if(K>0){
    for(int i=0;i<16;i++){
      if(borrow[i]==1){
	if(C[i] != '9'){
	  C[i]++;
	}
      K--;
      if(K==0)break;
      }
    }
  }
  int i;
  for(i=0;C[i]=='0';i++);
  for(;i<16;i++){
    printf("%c",C[i]);
  }
  puts("");

}

void SYORI(){
  for(int i=15;i>=1;i--){
    if((A[i]-'0')-borrow[i]>=(B[i]-'0')){
      C[i]=(A[i]-'0')-borrow[i]-(B[i]-'0') + '0';
      borrow[i-1]=0;
    }else{
      C[i]=(A[i]-'0')-borrow[i]+10-(B[i]-'0') + '0';
      borrow[i-1]=1;
    }
  }
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
int main()
{  int a,b,c,d,e,x,maxi;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	x=std::max(c,d);
	maxi=std::max(x,e);
	cout<<maxi;
}	


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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int ans=(a+b)/2;

    if((a+b)%2==0){
        cout << ans << endl;
    }else{
        puts("IMPOSSIBLE");
    }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void)
{
	int b, r, g, c, s ,t;
	
	while (scanf("%d %d %d %d %d %d", &b, &r, &g, &c, &s, &t)){
		if (b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) break;
		
		int coin = 100;
		
		for (int i = 0; i < (b * 5) + (r * 3); i++){
			coin += 13;
		}
		coin += b * 15;
		coin += r * 15;
		
		for (int i = 0; i < g; i++){
			coin += 7;
		}
		
		for (int i = 0; i < c; i++){
			coin += 2;
		}
		
		for (int i = 0; i < s; i++){
			coin += 3;
		}
		
		coin -= (t - (b*5 + r*3))*3;
		
		printf("%d\n", coin);
	}
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, a[nsz + 5];

bool inline add_one(int fm, int mx, map<int, int> &d) {
	if (mx == 1)  return 0;
	for (int i = fm; i >= 1; --i) {
		if (d[i] < mx - 1) {
			++d[i];
			return 1;
		}
		d[i] = 0;
	}
	return 0;
}

bool inline chk(int mx) {
	map<int, int> d;
	cont (i, n) {
		int cur = a[i], pre = a[i - 1];
		if (cur > pre) {
			d[cur] = 0;
		} else {
			if (!add_one(cur, mx, d))  return 0;
		}
		d.erase(d.upper_bound(cur), d.end());
	}
	return 1;
}

int inline solve() {
	int l = 0, r = n + 1, md = (l + r) >> 1;
	for (; r - l > 1; md = (l + r) >> 1) {
		(chk(md) ? r : l) = md;
	}
	return r;
}

int inline read() {
	int res = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar());
	for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
	return res;
}

void inline write(int a, char c) {
	int s = 0, d[10] = {0};
	for (; a; d[s++] = a % 10, a /= 10);
	for (s = s ? s : 1; s; putchar(d[--s] + 48));
}

int main() {
	n = read();
	cont (i, n) {
		a[i] = read();
	}
	write(solve(), ln);
}

Measured memory_bytes: 10368
#include<iostream>
using namespace std;
int main(){
    long int N,K,ans,p,x[100001];
    cin>>N>>K;
    for(int i=1;i<=K-1;i++){
        cin>>x[i];
    }
    cin>>x[K];
    if(x[1]*x[K]<0){
        if(-x[1]>x[K])ans=(2*x[K])-x[1];
        else ans=x[K]-(2*x[1]);
    }
    else if(x[1]<0)ans=-x[1];
    else ans=x[K];
    for(int i=K+1;i<=N;i++){
        cin>>x[i];
        if(x[i-K+1]*x[i]<0){
            if(-x[i-K+1]<x[i])p=x[i]-(2*x[i-K+1]);
            else p=2*x[i]-x[i-K+1];
        }
        else if(x[i-K+1]<0)p=-x[i-K+1];
        else p=x[i];
        if(p<ans)ans=p;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int a[10];
int main() {
	while (true) {
		for (int i = 0; i < 10; i++)cin >> a[i];
		if (a[0] == -1)break;
		int b[10] = { 0,1,2,3,4,5,6,7,8,9 }; int cnt = 0;
		do {
			int OK = 1; int f[10];
			for (int i = 0; i < 10; i++)f[i] = b[i] + 1;
			for (int i = 0; i < 10; i++) {
				if (a[i] >= 1 && a[i] != f[i])OK = 0;
			}
			if (OK == 0)continue;
			int c[4][4];
			for (int i = 0; i < 16; i++)c[i / 4][i % 4] = 0;
			for (int i = 0; i < 9; i++) {
				c[i / 3][i % 3] = f[i];
				c[3][i % 3] += f[i]; c[3][i % 3] %= f[9];
				c[i / 3][3] += f[i]; c[i / 3][3] %= f[9];
			}
			if (c[3][0] != c[3][1] || c[3][1] != c[3][2])continue;
			if (c[0][3] != c[1][3] || c[1][3] != c[2][3])continue;
			int d1 = c[0][0] + c[1][1] + c[2][2]; d1 %= f[9];
			int d2 = c[0][2] + c[1][1] + c[2][0]; d2 %= f[9];
			if (c[3][0] != d1 || d1 != d2)continue;
			cnt++;
		} while (next_permutation(b, b + 10));
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def bisect(a,B,lo,hi):
    if hi-lo<=1:
        return hi
    elif B[(hi+lo)//2]>=a:
        return bisect(a,B,(hi+lo)//2,hi)
    else:
        return bisect(a,B,lo,(hi+lo)//2)

N = int(input())

A = [int(input()) for i in range(N)]

B = [A[0]]

for i in range(1,N):
    if B[-1]>=A[i]:
        B.append(A[i])
    else:
        if B[0]<A[i]:
            B[0]=A[i]
        else: 
            B[bisect(A[i],B,0,len(B)-1)]=A[i]
print(len(B))

Measured memory_bytes: 7840
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

ll pow5(ll a) {
    return a * a * a * a * a;
}



signed main() {
    ll x;
    cin >> x;
    for (ll a = 0; a <= x; a++) {
        ll y = pow5(a) - x;

        ll z = abs(y);
        if (z == 0) {
            ll b = 0;
            cout << a << " " << b << endl;
            return 0;
        }

        ll ng = 0, ok = 2000;
        while (ng + 1 < ok) {
            ll mid = (ng + ok) / 2;
            if (pow5(mid) >= z) ok = mid;
            else ng = mid;
        }
        if (pow5(ok) == z) {
            ll b = ok;
            if (y < 0) b *= -1;
            cout << a << " " << b << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int W,a,b;
	scanf("%d%d%d",&W,&a,&b);
	int res;
	if(a>b){
		if(a-b<=W){
			printf("0");
		}
		else if(a-b>W){
			printf("%d",a-b-W);
		}
	}
	else if(a<b){
		if(b-a<=W){
			printf("0");
		}
		else if(b-a>W){
			printf("%d",b-a-W);
		}
	}
	else{
		printf("0");
	}
}

Measured memory_bytes: 128
import numpy as np
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
a=np.array(a)
b=np.array(b)
c=np.array(c)

cnt_a=np.searchsorted(a,b)
cnt_c=n-np.searchsorted(c,b,side='right')
print(np.sum(cnt_a*cnt_c))

Measured memory_bytes: 40324
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<string.h>
using namespace std;
int main(){
    char str1[1000],str2[1000],str3[1000];
    scanf("%s %s",str1,str2);
    strcpy(str3,str1);
    strcat(str3,str1);
    if(strstr(str3,str2)==NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
    
}




Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 2019;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long L, long long R)
{

    ll ans = INT16_MAX;
    if (R - L + 1 >= 2019)
    {
        cout << 0 << endl;
    }
    else
    {
        for (ll i = L; i <= R; i++)
        {
            for (ll j = L; j <= R; j++)
            {
                if (i < j)
                {
                    ans = min(((i % MOD) * (j % MOD)) % MOD, ans);
                }
                else
                {
                    continue;
                }
            }
        }
        cout << ans << endl;
    }
}

int main()
{
    long long L;
    scanf("%lld", &L);
    long long R;
    scanf("%lld", &R);
    solve(L, R);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; 
    cin >> n;
    int m; 
    cin >> m;
    vector<vector<int>> graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
    }

    int s, t;
    cin >> s >> t;
    --s, --t;

    const int INF = 1 << 29;
    vector<vector<int>> dis(n, vector<int>(3, INF));

    deque<pair<int,int>> que;
    que.emplace_back(s, 0);
    dis[s][0] = 0;

    while (!que.empty()) {
        int u = que.front().first;
        int st = que.front().second;
        que.pop_front();

        for (auto v : graph[u]) {
            int nst = (st + 1) % 3;
            int w = nst == 0 ? 1 : 0;
            if (dis[v][nst] > dis[u][st] + w) {
                dis[v][nst] = dis[u][st] + w;
                if (w == 0) {
                    que.emplace_front(v, nst);
                } else {
                    que.emplace_back(v, nst);
                }
            }
        }
    }

    if (dis[t][0] < INF) {
        cout << dis[t][0] << "\n";
    } else {
        cout << -1 << "\n";
    }


    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define M 100000008

ll h, w;
char a[1001][1001];
ll dp[1001][1001];
ll o[1001][1001];
ll m = 1000000007;

void pr(ll i, ll j)
{
//	trace2(i,j);
	if((i == h-1)&&(j == w-1))
		dp[i][j] = 1;
	else
	{
		if((i+1 < h)&&(a[i+1][j] == '.'))
		{
			if(o[i+1][j])
				dp[i][j] += dp[i+1][j];
			else
			{
				pr(i+1,j);
				o[i+1][j] = 1;
				dp[i][j] += dp[i+1][j];
			}
			dp[i][j] = dp[i][j]%m;
		}
		if((j+1 < w)&&(a[i][j+1] == '.'))
		{
			if(o[i][j+1])
				dp[i][j] += dp[i][j+1];
			else
			{
				pr(i,j+1);
				o[i][j+1] = 1;
				dp[i][j] += dp[i][j+1];
			}
			dp[i][j] = dp[i][j]%m;
		}
	}
}

int main()
{
	//FAST;
	ll i, j;
	cin >> h >> w;
	fr(i,0,h)
		fr(j,0,w)
			cin >> a[i][j];
	pr(0,0);
	cout << dp[0][0];
}


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

struct BIT
{
    static const int N= 4006;
    int a[N];
    int n;
    void init(int _n)
    {
        memset(a,0,sizeof(a));
        n = _n;
    }
    void update(int pos,int val)
    {
        for (int i=pos;n>=i;i+=i&(-i))
        {
            a[i] += val;
        }
    }
    int Q(int pos)
    {
        int ret=0;
        for (int i=pos;i>0;i-=i&(-i))
        {
            ret += a[i];
        }
        return ret;
    }
    int Q2(int L,int R)
    {
        return Q(R) - Q(L-1);
    }
} bit;

const int N = 4006;

int dp[N][N];

int a[N],b[N];
int pos[N];

int main ()
{
    int n;
    cin >> n;
    for (int i=1;2*n>=i;i++)
    {
        char c;
        int x;
        cin >> c >> x;
        if (c == 'W') a[i] = 1,b[i] = x;
        else a[i] = 2,b[i] = x;
        pos[ (a[i]-1)*n + x ] = i;
    }
    memset(dp,(0x3f3f3f3f),sizeof(dp));
    dp[0][0] = 0;
    for (int i=0;n>=i;i++)
    {
        bit.init(2*n);
        for (int j=1;n>=j;j++)
        {
            if (j <= i) ;
            else bit.update(pos[j],1);
            bit.update(pos[j+n],1);
        }
        for (int j=0;n>=j;j++)
        {
            if (j) bit.update(pos[j+n],-1);
            if (i != n) dp[i+1][j] = min(dp[i+1][j],dp[i][j] + bit.Q2(1,pos[i+1]-1));
            if (j != n) dp[i][j+1] = min(dp[i][j+1],dp[i][j] + bit.Q2(1,pos[j+n+1]-1));
        }
    }
    cout << dp[n][n] << endl;
}


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

int main(){
	map<string, int> mp;
	string s;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> s;
		mp[s]++;
	}
	int maxv=-11;
	map<string,int>::iterator it=mp.begin();
	for(; it!=mp.end(); it++){
		if((*it).second>maxv) maxv = (*it).second;
	}
	it = mp.begin();
	for(; it!=mp.end(); it++){
		if((*it).second==maxv) cout << (*it).first << endl;
	}
	return 0;
}

Measured memory_bytes: 25216
import heapq


def make_ans(str1, str2):
    while len(str1) < 6:
        str1 = '0' + str1
    while len(str2) < 6:
        str2 = '0' + str2
    return str1 + str2


n, m = map(int, input().split())
ken = [[] for _ in range(n + 1)]
# for i in range(1, n + 1):
#     heapq.heapify(ken[i])
memo = []
for i in range(1, m + 1):
    p, y = map(int, input().split())
    ken[p].append(y)
    memo.append((p, y))
for i in range(1, n + 1):
    ken[i].sort()
# print(ken)
for q in memo:
    ans_left = str(q[0])
    begin = 0
    end = len(ken[q[0]]) - 1
    ans_index = -1
    mid = 0
    while True:
        # if q[0] == 2:
        #     print(ken[q[0]])
        mid = (end + begin) // 2
        if ken[q[0]][mid] > q[1]:
            end = mid
        elif ken[q[0]][mid] < q[1]:
            begin = mid
        else:
            ans_index = mid
            break
        if ken[q[0]][end] == q[1]:
            ans_index = end
            break
        elif ken[q[0]][begin] == q[1]:
            ans_index = begin
            break
    ans_right = str(ans_index + 1)
    print(make_ans(ans_left, ans_right))

Measured memory_bytes: 94500
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
const int maxN = 1005;
const int maxV = maxN * (maxN - 1) / 2;
// トポロジカルソートされるグラフ
vector<int> to[maxV];
int id[maxN][maxN];
 
int toId(int i, int j) {
    if (i > j) swap(i, j);
    return id[i][j];
}
 
bool visited[maxV]; // 関数外の変数については, ポインタはnull数値はゼロ値になるらしい.
bool calced[maxV];
int day[maxV];
int dfs(int v) {
    if (visited[v]) {
        if (!calced[v]) return -1;
        return day[v];
    }
    visited[v] = true;
    day[v] = 1;
    // この計算中にまた自分自信に来ることがある. そのときは絶対に完成しないので, -1を返す.
    for (int e : to[v]) {
        int dayBefore = dfs(e); // 前回の回の日程を取得している.
        if (dayBefore == -1) {
            return -1;
        }
        // vに来るまでにやつ必要があった試合の日付よりも後の日付に設定する
        day[v] = max(day[v], dayBefore + 1);
    }
    calced[v] = true;
    return day[v];
}
 
 
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // A_{i, j + 1} は A_{i, j}が終わらないとできない -> Aが終わった後にBをしなければならない
    // とき A -> Bとしたグラフを作り, そのグラフについてトポロジカルソートみたいなことをやる.
    // トポロジカルソートすると同時に, day(B) = day(A) + 1みたいな感じにしておく
    int N;
    cin >> N;
 
    // 対戦相手の情報をとりあえず入れておくやつ
    vector<vector<int>> ops(N, vector<int>(N - 1));
    for (int i = 0; i < N; i ++) {
        for (int j = 0; j < N - 1; j++) {
            cin >> ops[i][j];
            ops[i][j]--;
        }
    }
    // 次はidを振る
    int V = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i >= j) continue;
            id[i][j] = V++;
        }
    }
    // そして試合番号のグラフを作る
    // 次のやつをグラフに入れるだけでいい.
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 2; j++) {
            // 一つ後の試合番号 ひとつ前の試合番号
            to[toId(i, ops[i][j + 1])].push_back(toId(i, ops[i][j]));
        }
    }
    // 次はトポロジカルソートっぽいことをして, 何日目かを得る.
    int last = 0;
    for (int v = 0; v < V; v++) {
        int day = dfs(v);
        if (day == -1) {
            cout << -1 << endl;
            return 0;
        }
        last = max(last ,day);
    }
    cout << last << endl;
 
    return 0;
}

Measured memory_bytes: 48384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		var ABC = Console.ReadLine().Split();
		if (ABC[0] == ABC[1])
		{
			Console.WriteLine(ABC[2]);
		}
		else if (ABC[1] == ABC[2])
		{
			Console.WriteLine(ABC[0]);
		}
		else
		{
			Console.WriteLine(ABC[1]);
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdint>
#include <vector>

int main() {
  std::int_fast64_t n, m, q;
  std::cin >> n >> m >> q;

  std::vector<std::vector<std::int_fast64_t>> table(n, std::vector<std::int_fast64_t>(n, 0));
  for (std::int_fast64_t i = 0; i < m; ++i) {
    std::int_fast64_t l, r;
    std::cin >> l >> r;
    --l;
    --r;
    ++table[l][r];
  }
  for (std::int_fast64_t l = 0; l < n; ++l) {
    for (std::int_fast64_t r = l + 1; r < n; ++r) {
      table[l][r] += table[l][r - 1];
    }
  }
  for (std::int_fast64_t i = 0; i < q; ++i) {
    std::int_fast64_t ll, rr;
    std::cin >> ll >> rr;
    --ll;
    --rr;

    std::int_fast64_t result = 0;
    for (std::int_fast64_t l = ll; l <= rr; ++l) {
      result += table[l][rr];
    }
    std::cout << result << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int main()
{
	int W,N,csn = 1;
	char ch;
	while(cin >> W,W){
		cin >> N;
		vector< P > takara(N + 1);
		vector< vector< int > > dp(N + 1, vector< int >(W + 1,0));
		for(int i = 1;i <= N;i++){
			cin >> takara[i].first >> ch >> takara[i].second;
		}
		for(int i = 1;i <= N;i++){
			for(int j = 1;j <= W;j++){
				if ((j - takara[i].second >= 0) && (dp[i - 1][j - takara[i].second] + takara[i].first > dp[i - 1][j])) {
					dp[i][j] = dp[i - 1][j - takara[i].second] + takara[i].first;
				}
				else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}
		int n = W;
		while (dp[N][n] == dp[N][W])
			n--;
		cout << "Case " << csn << ":" << endl;
		cout << dp[N][W] << endl;
		cout << n + 1 << endl;
		csn++;
	}
	return 0;
}

Measured memory_bytes: 5032