akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn main() {
    let n: usize = read();
    let m: usize = read();
    
    let mut po = vec![Vec::new(); n];
    for i in 0..m {
        let x: usize = read();
        let y: usize = read();
        let _: usize = read();
        po[x-1].push(y-1);
        po[y-1].push(x-1);
    }

    let mut ans = n;
    let mut used = vec![false; n];
    for i in 0..n {
        if used[i] {
            continue;
        }
        let mut que: VecDeque<usize> = VecDeque::new();
        que.push_back(i);
        used[i] = true;
        loop {
            if que.is_empty() {
                break;
            }
            let q = que.pop_front().unwrap();
            for i in &po[q] {
                if !used[*i] {
                    ans -= 1;
                    used[*i] = true;
                    que.push_back(*i);
                }
            }
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 12540
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int main() {
	int a[3];
	REP(i, 3) scanf("%d", &a[i]);
	sort(a, a + 3);
	
	int ans = 1;
	REP(i, 2) if (a[i] != a[i + 1]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#ABC 133 Remainder Minimization 2019
l, r = [ int(_) for _ in input().split() ]

ls = [2018]

for i in range(l,r):
    for j in range(i+1,r+1):
        y = (i*j) % 2019
        if (i*j) % 2019 < min(x%2019 for x in ls):
            ls.append(i*j)
        if y == 0:
            break
    if y == 0:
        break
    
print(min([ x%2019 for x in ls]))

Measured memory_bytes: 3060
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言

bool is_strong(string& S,int start,int last){ //[last]は含まない

	REP(i,last-start){

		if (S[start+i]!=S[last-1-i])
		{
			return false;
		}
	}

	return true;

}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
string S;
cin>>S;



bool a,b,c;

int N=S.size();

a= is_strong(S,0,N);

b=is_strong(S,0,(N-1)/2);

c=is_strong(S,((N+3)/2)-1,N);

if (a&&b&&c)
{
	cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;

//cout<<a<<b<<c<<endl;






return 0;





}

Measured memory_bytes: 3536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N = 100010;
int n, k, a[N];
 
 
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 2100000000;
    for (int i = 1; i+k-1 <= n; i++){
        if ((long long)a[i]*a[i+k-1] < 0)
            ans = min(ans,abs(a[i])+(int)abs(a[i+k-1])+min((int)abs(a[i]), (int)abs(a[i+k-1])));
        else ans = min(ans, max(abs(a[i]),abs(a[i+k-1])));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 5 + 3000;
constexpr int MOD = 998244353;

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

int n,arr[MAXN],memo[MAXN][MAXN];

int dp(int i, int s) {
  int& ans = memo[i][s];
  if (ans != -1) return ans;
  if (i == n) return ans = (s == 0);
  ans = add(dp(1+i,s), dp(1+i,s));
  if (s - arr[i] >= 0) {
    ans = add(ans, dp(1+i,s-arr[i]));
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int s; cin >> n >> s;
  foi (i,0,n) cin >> arr[i];
  memset(memo, -1, sizeof memo);
  cout << dp(0,s) << '\n';
  return 0;
}


Measured memory_bytes: 39124
from collections import deque

n = int(input())
T = [[] for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a,b = a-1, b-1
    T[a].append([b,i])
    T[b].append([a,i])

visited = [False]*n
colors = [0]*(n-1)

max_colors = max(len(t) for t in T)
que = deque([(0,0)])


while que:
    node, p_color = que.popleft()
    visited[node] = True
    color = 1
    
    for nxt_n, nxt_e in T[node]:
        if visited[nxt_n] == True:
            continue
        if color == p_color:
            color += 1
        colors[nxt_e] = color
        que.append((nxt_n, color))
        color += 1

print(max_colors)
print(*colors, sep='\n')

Measured memory_bytes: 48820
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;
    cin >> n;
    
    int h[n];
    forn(i, 0, n) {
        cin >> h[i];
    }
    
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    forn(i, 2, n) {
        int a = dp[i-1] + abs(h[i]-h[i-1]);
        int b = dp[i-2] + abs(h[i]-h[i-2]);
        dp[i] = min(a, b);
    }
    
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

ll o[65],z[65];

bool checkbit(ll N, int pos){
  return (bool)(N & (1LL<<pos));
}

int main(){
  ll n; cin >> n;
  
  rep(i,n){
    ll x; cin >> x;
    rep(j,62){
      if(checkbit(x,j)) o[j]++;
      else z[j]++;
    }
  }
  
  ll ans = 0;
  rep(i,62){
    ans = (ans+((((o[i]*z[i])%MOD)*((1LL<<i)%MOD))%MOD))%MOD;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
D(char*s){
	int v=0,d=1;
	for(;*s;s++){
		if(*s=='m')
			v+=1000*d,d=1;
		else if(*s=='c')
			v+=100*d,d=1;
		else if(*s=='x')
			v+=10*d,d=1;
		else if(*s=='i')
			v+=d,d=1;
		else
			d=*s-'0';
	}
	return v;
}
main(){
	char s1[9],s2[9];
	int v,i,r,d;
	scanf("%*d");
	for(;~scanf("%s%s",s1,s2);){
		v=D(s1)+D(s2);
		for(i=0,r=1000;r;r/=10,i++){
			d=v/r%10;
			if(d){
				if(d>1)
					putchar('0'+d);
				putchar("mcxi"[i]);
			}
		}
		puts("");
	}
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n = 5;
  int a[n];
  rep(i, n) cin >> a[i];

  int ans = 0;
  int mx = 0;
  rep(i, n) {
    int x = a[i] % 10;
    if (x == 0) {
      ans += a[i];
      continue;
    }
    mx = max(mx, 10 - x);
    for (int j = a[i] + 1; j <= 130; ++j) {
      if (j % 10 == 0) {
        ans += j;
        break;
      }
    }
  }

  ans -= mx;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(raw_input())
x = []
u = []
total = 0
for i in range(n):
	xi, ui = map(str,raw_input().split())
	if ui == 'BTC':
		sumi = float(xi) * 380000.0
	else:
		sumi = float(xi)
	total += sumi

print total

Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int main() {
	int i, q, n, LANtime = 0;
	P u;

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}

	head = 0; tail = n;

	while (head != tail) {
		u = dequeue();
		if (u.t > q) {
			LANtime += q;
			u.t -= q;
			enqueue(u);
		}
		else {
			LANtime += u.t;
			printf("%s %d\n", u.name, LANtime);
		}
	}

	return 0;
}

Measured memory_bytes: 10756
N, M = map(int,input().split())

dp = [[10**12]*((10**3)*N+1) for i in range(N+1)]
dp[0][0] = 0
v_sum = 0
for i in range(N):
    w, v = map(int,input().split())
    v_sum += v
    for j in range((10**3)*N+1):
        if j > v_sum:
            break
        if j - v >= 0:
            dp[i+1][j] = min(dp[i][j],dp[i][j-v]+w)#諸悪の根源
        else:
            dp[i+1][j] =dp[i][j]

for i in range(len(dp[-1])):
    if 0 < dp[-1][i]<= M:
        ans = i
    else:
        pass

print(ans)





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

int main () {
  int N,A,B,C,sum;
  sum = 0;
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> A >> B;
    C = B-A+1;
    sum += C; 
  }
  cout << sum << endl;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin>>n;
    ll temp,c=0;
    for(ll i=0;i<n;++i)
    {
        cin>>temp;
        if(temp!=i+1)
        {
            ++c;
        }
    }
    if(c==0||c==2)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll len(ll x1, ll y1, ll x2, ll y2){
    return abs(x1 - x2) + abs(y1 - y2);
}
ll calc(ll h, ll cx, ll cy, ll x, ll y){
    return max(h - len(cx, cy, x, y), 0LL);
}

int main(){

    ll N;
    cin >> N;
    vector<ll>X(N), Y(N), H(N);
    ll idx = 0;
    for(ll i = 0; i < N; i++){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] > 0)idx = i;
    }
    for(ll cx = 0; cx <= 100; cx++){
        for(ll cy = 0; cy <= 100; cy++){
            ll h = H[idx] + len(cx, cy, X[idx], Y[idx]);
            ll flg = 1;
            for(ll i = 0; i < N; i++){
                if(calc(h, cx, cy, X[i], Y[i]) != H[i]){
                    flg = 0;
                    break;
                }
            }
            if(flg){
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 058 怪文書 c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int dic[26];
int tmpDic[26];

int main()
{
  memset(dic, 1000000, sizeof(dic));
  int N;
  string inputStr;
  cin >> N;
  REP(i, N) {
    cin >> inputStr;
    memset(tmpDic, 0, sizeof(tmpDic));
    REP(j, inputStr.size()) {
      ++tmpDic[(int)inputStr[j] - 97];
    }
    REP(j, 26) {
      dic[j] = min(dic[j], tmpDic[j]);
    }
  }
  REP(i, 26) {
    REP(j, dic[i]) {
      printf("%c", 97 + i);
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n;cin>>n;
  ll sum = 0;
  vector<ll> A;
  rep(i,n){
    ll a;cin>>a;
    A.push_back(a);
    sum += a;
  }
  ll ans = LINF;
  ll ruiseki = 0;
  rep(i,n){
    ruiseki += A[i];
    chmin(ans, abs(sum-ruiseki - ruiseki));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <cmath>
#define MOD 1000000007
using namespace std;

int K, S;

int main() {
    cin >> K >> S;
    int c = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (S - i - j >= 0 && S - i - j <= K) c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
n = int(input())
data = list(map(int,input().split()))
nega = 0
for d in data:
  if d <= 0:
    nega += 1
    
data = sorted([abs(d) for d in data])
    
if nega % 2 == 0:
  res = sum(data)
  print(res)
  
else:
  res = sum(data[1:])
  print(res - data[0])
  

Measured memory_bytes: 14284
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] arr = new int[5];
            int n = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            map.put("M", 0);
            map.put("A", 1);
            map.put("R", 2);
            map.put("C", 3);
            map.put("H", 4);
            for (int i = 0; i < n; i++) {
                String s = in.nextString();
                String tmp = String.valueOf(s.charAt(0));
                if (map.containsKey(tmp))
                    arr[map.get(tmp)]++;
            }

            long ans = 0;
            for (int i = 0; i < 5; i++) {
                for (int j = i + 1; j < 5; j++) {
                    for (int k = j + 1; k < 5; k++) {
                        ans += ((long) arr[i]) * arr[j] * arr[k];
                    }
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 38956
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int w;
	int amida[31];
	int n;
	char aaa;
	cin >> w >> n;
	int a, b, keep;
	for (int i = 1; i <= w; i++) {
		amida[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> a >>aaa>> b;
		keep = amida[a];
		amida[a] = amida[b];
		amida[b] = keep;
	}
	for (int i = 1; i <= w; i++) {
		cout << amida[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> v(N);
  vector<int> r(N);
  REP(i, N){
    int a, b;
    cin >> a >> b;

    v[i] = a+b;
    r[i] = a-b;
  }

  sort(ALL(v));
  sort(ALL(r));

  cout << max(abs(r.back()-r[0]), abs(v.back()-v[0])) << "\n";

  return 0;
}


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

#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define ll long long 

int main() {
    IOS;
    string s;
    cin >> s;
    if (s == "RRR") cout << 3;
    else if (s == "RSR") cout << 1;
    else if (s == "RRS") cout << 2;
    else if (s == "SRR") cout << 2;
    else if (s == "SSS") cout << 0;
    else cout << 1;
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            var o = ReadAndParseIntArr();
            long n = o[0];
            long t = o[1];
            var ts = ReadAndParseLongArr();

            long ans = t;// n番目
            for(long i=n-2;i>=0;--i)
            {
                if( ts[i+1] - ts[i] >= t)
                {
                    ans += t;
                }
                else
                {
                    ans += ts[i + 1] - ts[i];
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int c1 = max(a * c, a * d);
  int c2 = max(b * c, b * d);
  cout << max(c1, c2) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- ------- <3 \n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;

LL dp[100][100005] = {0};
LL sum_dp[100][100005] = {0};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    VL a(n);
    REP(i,n)cin>>a[i];

    REP(i,a[0]+1)dp[0][i] = 1;
    REP(i,k+1)sum_dp[0][i+1] = dp[0][i] + sum_dp[0][i];
    LL sum_a = a[0];
    FOR(i,1,n){
        sum_a += a[i];
        LL limit = min(k, sum_a);
        REP(j,limit + 1){
            if(j <= a[i]){
                dp[i][j] = sum_dp[i-1][j+1] - sum_dp[i-1][0] + MOD;
                dp[i][j] %= MOD;
            }
            else{
                dp[i][j] = sum_dp[i-1][j+1] - sum_dp[i-1][j - a[i]] + MOD;
                dp[i][j] %= MOD;
            }
        }
        REP(j, k + 1){
            sum_dp[i][j+1] = dp[i][j] + sum_dp[i][j];
            sum_dp[i][j+1] %= MOD;
        }
    }
    PUTS(dp[n-1][k]);
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
vector<int> edges[200001];
void dfs(int i, int parent, set<int>& seq, vector<int> &ar, vector<int> &ans)
{
    int temp=-1;
    if (seq.lower_bound(ar[i]) != seq.end())
    {
        temp=*seq.lower_bound(ar[i]);
        seq.erase(seq.lower_bound(ar[i]));
        seq.insert(ar[i]);
    }
    else
        seq.insert(ar[i]);
    ans[i] = max(ans[i], (int)seq.size());
    for (auto j : edges[i])
    {
        if (j != parent)
        {
            dfs(j, i, seq, ar, ans);
        }
    }
    seq.erase(ar[i]);
    if(temp!=-1)
        seq.insert(temp);
}
void solve()
{
    int n;
    cin >> n;
    vector<int> ar(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> ar[i];
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> ans(n + 1, 1);
    set<int> seq = {ar[1]};
    dfs(1, -1, seq, ar, ans);
    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
}
int32_t main()
{
    _FAST

    int t;
    t = 1;
    while (t--)
        solve();

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    vector<int> per;
    for (int i = 1; i <= N; i++) per.push_back(i);

    int order = 1, a, b;
    do {
        if (P == per) a = order;
        if (Q == per) b = order;
        order++;
    } while (next_permutation(per.begin(), per.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 3636
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

S = input()
#N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
#W = [input() for _ in range(N)]
#A = A = list(map(int, input().split()))

def isKaibun(s):
    lenS = len(s)
    for i in range(lenS//2):
        if s[i] != s[-i-1]:
            return False
    return True

if isKaibun(S) == True:
    N = len(S)
    s_left = S[:(N-1)//2]
    s_right = S[(N+3)//2-1:]
    if isKaibun(s_left) and isKaibun(s_right):
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int c = a + b;
		int d = a - b;
		int e = a * b;

		if (c >= d && c >= e)
			System.out.println(c);
		else if (d >= c && d >= e)
			System.out.println(d);
		else
			System.out.println(e);

	}
}

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

namespace AtCorder
{
	public class Program
	{
		const int MAX = 2000;
		const int MOD = 1000000007;

		private static long[] fac = new long[MAX];
		private static long[] finv = new long[MAX];
		private static long[] inv = new long[MAX];

		// テーブルを作る前処理
		static void COMinit()
		{
			fac[0] = fac[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for (int i = 2; i < MAX; i++) {
				fac[i] = fac[i - 1] * i % MOD;
				inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
				finv[i] = finv[i - 1] * inv[i] % MOD;
			}
		}

		static long COM(long n, int k)
		{
			if (n < k) return 0;
			if (n < 0 || k < 0) return 0;
			return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
		}

		static Dictionary<BB, long> memo = new Dictionary<BB, long>();

		public struct BB
		{
			public long Basyo;
			public long Ball;
		}

		static void Main(string[] args)
		{
			COMinit();

			Scanner cin = new Scanner();
			long n = cin.Long();
			long k = cin.Long();

			long hole = k + 1;
			for (int i = 1; i <= k; i++) {
				long red = COM(n - k + 1, i);
				long blue = COM(k - 1, i - 1);
				Console.WriteLine(red * blue % MOD);
			}
		}

	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<int,int> pr;

pr a[100005];
pr lx[100005],rx[100005];

bool cmp(pr x,pr y) {
  return (x.FR!=y.FR)?x.FR<y.FR:x.SE>y.SE;
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	a[i]=pr(x,y);
  }
  sort(a+1,a+n+1,cmp);
  lx[0]=pr(1,1e9);
  for(int i=1;i<=n;i++) lx[i]=pr(max(lx[i-1].FR,a[i].FR),min(lx[i-1].SE,a[i].SE));
  rx[n+1]=pr(1,1e9);
  for(int i=n;i>0;i--) rx[i]=pr(max(rx[i+1].FR,a[i].FR),min(rx[i+1].SE,a[i].SE));
  int ans=0;
  for(int i=1;i<=n;i++)
    ans=max(ans,max(0,max(0,min(lx[i-1].SE,rx[i+1].SE)-max(lx[i-1].FR,rx[i+1].FR)+1))+a[i].SE-a[i].FR+1);
  for(int i=1;i<n;i++)
    ans=max(ans,max(0,lx[i].SE-lx[i].FR+1)+max(0,rx[i+1].SE-rx[i+1].FR+1));
  printf("%d\n",ans);
  return 0;
} 

Measured memory_bytes: 2560
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));


function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $array[] = 1<<(ord($str[$i])-97);
}
$seg = new SegTree($array);

while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    if(is_array($n)){
      $array = $n;
      $n = count($array);
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = $n, $I = 2**$this->bits; $i < $I; ++$i){
        $array[] = 0;
      }
      $this->tree[0] = $array;
      $this->rollupAll();
    }else{
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = 0; $i < $this->bits; ++$i){
        $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
      }
    }
  }
  function rollupAll(){
    for($i = 1; $i < $this->bits; ++$i){
      $treei = &$this->tree[$i];
      $treeim = $this->tree[$i-1];
      for($j = 0, $J = 2**($this->bits - $i + 1); $j < $J; $j+=2){
        $treei[$j>>1] = op($treeim[$j], $treeim[$j+1]);
      }
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = op($this->tree[$j-1][$i>>$j<<1], $this->tree[$j-1][($i>>$j<<1) + 1]);
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1 == 1){
        $sum = op($sum, $treei[$f>>$i]);
        $f+=1<<$i;
      }
      if(($t >> $i) & 1 == 1){
        $sum = op($sum, $treei[($t>>$i)-1]);
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 55912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
struct id{
  int num1, num2, num3;
};

int main(void) {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  arrll(a,x);
  arrll(b,y);
  arrll(c,z);

  sort(all(a), greater<ll>());
  sort(all(b), greater<ll>());
  sort(all(c), greater<ll>());

  vecll taste;
  rep(l,x){
    rep(m,y){
      rep(n,z){
        if((l+1)*(m+1)*(n+1)<=k){
          taste.push_back(a[l]+b[m]+c[n]);
        } else {
          break;
        }
      }
    }
  }

  sort(all(taste),greater<ll>());
  rep(i,k){
    prt(taste[i]);
  }


}


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

using namespace std;

int main(){
    string O, E;
    cin >> O >> E;

    for(int i=0;i<O.size()+E.size();i++){
        if(!(i%2)) cout << O.at(i/2);
        else cout << E.at(i/2);
    }
    cout << endl;
}   

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> xs(n);
    for (auto& x : xs) {
        cin >> x;
    }
    long long total_xor = 0;
    for (auto x : xs) {
        total_xor ^= x;
    }
    int K = 62;
    vector<long long> spanning(K, -1);
    for (auto x : xs) {
        x = x & (~total_xor);
        for (int bit = K-1; bit >= 0; --bit) {
            if (!(x & (1LL << bit))) {
                continue;
            }
            if (spanning[bit] == -1) {
                spanning[bit] = x;
                break;
            }
            x ^= spanning[bit];
        }
    }
    long long best = 0;
    for (int bit = K-1; bit >= 0; --bit) {
        if (spanning[bit] == -1) {
            continue;
        }
        if (!(best & (1LL << bit)) && spanning[bit] != -1) {
            best ^= spanning[bit];
        }
    }
    cout << (best + (best^total_xor)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, a[100005], l;

int main(){
	scanf("%d %d",&n,&l);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	int poss = -1;
	for(int i=1; i<n; i++){
		if(a[i] + a[i+1] >= l){
			poss = i;
		}
	}
	if(poss == -1){
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	for(int j=1; j<poss; j++){
		printf("%d\n", j);
	}
	for(int j=n-1; j>poss; j--){
		printf("%d\n", j);
	}
	printf("%d\n", poss);
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n;
    cin>> n;
    int a, b, cnt = 0, mx = -1;
    rep(i, 0, n){
        cin>> a>> b;
        if(a == b)
            cnt++;
        else
            cnt = 0;
        mx = max(mx, cnt);
    }
    mx = max(mx, cnt);    
    if(mx >= 3)
        cout<< "Yes\n";
    else
        cout<< "No\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3644
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab = sorted(ab, key=lambda x: x[1])
    t = 0
    for a, b in ab:
        t += a
        if t > b:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 84828
h,w=map(int,input().split())
x=[[0]*(w+2)]
for i in range(h):
    x.append([0]+list(input())+[0])
x.append([0]*(w+2))
c=0
for i in range(1,h+1):
    if c==1:
        break
    for j in range(1,w+1):
        if x[i][j]=="#":
            if x[i-1][j]!="#" and x[i][j-1]!="#" and x[i][j+1]!="#" and x[i+1][j]!="#":
                print("No")
                c+=1
                break
else:
    if c!=1:
        print("Yes")

Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }

vector<string> ans;

void dfs(string s, int n){
    // pr(s);
    if(s.size()==n) {
        ans.push_back(s);
        return;
    }

    char mc = 'a';
    rep(i, s.size()){
        chmax(mc, s[i]);
    }

    for(char c='a'; c<=mc+1; c++){
        dfs(s + c, n);
    }
}
int main()
{
    int n; cin >> n;

    string s = "a";

    dfs(s, n);

    sort(ALL(ans));

    rep(i, ans.size()){
        pr(ans[i]);
    }

    char a = 'a';
    return 0;}

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

int main()
{
	int ar[110];
	int n;
	std::cin >> n;
	for (int i = 1; i <= n; i++) {
		ar[i] = i;
	}
	int rslt = 1;
	int max_counter = 0;
	for (int i = 1; i <= n; i++) {
		int a = i;
		int counter = 0;
		while (true) {
			if (a % 2)break;
			a /= 2;
			counter++;
			if (max_counter < counter) {
				max_counter = counter;
				rslt = i;
			}
		}
	}
	cout << rslt;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__)
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, multiset<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n,a,b; cin >> n >> a >> b;
    vector<int> h(n); cin >> h;
    int l = 0, r = 1e9 + 10;
    while (l+1 < r) {
        int m = (l+r)/2;
        int cnt = 0;
        rep (i,n) {
            int rest = h[i]-b*m;
            if (rest > 0) cnt += (rest+(a-b)-1)/(a-b);
        }
        if (cnt > m) l = m; else r = m;
    }
    cout << r << endl;
}


Measured memory_bytes: 1024