akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
    } else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int Calc(int l,int r,int pos) {
  if (l <= pos && pos <= r) {
    return 0;
  } else if (pos < l) {
    return l - pos;
  } else {
    return r - pos;
  }
}

signed main() {
  int N;
  cin >> N;
  ll ans = 0;
  vector<P> seg(N);
  vector<P> l(N);
  vector<P> r(N);
  bool used[N];
  for (int i = 0; i < N; i++) {
    cin >> seg[i].F >> seg[i].S;
    used[i] = false;
    l[i].F = seg[i].F; l[i].S = i;
    r[i].F = seg[i].S; r[i].S = i; 
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  sort(r.begin(),r.end());

  int pos = 0;
  int lpos = 0;
  int rpos = 0;
  int turn = 0;
  while (lpos != N && rpos != N) {
    if (turn % 2 == 0) {
      if (used[l[lpos].S]) {
        lpos++;
      } else {
        ans += abs(Calc(seg[l[lpos].S].F,seg[l[lpos].S].S,pos));
        used[l[lpos].S] = true;
        pos += Calc(seg[l[lpos].S].F,seg[l[lpos].S].S,pos);
        turn++;  lpos++;
      }
    } else {
      if (used[r[rpos].S]) {
        rpos++;
      } else {
        ans += abs(Calc(seg[r[rpos].S].F,seg[r[rpos].S].S,pos));
        used[r[rpos].S] = true;
        pos += Calc(seg[r[rpos].S].F,seg[r[rpos].S].S,pos);
        turn++; rpos++;
      }
    }
  }

  ans += abs(pos);
  ll res1 = ans;

  pos = 0;
  lpos = 0;
  rpos = 0;
  turn = 0;
  ans = 0;
  for (int i = 0; i < N; i++) used[i] = false;

  while (lpos != N && rpos != N) {
    if (turn % 2 == 1) {
      if (used[l[lpos].S]) {
        lpos++;
      } else {
        ans += abs(Calc(seg[l[lpos].S].F,seg[l[lpos].S].S,pos));
        used[l[lpos].S] = true;
        pos += Calc(seg[l[lpos].S].F,seg[l[lpos].S].S,pos);
        turn++;  lpos++;
      }
    } else {
      if (used[r[rpos].S]) {
        rpos++;
      } else {
        ans += abs(Calc(seg[r[rpos].S].F,seg[r[rpos].S].S,pos));
        used[r[rpos].S] = true;
        pos += Calc(seg[r[rpos].S].F,seg[r[rpos].S].S,pos);
        turn++; rpos++;
      }
    }
  }
  ans += abs(pos);
  ll res2 = ans;
  
  cout << max(res1,res2) << endl;
  return 0;
}

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

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

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N - 1; j++)
    {
      if (v[j] < v[j + 1])
      {
        int tmp;
        tmp = v[j];
        v[j] = v[j + 1];
        v[j + 1] = tmp;
      }
    }
  }

  int cnt = 0, max = 101;
  for (int i = 0; i < N; i++)
  {
    if (max > v[i])
    {
      max = v[i];
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic


n = rri()
print 1-n


Measured memory_bytes: 65048
from pprint import pprint
from bisect import bisect_left
import numpy


def read():
    X, Y, A, B, C = list(map(int, input().strip().split()))
    P = list(map(int, input().strip().split()))
    Q = list(map(int, input().strip().split()))
    R = list(map(int, input().strip().split()))
    return X, Y, A, B, C, P, Q, R

def argsort(x, reverse=False):
    return sorted(range(len(x)), key=lambda k: x[k], reverse=reverse)

def solve(X, Y, A, B, C, P, Q, R):
    P = list(sorted(P, reverse=True))
    Q = list(sorted(Q, reverse=True))
    R = list(sorted(R, reverse=True))

    i = X
    j = Y
    score = sum(P[0:i]) + sum(Q[0:j])
    for r in R:
        if i > 0 and j > 0:
            if P[i-1] < Q[j-1] and P[i-1] < r:
                score = score - P[i-1] + r
                i -= 1
            elif Q[j-1] < r:
                score = score - Q[j-1] + r
                j -= 1
            else:
                break
        elif i > 0:
            if P[i-1] < r:
                score = score - P[i-1] + r
                i -= 1
            else:
                break
        elif j > 0:
            if Q[j-1] < r:
                score = score - Q[j-1] + r
                j -= 1
            else:
                break
        else:
            break
    return sum(P[:i] + Q[:j] + R[:(X-i)+(Y-j)])

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 33292
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i,N){
    cin >> S[i];
  }
  int ans = 0;
  rep(k,N){
    bool can = true;
    rep(i,N){
      rep(j,N){
        if(S[(i+k)%N][j] != S[(j+k)%N][i]) can = false;
      }
    }
    if(can){
      ans += N;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int Maxn = 1e5+7;

int n, k;
int h[Maxn], dp[Maxn];

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    memset(dp, 0x3f, sizeof dp);
    dp[1] = 0;
    for(int i = 2; i <= n; ++i)
    {
        for(int j = 1; j <= k && i-j >= 1; ++j)
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <list>

using namespace std;

#define ul unsigned long long
#define ull list<ul>

//#define DEBUG

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

	ul buf;
	ull x_sorted, x;
	for (ul a=0;a<n;a++) {
		cin >> buf;
		x_sorted.push_back(buf);
		x.push_back(buf);
	}
	x_sorted.sort();

	ull::iterator itr_xs, itr_x;
	itr_xs = x_sorted.begin();
	itr_x = x.begin();
	
#ifdef DEBUG
	for (;itr_xs != x_sorted.end();++itr_xs)  cout << *itr_xs << " ";
#endif //DEBUG

	ul cs[2];
	for (ul c=0;c<(n/2-1);c++) ++itr_xs;
	cs[0] = *itr_xs;
	++itr_xs;
	cs[1]=*itr_xs;

	if (cs[0]==cs[1])
		for (ul d=0;d<n;d++) cout << cs[0] << endl;
	else {
		for (;itr_x!=x.end();++itr_x) {
			if (*itr_x < cs[1]) cout << cs[1] << endl;
			else cout << cs[0] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 14720
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

string lcs(string s,string t,int a,int b)
{
	int i,j,k=0;
	int dp[a+1][b+1];
	for(i=0;i<=a;i++)
	dp[i][0]=0;

	for(i=0;i<=b;i++)
	dp[0][i]=0;

	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			
			else
			{
				dp[i][j]=std::max(dp[i-1][j],dp[i][j-1]);
			}
			
		}
	}
	string ans;
	int x=0,y,z;
	i=a;j=b;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans.push_back(s[i-1]);
			i--;j--;
		}

		else if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	return ans;
	//cout << dp[a][b] << endl;
	//cout << ans << endl;
}

int main()
{
	string s,t;
	cin >> s >> t;
	int a,b,i,j,k;
	a=s.size();
	b=t.size();
	string ans;
	ans=lcs(s,t,a,b);
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 38800
#include <cstdio>
char s[1110];
int cnt[30];
int main() {
    scanf("%s", s);
    for (int i = 0; s[i]; ++i) {
        ++cnt[s[i] - 'a'];
    }
    for (int i = 0; i < 26; ++i) {
        if (cnt[i] % 2) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define ss second
#define ff  first
using namespace std;
pair<char,int>a[100005],b[100005];
pair<char,int>L[100005],R[100005];
const int INF=1e9+7;
int Parttion(pair<char,int> a[],int l,int r)
{
    pair<char,int>x=a[r];
    int i=l-1;
    for(int j=l;j<r;j++)if(a[j].ss<=x.ss)swap(a[++i],a[j]);
    swap(a[++i],a[r]);

    return i;
}
int quickSort(pair <char ,int> a[],int l,int r)
{
    if(l<r)
    {
        int q=Parttion(a,l,r);
        quickSort(a,l,q-1);
        quickSort(a,q+1,r);
    }
}

void Merge(pair <char,int>a[],int l, int  m , int r )
{
    int n1=m-l;
    int n2=r-m;
    for(int i=0;i<n1;i++)L[i]=a[l+i];
    for(int i=0;i<n2;i++)R[i]=a[m+i];
    L[n1].ss=R[n2].ss=INF;      //归并排序的这里很重要
    for(int k=l,i=0,j=0;k<r;k++)
    {
        if(L[i].ss<=R[j].ss)a[k]=L[i++];    //排序的时候<=一定要加上，不然可能会有不稳定排序的情况发生。
        else a[k]=R[j++];
    }
}

int MergeSort(pair<char,int>a[],int l ,int r )
{
    if(l+1<r)
    {
        int m=l+r>>1;
        MergeSort(a,l,m);
        MergeSort(a,m,r);
        Merge(a,l,m,r);
    }
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i].ff>>a[i].ss,b[i]=a[i];
    quickSort(a,0,n-1);
    MergeSort(b,0,n);
    int flag=0;
    for(int i=0;i<n;i++)if(a[i]!=b[i]){flag=1;break;}
    if(flag)cout<<"Not stable"<<endl;
    else cout<<"Stable"<<endl;
    for(int i=0;i<n;i++)cout<<a[i].ff<<' '<<a[i].ss<<endl;//<<b[i].ff<<' '<<b[i].ss<<endl;
    return 0;
}



Measured memory_bytes: 6228
X,Y,A,B,C=map(int,input().split())
lp=list(map(int,input().split()))
lq=list(map(int,input().split()))
lr=list(map(int,input().split()))
lp.sort()
lq.sort()
lr.sort()
lnew=lp[A-X:]+lq[B-Y:]+lr
lnew.sort()
print(sum(lnew[C:]))


Measured memory_bytes: 23328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        a = Math.min(a, b/ 2);
        b /= 2;
        System.out.println((a+b)/2);
    }
}

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

int main(){
    int A,B,K; cin >> A >> B >> K;
    int C[100];
    int l=0;
    for (int i=min(A,B); i>=1; --i){
        if (A%i==0 && B%i==0){
            C[l]=i;
            l++;
        }
    }
    cout << C[K-1];
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,k,ans=LLONG_MAX;
    cin>>n>>k;
    Vi x(n),y(n);
    REP(i,0,n) cin>>x[i]>>y[i];
    
    REP(xi,0,n){
        REP(xj,xi+1,n){
            REP(yi,0,n){
                REP(yj,yi+1,n){
                    int x1=min(x[xi],x[xj]),x2=max(x[xi],x[xj]),y1=min(y[yi],y[yj]),y2=max(y[yi],y[yj]),count=0;
                    REP(i,0,n){
                        if(x1<=x[i] && x[i]<=x2 && y1<=y[i] && y[i]<=y2) count++;
                    }
//                    cout<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<" count="<<count<<endl;
                    if(count>=k) chmin(ans,(x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
int up(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),up);}

int main(void){
    ll N;
    scanf("%lld",&N);
    ll a[3*N+5];
    rep(i,0,3*N,1){
        scanf("%lld",&a[i]);
    }
    sortup(a,3*N);
    ll sum=0;
    rep(i,N,3*N,2){
        sum+=a[i];
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 6268
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let _ = scan.read::<usize>();
    let s = scan.chars();
    let c = vec![-1, 1];
    let mut ret = None;
    for &i in &c {
        for &j in &c {
            if let Some(ans) = check(i, j, &s) {
                ret = Some(ans);
                break;
            }
        }
    }
    if let Some(ans) = ret {
        println!("{}", ans.iter().map(|&x| if x == -1 {'S'} else {'W'}).collect::<String>());
    } else {
        println!("{}", -1);
    }
}

fn check(a0: i32, a1: i32, s: &Vec<char>) -> Option<Vec<i32>> {
    let n = s.len();
    let mut ans = vec![0; n];
    ans[0] = a0;
    ans[1] = a1;
    for i in 1..n-1 {
        match (s[i], ans[i]) {
            ('o', -1) => ans[i+1] = ans[i-1],
            ('x', -1) => ans[i+1] = -ans[i-1],
            ('o', 1) => ans[i+1] = -ans[i-1],
            _ => ans[i+1] = ans[i-1]
        }
    }
    for i in n-1..n+1 {
        if !(match (s[i%n], ans[i%n]) {
            ('o', -1) => {
                ans[(i+1)%n] == ans[i-1]
            },
            ('x', -1) => {
                ans[(i+1)%n] != ans[i-1]
            },
            ('o', 1) => {
                ans[(i+1)%n] != ans[i-1]
            },
            _ => {
                ans[(i+1)%n] == ans[i-1]
            }
        }) {return None;}
    }
    Some(ans)
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

int main(){
  int n;
  cin >> n;
  int a[n+1],c[n+1];
  for(int i = 1;i <= n;i++){
    cin >> a[i];
    c[i] = 0;
  }
  int m = 0;
  for(int i = n;i > 0;i--){
    int sum = 0;
    for(int j = 2;j*i <= n;j++){
      sum += c[i*j];
    }
    //cout << sum - a[i] << ' ' << (sum-a[i]) % 2 << endl;
    if(abs(sum-a[i]) % 2 == 1){
      c[i] = 1;
      m++;
    }
    else{
      c[i] = 0;
    }
    //cout << sum <<endl;
  }
  cout << m << endl;
  for(int i = 1;i <= n;i++){
    if(c[i] != 0){
      cout << i << ' ';
    }
  }
  cout << ' ' << endl;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	int a, b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a*b < c) printf("%d\n", a*b);
	else printf("%d\n",c);
}

Measured memory_bytes: 128
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    ll n,m;
    cin>>n>>m;
    ll arr[n+1];
    ll sum=0;
    for(int i=1;i<=n;i++)
     {
       cin>>arr[i];
       sum+=arr[i];
     }
     ll x=0;
     ll c=sum/(4*m);
     if(sum%(4*m)!=0)
      c++;
     for(int i=1;i<=n;i++)
      if(arr[i]<c)
      {

      }
      else
        x++;
      if(x>=m)
        cout<<"Yes\n";
      else
        cout<<"No\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    ans = 1
    n = ""
    b = S[0]
    for i in range(1, len(S)):
        n += S[i]
        if n != b:
            b = n
            ans += 1
            n = ""
    print(ans)
    return


if __name__ == "__main__":
    main()


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

long long n,a,b;

int main(){
	cin>>n>>a>>b;
	long long cishu = n / (a+b);
	long long MOD = n % (a+b);
	if(MOD <= a){
		cout<<cishu*a+MOD<<endl;
	}
	else{
		cout<<(cishu+1)*a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
A = []
C = []
counts = [0]*8
for i in range(3):
  inp = input().split()
  A.append(inp)
  C.append(inp)
A = np.array(A)
for i in range(3):
  C.append(list(A[:,i]))
C.append([A[0,0],A[1,1],A[2,2]])
C.append([A[0,2],A[1,1],A[2,0]])
#print(C)
N = int(input())
for i in range(N):
  b = input()
  for i, c in enumerate(C):
    if b in c:
      counts[i] += 1
if max(counts)==3:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 12512
#include<iostream>

using namespace std;

int main(){
	int n, m, a, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < m ;i++){
    	cin >> a;
        sum += a;
    }
    if((n -= sum) < 0)
    	cout << -1 << endl;
    else
    	cout << n << endl;
}

Measured memory_bytes: 3624
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input())


if (a[0] == a[1]) and (a[1] == a[2]):
    print("Yes")


elif (a[2] == a[1]) and (a[1] == a[3]):
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    unsigned long long p[m],y[m];
    unsigned long long x[m];
    for(int i=0;i<m;i++){
        scanf("%lu%lu",&p[i],&y[i]);
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    std::sort(x,x+m);
    int c=1;
    y[(x[0]<<47)>>47]=c;
    for(int i=1;i<m;i++){
        if(x[i]>>47==x[i-1]>>47)c++;
        else c=1;
        y[(x[i]<<47)>>47]=c;
    }
    for(int i=0;i<m;i++){
        x[i]=p[i]*1000000+y[i];
        printf("%012lu\n",x[i]);
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	int ans = 0;
	int A,B;

	cin >> A >> B;

	cout << max(A+B,max(2*A-1,2*B-1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

class UnionFind {
public:
  UnionFind(int n) : _parent(std::vector<int>(n, -1)) {
  }

  int root(int x) {
    if (_parent[x] < 0) {
      return x;
    }
    _parent[x] = root(_parent[x]);
    return _parent[x];
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) {
      return;
    }

    if (size(x) > size(y)) {
      swap(x, y);
    }

    _parent[x] += _parent[y];
    _parent[y] = x;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -_parent[root(x)];
  }

  int groups() {
    int res = 0;
    // 要素が0から始まるか1から始まるかによって初期値が0か1かで変わる
    for (size_t i = 1; i < _parent.size(); ++i) {
      if (_parent.at(i) < 0) {
        ++res;
      }
    }
    return res;
  }

private:
  vector<int> _parent;
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n + 1);
  rep (i, m) {
    int a, b;
    cin >> a >> b;
    uf.unite(a, b);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10308
from sys import stdin

a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())
c = int(stdin.readline().rstrip())
x = int(stdin.readline().rstrip())
x_500_100_50 = x

total=0


## 500
for i in range(0, a+1):
    if i * 500 > x_500_100_50:
        break
    #if i * 500 == x_500_100_50:
    #    total = total + 1
    x_100_50 = x_500_100_50 - i * 500

    ## 100
    for j in range(0, b+1):
        if j * 100 > x_100_50:
            break
        #if j * 100 == x_100_50:
        #    total = total + 1
        x_50 = x_100_50 - j * 100

        ## 50
        for k in range(0, c+1):
            if k * 50 > x_50:
                break
            if k * 50 == x_50:
                total = total + 1
                #print("500: %d  100: %d  50: %d" % (i, j, k))

print(total)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string a;
	cin >> a;
	if (a[0] == '9' || a[1] == '9')
	{
	cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n >> k;
  vector<int> a(n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  int ans = 1;
  vector<int> b;
  for (int i = 1; i * i <= s; ++i) {
    if (s % i == 0) {
      int x = i, ops = 0;
      b.clear();
      for (int j = 0; j < n; ++j) {
        b.push_back(a[j] % x);
      }
      sort(b.begin(), b.end());
      int p1 = 0, p2 = n - 1;
      while (p1 < p2) {
        int d = min(b[p1], x - b[p2]);
        b[p1] -= d;
        b[p2] += d;
        ops += d;
        if (b[p1] == 0) ++p1;
        if (b[p2] == x) --p2;
      }
      if (ops <= k) {
        ans = max(ans, x);
      }
      x = s / i;
      ops = 0;
      b.clear();
      for (int j = 0; j < n; ++j) {
        b.push_back(a[j] % x);
      }
      sort(b.begin(), b.end());
      p1 = 0;
      p2 = n - 1;
      while (p1 < p2) {
        int d = min(b[p1], x - b[p2]);
        b[p1] -= d;
        b[p2] += d;
        ops += d;
        if (b[p1] == 0) ++p1;
        if (b[p2] == x) --p2;
      }
      if (ops <= k) {
        ans = max(ans, x);
      }
    }
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;



int main(){
    int n,m;
    cin >> n >> m;//nは都市の数、mは道の数
    vector<int> a(50,0),b(50,0),ans(50,0);
    rep(i,m){
        cin >> a[i] >> b[i];
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }

    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main() {
  int x, n, count, xx, ans;
  cin >> x >> n;
  if(n != 0){
 	 vector<int> p(n), integer(102);
	  for(int i =0;i < n;i++){
  		cin >> p.at(i);
  	}
  
 	 for(int i = 0;i < 102;i++){
   		 integer.at(i) = i;
  	}
 	 for(int i = 0;i < n;i++){
   		 integer.at(p.at(i)) = -100;
  	}
  
  	count = 1;
  	while(true){
   	 xx = x;
    
      if(xx < 0 || 101 < xx){
        ans = x;
        break;
      }
   	 if(integer.at(xx) != -100){
       ans = xx;
    	  break;
   	 }
    	
   	  xx -= count;
      
    if(xx < 0 || 101 < xx){
        ans = x;
        break;
      }
   	 if(integer.at(xx) != -100){
       ans = xx;
   	   break;
   	 }
    
   	 xx += 2 * count;
      if(xx < 0 || 101 < xx){
        ans = x;
        break;
      }
   	 if(integer.at(xx) != -100){
       ans = xx;
    	  break;
   	 }
   	 count++;
  	}
  }
  else {
    ans = x;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        println(c);
    }
    else if (b == c) {
        println(a);
    }
    else {
        println(b);
    }
    return 0;
}

Measured memory_bytes: 3600
open Batteries
module SS = Set.Make(Int)
let s = SS.empty
let s = Scanf.sscanf (read_line()) "%d %d %d" (fun a b c ->
  List.fold_right SS.add [a;b;c] s
)
let _ = Printf.printf "%d\n" (List.length @@ SS.elements s)

Measured memory_bytes: 1408
#include <cstdio>

int main()
{
        int s;
        double w, h;

        while (scanf("%d,%lf,%lf", &s, &w, &h) != EOF) {
                double bmi = w / (h * h);
                if (bmi >= 25.0) {
                        printf("%d\n", s);
                }
        }

        return 0;
}

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

const ll mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  ll pw=1;
  for(int i=1; i<=n; i++){
    pw=pw*i%mod;
  }
  cout << pw << endl;
}

Measured memory_bytes: 3636
void main(){
  import std.stdio, std.conv, std.string, std.algorithm;

  long n, a, b, k; rd(n, a, b, k);

  const long mod=998244353;
  const int M=1_000_00*4;
  auto fact=new long[](M);
  fact[0]=fact[1]=1;
  foreach(i; 2..M) fact[i]=i*fact[i-1]%mod;
  auto inv_fact=new long[](M);
  long powmod(long a, long x){
    if(x==0) return 1;
    else if(x==1) return a;
    else if(x&1) return a*powmod(a, x-1)%mod;
    else return powmod(a*a%mod, x/2);
  }
  foreach(i; 0..M) inv_fact[i]=powmod(fact[i], mod-2);
  long comb(long nn, long rr){
    long ret=fact[nn]%mod;
    (ret*=inv_fact[rr])%=mod;
    (ret*=inv_fact[nn-rr])%=mod;
    return ret;
  }

  long tot=0;
  for(long x=0; x<=n; x++)if(k-a*x>=0){
    if((k-a*x)%b==0){
      long y=(k-a*x)/b;
      if(y>n) continue;
      (tot+=comb(n, x)*comb(n, y)%mod)%=mod;
    }
  }
  writeln(tot);
}

/*
  xマス赤で塗るとする (0<=x<=N)
  塗り方：comb(N, x)通り
  残りK-A*x点
  Bがこれを割るなら
    y=(K-A*x)/B マス青で上書きする
    y<=Nなら
      comb(N, x)*comb(N, y)

*/

/*
  (4C2)*2+(4C3)*3+(4C3)*3+(4C4)*4 = 40

  x=0 ... 残り5点 -> 無理
  x=1 ... 残り4点 -> y=2 -> (4C1)*(4C2)=24
  x=2 ... 残り3点 -> 無理
  x=3 ... 残り2点 -> y=1 -> (4C3)*(4C1)=16
*/

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}

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

int main() {
  vector<int> candy(3);
  for(int i = 0; i < 3; i++){
    cin >> candy.at(i);
  }
  
  sort(candy.begin(), candy.end());
  
  string ans = "No";
  
  if(candy.at(0) + candy.at(1) == candy.at(2)){
    ans = "Yes";
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
// C - Domino Quality /
#include <bits/stdc++.h>

using namespace std;

const char *a3[] = {
	"a..",
	"a..",
	".bb",
};

const char *a4[] = {
	"abcc",
	"abdd",
	"ccab",
	"ddab",
};

const char *a5[] = {
	"accdd",
	"ae..a",
	"be..a",
	"b.ffb",
	"ccddb",
};

const char *a6[] = {
	"aabc..",
	"ddbc..",
	"..aabc",
	"..ddbc",
	"bc..aa",
	"bc..dd",
};

const char *a7[] = {
	"aabbcc.",
	"dd.dd.a",
	"..d..da",
	"..d..db",
	"dd.dd.b",
	"..d..dc",
	"..d..dc",
};

void fill3(vector<string> &a, int x, int y)
{
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++) a[x + i][y + j] = a3[i][j];
}

void fill4(vector<string> &a, int x, int y)
{
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++) a[x + i][y + j] = a4[i][j];
}

void fill5(vector<string> &a, int x, int y)
{
	for (int i = 0; i < 5; i++)
		for (int j = 0; j < 5; j++) a[x + i][y + j] = a5[i][j];
}

void fill6(vector<string> &a, int x, int y)
{
	for (int i = 0; i < 6; i++)
		for (int j = 0; j < 6; j++) a[x + i][y + j] = a6[i][j];
}

void fill7(vector<string> &a, int x, int y)
{
	for (int i = 0; i < 7; i++)
		for (int j = 0; j < 7; j++) a[x + i][y + j] = a7[i][j];
}
int main(int argc, char *argv[])
{
	int n;
	cin >> n;

	bool ok = false;
	vector<string> a(n, string(n, '.'));

	if (n % 3 == 0) {
		for (int i = 0; i < n; i += 3) fill3(a, i, i);
		ok = true;
	} else if (n % 4 == 0) {
		for (int i = 0; i < n; i += 4) fill4(a, i, i);
		ok = true;
	} else if (n % 5 == 0) {
		for (int i = 0; i < n; i += 5) fill5(a, i, i);
		ok = true;
	} else if (n % 7 == 0) {
		for (int i = 0; i < n; i += 7) fill7(a, i, i);
		ok = true;
	}

	for (int x = 0, y = n; x < n && !ok; x += 4, y -= 4) {
		if (y % 5 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 4) fill4(a, i, i);
			for (int i = x; i < n; i += 5) fill5(a, i, i);
		} else if (y % 6 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 4) fill4(a, i, i);
			for (int i = x; i < n; i += 6) fill6(a, i, i);
		} else if (y % 7 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 4) fill4(a, i, i);
			for (int i = x; i < n; i += 7) fill7(a, i, i);
		}
	}

	for (int x = 0, y = n; x < n && !ok; x += 5, y -= 5) {
		if (y % 6 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 5) fill5(a, i, i);
			for (int i = x; i < n; i += 6) fill6(a, i, i);
		} else if (y % 7 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 5) fill5(a, i, i);
			for (int i = x; i < n; i += 7) fill7(a, i, i);
		}
	}

	for (int x = 0, y = n; x < n && !ok; x += 6, y -= 6) {
		if (y % 7 == 0) {
			ok = true;
			for (int i = 0; i < x; i += 6) fill6(a, i, i);
			for (int i = x; i < n; i += 7) fill7(a, i, i);
		}
	}

	if (ok)
		for (int i = 0; i < n; i++) cout << a[i] << endl;
	else
		cout << -1 << endl;

	return 0;
}


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


int main(){
    int64_t d, t, s;
    cin >> d >> t >> s;
    string ans = "No";

    if( d / s < t) ans = "Yes";
    if(t * s == d) ans = "Yes";


    cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
struct Fordfulkerson{
  const int INF = 1 << 28;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> used;

  Fordfulkerson(){}
  Fordfulkerson(int sz):n(sz),G(n),used(n){}

  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }

  int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0 ){
        int d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          G[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,lim);
      if(f==0) return fl;
      fl+=f;
      lim-=f;
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

};
//main
signed main(){
  int V,E;cin>>V>>E;
  Fordfulkerson fl(V);
  for(int i=0;i<E;i++){
    int a,b,c;cin>>a>>b>>c;
    fl.add_edge(a,b,c);
  }
  cout<<fl.flow(0,V-1)<<endl;
}



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

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}

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

    while(!is_prime(X)){
        X++;
    }
    cout << X << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import fractions

s=str(input())
if(len(s)%2==1):
    print("No")
    exit(0)
for i in range(len(s)-1):
    if(i%2==0):
        if(s[i]!='h' or s[i+1]!='i'):
            print("No")
            exit(0)
    if(s[i]!='h' and s[i]!='i'):
        print("No")
        exit(0)
if(s[len(s)-1]!='h' and s[len(s)-1]!='i'):
    print("No")
    exit(0)
print("Yes")

Measured memory_bytes: 23032
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

bingo = []
for i in range(3):
	bingo.append(rl())
N = ri()
B = []
for i in range(N):
	B.append(ri())

h = {}
for i in range(3):
	for j in range(3):
		n = bingo[i][j]
		h[n] = (i,j)
for b in B:
	if b not in h:
		continue
	i, j = h[b]
	bingo[i][j] = 0

def check(b):
	for i in range(3):
		bs = [1 for j in range(3) if b[i][j] == 0]
		if len(bs) == 3:
			return True
	for j in range(3):
		bs = [1 for i in range(3) if b[i][j] == 0]
		if len(bs) == 3:
			return True
	bs = [b[0][0],b[1][1],b[2][2]]
	bs = [1 for v in bs if v == 0]
	if len(bs) == 3:
		return True
	bs = [b[0][2],b[1][1],b[2][0]]
	bs = [1 for v in bs if v == 0]
	if len(bs) == 3:
		return True
	return False

if check(bingo):
	print('Yes')
else:
	print('No')




Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int x,y;
  cin>>x>>y;
 
  
  bool judge = false;
  for(int i = 0;i<=x;i++){
    int j=x-i;
    if(4*i+2*j==y){
      judge = true;
    }
  }
   
     if(judge==true)cout<<"Yes";
    else if(judge==false) cout<<"No";
 


}


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

class Program
{
    static void Main(string[] args)
    {
        int N = GetInputInt();

        int max = 0;
        int maxi = 0;
        int max2 = 0;

        int[] A = new int[N];

        A[0] = GetInputInt();
        A[1] = GetInputInt();

        if(A[0] >= A[1])
        {
            max = A[0];
            max2 = A[1];
        }
        else 
        {
            max = A[1];
            max2 = A[0];
            maxi = 1;
        }

        for (int i = 2; i < N; i++)
        {
            A[i] = GetInputInt();
            if(A[i] >= max2)
            {
                if(A[i] >= max)
                {
                    max2 = max;
                    max = A[i];
                    maxi = i;
                }
                else
                {
                    max2 = A[i];
                }
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (maxi == i)
            {
                Console.WriteLine(max2);
            }
            else
            {
                Console.WriteLine(max);
            }
        }
        Console.ReadKey();
    }

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


Measured memory_bytes: 17108
#include <iostream>
#include <queue>

using namespace std;

int h,w;
char a[1010][1010];
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

queue<pair <int,int> > Q;

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#'){
        Q.push(make_pair(i,j));
      }
    }
  }
  int k=Q.size();
  //cout<<k<<endl;
  int ans=0;
  while(Q.size()){
    pair<int,int> tq=Q.front();
    Q.pop();
    k--;
    for(int i=0;i<4;i++){
        if(tq.first+dx[i]>=0&&tq.first+dx[i]<h&&tq.second+dy[i]>=0&&tq.second+dy[i]<w)
        if(a[tq.first+dx[i]][tq.second+dy[i]]=='.'){
            a[tq.first+dx[i]][tq.second+dy[i]]='#';
            Q.push(make_pair(tq.first+dx[i],tq.second+dy[i]));
            //cout<<tq.first+dx[i]<<" "<<tq.second+dy[i]<<endl;
        }
    }
    
    if(k==0){
        ans++;
        k=Q.size();
    }
  }
  cout<<ans-1<<endl;
  return 0;
  
}





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

using namespace std;

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

int data[100];
inline int root(int x) {
  return data[x] < 0 ? x : data[x] = root(data[x]);
}

inline void unite(int x, int y) {
  x = root(x), y = root(y);
  if(x != y) {
    if(data[y] < data[x]) swap(x, y);
    data[x] += data[y]; data[y] = x;
  }
}
  
inline bool same(int x, int y) {
  return root(x) == root(y);
}

struct edges {
  int u, v, c;
  bool operator < (const edges& e) const {
    return c < e.c;
  }
};

int const INF = 1<<29;

int main() {
  
  int N, M;
  while(cin >> N >> M && (N|M)) {
    vector<edges> es;
    rep(i, M) {
      int a, b, c;
      cin >> a >> b >> c; a--, b--;
      es.push_back((edges){a, b, c});
    }
    sort(es.begin(), es.end());
    int ret = INF;
    
    for(; (int)es.size() >= N-1;) {
      memset(data, -1, sizeof data);
      int last = -1;
      int s = 0;
      rep(i, es.size()) {
	if(!same(es[i].u, es[i].v)) {
	  unite(es[i].u, es[i].v);
	  last = i;
	  s++;
	  if(s == N-1) break;
	}
      }
      rep(i, N) REP(j, i+1, N) {
	if(!same(i, j)) { goto exit; }
      }
      ret = min(ret, es[last].c-es[0].c);
      es.erase(es.begin());
    }
    
  exit:;
    cout << (ret < INF ? ret : -1) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
vector<long long> divs(long long v, vector<long long> &d){
	for(long long i = 1; i * i <= v; i++){
		if(v % i == 0){
			d.push_back(i);
			d.push_back(v / i);
		}
	}
	return d;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	vector<long long> d;
	divs(n, d);
	divs(n - 1, d);
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	int ans = 0;
	for(auto K : d){
		if(K == 1)
			continue;
		long long N = n;
		while(N % K == 0){
			N /= K;
		}
		if(N % K == 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);

void add_self(int & a, int b){
    a += b;
    if(a>= mod)a-= mod;
}



int main(){
   IOS

    int n; cin>>n;

    int a[n+5][n+5];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n;j++){
            cin>>a[i][j];
        }
    }

    vi dp((1 << n));

    dp[0] = 1;

    for(int mask = 0; mask < (1 << n) - 1; ++mask){
        int cnt = __builtin_popcount(mask);

        for(int i = 0; i < n; i++){
            if(a[cnt][i] and !(mask & (1 << i))){
                int mask_new = (mask ^ (1 << i));
                add_self(dp[mask_new], dp[mask]);
            }
        }
    }

    cout<<dp[(1<<n)-1]<<"\n";








}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; i++)cout << i << " ";
	ggr
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (b > a + w) {
			System.out.printf("%d\n", b - a - w);
		} else if (b + w < a) {
			System.out.printf("%d\n", a - b - w);
		} else {
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 21844
N = int(input())
dp = [N]*(N+1)
dp[0] = 0

for i in range(N+1):
  for j in [6**i for i in range(7)]:
    if i+j <= N:
      dp[i+j] = min(dp[i+j],dp[i]+1)
  for j in [9**i for i in range(1,6)]:
    if i+j <= N:
      dp[i+j] = min(dp[i+j],dp[i]+1)

print(dp[-1])

Measured memory_bytes: 3828
import math

def bitsum(bit,i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i&(-i)
    return s

def bitadd(bit,i,x):
    while i <= n:
        bit[i] += x
        i += i&(-i)
    return bit

s = input()
a = [2 if o == 'B' else 1 for o in s]
n = int(len(a))

n_ = int(math.log2(n)) + 1
bit = [0] * (2**n_)
bit.insert(0,0)

ass = 0
for j in range(n):
    ass += j-bitsum(bit,a[j])
    bit = bitadd(bit,a[j],1)
print(ass)  


Measured memory_bytes: 7144
import java.util.*;
 
public class Main {

    private static int N;
    private static int[] x;
    private static int[] y;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        x = new int[N];
        y = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        Set<Integer> used = new HashSet<>();
        List<Integer> list = new ArrayList<>();
        double sum = dfs(used, list);
        int div = 1;
        for (int i = 1; i <= N; i++) {
            div *= i;
        }
        System.out.println(sum/div);
    }

    private static double dfs(Set<Integer> used, List<Integer> list) {

        if (used.size() == N) {
            double ret = 0;
            for (int i = 0; i < N-1; i++) {
                int idx1 = list.get(i);
                int idx2 = list.get(i+1);
                int dx = x[idx1]-x[idx2];
                int dy = y[idx1]-y[idx2];
                ret += Math.sqrt(dx*dx+dy*dy);
            }
            return ret;
        }

        double sum = 0;
        for (int i = 0; i < N; i++) {
            if (!used.contains(i)) {
                used.add(i);
                list.add(i);
                sum += dfs(used, list);
                used.remove(i);
                list.remove(list.size()-1);
            }
        }
        return sum;
    }


}


Measured memory_bytes: 32340