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

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

  int max = 0;
  int sum = 0;
  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    sum += tmp;
    if (tmp > max) {
      max = tmp;
    }
  }

  if (max < sum - max) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,n;
	scanf("%d",&n);
	int r[n],min[n],max[n],Max=-1000000000;
	for(i=0;i<n;i++){
		scanf("%d",&r[i]);
    }

	min[0]=r[0];
	max[0]=r[n-1];
	for(i=1;i<n-1;i++){
		if(r[i] < min[i-1]){min[i]=r[i];}else{min[i]=min[i-1];}
		if(r[n-1-i] > max[i-1]){max[i]=r[n-1-i];}else{max[i]=max[i-1];}
	}
	for(i=0;i<n-1;i++){
		if(max[n-2-i]-min[i] > Max){Max=max[n-2-i]-min[i];}
	}
	printf("%d\n", Max);

	return 0;
}

Measured memory_bytes: 4196
while true
    n = gets.to_i
    break if n == 0
    arr = gets.chomp.split.map(&:to_i).sort
    min = nil
    for i in 1..n-1
        min = (arr[i] - arr[i - 1]).abs if min.nil? || min > (arr[i] - arr[i - 1]).abs
    end
    puts min
end


Measured memory_bytes: 7196
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//


int dp[100005];

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  rep(i, 100005) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) rrep(j, k) {
    chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4028
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
l=[]
pt=0
ns=t.replace('r', 'tr').replace('p', 'tp').replace('s', 'ts').replace('tr', 'p').replace('tp', 's').replace('ts', 'r')
pt+=(ns.count("r")*r)+(ns.count("s")*s)+(ns.count("p")*p)
for i in range(n):
    if i>=k and ns[i]==ns[i-k]:
        if ns[i]=="p":
            ns=ns[:i]+'X'+ns[i+1:]
            pt-=p
        if ns[i]=="r":
            ns=ns[:i]+'X'+ns[i+1:]
            pt-=r
        if ns[i]=="s":
            ns=ns[:i]+'X'+ns[i+1:]
            pt-=s
print(pt)


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

const int N = 2e6 + 12;

#define mkp make_pair
#define sz(s) (int)(s.size())
#define eb emplace_back

int main () {
	clog << "Ready\n";
	
	int a, b;
	cin >> a >> b;
	if ((a == 1 and b == 2) or (a == 2 and b == 1))
		cout << 3;
	else if ((a == 2 and b == 3) or (a == 3 and b == 2))
		cout << 1;
	else if ((a == 1 and b == 3) or (a == 3 and b == 1))
		cout << 2;
	
	cerr << '\n';
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N = z()


def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


ans = num2alpha(N)
print(ans.lower())
# # 26進数
# num = 26
# keta_su = 1
# keta = [26]
# while keta[-1] < N:
#     keta_su += 1
#     keta.append(pow(26, keta_su) + keta[-1])
# print(keta[-2])
# keta[-2] + 1  # 'a'*keta_su
# print('a'*keta_su)


Measured memory_bytes: 27148
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(), v.end());
	cout << v[2] * 10 + v[1] + v[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<c && c<b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<c && c<a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(b<a && a<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(c<a && a<b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<b && b<a){
		printf("%d %d %d\n",c,b,a);
	}
	else if(a==b && b==c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a==b && b<c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<b && b==c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a==c && c<b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(a<c && c==b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b==a && a<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<a && a==c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b==c && c<a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(b<c && c==a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c==a && a<b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<a && a==b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c==b && b<a){
		printf("%d %d %d\n",c,b,a);
	}
	else{
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define s second
#define f first
using namespace std;

int main(void){
  int n,ary[3] = {0},in,ret = 0;
  cin>>n;
  rep(i,n){
    cin>>in;
    ary[in%3] ++;
  }
  if(ary[1] || ary[2]) ret = ary[0];
  int mi = min(ary[1],ary[2]);
  int diff = max(ary[1],ary[2]) - mi;
  //cout<<diff<<endl;
  ret = ret + mi * 2 + min(3,diff);
  //cout<< min(3,diff)<<endl;

  
  
  cout<<(ret==0&&ary[0]?1:ret)<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x, y; cin >> x >> y;
	for(int i = 0; i <= x; ++i) {
		if(i * 2 + (x - i) * 4 == y) {
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,m;
int INF = 2000000000;
int cost[1005];
int open[1005];
int dp[1005][1<<12];
int all_opened;

int calculate(int a,int b){
	for(int i=0; i<n; i++){
		if((1<<i)&a && (1<<i)&b) a-=(1<<i);
	}
	return a;
}
int f(int key,int opened){
	int&ret = dp[key][opened];
	if(~ret) return ret;
	ret = INF;
	int new_opened = calculate(opened,open[key]);
	if(new_opened == 0) ret = cost[key];
	if(key==m) return ret;
	
	ret = min(ret,f(key+1,opened)); //이번 키를 안쓰고 다음 키부터 고려하는 경우  
	if(f(key+1,new_opened)!=INF) ret = min(ret,f(key+1,new_opened)+cost[key]); //이번 키를 사용한 경우  
	return ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	all_opened = (1<<n)-1;
	
	for(int i=1; i<=m; i++){
		int c,o;
		cin>>c>>o;
		cost[i] = c;
		int bit = 0;
		while(o--){
			int num;
			cin>>num;
			num--;
			bit |= (1<<num);
		}
		open[i] = bit;
	}
	int mincost = f(1,all_opened);
	if(mincost==INF) cout<<-1;
	else cout<<mincost;
}

Measured memory_bytes: 19720
#include<stdio.h>
int main(void){
    int x,y,a;
    do{
        scanf("%d %d",&x,&y);
        if(x==0 && y==0){
            break;
        }
        else if(x>y){
            a=x;
            x=y;
            y=a;
            printf("%d %d\n",x,y);
        }
        else{
            printf("%d %d\n",x,y);
        }
    }while(1);
    return 0;
}


Measured memory_bytes: 2056
package main
 
import (
  "fmt"
  "strings"
)
 
func main() {
  var S string
  fmt.Scanf("%s", &S)
  
  var cnt uint
  var before, str string
  
  for _, s := range strings.Split(S, "") {
    str = str + s
    
    if before != str {
      before = str
      cnt++
      str = ""
    }
    
  }
  
  fmt.Println(cnt)
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	int a = 0, b = 0;
	
	cin>>s;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '0') a++;
		else b++;
	}
	
	cout<<min(a,b)*2<<endl;
	return 0;
}

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

int main() {
    ll  n;
    cin >> n;
    vector<ll> a(n);
  for(ll i=0;i<n;i++){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(),a.end());
    ll b = a[n/2];
    ll ans = 0;
    for(ll i=0;i<n;i++){
        ans += max(a[i]-b,b-a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int D, G;
    cin >> D >> G;
    vi p(D), c(D);
    REP(i, D) cin >> p[i] >> c[i];

    int ans = INF;
    REP(S, 1 << D) {
        int num = 0;
        int score = 0;
        REP(i, D) {
            if (S >> i & 1) {
                num += p[i];
                score += 100 * (i + 1) * p[i] + c[i];
            }
        }
        dump(S, num, score);
        if (score >= G) {
            chmin(ans, num);
            continue;
        }
        REPR(i, D - 1) {
            if (S >> i & 1) continue;
            REP(j, p[i] - 1) {
                score += 100 * (i + 1);
                num++;
                if (score >= G) {
                    chmin(ans, num);
                    goto next;
                }
            }
        }
        next:;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
/*Aをmod2の配列Bに変換 Bのうち1と0の個数をカウント
*/


int main() {
 int N;
 cin >> N;
 string s,t;
 cin >> s >> t;
 int ans  =0;//tとsとで共通する部分の最大長
 for(int i = 1;i<=N;i++){
   int c = 0;
   if(t.substr(0,i) == s.substr(N-i,i)){
       c = i;
       ans = max(ans,i);
   } 
 }
 cout << 2*N - ans << endl;

 }


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
m = min(a)
M = max(a)
num_m = 0
num_M = 0
if M - m >= 2:
  print("No")
else:
  if m == M:
    if m == n-1:
      print("Yes")
    else:
      if m <= n/2:
        print("Yes")
      else:
        print("No")
  else:
    for i in range(n):
      if a[i] == m:
        num_m += 1
    more = n - num_m
    num_remain = M - num_m
    if 0 < num_remain <= more/2:
      print("Yes")
    else:
      print("No")

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

int main() {
  int q; cin >> q;
  string A, B;
  for (int i=0; i<q; i++) {
    cin >> A >> B;
    vector<vector<int>> LCS(A.length()+1, vector<int>(B.length()+1,0));
    int ans=0;
    for (int j=0; j<A.length(); j++) {
      for (int k=0; k<B.length(); k++) {
        if(A[j]==B[k]) LCS[j+1][k+1]=LCS[j][k]+1;
        else LCS[j+1][k+1]=max(LCS[j][k+1],LCS[j+1][k]);
        ans = max(ans, LCS[j+1][k+1]);
      }
    }
    cout << ans << "\n";
  }
}




Measured memory_bytes: 6876
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
const int MOD = 1e9+7;
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  int n;cin>>n;
  string moji;cin>>moji;
  int x=0;
  int ans[n];

  for(int i=0;i<n;i++){
    if(moji[i]=='I'){
      x+=1;
      ans[i]=x;
    }else{
      x-=1;
      ans[i]=x;
    }
  }
  sort(ans,ans+n);

  if(ans[n-1]<0){
    cout<<0<<endl;
  }else{
    cout<<ans[n-1]<<endl;
  }
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  char ch = A[0], ans;
  A.erase(A.begin());

  while (1) {
    if (ch == 'a') {
      if (A.size() == 0) {
        ans = 'A';
        break;
      }
      ch = A[0];
      A.erase(A.begin());
    } else if (ch == 'b') {
      if (B.size() == 0) {
        ans = 'B';
        break;
      }
      ch = B[0];
      B.erase(B.begin()); 
    } else if (ch == 'c') {
      if (C.size() == 0){
        ans = 'C';
        break;
      }
      ch = C[0];
      C.erase(C.begin());
    }
  }

  cout << ans << endl;
}

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

int main(void){
  int N,M;
  int T[111],P[111],X[111];
  int i;
  int t,p,x;
  int sum=0;

  cin>>N;
  for(i=1;i<=N;i++) {
    cin>>t;
    sum+=t;
    T[i]=t;
  }
  cin>>M;
  for(i=1;i<=M;i++) {
    cin>>p>>x;
    P[i]=p;
    X[i]=x;
  }


  for(i=1;i<=M;i++){
    cout<<sum-T[P[i]]+X[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    bool flag = false;
    for (int i = 1; i <= 9; i++) {
        if(n%i == 0 && (int)(n/i) <= 9) {
            flag = true;
            break;
        }
    }

    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
is_safe = [True] * (n+1)
for _ in range(m):
    is_safe[int(input())] = False

MOD = 10**9+7
dp = [0] * (n+1)
dp[0] = 1
if is_safe[1]:
    dp[1] = 1

for i in range(2, n+1):
    if is_safe[i-1]:
        dp[i] += dp[i-1]
    if is_safe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= MOD

print(dp[n])


Measured memory_bytes: 13540
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int,int>;

void solve_8(){//7m
    string a, b;
    cin >> a >> b;
    string tmp =  a+b;
    int c = atoi(tmp.c_str());
    //cout << c << endl;
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No") << endl;
    
}

void solve_8re(){
    string a, b;
    cin >> a >> b;
    //stoi -> int
    //stol -> long
    //stof -> float
    int c = stoi(a+b);
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No")<< endl;
}

void solve_9(){//12m
    int n,k;
    cin >> n >> k;
    int sum_distance = 0;
    rep(i, n){
        int x;
        cin >> x;
        sum_distance += 2 * min(x, k-x);
    }
    cout << sum_distance;
}

void solve_10(){//7m
    int n;
    cin >> n;
    priority_queue<int> pq;
    int a;
    rep(i, n){
        cin >> a;
        pq.push(a);
    }
    int alice = 0, bob = 0;
    int turn = 0;
    while(!pq.empty()){
        a = pq.top();
        pq.pop();
        if (turn % 2 == 0){
            alice += a;
        }
        else{
            bob += a;
        }
        turn += 1;
    }
    cout << alice - bob;
    
}

void solve_10re(){
    int n;
    cin >> n;
    vector<int> a;
    int a_;
    rep(i, n){
        cin >> a_;
        a.push_back(a_);
    }
    sort(a.begin(), a.end(), greater<int>());
    int total = 0;
    rep(i, n){
        total += (i%2==0?a[i]:-a[i]);
    }
    cout << total;
}

void solve_11(){//7m
    int n;
    cin >> n;
    int score;
    rep(i,7){
        if (n >= pow(2, i))
        {
            score = pow(2,i);
        }
    }
    cout << score;
}

void solve_12(){//13m
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    int tmp_a, tmp_b, tmp_c;
    while(a%2==0 && b%2==0 && c%2==0){
        if (a==b && b == c /*&& c == a*/)//while文内で書くことで、a,b,cが全て奇数というパターンを排除している
        {
            count = -1;
            break;
        }
        
        tmp_a = b/2 + c/2;
        tmp_b = a/2 + c/2;
        tmp_c = a/2 + b/2;
        a = tmp_a;
        b = tmp_b;
        c = tmp_c;
        count++;
    }
    cout << count << endl;

}

void solve_13(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a;
    a.push_back(n);
    n = abs(n-k);
    while(find(a.begin(), a.end(), n) == a.end()){
        n = abs(n-k);
        a.push_back(n);
    }
    cout << *min_element(a.begin(), a.end()) << endl;
    
}

void solve_13re(){
    ll  n, k;
    cin >> n >> k;
    ll m = n%k;
    cout << min(m, k-m) << endl;
}

void solve_14(){
    
}

void solve_15(){
    
}

void solve_16(){
    
}

int main(){
    solve_13re();
    return 0;
}

Measured memory_bytes: 3692
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    def insert(self, key):
        x, y, z = self.root, None, Node(key)
        while x != None: x, y = x.left if z.key < x.key else x.right, x
        if y == None: self.root = z
        elif z.key < y.key: y.left = z
        else: y.right = z
    def print_tree(self):
        def inorder(node):
            return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
        def preorder(node):
            return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''
        print(inorder(self.root))
        print(preorder(self.root))

tree = BST()
input()
for e in sys.stdin:
    if e[0] == 'i': tree.insert(int(e[7:]))
    else: tree.print_tree()


Measured memory_bytes: 63272
import java.util.Scanner;

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

	int a,b;
	String op;
	
	int s = 0;
	while (true){
		a  = in.nextInt();
		op  = in.next();
		b  = in.nextInt();
		if (op.equals("?")){
			break;
		}else if (op.equals("+")){
			s = a + b;
		}else if (op.equals("-")){
			s = a - b;
		}else if (op.equals("*")){
			s = a * b;
		}else if (op.equals("/")){
			s = a / b;
		}
		System.out.println(s);
	}	
    }   
}

Measured memory_bytes: 17376
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,k;
inline int read(){
    int x=0; char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int main(){
	n=read(),k=read();
	int all=(n-1)*(n-2)/2;
	if(k>all){printf("-1\n");return 0;}
	printf("%d\n",n-1+all-k);
	for(int i=2;i<=n;i++)printf("%d %d\n",1,i);
	int d=all-k;
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(d==0)return 0;d--;
			printf("%d %d\n",i,j);
		}
	}
}

Measured memory_bytes: 256
def resolve():
    N,T = map(int,input().split())
    C = [list(map(int,input().split())) for _ in range(N)]
    minc = 10**10
    for i in range(N):
        if C[i][1]<=T:
            minc = min(minc,C[i][0])
    print(minc if minc!=10**10 else 'TLE')
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector< pair<int,int> > V(n);
    rep(i,n){
        cin >> V[i].second >> V[i].first;
    }

    sort(ALL(V));
    // rep(i,n){
    //     cout << V[i].first << " " << V[i].second << endl;
    // }

    bool ok = true;
    int res = 0;
    int t = 0;
    for(int i=0; i<n; i++){
        // res += V[i].first - V[i].second;
        t+=V[i].second;
        if(t > V[i].first){
            ok = false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.*; 
public class Main{
 public static void main(String ... string){
   Scanner sc = new Scanner(System.in); 
   int a = sc.nextInt(),b = sc.nextInt(), c = sc.nextInt(); 
   if( a <= c && c <= b) System.out.println("Yes"); 
   else System.out.println("No");
 }
}

Measured memory_bytes: 21844
# 参考： https://atcoder.jp/contests/abc087/submissions/8934132
N, M = gets.chomp.split.map(&:to_i)

edges = Array.new(N) { Array.new }
M.times do
  l, r, d = gets.split.map(&:to_i)
  l -= 1
  r -= 1
  edges[l] << [r, d]
  edges[r] << [l, -d]
end

point = Array.new(N, nil)
flag = true
N.times do |base|
  next unless point[base].nil?
  stack = [[base, 0]]
  while !stack.empty?
    v, at = stack.pop
    unless point[v].nil?
      flag = false if point[v] != at
      next
    end
    point[v] = at
    edges[v].each do |vv, d|
      stack << [vv, at + d]
    end
  end
end
puts flag ? 'Yes' : 'No'

Measured memory_bytes: 54268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n;
    while (cin >> n)
    {
        if (n == 0)
        {
            break;
        }
        vector<ll> S(n);
        repi(i, n, 0)
        {
            cin >> S[i];
        }
        double mean = accumulate(all(S), 0.0) / n;
        double variance = 0;
        repi(i, n, 0)
        {
            variance += pow(S.at(i) - mean, 2);
        }
        cout << fixed << setprecision(10) << sqrt(variance / n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3256
import java.util.Scanner;

/**
 * LLoE
 */

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        a = sc.nextInt();
        b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
	cin >> n;
	std::vector<int> s(n+1,0);
	rep(i,n) {
		int x;
		cin >> x;
		s[i+1] = s[i] + x;
	}

	int min = INF;
	FOR(i,1,n+1){
		int x = abs(s[i] - (s[n]-s[i]));
		chmin(min, x);
	}
	cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


 int N,A,B,C;
 int l[9];

int dfs(int cur,int a,int b,int c){
    
    if(cur==N){
        if(min({a,b,c})>0)
            return abs(A-a)+abs(B-b)+abs(C-c)-30;
        else
            return INF;
    }
    int rec0=dfs(cur+1,a+l[cur],b,c)+10;
    int rec1=dfs(cur+1,a,b+l[cur],c)+10;
    int rec2=dfs(cur+1,a,b,c+l[cur])+10;
    int rec3=dfs(cur+1,a,b,c);
    
    return min({rec0,rec1,rec2,rec3});
}


signed main(void) {
   
    cin>>N>>A>>B>>C;
    rep(i,N) cin>>l[i];
    cout<<dfs(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,m,c,i,j,k=0,s;
  cin>>n>>m>>c;
  ll a[n][m],b[m];
  for(i=0;i<m;i++)
  cin>>b[i];
  for(i=0;i<n;i++)
  {
      s=0;
      for(j=0;j<m;j++)
      {
          cin>>a[i][j];
          s+=a[i][j]*b[j];
      }
      s+=c;
      if(s>0)
      k++;
  }
  cout<<k<<endl;
}

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

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int k = n - i * r - j * g;
           if((0 == k || k % b == 0) && k >= 0)
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n)
    {
        k=n;
    }
    ll ans=(x*k)+((n-k)*y);
    cout<<ans;
    return 0;
}







Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    boolean ans = false;
    for (int i = A; !ans && i <= B; i++)
      ans = i % K == 0;

    System.out.println(ans ? "OK" : "NG");
  }
}

Measured memory_bytes: 35776
from collections import deque
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
graph = [[] for i in range(N)]

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

#print(graph)
v = [0]*N
for i in range(Q):
    p,x = map(int,input().split())
    v[p-1] += x

notv = [True]*N
notv[0] = False
stack = deque([0])

while stack:
    now = stack.popleft()
    for i in graph[now]:
        if notv[i]:
            notv[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)

Measured memory_bytes: 94100
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    vector<ll> num(3, 0);

    for (char c : S) {
        num[c-'a']++;
    }

    sort(num.begin(), num.end(), greater<ll>());
    ll a = num[0];
    ll b = num[1];
    ll c = num[2];

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

    if (a == b && b == c || a == b && b == c + 1 || a == b + 1 && b == c) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

}

Measured memory_bytes: 512
def main():
    import heapq
    N = int(input())
    a = list(map(int, input().split()))
    q = []
    LR = [[0, N-1] for i in range(N)]
    for i in range(N):
        x = a[i]
        while(q and -q[0][0] > x):
            v, id = heapq.heappop(q)
            LR[id][1] = i - 1
        heapq.heappush(q, (-x, i))

    for i in range(N-1, -1, -1):
        x = a[i]
        while(q and -q[0][0] > x):
            v, id = heapq.heappop(q)
            LR[id][0] = i+1
        heapq.heappush(q, (-x, i))
    ans = 0
    for i in range(N):
        ans += a[i] * (LR[i][1] - i + 1)*(i - LR[i][0] + 1)
    print(ans)


main()


Measured memory_bytes: 66496
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n; cin >> n;
    int x = 1, sum = 1;
    while (sum < n) {
        x++;
        sum += x;
    }
    vector<int> ans;
    for (int i = x; i >= 1; i--) {
        if (n >= i) {
            n -= i;
            ans.pb(i);
        }
    }
    sort(all(ans));
    for (int i : ans) {
        printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int t;
int a[65];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	ll x;
	while (cin >> n)
	{
		f(i, 1, n)
		{
			scanf("%lld", &x);
			f(j, 0, 60)
			{
				if (x >> j & 1)a[j]++;
			}
		}
		ll ans = 0;
		f(i, 0, 60)
		{
			ans = (ans + (ll)a[i] * (n - a[i])%mod*quickmod(2, i, mod)%mod) % mod;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std; 
  
int main()  
{ 
    string s;
    cin >> s;
    int K;
    cin >> K;

    set<string> subset;
    for (int i = 0; i < s.size(); i++)  
        for (int len = 1; len <= s.size() - i; len++) {
            if (len > K) {
                break;
            }
            subset.insert(s.substr(i, len));
        }

    int j = 0;
    for (auto it = subset.begin(); it != subset.end(); it++, j++) {
        if (j == K - 1) {
            cout << *it << endl;
            break;
        } 
    }

    return 0; 
} 


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,h[100005],f[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	f[1]=0;
	f[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		f[i]=min(f[i-2]+abs(h[i]-h[i-2]),f[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<f[n];
	return 0;
}

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

using namespace std;

int main () {
    int N;
    cin >> N;
    unordered_map<int, int> m;
    vector<int> nums(N);
    
    long long sum = 0;
    for (int i = 0;i < N; i++) {
        cin >> nums[i];
        m[nums[i]]++;
        sum += nums[i];
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
         int B, C;
         cin >> B>> C;
         sum += m[B] * (C - B);
         m[C] += m[B];
         m[B] = 0;
         cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 7408
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int T;
	while(~scanf("%d%d", &N, &T)) {
		vector<int> A(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &A[i]);
		int maxDiff = 0;
		int mi = INF;
		for(int a : A) {
			amin(mi, a);
			amax(maxDiff, a - mi);
		}
		mi = INF;
		int ans = 0;
		for(int a : A) {
			amin(mi, a);
			if(a - mi == maxDiff)
				++ ans;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INF 100000005
#define MAX 1004

int p[MAX], q[MAX*MAX];
int main(){
	int n, m, ans, qq;
	while(cin >> n >> m, n){
		for(int i = 1;i <= n;i++)scanf("%d", &p[i]);
		ans = 0;p[0] = 0;qq = 0;
		
		for(int i = 0;i <= n;i++)
			for(int j = 0;j <= n;j++)
				if(p[i]+p[j] <= m)q[qq++] = p[i] + p[j];
		
		sort(q, q+qq);
		int t;
		for(int i = 0;i < qq;i++){
			t = upper_bound(q, q+qq, (m-q[i]))-q;
			if(t-1 >= 0)ans = max(ans, q[i]+q[t-1]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7120
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
 
#define rep(p,q) for(int i = p;i < q;i++)
 
using namespace std;
 
const int cons = 1e9 + 7;
 
//A
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	string str = a == b && a == c ? "Yes" : "No";
	cout << str << endl;
}

Measured memory_bytes: 256
def f(n, k, W):
    sum = 0
    i = 0
    while k > 0 and i < len(W):
        sum += W[i]
        if sum <= n:
            i += 1
        else:
            sum = 0
            k -= 1
    if k == 0:
        return False
    else:
        return True


n ,k = [int(_) for _ in input().split()]
W = []
for i in range(n):
    W.append(int(input()))
low = 0
high = 10 ** 9
while low + 1 < high:
    mid = (low + high) // 2
    # print("mid", mid)
    # print("low", low)
    # print("high", high)
    # print("f", f(mid, k, W))
    # print("-----------------------")
    if f(mid, k, W):
        high = mid
    else:
        low = mid
print(high)



Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int find(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = find(x); //xの根をrx
		int ry = find(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = find(x);
		int ry = find(y);
		return rx == ry;
	}
};

int main() {
	init();

	int W, H, N; cin >> W >> H >> N;
	Graph maze(H, vector<int>(W, 0));
	rep(i, N) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) {
			rep(i, x) {
				rep(j, H) {
					maze[j][i] = 1;
				}
			}
		}
		else if (a == 2) {
			REP(i, x, W) {
				rep(j, H) {
					maze[j][i] = 1;
				}
			}
		}
		else if (a == 3) {
			rep(i, y) {
				rep(j, W) {
					maze[i][j] = 1;
				}
			}
		}
		else {
			REP(i, y, H) {
				rep(j, W) {
					maze[i][j] = 1;
				}
			}
		}
	}
	bool is = false;
	pair<int,int> a, b;
	rep(i, H ) {
		rep(j, W ) {
			if (maze[i][j] == 0) {
				a = make_pair(i, j);
				is = true;
				goto e;
			}
		}
	}e:

	for (int i = H-1;i >= 0;--i) {
		for (int j = W-1;j >= 0;--j) {
			if (maze[i][j] == 0) {
				b = make_pair(i, j);
				goto f;
			}
		}
	}f:
	if (is) {
		int x = abs(b.first - a.first) + 1, y = abs(a.second - b.second) + 1;
		cout << x * y << "\n";
		return 0;
	}
	cout << 0 << "\n";



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int h,w;
string s[51];

void input(){
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> s[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool flg = true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                if(i==0){
                    if(j==0 && s[i+1][j]=='.' && s[i][j+1] == '.') flg = false;
                    else if(j==w-1 && s[i][j-1]=='.' && s[i+1][j]=='.') flg = false;
                    else if(s[i+1][j]=='.' && s[i][j+1]=='.' && s[i][j-1]=='.') flg = false;  
                }
                else if(i==h-1){
                    if(j==0&&s[i-1][j]=='.'&&s[i][j+1]=='.') flg = false;
                    else if(j==w-1&&s[i][j-1]=='.'&&s[i-1][j]=='.') flg = false;
                    else if(s[i-1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.') flg = false;
                }
                else if(j==0&&s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j+1]=='.') flg = false;
                else if(j==h-1&&s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j-1]=='.') flg = false;
                else if(s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.') flg = false;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int n, a, b;
int main() {
	cin >> n >> a >> b;
	cout << min(n * a, b);
	return 0;
}

Measured memory_bytes: 256
H,W,M = list(map(int, input().split()))

hw = set()
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.add((h_i-1) + (w_j-1)*3*10**6)
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not(i + j*3*10**6 in hw):
            print(mxh_v+mxw_v)
            exit()
print(mxh_v+mxw_v-d)

Measured memory_bytes: 169312
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = 0;
        int X_MAX = 0;
        String S = "";
        S = sc.next();
        for(int i = 0; i < N ;i++){
            char moji = S.charAt(i);
            if(moji == 'I'){
                X++;
                if(X > X_MAX){
                    X_MAX = X;
                }
            }else{
                X--;
            }
        }
        System.out.println(X_MAX);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if (A != B && B != C && A != C) cout << "No";
  else if (A == B && B == C && A == C) cout << "No";
  else cout << "Yes"; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <sstream>

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;


int main() {
   int a, b; cin >> a >> b;
   string s; cin >> s;
   
   string res = "Yes";
   rep(i, s.length()) {
       if (i != a && (s[i] < '0' || s[i] > '9')) res = "No";
       if (s[a] != '-') res = "No";
   }
   cout << res << endl;
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << "\n";
    } else if (B == C) {
        cout << A << "\n";
    } else {
        cout << B << "\n";
    }
}

Measured memory_bytes: 256