akhauriyash/Code-Regression huggingface dataset:
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(n: usize, a: usize, b: usize, s: chars);
    let mut qualifies = 0;
    let mut b_qualifies = 1;
    let mut ans = vec![false; n];

    for i in 0..n {
        match s[i] {
            'a' => {
                if qualifies < a + b {
                    qualifies += 1;
                    ans[i] = true;
                }
            }
            'b' => {
                if qualifies < a + b && b_qualifies <= b {
                    qualifies += 1;
                    b_qualifies += 1;
                    ans[i] = true;
                }
            }
            _ => {}
        }
    }

    for &f in ans.iter() {
        println!("{}", if f { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> b(n);
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        b[i]=a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++)
    {
        if(b[i]==a[n-1])
        cout << a[n-2] << '\n';
        else
        cout << a[n-1] << '\n';
    }
    return 0;
}

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

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int N = int.Parse(s);

            for (int i = 1; i < 10; i++)
            {
                if (N % i == 0 && i.ToString().Length == 1 && (N / i).ToString().Length == 1)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27232
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])
    X = Number(tmp0[1])
    L = input[1].split(" ").map(str => parseInt(str,10))

    var ans = 1

    var beforeD = 0
    for(var i=2; i<=N+1; i++)
    {
        var afterD = beforeD + L[i-1-1]
        if(afterD>X){
            break
        }
        beforeD = afterD
        ans++
    }
    console.log(ans)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("3 6\n3 4 5\n");

Measured memory_bytes: 21064
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N, W, H;
    cin >> N;
    cin >> W;
    cin >> H;
    int w = N - W + 1;
    int h = N - H + 1;
    cout << w * h << endl;
    return 0;
}

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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
#define MAX 200002

int n;

vector<int> v[MAX];

vector<int> nd[2];

inline void dfs(int b,int dep=0,int pr=-1){
	nd[dep&1].push_back(b);
	for(int el:v[b]){
		if(pr==el)continue;
		dfs(el,dep+1,b);
	}
}
vector<int> val[3];
int ans[MAX];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	for(int i=1;i<=n;i++)val[i%3].push_back(i);
	auto apply=[&](int a,int b,int c=-1){
		while(nd[a].size()&&val[b].size()){
			ans[nd[a].back()]=val[b].back();
			nd[a].pop_back();
			val[b].pop_back();
		}
		b=c;
		while(b!=-1&&nd[a].size()&&val[b].size()){
			ans[nd[a].back()]=val[b].back();
			nd[a].pop_back();
			val[b].pop_back();
		}
	};
	if(nd[0].size()<=val[0].size()){
		apply(0,0);
		apply(1,1,2);
		apply(1,0);
	}
	else{
		if(nd[1].size()<=val[0].size()){
			apply(0,1,2);
			apply(1,0);
			apply(0,0);
		}
		else{
			if(true||nd[0].size()>=val[1].size()&&nd[1].size()>=val[2].size()){
				apply(0,1);
				apply(1,2);
			}
			else{
				apply(0,2);
				apply(1,1);
			}
			apply(0,0);apply(1,0);
		}
	}
	for(int i=0;i<n;i++){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 18292
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char S []= sc.next().toCharArray();
    char T []= sc.next().toCharArray();
    
    int cnt = 0;
    for(int i=0; i<S.length; i++){
      if(S[i]!=T[i]){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}
    

Measured memory_bytes: 41888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
bool compare_by_b(pair<int, string> a, pair<int, string> b) {
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return 0;
	}
}
bool compare_by_a(pair<int, string> a, pair<int, string> b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}
	else {
		return 0;
	}
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	bool primeFlag = true;
	cin >> x;
	for (ll i = 0; i <= pow(10, 9); i++) {
		for (ll k = 2; k <= sqrt(i); k++) {
			if (i % k == 0) {
				primeFlag = false;
				break;
			}
		}
		if (primeFlag) {
			if (x <= i) return cout << i << endl, 0;
		}
		primeFlag = true;
	}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAXH = 80;
const int MAXW = 80;

const int D = 80 * 160 + 10;
const int D2 = D * 2;
typedef bitset<D2> bs;

int a[MAXH][MAXW];
bs dp[90][90];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) {
        int x;
        cin >> x;
        a[i][j] = abs(a[i][j] - x);
    }

    dp[0][0][D-a[0][0]] = 1;
    dp[0][0][D+a[0][0]] = 1;
    rep(i, h) rep(j, w) {
        if (i) {
            dp[i][j] |= dp[i - 1][j] << a[i][j];
            dp[i][j] |= dp[i - 1][j] >> a[i][j];
        }
        if (j) {
            dp[i][j] |= dp[i][j - 1] << a[i][j];
            dp[i][j] |= dp[i][j - 1] >> a[i][j];
        }
    }
    int ans = D2;
    rep(i, D2) {
        if (dp[h - 1][w - 1][i]) {
            ans = min(ans, abs(i - D));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24704
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	auto N=in();
	int M=(1<<N);
	
	int C=in();
	REP(i,M){
		bitset<18> bs(i);
		if(bs.count()!=C) continue;
		int v=i;
		int n=0;
		cout << i <<":";
		while(v){
			if(v&1) cout << ' ' << n;
			v >>= 1;
			n++;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

int dp[100010][13];
const int mod = 1e9+7;

int main() {
    string s; cin >> s;
    int len = s.size();

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    rep(i,len) {
        if (s[i] != '?') {
            int d = s[i]-'0';
            rep(j,13) {
                int nj = (j*10+d)%13;
                (dp[i+1][nj] += dp[i][j]) %= mod;
            }
        } else {
            rep(j,13) rep(d,10) {
                int nj = (j*10+d)%13;
                (dp[i+1][nj] += dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[len][5] << endl;
    return 0;
}


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

int main() {
  int r,g,b,x ;
  cin>> r>> g>> b;
  x=100*r+10*g+b;
  if(x%4==0){
  cout << "YES" << endl; 
  }
  else{
  cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val M = sc.nextInt

    var time = 1900 * M + 100 * (N - M)
    for(i <- 1 to M){
      time *= 2
    }
    println(time)
  }
}


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

int main()
{
    int n, y;
    int b, r, t;
    int maxp;
    double maxm;

    while (cin >> n, n != 0) {
        maxp = 0;
        maxm = 0;
        
        cin >> y;

        for (int i = 0; i < n; i++) {
            cin >> b >> r >> t;

            double m;

            if (t == 1) {
                m = 1 + (double)y * ((double)r / 100.0);
            }
            else {
                m = pow((1.0 + (double)r / 100.0), y);
            }

            if (maxm < m) {
                maxp = b;
                maxm = m;
            }
        }

        cout << maxp << endl;        
    }

    return 0;
}



Measured memory_bytes: 3264
import sys
n, m = map(int, input().split())
X = list(map(int, input().split()))
if n >= m:
  print(0)
  sys.exit()

#print(X)
X.sort()
#print(X)

L = []
for i in range(m-1):
  L.append(X[i+1] - X[i])
#print(L)
L.sort(reverse=True)
#print(L)
print((X[m-1]-X[0]) - (sum(L[0:n-1])))


Measured memory_bytes: 13968
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();

//		パターン1（SとKを比べて場合分け）
//		if(S.length() <= K) {
//			System.out.print(S);
//		}
//		else {
//			System.out.print(S.substring(0,K) + "...");
//		}

//	パターン2（Kまで1文字ずつ表示）
		if(K < S.length()) {
			for(int i=0 ; i<K ; i++) {
				System.out.print(S.charAt(i));
			}
			System.out.print("...");
			return;
		}
		else {
			System.out.print(S);
		}
	}
}

Measured memory_bytes: 26972
#include <cstdio>
#include <cstring>
using namespace std;

#define MAX_N 100
typedef long long Int;
int N, A[MAX_N];
Int table[MAX_N][21];

Int dp(int p, int res){
	if(res > 20 || res < 0) return 0;
	if(p == N - 1){
		return (res == A[p])? 1 : 0;
	}
	if(table[p][res] > -1) return table[p][res];
	return table[p][res] = (p != 0)? dp(p + 1, res + A[p]) + dp(p + 1, res - A[p]) : dp(p + 1, res + A[p]);
}

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", A + i);
	}
	
	memset(table, -1, sizeof(table));
	
	printf("%lld\n", dp(0, 0));
	
	return 0;
}

Measured memory_bytes: 1056
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// AC
public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n=10;
	int[][] a;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			a=new int[n][n];
			for(int j=0; j<n; j++){
				String s=sc.next();
				for(int i=0; i<n; i++){
					a[j][i]=s.charAt(i)=='.'?0:1;
				}
			}
			solve();
		}
	}

	void solve(){
		int[][] dp=new int[n][n];
		int max=0;
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				if(a[j][i]==0){
					if(i>0&&j>0){
						int n=Math.min(dp[j-1][i-1],
								Math.min(dp[j][i-1], dp[j-1][i]));
						dp[j][i]=n+1;
					}else{
						dp[j][i]=1;
					}
				}else{
					dp[j][i]=0;
				}
				max=Math.max(max, dp[j][i]);
			}
		}
		println(""+max);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 17000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <iostream>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int n, c[2];

int main() {
	scanf("%d", &n);
	while(n--) {
		int x; scanf("%d", &x);
		c[x&1] += 1;
	}
	while(c[1] >= 2) {
		c[1] -= 2;
		c[0] += 1;
	}
	puts((c[1] % 2 == 1) ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 384
acgt=["A", "C", "G", "T"]
s=list(raw_input())
a=[-1]
maxL=0
for pos in range(len(s)):
   if s[pos] not in acgt:
       a.append(pos)
a.append(len(s))
for pos in range(1,len(a)):
   L=a[pos]-a[pos-1]-1
   if L>maxL:
       maxL=L
print(maxL)

Measured memory_bytes: 2568
#include <stdio.h>

int num[13] ;
int ans[3] ;

int main ( )
{
	while ( scanf ( "%d" , &num[0] ) == 1 ) {
		for ( int i = 1 ; i < 10 ; i++ ) {
			scanf ( "%d" , &num[i] ) ;
		}
		ans[0] = num[0] ;
		ans[1] = ans[2] = 0 ;
		for ( int i = 1 ; i < 10 ; i++ ) {
			if ( num[i] >= ans[0] ) {
				ans[2] = ans[1] ;
				ans[1] = ans[0] ;
				ans[0] = num[i] ;
			}
			else if ( num[i] >= ans[1] && num[i] < ans[0] ) {
				ans[2] = ans[1] ;
				ans[1] = num[i] ;
			}
			else if ( num[i] >= ans[2] && num[i] < ans[1] ) {
				ans[2] = num[i] ;
			}
		}
		for ( int i = 0 ; i < 3 ; i++ ) {
			printf ( "%d\n" , ans[i] ) ;
		}
	}
	return 0 ;
} 

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n),e(n);
    int ans=0;
    rp(i,n){
        cin >> b.at(i) >> e.at(i);
        ans += e.at(i) - b.at(i)+1;
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i , L , R) for( i = L ; i < R ; i++)
#define per(i,L,R) for( i = L; i >= R; i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] << (i==R?'\n':' ')
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

int main()
{
   SPEED
//   ll q,i,l,r;
//   string s;
//   cin>>s;
//   ll n = s.length();
//   ll a[n+1]={0};
//   rep(i,0,n-1)
//   {
//       if(s[i]==s[i+1])
//        a[i+1]=1;
//   }
//   printa(a,0,n+1);
//   cout<<"\n";
//   rep(i,1,n+1)
//   {
//       a[i]=a[i]+a[i-1];
//   }
//
//  // printa(a,0,n);
//   cin>>q;
//   while(q--)
//   {
//       cin>>l>>r;
//       cout<<a[r-1]-a[l-2]<<"\n";
//   }
    ll n,k,i,s=0,a;
    cin>>n>>k;
    rep(i,0,n)
    {
        cin>>a;
        if(a>=k)
            s++;
    }
    cout<<s<<"\n";

}












Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::iter::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let x: Vec<f64> = (0..n).map(|_| sc.read()).collect();
    let y: Vec<f64> = (0..n).map(|_| sc.read()).collect();
    let xy: Vec<_> = x.iter().zip(y.iter()).collect();
    for &p in [1.0, 2.0, 3.0].iter() {
        println!("{:.09}", xy.iter().fold(0.0, |acc, &(x, y)| acc + (x - y).abs().powf(p)).powf(1.0 / p));
    }
    println!("{:.09}", xy.iter().fold(0.0, |acc, &(x, y)| if acc > (x - y).abs() { acc } else { (x - y).abs() }));
}



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

using namespace std;

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

	for(int x=1; x<=n; x++) {
		if(floor(1.08 * x) == n) {
			cout<<x<<endl;
			return 0;
		}
	}

	cout<<":(\n";
	
	return 0;
}

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

long count(string s){
  int n2[s.size()],i,j=0;
  long r=0;
  for(i=s.size()-1;i>=0;i--){
    if(s[i]=='2') j++;
    n2[i]=j;
  }
  if(j==0) return 0;

  for(i=0;i<s.size();i++){
    if(s[i]=='1') r+=n2[i];
  }
  return r;
}

int main(){
  int i;
  long n=0;
  string s,buf;
  cin>>s;
  buf.clear();
  s.push_back('X');
  for(i=0;i<s.size();i++){
    if(s[i]=='A') buf.push_back('1');
    else if(s.substr(i,2)=="BC"){
      buf.push_back('2');
      i++;
    }
    else{
      if(buf.size()) n+=count(buf);
      buf.clear();
    }
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 1672
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
	if(S.equals("ABC")) {
		System.out.println("ARC");
	}
	if(S.equals("ARC")) {
		System.out.println("ABC");
	}
	}
}


Measured memory_bytes: 26916
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  ld ans = 0;
  rep(i, N) {
    ld x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }
  COUTF(ans);
  return 0;
}

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

int main() 
{
  int X ;
  cin >> X ;
  
  if ( X < 600 )
    cout << "8" << endl ;
  
  else if ( X < 800 )
    cout << "7" << endl ;
  
  else if ( X < 1000 )
    cout << "6" << endl ;
  
  else if ( X < 1200 )
    cout << "5" << endl ;
  
  else if ( X < 1400 )
    cout << "4" << endl ;
  
  else if ( X < 1600 )
    cout << "3" << endl ;
  
  else if ( X < 1800 )
    cout << "2" << endl ;
  
  else if ( X < 2000 )
    cout << "1" << endl ;
}

Measured memory_bytes: 3632
#include <iostream>
#include <utility>
#include <stdint.h>
#include <map>

using namespace std;

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

  map<int, int> A;

  for (int n=1; n<=N; ++n) {
    int a;
    cin >> a;
    A.emplace(a,n);
  }

  for (auto a : A) {
    cout << a.second << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5504
# coding: utf-8

hage = int(input())
hoge = input().split()
 
hoge[0] = int(hoge[0])
hoge[1] = int(hoge[1])

renji = int(hoge[0]) - int(hoge[1])
 
e = hage
 
while e <= hoge[1]:
    if hoge[0] <= e and hoge[1] >= e:
        print("OK")
        break
    e = e + hage
if e > hoge[1] or e < hoge[0]:
    print("NG")

Measured memory_bytes: 9200
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            cnt += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 41580
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

set<int> st;
vector<int> v;

void dfs(int a){
    int sz = v.size();
    for(int i = 0; i < sz; i++){
        if (st.find(v[i] + a) == st.end()){
            st.insert(v[i]+a);
            v.push_back(v[i]+a);
        }
    }
    v.push_back(a);
}
int main(){
    int s[2] = {0};
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 4; j++){
            int a; cin >> a;
            s[i] += a;
        }
    }
    cout << max(s[0],s[1]) << endl;
}
  




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

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main() {
  int x,y;
  cin >> x >> y;
  string grid[x];
  rep(i,x) cin >> grid[i];

  int cnt1[x][y];
  rep(i,x) rep(j,y) cnt1[i][j] = 0;
  int l,r,cnt;
  rep(i,x) {
    l = 0;
    cnt = 0;
    rep(j,y) {
      if (grid[i][j] == '#') {
        for(int z = l; z < j; z++) cnt1[i][z] = cnt;
        l = j+1;
        cnt = 0;
      }
      else cnt++;
    }
    for(int z = l; z < y; z++) cnt1[i][z] = cnt;
  }

  int cnt2[x][y];
  rep(i,x) rep(j,y) cnt2[i][j] = 0;
  rep(i,y) {
    l = 0;
    cnt = 0;
    rep(j,x) {
      if (grid[j][i] == '#') {
        for(int z = l; z < j; z++) cnt2[z][i] = cnt;
        l = j+1;
        cnt = 0;
      }
      else cnt++;
    }
    for(int z = l; z < x; z++) cnt2[z][i] = cnt;
  }

  int ans = 0;
  rep(i,x) {
    rep(j,y) {
      if (grid[i][j] != '#') ans = max(ans,cnt1[i][j]+cnt2[i][j]-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 42444
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long A = sc.nextLong();
	        long B = sc.nextLong();
	        long C = sc.nextLong();
	        long K = sc.nextLong();
	        long ans=0;
	        if(K<=A) {
	        	ans=K;
	        } else if(K<=A+B) {
	        	ans=A;
	        } else {
	        	ans = A-(K-A-B);
	        }
	        System.out.println(ans);
	    }
	}

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

int N;
int A[20];

bool dfs(int i, int sum, int q)
{
  if (i == N)
  {
    return (sum == q);
  }
  else
  {
    return (dfs(i + 1, sum + A[i], q) || dfs(i + 1, sum, q));
  }
}

int main()
{
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
  }

  int m;
  cin >> m;
  for (int i = 0; i < m; ++i)
  {
    int q;
    cin >> q;
    bool res = dfs(0, 0, q);
    if (res)
    {
      cout << "yes" << endl;
    }
    else
    {
      cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
const ll M=1e9+7;
int n,a[23][23],dp[23][(1<<21)+11];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n) fo(j,0,n)cin>>a[i][j];
	dp[0][0]=1;
	fo(i,0,n) fo(j,0,(1<<n)) if(dp[i][j])
	fo(k,0,n) if(!(j&(1<<k))&&a[i][k])dp[i+1][j|(1<<k)]=(dp[i+1][j|(1<<k)]+dp[i][j])%M;
	cout<<dp[n][(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 164096
a,b,c,d,n,*A=`dd`.split.map &:to_i;e=f=1;a>c&&(a,c,e=c,a,-1);b>d&&(b,d,f=d,b,-1);V=[];A.each_slice(2){|x,y|a<=x&&x<=c&&b<=y&&y<=d&&V<<[x*e,y*f]};D=[F=1e9]*-~n;V.sort.map{|x,y|D[D.bsearch_index{|e|e>y}]=y};N=D.index{|e|e>=F};p 1e2*(c-a+d-b)-20*N+5*(N+(N>[c-a,d-b].min ? 1:0))*Math::PI

Measured memory_bytes: 45684
f=range
h,w,k=map(int,input().split())
g=[[int(i) for i in input()] for _ in f(h)]
s=[[0]*-~w for _ in f(h+1)]
for i in f(h):
  for j in f(w):
    s[i+1][j+1]=s[i+1][j]+s[i][j+1]+g[i][j]-s[i][j]
a=h+w
for i in f(2**~-h):
  u=d=l=r=c=0
  e=[]
  for d in f(h):
    if i>>d&1: e+=[(u,d+1)]; c+=1; u=d+1
  e+=[(u,h)]
  for r in f(w):
    if max(s[d][r+1]-s[u][r+1]-s[d][l]+s[u][l] for u,d in e)>k:
      if r==l: break
      c+=1; l=r
  else: a=min(a,c)
print(a)

Measured memory_bytes: 3564
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        sum+=a[i]-1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import random
N, K = map(int, input().split())
*V, = map(int, input().split())
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    VM = 2**(V[i]+1)-2
    l = 1
    while a and b and l:
        if a & 1 and b & VM:
            ans -= 1
            break
        l = max((a & -a).bit_length()-1, (b & -b).bit_length()-V[i]-1)
        a >>= l; b >>= l
print(ans)


Measured memory_bytes: 10740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i,j;
	long long arr[n][3];
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	long long ans[n][3];
	ans[0][0]=arr[0][0];
	ans[0][1]=arr[0][1];
	ans[0][2]=arr[0][2];
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			ans[i][j]=max(ans[i-1][(j+1)%3],ans[i-1][(j+2)%3])+(arr[i][j]);
		}
	}
	long long ma=max(ans[n-1][0],ans[n-1][1]);
	long long ans1=max(ma,ans[n-1][2]);
	cout<<ans1;
}

Measured memory_bytes: 4992
n=int(input())
m=n
ans=[]
for i in range(2,int(n**0.5)+1):
  while n % i == 0:
    ans.append(i)
    n //= i
if n != 1:
  ans.append(n)
l=str(m)+":"
print(l," ".join(map(str,ans)))


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

const int MAXN = 2100;
int n, x, y, a, b;
set<pair<int, int>> resp[MAXN];
int mark[MAXN];

void bfs(int u){
	memset(mark, -1, sizeof(mark));
	queue<int> Q;
	Q.push(u);
	mark[u] = 0;
	while(!Q.empty()){
		int v = Q.front();
		Q.pop();
		resp[mark[v]].insert({min(u, v), max(u, v)});
		if (v < n-1 && mark[v+1] == -1){
			mark[v+1] = mark[v] + 1;
			Q.push(v+1);
		}
		if (v > 0 && mark[v-1] == -1){
			mark[v-1] = mark[v] + 1;
			Q.push(v-1);
		}
		if(v == x && mark[y] == -1){
			mark[y] = mark[v]+1;
			Q.push(y);
		}
		if (v == y && mark[x] == -1){
			mark[x] = mark[v]+1;
			Q.push(x);
		}
	}
}

int main(){
	//memset(resp, 0, sizeof(resp));
	cin >> n >> a >> b;
	a--; b--;	
	x = min(a, b);
	y = max(a, b);

	for (int i = 0; i < n; i++){
		bfs(i);
	}

	for (int i = 1; i < n; i++){
		//cout << "I ----- " << i << endl;
		cout << resp[i].size() << endl;
	}
	return 0;
}

Measured memory_bytes: 97540
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[111][222222];

main(){
	int n,ub;cin>>n>>ub;
	int w[n],v[n];rep(i,n)cin>>w[i]>>v[i];
	
	rep(i,n){
		rep(j,ub+1){
			if(j-w[i]<0)dp[i+1][j]=dp[i][j];
			else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
		}
	}
	dump(dp[n][ub]);
}






Measured memory_bytes: 174592
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int cnt[N],n,m;
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a==1||a==n)cnt[b]++;
		if(b==1||b==n)cnt[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]>=2)
		{
			cout<<"POSSIBLE\n";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE\n";
	return 0;
} 

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

using namespace std;

int dp[16][16];
int a,b;

int solve(int x,int y){
  if(dp[y][x] >= 0) return dp[y][x];
  if(x == a && y==b) return 1;

  if(x > a || y > b)return 0;

  return dp[y][x] = (solve(x+1,y) + solve(x,y+1));

}


int main(){
  // int a,b;
  int n;
  
  while(cin>>a>>b){
    //cin>>a>>b;
    if(a==0 && b==0)return 0;
    a--;
    b--;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++){
      int x,y;
      cin>>x>>y;
      dp[--y][--x] = 0;
    }
  
    cout<<solve(0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int c[3][3];
int a[3];
int b[3];

int main()
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (c[i][j] != a[i] + b[j])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=3e5+5;

int n,a[N],p[N];

bool check(int x) {
	int tmp=0;
	for(int i=2;i<n;i+=2) if (p[i-1]-tmp>=x) tmp=min(tmp,p[i]);
	return p[n]-tmp>=x;
}

int main() {
	n=read();
	fo(i,1,n) a[i]=read();
	if (!(n&1)) {
		static int c[2];
		fo(i,1,n) c[i&1]+=a[i];
		printf("%d %d\n",max(c[0],c[1]),min(c[0],c[1]));
		return 0;
	}
	int b=0,s=0;
	fo(i,1,n) {
		if (!(i&1)) b+=a[i];
		s+=a[i];
	}
	fo(i,1,n) p[i]=((i&1)?1:-1)*a[i]+p[i-1];
	int l=b,r=s,p=b;
	while (l<=r) {
		int mid=l+r>>1;
		if (check(mid-b)) p=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d %d\n",p,s-p);
	return 0;
}

Measured memory_bytes: 2560
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = arg[0].split("").map(n=>parseInt(n));
    
    let last = N[0];
    
    for(let i=1; i<N.length; i++) {
        if(last === N[i]) {
            console.log("Bad");
            return;
        }
        
        last = N[i];
    }
    
    console.log("Good");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int s;
	cin >> s;
	vi c(1000005, 0);
	c[s] = 1;
	FOR(i, 2, 1000005) {
		if (s % 2 == 1) {
			s = 3 * s + 1;
		}
		else {
			s = s / 2;
		}

		if (c[s] != 0) {
			cout << i << endl;
			break;
		}
		else {
			c[s] = i;
		}
	}

	return 0;
}

Measured memory_bytes: 4096
// 解き直し.
// ABC 143解説.
// https://img.atcoder.jp/abc143/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int MAX = 321123;
LL A[MAX], C[MAX], D[MAX], DCUM[MAX], KDCUM[MAX], f[MAX];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%lld", &A[i]), C[A[i]]++;
    for(int i = 1; i <= N; i++) D[C[i]]++;
    
    // 2. 解説通り(累積和).
    for(int i = 1; i <= N; i++) DCUM[i] = DCUM[i - 1] + D[i];
    for(int i = 1; i <= N; i++) KDCUM[i] = KDCUM[i - 1] + (LL)i * D[i];
    
    // 3. f(X) の 計算.
    // -> lower_bound を 使用する都合上, index を ずらした.
    for(int x = 0; x < N; x++){
        f[x] = KDCUM[x];
        f[x] += (LL)(x + 1) * (DCUM[N] - DCUM[x]);
        f[x] /= (x + 1);
    }
    // for(int i = 0; i <= N; i++) printf("%lld ", DCUM[i]);
    // printf("\n");
    // for(int i = 0; i <= N; i++) printf("%lld ", KDCUM[i]);
    // printf("\n");
    
    // 4. f(X) の sort.
    // -> lower_bound を 使用する都合上, 昇順sort した.
    sort(f, f + N);
    // for(int i = 0; i < N; i++) printf("%lld ", f[i]);
    // printf("\n");
    
    // 5. N個の整数を出力.
    for(int t = 1; t <= N; t++) printf("%d\n", N - (lower_bound(f, f + N, t) - f));
    return 0;
    
}

Measured memory_bytes: 15744
#include <stdio.h>
int main()
{
  int a,n,ai;
  long long max,min,sum;

   min=1000000;
   max=-1000000;

   scanf("%d",&n);
   sum=0;

  for(a=1;n>=a;a++){
    scanf("%d",&ai);   
    if(min>=ai) min=ai;
    if(max<=ai) max=ai;
    sum=ai+sum;
  }

  printf("%lld %lld %lld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 600
H,W=map(int,input().split())
A = []
for _ in range(H):
    a = input()
    A.append(a)
count=0
for val in A:
    for query in val:
        if query=="#":
            count +=1
if count == H+W-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int K, S, cnt = 0;
    cin >> K >> S;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K) {
                cnt += 1;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
mc = 0
mindex = -1
for i in range(1, len(s)):
    a = {}
    b = {}
    sa = s[0:i]
    sb = s[i:]
    c = 0
    for x in range(len(sa)):
        a[sa[x]] = True
    for x in range(len(sb)):
        b[sb[x]] = True
    for j in a.keys():
        if j in b:
            c += 1
    if mc < c:
        mc = c
        mindex = i
print(mc)

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

template <typename T>
struct RectangleSum{
    vector<vector<T>> sum;

    RectangleSum(int h, int w){
        init(h, w);
    }

    void init(int h, int w){
        sum.resize(h + 1, vector<T> (w + 1, 0));
    }

    void add(int y, int x, T val){
        y++;
        x++;
        sum[y][x] += val;
    }

    void build(){
        for(int i = 1; i < sum.size(); i++){
            for(int j = 1; j < sum[i].size(); j++){
                sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            }
        }
    }

    T getsum(int top, int left, int bottom, int right){//[top, bottom), [left, right)
        return sum[bottom][right] - sum[bottom][left] - sum[top][right] + sum[top][left];
    }
};

signed main(){
    int n,k;
    cin >> n >> k;
    RectangleSum<int> rs(2 * k, 2 * k);
    int x,y;
    char c;
    int cntW = 0, cntB = 0;
    REP(i,n){
        cin >> x >> y >> c;
        x %= (k * 2);
        y %= (k * 2);
        if(c == 'W'){
            rs.add(y, x, 1);
            cntW++;
        }else{
            rs.add(y, x, -1);
            cntB++;
        }
    }
    rs.build();
    int mx = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int sum = rs.getsum(0, 0, i, j) + rs.getsum(i, j, i + k, j + k) + rs.getsum(i + k, j + k, 2 * k, 2 * k) + rs.getsum(i + k, 0, 2 * k, j) + rs.getsum(0, j + k, i, 2 * k);
            mx = max({mx, n - (cntW - sum), n - (cntB + sum)});
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string s, t; std::cin >> s >> t;
  int lcs[3001][3001] = {};
  int s_length = static_cast<int>(s.length());
  int t_length = static_cast<int>(t.length());

  for (int i = 1; i <= s_length; ++i) {
    for (int j = 1; j <= t_length; ++j) {
      if (s[i-1] == t[j-1]) {
        lcs[i][j] = lcs[i-1][j-1] + 1;
      } else {
        lcs[i][j] = std::max(lcs[i-1][j], lcs[i][j-1]);
      }
    }
  }

  int i = s_length, j = t_length;
  std::string ans;
  while (lcs[i][j] > 0) {
    if (s[i-1] == t[j-1]) {
      ans = s[i-1] + ans;
      --i;
      --j;
    } else {
      if (lcs[i-1][j] > lcs[i][j-1]) --i;
      else                           --j;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 35456
n=int(input())
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
v=[]
r.sort()
b.sort()
count=0
 
for i in range(n):
    for j in range(len(r)):
        if b[i][0]<=r[j][0] or b[i][1]<=r[j][1]:
            pass
        else:
            v.append(r[j])    
    if v!=[]:
        v.sort(key=lambda x:x[1])
        v.reverse()
        r.remove(v[0])
        
            
        v=[]
        count+=1
print(count)

Measured memory_bytes: 3064