akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int M;
char A[50][52];
char B[50][52];
int main(){
  int i, j, k, res=0, x, y;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<M;KL2GvlyY++){
      rd(B[KL2GvlyY]);
    }
  }
  for(x=0;x<N-M+1;x++){
    for(y=0;y<N-M+1;y++){
      k = 0;
      for(i=0;i<M;i++){
        for(j=0;j<M;j++){
          if(A[i+x][j+y] == B[i][j]){
            k++;
          }
        }
      }
      if(k==M*M){
        wt_L("Yes");
        wt_L('\n');
        return 0;
      }
    }
  }
  wt_L("No");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, M;
// char A[50][52], B[50][52];
// {
//   int i, j, k, x, y, res = 0;
//   
//   rd(N,M,A(N),B(M));
// 
//   rep(x,N-M+1) rep(y,N-M+1){
//     k = 0;
//     rep(i,M) rep(j,M) if(A[i+x][j+y] == B[i][j]) k++;
//     if(k==M*M){
//       wt("Yes");
//       return 0;
//     }
//   }
// 
//   wt("No");
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
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; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    VLL X(N);
    rep(i,N){
        cin >> X[i];
    }
    int sum=0;
    int ave=0;
    int tmp1=0;
    int tmp2=0;
    int tmp3=0;
    rep(i,N){
        sum+=X[i];
    }
    ave=sum/N;
    rep(i,N){
        tmp1+=pow(ave-X[i],2);
    }
    rep(i,N){
        tmp2+=pow(ave+1-X[i],2);
    }
    rep(i,N){
        tmp3+=pow(ave-1-X[i],2);
    }
    int mini=INF;
    mini=min(mini,tmp1);
    mini=min(mini,tmp2);
    mini=min(mini,tmp3);

    cout << mini << endl;
}


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

using namespace std;
using ll = long long;


int main()
{
	int h, w, k; cin >> h >> w >> k;

	for(int i = 0; i <= h; i++) {
		for(int j = 0; j <= w; j++) {

			if(i * j + (h - i) * (w - j) == k) {
				cout << "Yes" << endl;
				return 0;
			}

		}
	}
	cout << "No" << endl;

}

Measured memory_bytes: 256
def solver(S,T):
    search_len = len(T)
    times = len(S) - len(T) + 1
    min = 1000
    for i in range(times):
        diff = diff_counter(S[i:search_len+i],T)
        if diff < min:
            min = diff
    return min
def diff_counter(S,T):
    counter = 0
    for i in range(len(S)):
        Si = S[i]
        Ti = T[i]
        if Si != Ti:
            counter += 1
    return counter
S = input()
T = input()
print(solver(S,T))

Measured memory_bytes: 9136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
Int rest;

Int cnt(vector<Int> &a, Int m){
    Int ans = 0;
    for(int i = 0;i < a.size() - 1;i++){
        ans += max(0ll, a[i] - m + 1);
    }
    ans += a.back() - max(rest, m-1);
    return ans;
}

int main(){
    Int n, m, k;
    cin >> n >> m >> k;
    vector<Int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    rest = m;
    while(!a.empty() && a.back() <=rest){
        rest -= a.back();
        a.pop_back();
    }
   
    Int sum = 0;
    for(auto x:a)sum += x;
    if(sum - k - rest <= 0){
        cout << 0 << endl;
        return 0;             
    }
    
    Int bottom = 0, top = a.back() + 1;
    while(top - bottom > 1){
        Int mid = (top + bottom) / 2;
        if(cnt(a, mid) <= k)top = mid;
        else bottom = mid;
    }
    for(int i = 0;i < a.size();i++){
        Int goal = top-1;
        if(i+1 == a.size())goal = max(goal, rest);
        if(a[i] >= goal){
            k -= a[i] - goal;
            a[i] = goal;
        }
    }
    if(a.back() == rest){
        rest = 0;
        a.pop_back();
    }
    for(int i = (int)a.size()-1;i >= 0 && k > 0;i--){
        a[i]--;
        k--;
    }
    Int ans = 0;
    for(auto x:a)ans += (x+1) * x / 2;
    ans -= (rest + 1) * rest / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>

using namespace std;

int X;

int main() {
  scanf("%d", &X);
  if (400 <= X && X <= 599) {
    puts("8");
  } else if (600 <= X && X <= 799) {
    puts("7");
  } else if (800 <= X && X <= 999) {
    puts("6");
  } else if (1000 <= X && X <= 1199) {
    puts("5");
  } else if (1200 <= X && X <= 1399) {
    puts("4");
  } else if (1400 <= X && X <= 1599) {
    puts("3");
  } else if (1600 <= X && X <= 1799) {
    puts("2");
  } else if (1800 <= X && X <= 1999) {
    puts("1");
  }
}


Measured memory_bytes: 3756
using System;

public class Test
{
	public static void Main()
	{
            string[] data;
            int H, W;//???????¨?
            while(true){

                data = Console.ReadLine().Split();
                if (int.Parse(data[0])== 0 && int.Parse(data[1]) == 0)
                {
                    break;
                }

                for (H = int.Parse(data[0]); H > 0; H--)
                {
                    for (W = int.Parse(data[1]); W > 0; W--)
                    {
                        if (H != 1 && W!=1 && H!=int.Parse(data[0]) && W != int.Parse(data[1]))
                        {
                            Console.Write(".");
                        }
                        else
                        {
                            Console.Write("#");
                        }                  
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
	}
}

Measured memory_bytes: 8792
h, w = map(int, input().split())
b = 0
l = [0]*h
for k in range(h):
  a = str(input())
  for k_ in range(w):
    if a[k_] == '#':
      b += 1
  l[k] = a
#l = [str(input()) for _ in range(h)]
 
from collections import deque
 
queue = deque()
visit = [[-1]*w for _ in range(h)]
queue.append([0, 0])
visit[0][0] = 1
 
while queue:
  y, x = queue.popleft()
  if y == h-1 and x == w-1:
    print(h*w-visit[y][x]-b)
    exit()
  for i, j in ([-1, 0], [1, 0], [0, 1], [0, -1]):
    new_y, new_x = y+i, x+j
    if (new_x>=0) and (new_x<w) and (new_y>=0) and (new_y<h) and l[new_y][new_x]=='.' and visit[new_y][new_x] == -1:
      visit[new_y][new_x] = visit[y][x]+1
      queue.append([new_y,new_x])
    else:
      continue
else:
  print('-1')

Measured memory_bytes: 3316
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [int(p) for p in input().split()]
    diff = 0
    for i in range(N):
        if P[i] != i + 1: diff += 1
    if diff <= 2: print("YES")
    else: print("NO")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9036
//
//  main.cpp
//  1094
//
//  Created by cfhaiteeh on 2018/4/20.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define LL long long
using namespace  std;
struct he{
    int ch[12];
}edge[1234];
int T;
int n,m,k;

char ch[12];
LL ans;
bool vis[12];
int ci[12];
LL calsum(int len,int now,int l,int r){
    if(now==len+1){
        return 0;
    }
    if(l>r)return 0;
    int x=ci[now];
   
    int sum1=0,sum2=0;
    for(int i=l;i<=r;i++){
        if(edge[i].ch[x]==1){
            sum1++;
        }
        else{
            sum2++;
        }
    }
    int ee=r;
    for(int i=l;i<=sum1+l-1;i++){
        if(edge[i].ch[x]==2){
            for(int j=ee;j>=1;j--){
                if(edge[j].ch[x]==1){
                    ee=j-1;
                    swap(edge[i],edge[j]);
                    break;
                }
            }
        }
    }
    LL tm1=calsum( len, now+1,l,l+sum1-1);
    LL tm2=calsum(len, now+1,r-sum2+1,r);
    return tm1+tm2+(sum1*sum2);
}
vector<he> V;
void DFS(int depth){
    if(depth==m+1){
        memset(ci,0,sizeof(ci));
        int st=0;
        for(int i=1;i<=m;i++){
            if(vis[i]){
                st++;
                ci[st]=i;
            }
        }
        LL sum=calsum( st, 1,1,n);
        if(sum>=k){
            ans++;
        }
        
        return;
    }
    vis[depth]=1;
    DFS(depth+1);
    vis[depth]=0;
    DFS(depth+1);
    
}
int main() {
    // insert code here...
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n>=2800)printf("AGC\n");
        else if(n>=1200)printf("ARC\n");
        else printf("ABC\n");
    }
    return 0;
}


Measured memory_bytes: 256
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	s=26
	1-s
	s+1 - 
	s*(s+1)+1 - s*(s+1)*(s+1)      
	27-26*27
	26

*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		ll n;
		cin>>n;
		string ans="";
		while(n)
		{
			n--;
			ans+=char((int)'a' + n%26);
			n/=26;
		}
		reverse(all(ans));
		cout<<ans;
    }
    return 0;
} 


Measured memory_bytes: 3624
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String n = sc.next();
		if (n.charAt(0) == '7' || n.charAt(1) == '7' || n.charAt(2) == '7') {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}

Measured memory_bytes: 27000
inf = 1 << 20
need = -1, 2, 5, 5, 4, 5, 6, 3, 7, 6

n, m = map(int, input().split())
a = map(int, input().split())
d = {need[x]: x for x in sorted(a)}  # sortedで昇順にすることで、同じ本数のとき最大値が残る
e = tuple(sorted(d.items(), key=lambda x: x[1], reverse=True))  # (必要本数,数字)

dp = [-inf] * (n + 1)
dp[0] = 0
# dp[k]:=k本で構成可能な最大桁数

for j in range(1, n + 1):
    dp[j] = max((dp[j - cnt] for cnt, _ in e if j - cnt >= 0), default=-inf) + 1

ret = []
r = dp[n]

curr = n
while r > 0:
    for cnt, num in e:
        if curr - cnt >= 0 and dp[curr - cnt] == r - 1:
            ret.append(num)
            r -= 1
            curr -= cnt
            break

ret.sort(reverse=True)
print(''.join(map(str, ret)))


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] f = new int[n][10];
		int[][] p = new int[n][11];
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < 10 ; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < 11 ; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		int ans = -1001001001;
		for(int mask = 1 ; mask < (1<<10) ; mask++) {
			int money = 0;
			for(int i = 0 ; i < n ; i++) {
				int cnt = 0;
				for(int j = 0 ; j < 10 ; j++) {
					if((mask&(1<<j)) >= 1 && f[i][j] == 1) cnt++;
				}
				money += p[i][cnt];
			}
			ans = Math.max(ans, money);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26520
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

typedef long long ll;

const int MX=200005;
string s[MX];

struct node{
    int to[26],cnt[26],f;
    node(){
        f=0;
        memset(to,-1,sizeof(to));
        memset(cnt,0,sizeof(cnt));
    }
};
int sz=1;
vector <node> trie(1);

void insert(string &s,int len)
{
    int v=0;
    vector <int> p(26,-1);
    for(int i=0;i<len;i++){
        int c=s[i]-97;
        trie[v].cnt[c]++;
        if(p[c]!=-1) trie[p[c]].cnt[c]--;
        p[c]=v;
        if(trie[v].to[c]==-1){
            trie.emplace_back();
            trie[v].to[c]=sz++;
        }
        v=trie[v].to[c];
    }
    trie[v].f++;
}

void fun(int v)
{
    for(int c=0;c<26;c++){
        int k=trie[v].to[c];
        if(k!=-1){
            fun(k);
            for(int d=0;d<26;d++){
                trie[v].cnt[d]+=trie[k].cnt[d];
            }
        }
    }
}

int find(string &s,int len)
{
    int v=0;
    for(int i=0;i<len-1;i++){
        int c=s[i]-97;
        v=trie[v].to[c];
    }
    int c=s[len-1]-97;
    return trie[v].cnt[c]-1;
}

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

    int n;
    cin>> n;
    for(int i=0;i<n;i++){
        cin>> s[i];
        reverse(begin(s[i]),end(s[i]));
        int m=s[i].length();
        insert(s[i],m);
    }
    fun(0);
    //cout<< trie[0].cnt[0] <<endl;
    ll ans=0;
    for(int i=0;i<n;i++){
        int m=s[i].length();
        ans+=(ll)find(s[i],m);
        //cout<< i << " " << ans <<endl;
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 275724
# X:動物の総数　Y:足の総数
X, Y = map(int, input().split())
turu_a = X * 2
kame_a = X * 4
if turu_a <= Y and Y <= kame_a and Y%2 == 0 and (kame_a - turu_a) % 2 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9164
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut xyhv = vec![(0i32, 0i32, 0i32); n];
    for i in 0..n {
        xyhv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        xyhv[i].1 = read(&mut stdin_lock, &mut buf, b' ');
        xyhv[i].2 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    for cx in 0..100 + 1 {
        for cy in 0..100 + 1 {
            let mut h = 0;
            for i in 0..n {
                let (xi, yi, hi) = xyhv[i];
                h = hi + (cx - xi).abs() + (cy - yi).abs();
                if h > 0 && hi > 0 {
                    break;
                }
            }

            if (0..n).all(|i| {
                let (xi, yi, hi) = xyhv[i];
                hi == max(h - (cx - xi).abs() - (cy - yi).abs(), 0)
            }) {
                println!("{} {} {}", cx, cy, h);
                return;
            }
        }
    }

    unreachable!();
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i=0; i<n; ++i)
      p[i] = sc.nextInt();
    int ans = 0;
    int min = p[0];
    for(int i=0; i<n; ++i){
      if(p[i] <= min){
        min = p[i];
        ++ans;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n; cin >> n;
  
  int v[n],c[n],sum=0;
  for(int i=0; i<n; i++){cin >> v[i];}
  for(int i=0; i<n; i++){cin >> c[i];}
  for(int i=0; i<n; i++){if(v[i]>c[i]){sum = sum + v[i]-c[i];}}
  
  cout << sum;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

template<typename T>
T max(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size()) {
		maxi(ret, v[i]);
	}
	return ret;
}

signed main() {
	makei(n);
	vi a, b, c;
	rep(n) {
		int q, w, e;
		cin >> q >> w >> e;
		a.push_back(q);
		b.push_back(w);
		c.push_back(e);
	}
	vvi ans = fill_vector(n, 3, 0);
	ans[0][0] = max(b[0], c[0]);
	ans[0][1] = max(a[0], c[0]);
	ans[0][2] = max(a[0], b[0]);
	Rep(1, n) {
		ans[i][0] = a[i] + max(ans[i - 1][1], ans[i - 1][2]);
		ans[i][1] = b[i] + max(ans[i - 1][0], ans[i - 1][2]);
		ans[i][2] = c[i] + max(ans[i - 1][0], ans[i - 1][1]);
	}
	say(max(ans[n - 1]));
}

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

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

  if (a==b && b != c) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a==c && b != c) {
    cout << "Yes" << endl;
    return 0;
  } 
  if (b==c && a != c) {
    cout << "Yes" << endl;
    return 0;
  } 
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public Main(int opt1, int opt2) {
		Map<Integer, Integer> map = new HashMap<>();
		map.put(1, 1);
		map.put(2, 2);
		map.put(3, 3);
		map.remove(opt1);
		map.remove(opt2);
		System.out.println(map.entrySet().iterator().next().getValue());

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int opt1 = sc.nextInt();
		int opt2 = sc.nextInt();
		Main m = new Main(opt1, opt2);

	}
	
}

Measured memory_bytes: 22868
#include <iostream>
int main() {
    int n, t = 0, h = 0;
    std::cin >> n; // skip
    std::string ts, hs;
    while (std::cin >> ts >> hs) {
        if (ts > hs) {
            t += 3;
        } else if (ts < hs) {
            h += 3;
        } else {
            t += 1;
            h += 1;
        }
    }
    std::cout << t << ' ' << h << std::endl;
}



Measured memory_bytes: 3156
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

int main() {
    string s;
    cin >> s;
    int n = s.size();
    VI a(n);
    REP(i,n) a[i] = s[i] - 'a';

    VI d(n+1);
    REP(i,n-1) d[i+1] = (a[i+1] - a[i] + 26) % 26;
    d[0] = a[0];
    d[n] = (-a[n-1] + 26) % 26;

    n++;

    union_find uf;
    uf.init(n);
    REP(i,n) uf.merge(i, n-1-i);

    int m;
    cin >> m;
    while (m--){
        int l, r;
        cin >> l >> r;
        uf.merge(l-1, r);
    }

    VI sum(n);
    REP(i,n) sum[uf.find(i)] += d[i];
    REP(i,n){
        if (sum[i] % 26 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}




Measured memory_bytes: 2048
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    double d=sc.nextDouble();
    double t=sc.nextDouble();
     double s=sc.nextDouble();
    if(d/s<=t) System.out.println("Yes");
    else System.out.println("No");
  }
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;

    bool flag = true;
    for (int i = 1; i < S.length(); i++) {
        if (S[0] != S[i]) {
            flag = false;
            break;
        }
    }
    if (flag) print("No");
    else print("Yes");
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int p[100];
int root(int x){
	if(x == p[x]) return x;
	return p[x] = root(p[x]);
}
int n, m;
vector<pair<int, pi > > es;

int main(){
	while(cin >> n >> m, n){
		es.clear();
		rep(i, m){
			int a, b, c;
			cin >> a >> b >> c;
			es.pb(mp(c, mp(a - 1, b - 1)));
		}
		sort(all(es));
		int ans = inf;
		rep(i, m - n + 2){
			rep(j, n) p[j] = j;
			int sz = n;
			for(int j = i; j < m && sz > 1&& es[j].first - es[i].first < ans; j++){
				int a = es[j].second.first, b = es[j].second.second;
				a = root(a); b = root(b);
				if(a == b) continue;
				p[b] = a;
				if(--sz == 1){
					ans = min(ans, es[j].first - es[i].first);
					break;
				}
			}
		}
		cout << (ans == inf ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include<iostream>

using namespace std;

int main()
{
	unsigned int a, b, c,d,e,f, n,ans=0;


	cin >>d >> e >> f >> n;

	if (d >= e && d >= f) {
		a = d;
		if (e >= f) {
			b = e;
			c = f;
		}
		else {
			b = f;
			c = e;
		}
	}

	if (d <= e && e >= f) {
		a = e;
		if (d >= f) {
			b = d;
			c = f;
		}
		else {
			b = f;
			c = d;
		}
	}
			if (f >= e && d <= f) {
				a = f;
				if (e >= d) {
					b = e;
					c = d;
				}
				else {
					b = d;
					c = e;
				}
			}
		for (int j = 0; j <= n / a; j++)
		{
				for (int k = 0; k <= (n - j * a) / b; k++)
				{
					if ((n - (j * a + b * k)) % c == 0) ans++;
				}
		}
		cout << ans;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
def D(x,a):
	ans=0
	for i in range(len(a)):
		ans+=(x-a[i])**2
	return ans
for i in range(0,101):
	if D(i,X)<D(i+1,X):
		print(D(i,X))
		break


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    //static List<string> str = new List<string>();
    static void Main(string[] args)
    {
        // 入力
        string[] input = Console.ReadLine().Split(' ');
        int x1 = int.Parse(input[0]);
        int y1 = int.Parse(input[1]);
        int x2 = int.Parse(input[2]);
        int y2 = int.Parse(input[3]);

        int x3, y3, x4, y4;

        // 1辺の長さ
        // int length = (int)Math.Sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
        // 正方形のどの辺を表しているか、4パターンある

        x3 = x2 + (y1 - y2);
        y3 = y2 + (x2 - x1);

        x4 = x1 + (y1 - y2);
        y4 = y1 + (x2 - x1);

        Console.WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
       
    }

}

Measured memory_bytes: 11092
#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;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    
    if(A.size() != N) return "NO";
    else return "YES";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    string s;
    int a=0,b=0;
    cin>>s;
    
    for(const auto &c:s){
        if(c=='0'){
            a++;
        }else{
            b++;
        }
    }

    cout<<s.size()-abs(a-b)<<endl;

    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        init(n, m);
        for (int i = 0; i < m; i++) {
            int x = nextInt() - 1;
            int y = nextInt() - 1;
            addEdge(x, y);
        }
        int[] p = new int[2 * n + 1];
        int h = n;
        int t = n + 1;
        p[h] = 0;
        p[t] = dst[head[0]];
        boolean[] z = new boolean[n];
        z[p[h]] = true;
        z[p[t]] = true;
        while (true) {
            boolean ok = false;
            int j = head[p[h]];
            while (j >= 0) {
                int y = dst[j];
                if (!z[y]) {
                    ok = true;
                    p[h - 1] = y;
                    z[y] = true;
                    h--;
                    break;
                }
                j = nx[j];
            }
            if (!ok) break;
        }
        while (true) {
            boolean ok = false;
            int j = head[p[t]];
            while (j >= 0) {
                int y = dst[j];
                if (!z[y]) {
                    ok = true;
                    p[t + 1] = y;
                    z[y] = true;
                    t++;
                    break;
                }
                j = nx[j];
            }
            if (!ok) break;
        }
        out.println(t - h + 1);
        for (int i = h; i <= t; i++) {
            out.print((p[i] + 1) + " ");
        }
        out.println();
    }

    void init(int n, int m) {
        m *= 2;
        this.n = n;
        this.m = m;
        last = 0;
        head = new int[n];
        nx = new int[m];
        dst = new int[m];
        src = new int[m];
        Arrays.fill(head, -1);
        z = new boolean[n];
    }

    void addEdge(int x, int y) {
        nx[last] = head[x];
        src[last] = x;
        dst[last] = y;
        head[x] = last;
        last++;
        nx[last] = head[y];
        src[last] = y;
        dst[last] = x;
        head[y] = last;
        last++;
    }

    int n, m;
    int[] head;
    int[] nx;
    int[] src;
    int[] dst;
    boolean[] z;
    int last;

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

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

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 47112
#include<bits/stdc++.h>
using namespace std;
int N,k,sum;
bool complare(int a,int b)
{
	return a>b;
}
int main()
{	
	while(cin>>N>>k)
	{	
		sum=0;
		int a[N];
		int i;
		for(i=0;i<N;i++)
		{
			cin>>a[i];
		}
		sort(a,a+N,complare);
		for(i=0;i<k;i++)
		{
			sum+=a[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
  	val a = readLine()!!.split(" ").map{ it.toLong() }
  	var result = 1L
  	val max = 1_000_000_000_000_000_000L
  	
  	if (a.contains(0)) {
     	println("0")
      	return
    }

  	a.forEach {
    	result *= it
      	if (result > max) {
        	println("-1")
          	return
        }
      
      	if (result < it) {
        	println("-1")
          	return
        }
    }

 	println(result)  
}

Measured memory_bytes: 62900
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	string s,t;cin>>s>>t;
	rep(i, n){
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <assert.h>
using namespace std;
#define int unsigned long long
#define pb push_back
template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int s;
void read() {
	cin >> s;
}

vector<int> a;
void run() {
	int l = sqrt(s);
	if (l * l < s)
		l++;
	int b = l * l - s;
	int x1 = 0, y1 = 0;
	int x2 = l, y3 = l;
	int x3 = b, y2 = 1;

	
	assert(s == (x2 * y3 - x3 * y2));
	a = {x1, y1, x2, y2, x3, y3};

}

void write() {
	for (auto i : a) {
		cout << i << " ";
	}
	cout << endl;
	//cout << "0 0 557776632 1 641221927 557776632";
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i;
	char a[1201];
	int ans[26]={0};

	i=0;
	while(scanf("%c",&a[i])!=EOF){
		if(a[i]>='a' && a[i]<='z') ans[a[i]-'a']++;
		if(a[i]>='A' && a[i]<='Z') ans[a[i]-'A']++;
		i+=1;
	}
	for(i=0; i<26; i++) printf("%c : %d\n",'a'+i,ans[i]);
	return 0;
}


Measured memory_bytes: 2740
MOD = 10 ** 9 + 7


# def main(n):
#     tenn = mfact(8, n)
#     twon = mfact(2, n)
#     print(tenn, twon)
#     result = (tenn - 3 * twon - 1) % MOD
#     return result

def main(n):
    result = 0
    tens = 10
    eights = 9
    fives = 8
    for i in range(1, n+1):
        result = (tens - (2 * eights) + fives) % MOD
        tens = (tens * 10) % MOD
        eights = (eights * 9) % MOD
        fives = (fives * 8) % MOD
    return result


n = int(input())
print(main(n))

Measured memory_bytes: 9080
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;

const int N = 5e3 + 10;
char s[N];
int dp[N][N];
int A[N], B[N];
int n;

int solve(int x, int y, int step) {
  if (x + y == 2 * n) return 1;
  step = min(step, n);
  int& ret = dp[x][y];
  if (ret >= 0) return ret;
  ret = 0;
  // trace(x, y, step, A[step], B[step]);
  if (A[step] > x) ret = (ret + solve(x + 1, y, step + 1)) % MOD;
  if (B[step] > y) ret = (ret + solve(x, y + 1, step + 1)) % MOD;
  // trace(x, y, ret);
  return ret;
}

int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      A[i + 1] = A[i] + 2;
      B[i + 1] = B[i];
    } else if (s[i] == '1') {
      A[i + 1] = A[i] + 1;
      B[i + 1] = B[i] + 1;
    } else {
      A[i + 1] = A[i];
      B[i + 1] = B[i] + 2;
    }
  }
  memset(dp, 255, sizeof(dp));
  int ret = solve(0, 0, 1);
  printf("%d\n", ret);
  return 0;
}


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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> p(n, vector<int> (3));
  rep(i,n)rep(j,3){{
    cin >> p[i][j];
  }}
  
  int minx=0,maxx=w,miny=0,maxy=h;
  
  rep(i,n){
    if(p[i][2] == 1) {minx = max(minx,p[i][0]);}
    if(p[i][2] == 2) {maxx = min(maxx,p[i][0]);}
    if(p[i][2] == 3) {miny = max(miny,p[i][1]);}
    if(p[i][2] == 4) {maxy = min(maxy,p[i][1]);}
  }
  
 
  if(minx >= maxx||miny>=maxy){cout << 0 << endl;}
  else{cout << (maxx-minx)*(maxy-miny) << endl;}
  
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <sstream>
#include <iostream>
#include <cstring>
#define REP(i,x,v)for(int i=x;i<=v;i++)
#define REPD(i,x,v)for(int i=x;i>=v;i--)
#define FOR(i,v)for(int i=0;i<v;i++)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second
#define un(x) x.erase(unique(ALL(x)),x.end());
#define ll long long
#define IN(x,y) ((y).find((x))!=(y).end())
#define LOLDBG
#ifdef LOLDBG
#define DBG(vari) cout<<#vari<<" = "<<vari<<endl;
#define DBG2(v1,v2) cout<<(v1)<<" - "<<(v2)<<endl;
#else
#define DBG(vari)
#define DBG2(v1,v2)
#endif
#define CZ(x) scanf("%d",&(x));
#define CZ2(x,y) scanf("%d%d",&(x),&(y));
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
template<typename T,typename TT> ostream &operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream &operator<<(ostream &s,vector<T> t){s<<"{";FOR(i,t.size())s<<t[i]<<(i==t.size()-1?"":",");return s<<"}"<<endl; }

int sum[333333];
int best[333333];

int main()
{
    ios_base::sync_with_stdio(0);
    vector<pii> v;
    int n;cin>>n;
    FOR(i,n)
    {
        int x,l;cin>>x>>l;
        v.pb(mp(x-l,x+l));
    }
    vi z;
    FOR(i,sz(v)) z.pb(v[i].fi);
    FOR(i,sz(v)) z.pb(v[i].se);
    sort(ALL(z));un(z);
    map<int,int> re;
    FOR(i,sz(z)) re[z[i]]=i;
    FOR(i,sz(v))
    {
        v[i]=mp(re[v[i].fi],re[v[i].se]);
    }
    sort(ALL(v));
    FOR(i,sz(v))
    {
        sum[v[i].se+1]++;
    }
    REP(i,1,333222) sum[i]+=sum[i-1];
    best[0]=0;
    int prev=0;
    int mx=0;
    FOR(i,sz(v))
    {
        REP(j,prev+1,v[i].se) best[j]=best[prev];
        int inters=sum[v[i].fi+1];
        //DBG(v[i]);
        //DBG(inters);
        best[v[i].se]=max(best[v[i].se],best[v[i].fi]+1);
        prev=v[i].se;
        mx=max(best[v[i].se],mx);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 13300
N=int(input())
answers={}
for a in range(N):
    S=input()
    if S in answers:
        answers[S]+=1
    else:
        answers[S]=1
a=max(answers.values())
keys = [k for k, v in answers.items() if v == a]
answer=sorted(keys)
for a in answer:
    print(a)
    

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 2;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }

  vector<int> ans(N);
  ll middle = N / 2;

  rrep(i, N, 0) {
    if (i >= middle) {
      ans[i] = a[i];
      continue;
    }

    int total = 0;
    for (int j = i; j < N; j += (i + 1)) total += ans[j];

    if (total % 2 == a[i]) continue;
    ans[i] = 1;
  }

  ll sum = 0;
  string s;
  rep(i, 0, N) {
    sum += ans[i];
    if (!ans[i]) continue;
    s += to_string(i + 1) + " ";
  }
  if (sz(s)) s.pop_back();
  cout << sum << endl;
  if (sz(s)) cout << s << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 4100
#include <iostream>
using namespace std;
int main(void){
    long long N;
    cin>>N;
    long long max=1;
    for(long long i=1;i*i<=N;i++){
       if(N%i==0&&max<=i) max=i;
    }
    long long a=N/max;
    int ans=0;
    while(a>0){
        a=a/10;
        ans++;
    }
    cout<<ans;
   return 0;
}

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

const ll INF = 1LL << 60;

ll N;
vector<P> red;
vector<P> blue;

int main() {
    cin >> N;
    red.resize(N);
    blue.resize(N);

    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        red[i] = P(a, b);
    }
    rep(i, N) {
        ll c, d;
        cin >> c >> d;
        blue[i] = P(c, d);
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    // blue -> red
    ll cnt = 0;
    rep(i, N) {
        ll red_y = -1;
        ll red_idx = -1;

        rep(j, N) {
            if (blue[i].first > red[j].first && blue[i].second > red[j].second) {
                if (red_y < red[j].second) {
                    red_y = red[j].second;
                    red_idx = j;
                }
            }
        }

        if (red_y != -1) {
            red.erase(red.begin() + red_idx);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,r=1<<29;
  for(scanf("%d",&n);n--;){
    int a,c=0;
    for(scanf("%d",&a);a%2<1;a/=2)++c;
    r=r>c?c:r;
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

int pw(int a, int b, int m = MOD) {
    if (b == 0)
        return 1;
    if (b & 1)return a * pw(a, b - 1) % m;
    return pw(a * a % m, b / 2);
}

int inverse(int a) {
    return pw(a, MOD - 2);
}

int nCr(int n, int r) {
    int num = 1;
    for (int i = n; i >= n - r + 1; i--) {
        num = (num * i) % MOD;
    }
    int inv = 1;
    for (int i = 1; i <= r; i++) {
        inv = (inv * i) % MOD;
    }
    return num * inverse(inv) % MOD;
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;

    int ans = pw(2, n);
    ans = (ans - nCr(n, a) + MOD) % MOD;
    ans = (ans - nCr(n, b) + MOD) % MOD;

    ans = (ans + MOD - 1) % MOD;
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256