akhauriyash/Code-Regression huggingface dataset:
/*https://bom.to/nxtvde2k1m4l*/
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define task "NAME"
typedef pair<int,int> ii;
typedef long long ll;
void init()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i ++) cout << 'x';
}







Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

ll cal_step(ll n, ll a) {
  if (n % a == 0) {
    return n / a;
  } else {
    return n / a + 1;
  }
}

ll N, A, B, C, D, E;

int main() {
  scanf("%lld", &N);
  scanf("%lld", &A);
  scanf("%lld", &B);
  scanf("%lld", &C);
  scanf("%lld", &D);
  scanf("%lld", &E);

  queue<ll> Q;
  Q.push(B);
  Q.push(C);
  Q.push(D);
  Q.push(E);

  ll time = cal_step(N, A);
  ll v = A;
  ll bef_step = cal_step(N, A);
  while (!Q.empty()) {
    ll x = Q.front();
    Q.pop();
    if (v <= x) {
      time++;
    } else {
      v = x;
      ll d = cal_step(N, x) - bef_step;
      time += d + 1;
      bef_step = cal_step(N, x);
    }
  }
  printf("%lld\n", time);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	vector<string> S(N);
	vector<int> T(N);
	for(int i = 0; i < N; ++i) {
		cin >> S[i] >> T[i];
	}
	string X; cin >> X;
	int ans = 0,flg = 0;
	for(int i = 0; i < N; ++i) {
		if(flg) ans += T[i];
		if(X==S[i]) flg = 1;
	}
	cout << ans << endl;



    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int min = 100000000,max = -100000000;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
        if(max < x){
            max = x;
        }
        if(min > x){
            min = x;
        }

    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


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

int h,w,k;

string arr[6];

bool check(int a,int b)
{
	int cnt=0;
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if((a&(1<<i)) || (b&(1<<j)))
			{
				int tt=0;
			}
			else if(arr[i][j]=='#')
			{
				cnt++;
			}
		}
	}
	
	return cnt==k;
}
int main()
{
	cin>>h>>w>>k;
	
	for(int i=0;i<h;i++)
	{
		cin>>arr[i];
	}
	
	int m1=(1<<h);
	int m2=(1<<w);
	
	int cnt=0;
	
	for(int i=0;i<m1;i++)
	{
		for(int j=0;j<m2;j++)
		{	
			if(check(i,j))
			{
				cnt++;
			}
		}
	}
	
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int max_cnt=0;
    int cnt=0;
    int H;
    cin >> H;  // i=0
    for(int i=1;i<N;i++){
        int h;
        cin >> h;
        if(h <= H){
            cnt++;
        }
        else{
            cnt = 0;
        }
        if(max_cnt < cnt){
            max_cnt = cnt;
        }
        H = h;
    }
    cout << max_cnt << endl;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << b * (t / a) << endl;

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;
ll frac[100100];

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

ll comb(ll n, ll r){
    ll res=1;
    res*=frac[n];
    res*=modpow(frac[r],MOD-2,MOD);
    res%=MOD;
    res*=modpow(frac[n-r],MOD-2,MOD);
    res%=MOD;
    return res;
}


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

    frac[0]=1;
    for(int i=1;i<=n;i++){
        frac[i]=frac[i-1]*i;
        frac[i]%=MOD;
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        ll now=a[i];
        if(i>=k-1){
            //cout<<comb(i,k-1)<<" ";
            ans+=now*comb(i,k-1);
        }
        ans=(ans+MOD)%MOD;
        if(n-i>=k){
            ans-=now*comb(n-i-1,k-1);
        }
        ans=(ans+MOD)%MOD;
        //cout<<ans<<endl;
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 4760
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    char a,b;
    cin>>a>>b;
    
    if((a=='H'&&b=='H') || (a=='D'&&b=='D')){
        cout<<"H"<<endl;
    }else{
        cout<<"D"<<endl;
    }
    
    
    return 0;
}






Measured memory_bytes: 384
import sys
from heapq import *

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

def main():
    x = int(input())
    k = int(input())
    rr = LI()
    q = int(input())
    ta = LLI(q)
    # [時間,命令,(a)]でタイムラインに登録
    # 命令0でひっくり返す 1で質問に答える
    timeline = []
    for r in rr:
        heappush(timeline, [r, 0, 0])
    for t, a in ta:
        heappush(timeline, [t, 1, a])
    # print(timeline)
    # Aのパーツが一度でも空や満タンになると、aは関係なくなるのが大事な所
    # だから空になるaはal未満のaとしてひとまとめ
    # 満タンになるaはarより大きいaとして
    # ひとまとめで管理する
    #       l       r
    # a=0 1 2 3 4 5 6 7 8 9 10...
    #       al      ar
    # al(=2)未満のaの砂の量sl
    # ar(=6)より大きいaの砂の量sr
    # al以上ar以下のaの砂の量a+sm
    sl = sm = 0
    sr = x
    al = 0
    ar = x
    rev_t = 0
    trend = False
    while timeline:
        t, op, a = heappop(timeline)
        sd = t - rev_t
        if op:
            if trend:
                if a < al:
                    print(min(sl + sd, x))
                elif a > ar:
                    print(min(sr + sd, x))
                else:
                    print(min(a + sm + sd, x))
            else:
                if a < al:
                    print(max(sl - sd, 0))
                elif a > ar:
                    print(max(sr - sd, 0))
                else:
                    print(max(a + sm - sd, 0))
        else:
            if trend:
                sl = min(sl + sd, x)
                sr = min(sr + sd, x)
                ar = min(ar, x - sm - sd - 1)
                sm += sd
            else:
                sl = max(sl - sd, 0)
                sr = max(sr - sd, 0)
                al = max(al, sd - sm + 1)
                sm -= sd
            trend = not trend
            rev_t = t
        # print(t, op, a, al, ar, sl, sm, sr)
main()


Measured memory_bytes: 47184
#include <cstdlib>
#include <iostream>


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

  int x;
  std::cin >> x;
  std::cout << (x < 1200 ? "ABC" : "ARC") << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int x=0;
  cin>>x;
  int cat=0,rest;
  cat = x/100;
  rest = x%100;
  int cv=1; 
  if(rest%5==0) cv --;
    if(rest / 5 +cv <= cat ) cout<<1;
    else cout<<0;
   
    return 0;
}

Measured memory_bytes: 256
def gcd(m, n):
  while n:
    m, n = n, m % n
  return m

def lcm(m, n):
  return m * n // gcd(m, n)

def count(a, b, q):
  _a = min(a, b)
  _b = max(a, b)
  if a % q == 0:
    return _b // q - _a // q + 1
  else:
    return _b // q - _a // q

A, B, C, D = list(map(int, input().split()))
lcm = lcm(max(C, D), min(C, D))
print((B - A + 1) - count(A, B, C) - count(A, B, D) + count(A, B, lcm))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
// #define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
// const int INF = 1e12;

int n;
vector<int> a;
int memo[21][400001];

bool solve(int i, int m){
    if(memo[i][m] != -1) return memo[i][m];
    if(m == 0) return true;
    if(i >= n) return false;
    // bool res = solve(i + 1, m) || solve(i + 1, m - a[i]);
    // return res;
    return memo[i][m] = solve(i + 1, m) || solve(i + 1, m - a[i]);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, 21) rep(j, 0, 400001) memo[i][j] = -1;
    int q;
    cin >> q;
    rep(i, 0, q){
        int m;
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

Measured memory_bytes: 36020
n=int(input())
c=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
  t=str(i)
  c[int(t[-1])][int(t[0])]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=c[i][j]*c[j][i]
print(ans)


Measured memory_bytes: 9132
#include<stdio.h>
void call(int);
main()
{
    int n;
    scanf("%d", &n);
    call(n);
}
void call(int n)
{
    int i = 1, x;
    do{
        x = i;
        if(!(x % 3)){
            printf(" %d", i);
        }else {
            while(x){
                if(x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
                x /= 10;
           }
        }
    }while(++i <= n);
    putchar('\n');
}

Measured memory_bytes: 1796
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	ll N, K, Q;
	cin >> N >> K >> Q;
	vll S(N, 0);
	ll i, j;
	for (i = 0; i < Q; i++){
		ll a;
		cin >> a;
		S[a - 1]++;
	}
	for (i = 0; i < N; i++){
		if (K + S[i] - Q > 0) {
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1408
import math
from decimal import Decimal as dec

def main():
    a, b, h, m = map(int, input().split())
    hr = dec(360//12*(h%12)+30*(m%60)/60)
    mr = 360//60*(m%60)
    ans = dec(math.sqrt(a**2+b**2-2*a*b*dec(math.cos(dec(math.radians(abs(hr-mr)))))))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 10320
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int ans = a[0];
    for(int i = 1; i < n; i++) {
      ans = func(ans, a[i]);
    }
    System.out.println(ans);
  }
  public static int func(int a, int b) {
    if(b == 0) return a;
    return func(b, a % b);
  }
}

Measured memory_bytes: 50588
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


struct HLD {
	vector<ll> g[110000];
	vector<ll> sz, in, out, head, rev, par; //rev = in -> index
	HLD(ll n) : sz(n), in(n), out(n), head(n), rev(n), par(n) {};
	void dfs_sz(ll a, ll p) { 
		par[a] = p;
		sz[a] = 1;
		for (auto& to : g[a]) {
			if (to == p)continue;
			dfs_sz(to, a);
			sz[a] += sz[to];
			if (sz[g[a][0]] < sz[to])swap(g[a][0], to);
		}
	}
	void dfs_hld(ll a, ll p, ll& t) {
		in[a] = t++;
		rev[in[a]] = a;
		for (auto& to : g[a]) {
			if (to == p)continue;
			head[to] = (g[a][0] == to ? head[a] : to);
			dfs_hld(to, a, t);
		}
		out[a] = t;
	}
	void edgeset(ll a, ll b) {
		g[a].push_back(b);
		g[b].push_back(a);
	}
	void build() {
		dfs_sz(0, -1);
		ll t = 0;
		dfs_hld(0, -1, t);
	}
	ll la(ll a, ll x) {
		while (1) {
			ll h = head[a];
			if (in[a] - x >= in[h])return rev[in[a] - x];
			a = par[head[a]];
			x -= in[a] - in[h] + 1;
		}
	}
	ll lca(ll a, ll b) { //a < b
		for (;; b = par[head[b]]) {
			if (in[a] > in[b])swap(a, b);
			if (head[a] == head[b])return a;
		}
	}
};

int main() {
	ll n;
	cin >> n;
	HLD tree(n);
	REP(i, n) {
		ll k;
		cin >> k;
		REP(j, k) {
			ll a;
			cin >> a;
			tree.edgeset(i, a);
		}
	}
	tree.build();
	ll q;
	cin >> q;
	REP(i, q) {
		ll a, b;
		cin >> a >> b;
		cout << tree.lca(a, b) << endl;
	}
}



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

const int N = 3e3 + 10, mod = 998244353;

int n, sum;
int dp[N][N];
int arr[N];

int solve(int i, int s) {
    if(s > sum) return 0;
    if(sum == s) return n - i + 1;
    if(i == n) return 0;
    if(dp[i][s] != -1) return dp[i][s];
    int ret = 0;
    ret = solve(i + 1, s + arr[i]);
    ret = (1ll * ret + solve(i + 1, s)) % mod;
    return dp[i][s] = ret;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    while(tc--) {
        scanf("%d%d", &n, &sum);
        for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
        int ans = 0;
        memset(dp, -1, sizeof(dp));
        for(int i = 0; i < n; i++) {
            ans = (ans + 1ll * (i + 1) * solve(i + 1, arr[i]) % mod) % mod;
        }
        printf("%d\n", ans);
    }    
    return 0;
}

Measured memory_bytes: 35840
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try{
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				String[] str=br.readLine().split(" ");
				int[] data=new int[3];
				for(int j=0;j<3;j++){
					data[j]=Integer.parseInt(str[j]);
				}
				Arrays.sort(data);
				if(data[0]*data[0]+data[1]*data[1]==data[2]*data[2]){
					System.out.println("YES");
				}else{
					System.out.println("NO");
				}
			}
		}catch(Exception e){
		}
	}
}

Measured memory_bytes: 20200
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b,c,cnt=0;
	cin >> a >> b >> c;
	for(int i=a;i<=b;i++){
		if(c%i==0){
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3100
import Data.List
import Control.Monad
import Control.Applicative

data Segtree = Leaf Int
             | Node Segtree Int Segtree Int
               deriving (Show, Eq)

size (Leaf _) = 1
size (Node _ _ _ n) = n

point (Leaf x) = x
point (Node _ x _ _) = x

mkNode lch rch = Node lch rootPoint rch rootSize
    where rootPoint = point lch `min` point rch
          rootSize = size lch + size rch

update leaf@(Leaf x) k x'
    | k == 0 = Leaf x'
    | otherwise = leaf
update node@(Node lch _ rch _) k x'
    | k < size lch = mkNode (update lch k x') rch
    | otherwise = mkNode lch $ update rch (k - size lch) x'

minQuery (Leaf x) a b
    | a <= 0 && b > 0 = x
    | otherwise = 2 ^ 31 - 1
minQuery (Node lch x rch n) a b
    | a <= 0 && n <= b = x
    | b <= 0 || n <= a = 2 ^ 31 - 1
    | otherwise =
        minQuery lch a b `min` minQuery rch (a - size lch) (b - size lch)

buildSegtree n
    | n < 1 = error "Invalid size of Segtree"
    | n == 1 = Leaf $ 2 ^ 31 - 1
    | otherwise = mkNode (buildSegtree lSize) (buildSegtree (n - lSize))
        where lSize = n `div` 2

processQuery n = foldl' process ([], buildSegtree n)
    where process (out, root) [0, x, y] = (out, update root x y)
          process (out, root) [1, x, y] = (minQuery root x (y + 1) : out, root)

splitRead = map read . words <$> getLine

main = do
    [n, q] <- splitRead
    qs <- replicateM q splitRead
    let (result, _) = processQuery n qs
    mapM_ print $ reverse result

Measured memory_bytes: 123016
#include <cstdio>
#include <cstring>
int flag;
char c[105];
int main(){
	scanf("%s",c + 1);
	int len = strlen(c + 1);
	for (int i = 1 ; i <= len; i ++){
		if (c[i] == 'C') flag = 1;
		if (c[i] == 'F' && flag == 1){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
# A - Zero-Sum Ranges
from itertools import accumulate
from collections import defaultdict as dd
n=int(input())
a=[0]+list(map(int,input().split()))
acc=accumulate(a)
acc=list(acc)
acc.sort()

# print(acc)
d=dd(int)
for aa in acc:
    d[aa]+=1

ans=0
for k,v in d.items():
    if v>=2:
        ans+=v*(v-1)//2
print(ans)

Measured memory_bytes: 41620
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    X = [list(map(int,input().split())) for _ in range(N)]
    X.sort(key = lambda x:x[1])
    time = 0

    for i in range(N):
        time += X[i][0]

        if time > X[i][1]:
            print('No')
            return

    print('Yes')

if __name__ == "__main__":
	main()


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if (abs(x - a) > abs(x - b))
    cout << "B" << endl;
  else
    cout << "A" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin >>s;
	if(s[s.length()-1]!='s')
      s+='s';
  	else if(s[s.length()-1]=='s')
    {
      s+='e';
      s+='s';
    }
  
    cout <<s<<endl;
  
}

Measured memory_bytes: 3624
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if sum(a)==x:
    print(N)
else:
    a.sort()
    s=0
    i=0
    while True:
       s+=a[i]
       if i==N-1 and s!=x:
           print(N-1)
           break
       if s>x:
           print(i)
           break
       i+=1
       if i>=N:
           print(N)
           break



Measured memory_bytes: 9168
// ConsoleApplication1.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include "stdio.h"

struct Node { int p, l, r; };
struct Node T[10000];
int n;

void preParse(int u) {
    if (u == -1) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == -1) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == -1) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main()
{
    int i, v, l, r, root;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        T[i].p = -1;
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != -1) T[l].p = v;
        if (r != -1) T[r].p = v;
    }
    
    for (i = 0; i < n; i++) if (T[i].p == -1) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}

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

#define MOD 1000000007
#define N 60
#define ll long long

ll dp[N];
string s[2];
ll n;

ll S(ll a){
	a %= MOD;
	while(a < 0)
		a += MOD;
	return a;
}

ll f(ll idx){
	// printf("IN %lld %lld\n", idx, n);
	ll i,j,&ans = dp[idx];
	if(idx == n)
		ans = 1;
	else if(s[0][idx] == s[1][idx]){
		if(idx == 0)
			ans = S(3 * f(idx + 1));
		else{
			if(s[0][idx - 1] != s[1][idx - 1])
				ans = f(idx + 1);
			else
				ans = S(2 * f(idx + 1));
		}
	}
	else{
		if(idx == 0)
			ans = S(6 * f(idx + 2));
		else{
			if(s[0][idx - 1] != s[1][idx - 1])
				ans = S(3 * f(idx + 2));
			else
				ans = S(2 * f(idx + 2));
		}
	}
	// printf("OUT %lld %lld %lld\n", idx, n, ans);
	return ans;
}

int main(){
	ll i,j;
	scanf("%lld", &n);
	cin >> s[0];
	cin >> s[1];
	memset(dp, -1, sizeof(dp));
    printf("%lld\n", f(0));
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, max, min;

	long long sum = 0;

	int a[10001];

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];

		if (i == 1)
		{
			max = a[i];
			min = a[i];
		}
		else
		{
			if (a[i] > max)
			{
				max = a[i];
			}

			if (a[i] < min)
			{
				min = a[i];
			}
		}

		sum += a[i];
	}
	cout << min << ' ' << max << ' ' << sum << endl;
	return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;

	int ans = 0;

	for (char c : s) {
		ans += (c - '0');
	}


	if (ans % 9 == 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;


}


Measured memory_bytes: 3792
#include <stdio.h>
    int main (){
      int n, b;

      scanf("%d", &n);

      b=n%10;

      if (b==3)
        printf("bon\n");
      else {
      if (b==0 || b==1 || b==6 || b==8)
        printf("pon\n");
      else
        printf("hon\n");}
    }



Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int r , g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   string n;
   cin >> n;
   
   if(n[0]=='7' || n[1]=='7' || n[2]=='7') cout << "Yes\n";
   else cout << "No\n";
   
   return 0;
}

Measured memory_bytes: 3636
n, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

ans = (n - 2)** 2
c, wh = [n - 2, n - 2], [[None] * (n - 2), [None] * (n - 2)]
for num, x in query:
    num, x = num - 1, x - 2
    if c[num] > x:
        ans -= c[1 - num]
        for i in range(x, c[num]):
            wh[num][i] = c[1 - num]
        c[num] = x
    elif c[num] <= x:
        ans -= wh[num][x]
    wh[num][x] = 0
print(ans)


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  rep(i, 0, n-2){
    if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') ans++; 
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,x,a[100],b=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    sort(a,a+n);
    for(int i=0;i<n;i++){
        x-=a[i];
        if(x>=0){
            if(i<n-1||x==0){
                b++;
            }
        }else{
            i=n;
        }
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

import math

def solve(x, N, K, A, F):
    total = 0
    for i in range(N):
        total += max(0, math.ceil((A[i]*F[i] - x) / F[i]))
    if total <= K:
        return True
    else:
        return False

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    F = list(map(int,input().split()))

    A.sort()
    F.sort(reverse=True)

    ok = 10**13+1
    ng = -1
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if solve(mid, N, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == "__main__":
    main()

Measured memory_bytes: 114824
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<float> v(N);
	float ans = 0;
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v.begin(), v.end());
	for (int i = 0; i < N - 1; i++) {
		ans = (v[i] + v[i + 1]) / 2;
		v[i + 1] = (v[i] + v[i + 1])/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;

    int ans = 0;
    int a = 0, b = 0;
    rep(i, s.length()) {
        if (s[i] == '0') a++;
        if (s[i] == '1') b++;
    }


    cout << min(a, b)*2 << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> pi(n);
  vector<int> sortedPi(n);
  for(int i=0; i<n; i++){
    cin >> pi[i];
    sortedPi[i] = pi[i];
  }

  sort(sortedPi.begin(), sortedPi.end());

  int out_count = 0;
  for(int i=0; i<n; i++){
    if(sortedPi[i] != pi[i]) out_count += 1;
  }

  if( out_count == 2 || out_count == 0 ) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

using namespace std;

const int max_matrix_size = 100;

void p(int a[max_matrix_size][max_matrix_size], int size, int offseti = 0, int offsetj = 0){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			cout << a[offseti+i][offsetj+j] << ' ';
		}
		cout << endl;
	}
}

// aの[starti][startj]からsize分の正方行列を比較
bool compareMatrix(int a[max_matrix_size][max_matrix_size], int b[max_matrix_size][max_matrix_size], int starti, int startj, int size){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			if( b[i][j] == -1) continue;
			if(a[starti+i][startj+j] != b[i][j]) return false;
		}
	}
	//p(a, size, starti, startj);
	//p(b, size);

	return true;
}

// 2次元配列を90度回転
void rotateMatrix(int (*a)[max_matrix_size], int size){
	int tmp[max_matrix_size][max_matrix_size];
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			tmp[i][j] = a[j][(size-1)-i];
		}
	}
	memcpy(a, tmp, sizeof(int)*max_matrix_size*max_matrix_size);
}

void printnonnegative(int piece[max_matrix_size][max_matrix_size], int size, int offseti, int offsetj){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			if(piece[i][j] != -1){
				cout << offsetj+j+1 << ' ' << offseti+i+1 << endl;
				return;
			}
		}
	}
}


void search(int pict[max_matrix_size][max_matrix_size], int pictsize, int piece[max_matrix_size][max_matrix_size], int piecesize ){
	for(int i = 0; i < pictsize - piecesize + 1; i++){
		for(int j = 0; j < pictsize - piecesize + 1; j++){
			//cout << "i = " << i << ", j = " << j << endl;
			for(int k = 0; k < 4; k++){
				//cout << "rotate:" << k*90 << endl;
				if(compareMatrix(pict, piece, i, j, piecesize) == true){
					printnonnegative(piece, piecesize, i, j);
					return;
				}
				rotateMatrix(piece, piecesize);
			}
		}
	}
	cout << "NA" << endl;
}

int main(){
	int picture[max_matrix_size][max_matrix_size];
	int piece[max_matrix_size][max_matrix_size];

	int n, m;
	while(cin >> n >> m){
		if(!n && !m) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> picture[i][j];
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> piece[i][j];
			}
		}

		search(picture, n, piece, m);
	}

	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <assert.h>
using namespace std;
int MOD = 1000000007;

struct FastSet {
	vector<int> list;
	vector<int> pos;
	void init(int N) {
		pos.resize(N, -1);
		list.reserve(N);
	}
	void insert_all() {
		list.clear();
		list.resize(pos.size());
		for (int i = 0; i < list.size(); i++) {
			pos[i] = list[i] = i;
		}
	}
	void insert(int a) {
		if (pos[a] == -1) {
			pos[a] = list.size();
			list.push_back(a);
		}
	}
	void erase(int a) {
		if (pos[a] >= 0) {
			swap(list[pos[a]], list.back());
			pos[list[pos[a]]] = pos[a];
			pos[a] = -1;
			list.pop_back();
		}
	}
	void flip(int a) {
		if (pos[a] == -1) {
			pos[a] = list.size();
			list.push_back(a);
		}
		else {
			swap(list[pos[a]], list.back());
			pos[list[pos[a]]] = pos[a];
			pos[a] = -1;
			list.pop_back();
		}
	}
	inline int size() {
		return list.size();
	}
	inline void erase_all() {
		for (int i : list) {
			pos[i] = -1;
		}
		list.clear();
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, T;
	cin >> N >> M >> T;
	int A, B, C;
	vector < pair<int, pair<int, int> > > vp(M);
	vector<vector<int> > V(N);
	for (int i = 0; i < M; i++) {
		cin >> A >> B >> C;
		vp[i].first = A;
		vp[i].second.first = C;
		vp[i].second.second = B - 1;
		V[B - 1].push_back(A);
	}

	for (int i = 0; i < N; i++) {
		if ((int)V[i].size() % 2 == 1) {
			V[i].push_back(T);
		}
	}


	sort(vp.begin(), vp.end());
	vector<int> cur(N, 0);


	FastSet fs;
	fs.init(N);
	vector<map<int, int> > vm(N);
	for (int i = 0; i < M; i++) {
		A = vp[i].first;
		B = vp[i].second.second;
		C = vp[i].second.first;
		//assert(A == V[B][cur[B]]);
		cur[B]++;
		if (C == 0) {
			fs.erase(B);
		}
		else {
			//assert(cur[B] % 2 == 1);

			int t = V[B][cur[B]];
			if (t > A) {
				for (const int &j : fs.list) {
					//assert(cur[i] % 2 == 1);
					//assert(val > 0);
					//cerr << " " << B << " " << i << " " << val << endl;
					vm[B][j] += min(t, V[j][cur[j]]) - A;
					//vm[j][B] += val;
				}
				fs.insert(B);
				//assert(fs.size() <= 100);
			}
		}
	}
	vector<int> res(N, 0);
	res[0] = 1;
	vector<int> mx(N, 0);
	for (int i = 0; i < N; i++) {

		vector<pair<int, int> > vp;
		for (auto &m : vm[i]) {
			vp.push_back(m);
		}
		for (auto &m : vp) {
			int t = m.second;
			auto a = vm[m.first].find(i);
			if (a != vm[m.first].end()) {
				t += (*a).second;
			}
			if (mx[i] <= t) {
				if (mx[i] < t) {
					mx[i] = t;
					res[i] = m.first;
				}
				else {
					res[i] = min(res[i], m.first);
				}
			}
			if (mx[m.first] <= t) {
				if (mx[m.first] < t) {
					mx[m.first] = t;
					res[m.first] = i;
				}
				else {
					res[m.first] = min(res[m.first], i);
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << res[i] + 1 << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 128904
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()
        {
            char c = Console.ReadLine()[0];
            if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
            {
                Console.WriteLine("vowel");
            }
            else
            {
                Console.WriteLine("consonant");
            }
        }

        #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: 11092
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

ss = np.array([[c=="#" for c in input()] for _ in range(h)])
@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    # dx = [0,1,0,-1]
    # dy = [1,0,-1,0]
    dx = []
    dy = []
    vvs = []
    for i in range(-2,3):
        for j in range(-2,3):
            if not (i==j==0):
                dx.append(i)
                dy.append(j)
                if abs(i)+abs(j)>1:
                    vvs.append(1)
                else:
                    vvs.append(0)
    while q:
#         print(seen)
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        # print(pnum,divmod(pu,w))
        if pu==goal:
            break
        for xx,yy,vv in zip(dx,dy,vvs):
    #         x = ux+xx
    #         y = uy+yy
            x,y = ux+xx, uy+yy
            u = x*w + y
            num = pnum+vv
            if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                continue
    #         print(x,y)
            if seen[u]>num:
                seen[u] = num
                hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
print(main(ss,ch,cw,dh,dw))

Measured memory_bytes: 126548
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b = Is()
ax = a * 12.5  # /0.08
bx = b * 10    # /0.1
# print(ax, bx)
for i in range(floor(bx-15), floor(bx-15)+40):
    # print(i, floor(i*0.08), floor(i*0.1))
    if a == floor(i*0.08) and b == floor(i*0.1):
        print(i)
        exit()

print("-1")

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

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

  int k = 0;
  for (int i = 1; i < N + 2; i++) {
    if (i * (i - 1) / 2 == N) {
      k = i;
    }
  }
  if (!k) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  cout << k << endl;

  vector<vector<int>> mat(k + 1, vector<int>(k + 1, 0));
  int c = 1;
  for (int i = 1; i < k + 1; i++) {
    for (int j = 1; j < i; j++) {
      mat[i][j] = c++;
    }
  }
  
  for (int i = 1; i < k + 1; i++) {
    set<int> s;
    for (int j = 1; j < k + 1; j++) {
      if(mat[i][j]) s.insert(mat[i][j]);
      if(mat[j][i]) s.insert(mat[j][i]);
    }

    vector<int> v(begin(s), end(s));
    cout << v.size() << ' ';
    for (int j = 0; j < (int)v.size(); j++) {
      cout << v[j] << ( (j == (int)v.size() - 1) ? '\n' : ' ' );
    }
  }

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define pf push_front
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s;
int q;
deque<char>a;
bool ch=1;
int main()
{
	cin>>s;
	rep(i,s.size()) a.pb(s[i]);
	FOR(q)
	{
		int t;
		cin>>t;
		if(t==1) ch^=1;
		else
		{
			int c;
			char k;
			cin>>c>>k;
			if(c-ch==1) a.pb(k);else a.pf(k);
		}
	}
	if(ch) rep(i,a.size()) cout<<a[i];
	else for(int i=a.size()-1;i>=0;i--) cout<<a[i];
	cout<<endl;
	return 0;}

Measured memory_bytes: 896