akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b){
        if(b<c){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(void){
    int n,r,i=0;
    cin >> n >> r;
    while(n){
        n=n/r;
        i++;
    }
    cout << i;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>

int read() {
	int x=0; char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0', c=getchar();
	return x;
}

const int LIM=1e5+10;
int a[LIM];

int main() {
	int n=read(), k=read(), q=read();
	if(k>q) { for(int i=1; i<=n; i++) { printf("%s\n", "Yes"); } return 0; }
	for(int i=1; i<=n; i++) a[i]=k-q;
	for(int i=1; i<=q; i++) {
		int t=read();
		a[t]++;
	}
	for(int i=1; i<=n; i++) {
		printf("%s\n", a[i]>0 ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		ArrayList<Integer>ans =new ArrayList<>();

			int i;
			int j;
			int s=0;
			while(true) {
				int n=sc.nextInt();
				int p=sc.nextInt();
				if(n==0&&p==0)
					break;
				int []a=new int[n];
				int []key=new int[n];
				for(i=0;i>-1;i++){
					if(s==1)
						break;
					if(i==n)
						i=0;
					if(p>0) {	//おわんにある
						a[i]++;
						p--;;
						key[i]=1;
						if(p==0) {
							for(j=0;j<n;j++){
								if(j!=i && key[j]==1)
									break;
								else if(j==n-1) {
									s=1;
									ans.add(i);
								}
							}
						}
					}
					else {	//おわんが空
						p=a[i];
						a[i]=0;
						key[i]=0;
					}
				}
				s=0;
			}
			for(i=0;i<ans.size();i++) {
				System.out.println(ans.get(i));
			}
	}
}




Measured memory_bytes: 27632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vi perm(n);
    rep(i,0,n) {
        cin >> perm[i];
        --perm[i];
    }
    vector<vi> g(n);
    rep(i,0,m) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> vis(n);
    vi scratch(n);
    int ans=0;
    rep(i,0,n) if(!vis[i]) {
        queue<int> q;
        q.push(i);
        vi ids;
        while(!q.empty()) {
            int i=q.front();
            q.pop();
            if(!vis[i]) {
                vis[i]=true;
                ids.push_back(i);
                for(int j:g[i]) q.push(j);
            }
        }
        for(int i:ids) ++scratch[i];
        for(int i:ids) if(scratch[perm[i]]) ++ans;
        for(int i:ids) --scratch[i];
    }
    cout<<ans<<"\n";
    
}


Measured memory_bytes: 7164
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)

void init() {
    string s; cin >> s;
    cout << count(all(s), '+') - count(all(s), '-') << '\n';
}

void solve() {
    
}

int main () {
    cin.tie(0); cin.sync_with_stdio(0);
    int T = 1;
    //cin >>T;
    for (int i=1; i<=T; i++) {
        init();
        solve();
    }
}


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

using namespace std;


long long lcmf(long long x, long long y){
    if(x < y){
        long long t = y;
        y = x;
        x = t;
    }
    if(x%y == 0) return y;
    return lcmf(y, x%y);
}

//x以下でc,dで割り切れない数の個数
long long f(long long x, long long c, long long d){
    long long gcb = ( c / lcmf(c,d) ) * d;
    return x - x / c - x / d + x / gcb;
}


int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << f(b,c,d) - f(a-1,c,d) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X, Y, T = 0, 0, 0
flag = True

for _ in range(N):
    t, x, y = map(int, input().split())
    duration = t - T
    x_diff = x - X
    y_diff = y - Y
    if abs(x_diff) + abs(y_diff) > duration:
        flag = False
    if (x_diff + y_diff + duration)%2:
        flag = False
    X = x
    Y = y
    T = t
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define ULL ull
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int, pii >
#define pll pair <ll,ll>
#define pb push_back
#define big 20160116
#define INF 2147483647
#define pq priority_queue
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
namespace Mymath{
	LL qp(LL x,LL p,LL mod){
		LL ans=1;
		while (p){
			if (p&1) ans=ans*x%mod;
			x=x*x%mod;
			p>>=1;
		}
		return ans;
	}
	LL inv(LL x,LL mod){
		return qp(x,mod-2,mod);
	}
	LL C(LL N,LL K,LL fact[],LL mod){
		return fact[N]*inv(fact[K],mod)%mod*inv(fact[N-K],mod)%mod;
	}
	template <typename Tp> Tp gcd(Tp A,Tp B){
		if (B==0) return A;
		return gcd(B,A%B);
	}
	template <typename Tp> Tp lcm(Tp A,Tp B){
		return A*B/gcd(A,B);
	}
};
namespace fwt{
	using namespace Mymath;
	void FWT(int a[],int n,LL mod)
	{
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=(x+y)%mod,a[i+j+d]=(x-y+mod)%mod;
	                //xor:a[i+j]=x+y,a[i+j+d]=x-y;
	                //and:a[i+j]=x+y;
	                //or:a[i+j+d]=x+y;
	            }
	}

	void UFWT(int a[],int n,LL mod)
	{
		LL rev=inv(2,mod);
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=1LL*(x+y)*rev%mod,a[i+j+d]=(1LL*(x-y)*rev%mod+mod)%mod;
	                //xor:a[i+j]=(x+y)/2,a[i+j+d]=(x-y)/2;
	                //and:a[i+j]=x-y;
	                //or:a[i+j+d]=y-x;
	            }
	}
	void solve(int a[],int b[],int n,LL mod)
	{
	    FWT(a,n,mod);
	    FWT(b,n,mod);
	    for(int i=0;i<n;i++) a[i]=1LL*a[i]*b[i]%mod;
	    UFWT(a,n,mod);
	}
};
LL s(LL x){
	LL ret=0;
	while (x) ret+=x%10,x/=10;
	return ret;
}
double f(LL x){
	return 1.0*x/s(x);
}
int main(){
	vector<LL> ans;
	//cout<<ans.size()<<endl;
	//for (int i=0;i<ans.size();i++) cout<<ans[i]<<endl;
	LL stp=1;
	for (LL i=1;i<=1e15;i+=stp){
		LL tm=1;
		if (i==9999) stp=1000;
		if (i==99999) stp=10000;
		if (i==999999) stp=100000;
		if (i==9999999) stp=1000000;
		if (i==99999999) stp=10000000;
		if (i==999999999) stp=100000000;
		if (i==9999999999) stp=1000000000;
		LL tmp=i;
		while (tmp%10==9) tmp/=10,tm*=10;
		if (f(i)<=f(i+tm)) ans.pb(i);
	}
	int k;
	cin>>k;
	for (int i=0;i<k;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
author : seryu
title : ABC175A_"Rainy Season"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
    string s;
    cin >> s;
    if (s == "RRR")
        cout << 3 << endl;
    else if(s == "RRS" || s == "SRR")
        cout << 2 << endl;
    else if(s == "SSS")
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return;	
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    if (n % 2 != 0) flag = false;
    else {
        rep(i, n / 2){
            if (s[2 * i] != 'h' || s[2 * i + 1] != 'i')  flag = false;
        }
    }
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
char ma[60][60];
int main(void)
{
    int a,b,c,k;
    LL sum = 0;
    cin>>a>>b>>c;
    cin>>k;
    sum += a + b + c;
    LL maxx = max(a,max(b,c));
    sum -= maxx;
    while(k)
    {
        k--;
        maxx = maxx*2ll;
    }
    sum += maxx;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h;
    cin >> n >> h;
    vector<int> throwing(n);
    vector<int> attacking(n);
    rep(i, n) cin >> attacking[i] >> throwing[i];

    sort(throwing.begin(), throwing.end(), greater<int>());
    sort(attacking.begin(), attacking.end(), greater<int>());
    
    int a = n;
    int dmg = 0;
    rep(i, throwing.size()){
        if(attacking[0] >= throwing[i]){
            a = i;
            break;
        }
        dmg += throwing[i];
        if(dmg >= h){
            cout << i + 1 << endl;
            return 0;
        }
    }
    
    int howmany = (h - dmg) / attacking[0];
    if((h - dmg) % attacking[0] > 0) howmany++;
    howmany += a;

    // cout << (h - dmg) / attacking[0] << endl;
    // cout << (h - dmg) % attacking[0] << endl;
    // cout << a << ',' << dmg << endl;
    cout << howmany << endl;

    return 0;
}

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

static const int MAX = 300000;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
vector<int> G[MAX], d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v = 0; v < G[u].size(); v++) {
      if (d[G[u][v]] == INF) {
        d[G[u][v]] = d[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:辺数
  cin >> n >> m;
  
  // vector<int> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v + 100000);
    G[u + 100000].emplace_back(v + 200000);
    G[u + 200000].emplace_back(v);
  }
  
  int s, t;
  cin >> s >> t;
  s--;
  t--;
  
  bfs(s);
  
  if (d[t] == INF) cout << "-1\n";
  else cout << d[t] / 3 << '\n';
}

Measured memory_bytes: 17792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int a; string s; cin >> a >> s;
    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, M, A, D;
int G[30][10];

bool can(int phase, int index){
    // printf("%d, %d, %d\n", phase, index, G[phase][index]);
    if(phase == D){return index == A;}

    if(G[phase][index] != -1){
        return can(phase+1, G[phase][index]);
    }
    return can(phase+1, index);
}

int main(){
    while(std::cin >> N >> M >> A >> D, N != 0){
        --M; --A;

        REP(i, 30){
            REP(j, 10){
                G[i][j] = -1;
            }
        }

        REP(i, D){
            REP(j, N-1){
                char f;
                std::cin >> f;
                if(f == '1'){G[i][j] = j+1; G[i][j+1] = j;}
            }
        }

        if(can(0, M)){puts("0");}
        else{
            P res = mp(-1, -1);
            REP(i, D){
                REP(j, N-1){
                    if(G[i][j] == -1 && (j+1 >= N || G[i][j+1] == -1)){
                        G[i][j] = j+1;
                        G[i][j+1] = j;
                        if(res.first == -1 && can(0, M)){res = mp(i+1, j+1);}
                        G[i][j] = -1;
                        G[i][j+1] = -1;
                    }
                }
            }
        

            if(res.first != -1){
                printf("%d %d\n", res.first, res.second);
            }else{
                puts("1");
            }
        }
    }
}

Measured memory_bytes: 1148
<?php
$N = (int)fgets(STDIN);
$T = array_map('intval', explode(' ', trim(fgets(STDIN))));
$M = (int)fgets(STDIN);
$D = [];
for($i = 0; $i < $M; $i++) {
    $D[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}

$total = array_sum($T);

foreach($D as $num => $data) {
    $diff = $data[1] - $T[$data[0] - 1];
    $time = $total + $diff;
    echo "$time\n";
}

Measured memory_bytes: 3828
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

const int mxn = 100005;
const int inf = 1e7;
int n, k, h[mxn];
int ff[mxn];

int dfs( int pos ) 
{
  if( pos > n ) return 0;
  int& ret = ff[pos];
  if( ~ret ) return ret;
  
  ret = 0;
  if( pos < n )
  {
    ret = abs(h[pos] - h[pos + 1]) + dfs( pos + 1 );
    for(int i = 2; i <= k and pos + i <= n; i++)
    {
      ret = min(ret, abs(h[pos] - h[pos + i]) + dfs( pos + i ));
    }
  }
  return ret;
}

int main()
{
  scanf("%d %d", &n, &k);
  for(int i = 1; i <= n; i++) 
  { 
    scanf("%d", h + i);
  }
  memset(ff, -1, sizeof ff);
  printf("%d\n", dfs( 1 ));
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
const int inf = 1e8;

int main() {
    int h, w;
    cin >> h >> w;
    int dis[10][10];
    rep(i,10)rep(j,10) cin >> dis[i][j];
    rep(k,10)rep(i,10)rep(j,10) dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
    int ans = 0;
    rep(i,h*w) {
        int x;
        cin >> x;
        if (x == -1) continue;
        ans += dis[x][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 10**11

def fast_pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1
    return res


n, k = map(int,input().split())
if n == 1:
    print(k)
else:
    print(k * fast_pow(k-1, n-1, MOD))

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}


void solve() {
  int a[3][3];
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  map<int, pii> mp;
  rep(i, 3) rep(j, 3) mp[a[i][j]] = pii(i, j);

  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    if (!mp.count(b)) continue; // debuged
    pii p = mp[b];
    a[p.F][p.S] = 0;
  }
  // rep(i, 3) { rep(j, 3) cout << a[i][j] << " "; cout << endl; }

  rep(i, 3) {
    rep(j, 3) {
      if (a[i][j] != 0) break;
      if (j == 2) {
        cout << "Yes" << endl;
        return;
      }
    }
  }

  rep(j, 3) {
    rep(i, 3) {
      if (a[i][j] != 0) break;
      if (i == 2) {
        cout << "Yes" << endl;
        return;
      }
    }
  }

  rep(i, 3) {
    if (a[i][i] != 0) break;
    if (i == 2) {
      cout << "Yes" << endl;
      return;
    }
  }

  rep(i, 3) {
    if (a[i][2 - i] != 0) break;
    if (i == 2) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n, m := readInt(), readInt()
	nums := make(map[int]int)
	var key, val int
	for i := 1; i <= m; i++ {
		key = readInt()
		val = readInt()
		if key == 1 && val == 0 && n > 1 {
			fmt.Println(-1)
			return
		}
		if v, ok := nums[key]; ok && v != val {
			fmt.Println(-1)
			return
		}
		nums[key] = val
	}
	for i := 1; i <= n; i++ {
		if v, ok := nums[i]; ok {
			fmt.Print(v)
			continue
		}
		if i == 1 {
			if n == 1 {
				fmt.Print(0)
			} else {
				fmt.Print(1)
			}
			continue
		}
		fmt.Print(0)
	}
	fmt.Println()
}


Measured memory_bytes: 640
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define prinvec(a, n) for(ll i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	#ifndef ONLINE_JUDGE
	freopen("/home/ram/Competitive Programming/IO/in.txt", "r", stdin);
	freopen("/home/ram/Competitive Programming/IO/out.txt", "w", stdout);
	#endif

	int k;
	cin >> k;

	ll sum = 0;

	fr(i,1,k+1)
	{
		fr(j,1,k+1)
		{
			fr(x,1,k+1)
			{
				sum += __gcd(__gcd(i, j), x);
			}
		}
	}

	cout << sum;
}

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

int main()
{
    
    /*
    string s1;
    getline( cin, s1 );
    int n1 = s1.size();
    */
    int a,b, c, d, e;
    cin >> a >> b >> c >> d >> e ;
    if( a != 1 ){
        cout << 1 << endl;
    }
    if( b != 2 ){
        cout << 2 << endl;
    }
    if( c != 3 ){
        cout << 3 << endl;
    }
    if( d != 4 ){
        cout << 4 << endl;
    }
    if( e != 5 ){
        cout << 5 << endl;
    }
    
      
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[25],b[25],c[24];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n-1;i++){
		cin >> c[i];
	}
	int sum = b[a[0] - 1];
	for(int i=1;i<n;i++){
		sum+=b[a[i] - 1];
		if(a[i] - 2 == a[i - 1] - 1){
			sum+=c[a[i] - 2];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
  if (a < b)
    tmp = a; a = b; b = tmp
  end

  while ((c = a % b) > 0)
    a = b
    b = c
  end

  return b
end

while (line = gets)
  a, b = line.chop.split(" ").map { |s| s.to_i }
  g = gcd(a, b)
  l = a * b / g

  printf("%d %d\n", g, l)
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;


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

  long long minval = 0;
  long long maxval = 0;
  long long ans=0;
  for(long long i = K; i<= N+1; i++){
    minval = i*(i-1)/2;
    maxval = N*i - minval;
    ans += (maxval-minval) + 1;
  }

  long long division=1000000007;
  cout << ans%division << endl;
}

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

int H,W;
char s[57][57];
int d[57][57];

int vx[4] = {0,1,0,-1};
int vy[4] = {1,0,-1,0};

int wall = 0;

void write(){
    string row[100];
    for(int y = 1;y < H+1;y++){
        for(int x = 1;x < W+1;x++){
            row[y] += s[x][y];
        }
    }

    cout << "" << endl;
    for(int y = 1;y < H+1;y++){
        cout << row[y] << endl;
    }

}

int bfs(){
    int way = 8192;
    pair<int,int> p;
    queue < pair<int,int> > Q;
    Q.push(make_pair(1,1) );
    d[1][1] = 0;
    s[1][1] = '#';

    while(!Q.empty()){
        //write();
        p = Q.front(); Q.pop();

        if(p.first == W && p.second == H){
            way = d[p.first][p.second];
            break;
        }
        

        for(int i = 0;i < 4;i++){
            int nx = p.first + vx[i];
            int ny = p.second + vy[i];

            if(1 <= nx && nx <= W && 1 <= ny && ny <= H && s[nx][ny] == '.'){
                Q.push(make_pair(nx,ny)); 
                s[nx][ny] = '#';
                d[nx][ny] = d[p.first][p.second] + 1;

                if(nx == W && ny == H){
                    way = d[nx][ny];
                    break;
                }
            }

        }
    }

    return way;
}

int main(){
    cin >> H >> W;
    for(int y = 1;y < H + 1;y++){
        for(int x = 1;x < W + 1;x++){
            cin >> s[x][y];
            if(s[x][y] == '#') wall++;
        }
    }
    int way = bfs(); 

    int ans = W * H - (way + 1 + wall);

    if(way == 8192){
        ans = -1;
    }

    //cout << "最短手順:" << way << " 壁:" << wall << endl;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const ll INF=1e9;
const double PI=acos(-1);
const int MAX=200010;

ll gcd(ll a,ll b) {
    if (a<b) swap(a,b);
    while (b>0) {
        ll tmp=b;
        b=a%b;
        a=tmp;
    }
    return a;
}

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

int main() {
    ios_base::sync_with_stdio(false); 

    ll n,m;
    cin >> n >> m;
    ll ans=0;
    vector<ll> b(n),c(n);
    rep(i,n) {
        ll a;
        cin >> a;
        while (a%2==0) {
            a/=2;
            ++c[i];
        }
        b[i]=a;
    }
    bool flag=0;
    rep(i,n-1) {
        if (c[i]!=c[i+1]) flag=1;
    }
    if (flag==1) cout << 0 << endl;
    else {
        ll l=1;
        ll p=1;
        rep(i,c[0]-1) p*=2;
        rep(i,n) {
            l=lcm(b[i],l);
            if (l*p>m) {
                cout << 0 << endl;
                return 0;
            }
        } 
        ll d=p*l;
        ll ans=m/(2*d);
        if (m%(2*d)>=d) ++ans;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4808
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        mut n: usize,
    }
    let alphabet: Vec<char> = (97..97+26).map(|x| std::char::from_u32(x).unwrap()).collect();;

    let mut ans = String::new();

    while n != 0 {
        n -= 1;
        ans.push(alphabet[n % 26]);
        n /= 26;
    }

    println!("{}", ans.chars().rev().collect::<String>())
}


Measured memory_bytes: 2200
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i;
	char moji[1001];
	scanf("%s",moji);
	for(i=0;i<strlen(moji);i++){
		moji[i]-=3;
		if(moji[i]<'A') moji[i]+=26;
	}
	printf("%s\n",moji);
	return 0;
}


Measured memory_bytes: 2624
#include "bits/stdc++.h"
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    long long a[n];
    for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<long long> path;
    set<long long> pr;

    long long curr = 0;
    long long st = 0;
    while (true)
    {
        if (pr.find(curr) != pr.end())
        {
            st = curr;
            break;
        }
        else
        {
            path.push_back(curr);
            pr.insert(curr);
            curr = a[curr];
        }
    }
    vector<long long>::iterator it = find(path.begin(), path.end(), st);
    long long b = it - path.begin();
    long long l = path.size();
    // for (int i = 0; i < l; i++)
    // cout << path[i] << " ";
    // cout << endl;
    if (k < l)
    {
        cout << path[k] + 1 << endl;
        return 0;
    }

    vector<long long> cycle;
    for (int i = b; i < l; i++)
    {
        cycle.push_back(path[i]);
    }
    k -= b;
    l = cycle.size();
    // for (int i = 0; i < l; i++)
    // cout << cycle[i] << " ";
    // cout << endl;
    long long rem = k % l;
    cout << cycle[rem] + 1 << endl;
    return 0;
}

Measured memory_bytes: 16376
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main()
{
	int  n;
	int a[100000];
	cin >> n;
	rep(i, 0, n){
		cin >> a[i];
	}
	int d[2] = {};
	rep(i, 0, n){
		if (a[i] % 4 == 0){
			d[0]++;
		}
		else if (a[i] % 2 != 0){
			d[1]++;
		}
	}
	if (d[0] >= d[1]){
		cout << "Yes" << endl;
	}
	else if ((d[0] - d[1] == -1) && (d[0] + d[1] == n)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int N;

int digit_sum(int N) {
  int sum;

  for (;N != 0; N /= 10) {
    sum += N % 10;
  }

  return sum;
}

int main() {
  cin >> N;

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

  return 0;
}

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

int n, maxx=0;
long long sum;
long long a[200010], t[200010];

long long cal(long long x) {
	return x * (x - 1) / 2;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		t[a[i]]++;
		maxx = maxx >= a[i] ? maxx : a[i];
	}
	for (int i = 1; i <= maxx; i++) sum += cal(t[i]);
	for (int i = 1; i <= n; i++) printf("%lld\n", sum - cal(t[a[i]]) + cal(t[a[i]] - 1));
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;
string hna="MARCH";
int main()
{
    IO;
    int n;cin >> n;
    set<char> st;
    map<char,ll> mp;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        if(hna.find(s[0])!=-1){
            ++mp[s[0]];
            st.insert(s[0]);
        }
    }
    n=st.size();
    int mo2ktn=0;
    for(auto i:st)
        hna[mo2ktn++]=i;
    ll ans=0;
    for(int i=0;i<(1<<n);++i){
        int x=i,idx=0;
        set<char> temp;
        while(x){
            if(x&1)temp.insert(hna[idx]);
            ++idx;x/=2;
        }
        if(temp.size()!=3)continue;
        ll m3lsh=1;
        for(auto i:temp)
            m3lsh*=mp[i];
        ans+=m3lsh;
    }
    cout<<ans<<endl;
    re 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#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--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n'
#define pe(x) cout<<x<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
int MOD = 1e9+7;

const int MAX = 200060;
const double pi = acos(-1);
const double EPS = 1e-12;


void solve(){
	double a, b, x; cin >> a >> b >> x;
	if (a*a*b == x) {
		print(0); return;
	}
	if (x >= a * a*b / 2.0) {
		double l = x / (a*a);
		double theta = atan(a / (b - l) / 2.0);
		theta = theta * 180 / pi;
		theta = 90 - theta;
		cout << setprecision(10) << theta << endl;
	}
	else {
		double l = x / (a*a);
		double theta = atan(2 * a*l / b/b);
		theta = theta * 180 / pi;
		theta = 90 - theta;
		cout << setprecision(10) << theta << endl;
	}
	
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


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

int main()
{
    int N, i, j;
    cin >> N;

    vector<int64_t> list = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    for (i = 0, j = 0; j < N; i++)
    {
        if (list[i] % 10 != 0)
        {
            list.push_back(list[i] * 10 + list[i] % 10 - 1);
            j++;
        }

        list.push_back(list[i] * 10 + list[i] % 10);
        j++;

        if (list[i] % 10 != 9)
        {
            list.push_back(list[i] * 10 + list[i] % 10 + 1);
            j++;
        }
    }

    cout << list[N - 1];
}

Measured memory_bytes: 1464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n; sc(n);
    vector<int> a(n+1);
    rep(i, 1, n+1) sc(a[i]);
    vector<ll> sum(n+1,0);
    sum[1] = a[1], sum[2] = a[2];
    rep(i, 3, n+1) sum[i] = sum[i-2] + a[i];

    ll ans;
    rep(i, 1, n+1){
        if (i == 1) ans = 0;
        else ans = 2 * sum[i-1] - 2 * sum[i-2];
        if (i != 1) cout << " ";
        if (i % 2) cout << ans+sum[n]-sum[n-1];
        else cout << ans+sum[n-1]-sum[n];
        if (i == n) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const ll INF =  1e18 + 7;
const int nax = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		ll k, a, b;
		cin >> k >> a >> b;
		for (ll i = a; i <= b; i++) {
			if (i % k == 0) {
				cout << "OK";
				return 0;
			}
		}
		cout << "NG";
	}
	return 0;
}




















Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxX = 1e5 + 1;
int x;
bool visited[maxX];
void bfs()
{
  queue<int> q; q.push(0);
  while (!q.empty())
  {
    int u = q.front(); q.pop();
    if (u >= maxX || visited[u]) continue;
    visited[u] = true;
    for (int i = 100; i <= 105; i ++)
      q.push(u + i);
  }
}

int main()
{
  memset(visited, false, sizeof(visited));
  bfs();

  while (scanf("%d", &x) != EOF)
    printf("%d\n", visited[x]);
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;

/**
 * Library
 * --------------------------------------------------------
 */

/**
 * ワーシャルフロイド法
 * 隣接行列で受け取り、全頂点間最短経路を算出
 */
void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}
/**
 * --------------------------------------------------------
 */

/**
 * https://atcoder.jp/contests/abc073/submissions/7665203
 * ABC 073 D - joisino's travel
 */
void Main() {
    ll N, K;
    cin >> N >> K;
    if (N / K >= 1){N = N % K;}
    if (N % K == 0){
        cout << 0 << endl;
    } else {
        ll ans = N > (K - N) ? (K - N) : N;
        cout << ans << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import heapq
N,M=map(int,input().split())
l=list(map(int,input().split()))
l=[-n for n in l]
heapq.heapify(l)
while M>0:
  a=-heapq.heappop(l)
  a=a//2
  heapq.heappush(l,-a)
  M-=1
print(-sum(l))

Measured memory_bytes: 14180
#include<cstdio>
#include<algorithm>
using namespace std;

int n;
long long x,y,t,a,tmp;

long long ce(long long p,long long q) {
	return (p+q-1)/q;
}
int main() {
	scanf("%d",&n);
	scanf("%lld %lld",&x,&y);
	for(int i=2;i<=n;i++) {
		scanf("%lld %lld",&t,&a);
		tmp=max(ce(x,t),ce(y,a));
		x=t*tmp,y=a*tmp;
	}
	printf("%lld\n",x+y);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int main(int argc, char **argv)
{
    
    int N;
    std::cin >> N;

    std::vector<int> x(N), y(N), t(N);

    for(int i = 0; i < N; i++){
        std::cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    int px = 0, py = 0, pt = 0;
    for(int i = 0; i < N; i++){
        int dx, dy, dt;
        dx = std::abs(px - x.at(i));
        dy = std::abs(py - y.at(i));
        dt = t.at(i) - pt;
        if((dx + dy <= dt) && (((dx + dy) % 2) == (dt % 2))){
            px = x.at(i);
            py = y.at(i);
            pt = t.at(i);
        }else{
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double

bool isPrime(int x) {
	if(x <= 1) return false;
	for(int i=2;(ll)i*i<=x;i++) {
		if(x % i == 0) return false;
	}
	return true;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<cstdlib>
//#include<algorithm>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
const int MAX_N=200005;
struct node{
	int v,idx;
}a[MAX_N];
bool comp(const node &t1,const node &t2){
	return t1.v<t2.v;
}
int main(){
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	mii m;
	for(int i=1;i<=n;i++){
		cin>>a[i].v;
		a[i].idx=i;
	}
	sort(a+1,a+n+1,comp);
	for(int i=1;i<=n;i++)m[a[i].idx]=a[i].v;
	for(int i=1;i<=n;i++){
		if(m[i]==a[n].v)cout<<a[n-1].v<<endl;
		else cout<<a[n].v<<endl;
	}
//	for(int i=1;i<=n;i++){
//		cout<<a[i].v<<' '<<a[i].idx<<' '<<m[a[i].idx]<<endl;
//	}
	return 0;
}


Measured memory_bytes: 12544
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		log.Fatal(e)
	}
	return num
}

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	N := scanInt()
	maxv := -1000000000
	minv := scanInt()
	for i := 0; i < N-1; i++ {
		r := scanInt()
		maxv = max(maxv, r-minv)
		minv = min(minv, r)
	}
	fmt.Println(maxv)
}



Measured memory_bytes: 4136
#include <iostream>
#include <algorithm>
using namespace std;
  
struct Trump{
    char suit;
    char num;
};
  
  
void BubbleSort(struct Trump A[], long N){
    for (long i = 0; i < N; i++){
        for (long j = N - 1; j >= i && j > 0; j--){
            if (A[j].num < A[j - 1].num) swap(A[j], A[j - 1]);
        }
    }
}
  
void SelectionSort(Trump trump[], int n) {
    for (int i = 0; i < n; i++) {
        int minj;
        minj = i;
        for (int j = i; j < n  ; j++) {
            if (trump[j].num < trump[minj].num) {
                minj = j;
            }
        }
        swap(trump[i], trump[minj]);
    }
}
  
  
int main (){
    int n;
    Trump a[36],b[36];
    cin >> n;
  
    //cin
    for (int i = 0; i < n ; i++) {
        cin >> a[i].suit >> a[i].num;
    }
    for (int j = 0; j < n ; j++) {
        b[j] = a[j];
    }
  
    //sort
    BubbleSort(a,n);
    SelectionSort(b,n);
  
    //cout
    for (int i = 0; i < n-1 ; i++) {
        cout << a[i].suit << a[i].num << " ";
    }
        cout << a[n-1].suit << a[n-1].num << endl;
        cout << "Stable" << endl;
  
    for (int i = 0; i < n-1 ; i++) {
        cout << b[i].suit << b[i].num << " ";
    }
        cout << b[n-1].suit << b[n-1].num << endl;
  
    //check "is stable"
    int check;
    for (int i = 0; i < n ; ++i) {
        if (a[i].num == b[i].num and a[i].suit != b[i].suit) check++;
    }
    if (check == 0){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

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

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

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, m;
    cin >> n >> m;
    VI h(n);
    REP(i,n) h[i] = in();
    VVI e(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int ans = 0;
    REP(i,n){
        bool f = true;
        for (int j : e[i]){
            if (h[i] <= h[j]) f = false;
        }
        ans += f;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8848
#!/usr/bin/env python
# coding: utf-8

# In[7]:


from itertools import accumulate


# In[19]:


N,K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
P = [p-1 for p in P]


# In[20]:


check = [False]*N
ans = -float("inf")
for i in range(N):
    if not check[i]:
        score = []
        stop = i
        while 1:
            check[i] = True
            score.append(C[i])
            if P[i] == stop:
                break
            i = P[i]
        length = len(score)
        for j in range(length):
            if j != 0:
                score = score[1:] + [score[0]]
            ac = list(accumulate(score))
            if sum(score) <= 0:
                ans = max(ans, max(ac[:min(K,length)]))
            else:
                if K%length == 0:
                    ans = max(ans, ac[-1]*(K//length-1)+max(ac))
                else:
                    ans = max(ans, ac[-1]*(K//length) + max(ac[:K%length]))
print(ans)


# In[ ]:






Measured memory_bytes: 10256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
}

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

int main(){
	int P;
	int Q;
	int R;
	cin >> P;
	cin >> Q;
	cin >> R;
	if(P >= Q && P >= R){
		cout << Q + R;
	}else if(Q >= P && Q >= R){
		cout << P + R;
	}else if(R >= P && R >= Q){
		cout << P + Q;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int n;
scanf("%d",&n);
int all = 0;
for(int i = 0; i <  n; i++)
{
int q;
scanf("%d",&q);
bool w = true;
for(int j = 1; j <= (1 << 15); j++)
{
if(q - j <= 0)
{
break;
}
if(0 == (q - j) % (j * 2 + 1))
{
w = false;
break;
}
}
if(w)
{
all++;
}
}
printf("%d\n",all);
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(ll i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int N, K;
ll x[55], y[55];

int main(void) {
	cin >> N >> K;
	rep(i, N) cin >> x[i] >> y[i];
	ll ans = INFF * 4;
	rep(l, N)rep(r, N)rep(d, N)rep(u, N){
		ll xl = x[l], xr = x[r], yd = y[d], yu = y[u];
		int cnt = 0;
		rep(i, N) {
			if(xl <= x[i] && x[i] <= xr && yd <= y[i] && y[i] <= yu) cnt++;
		}
		// printf("%d %d %d %d %d\n", xl, xr, yd, yu, cnt);
		if(cnt >= K) {
			// printf("ok\n");
			chmin(ans, (xr - xl) * (yu - yd));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384