akhauriyash/Code-Regression huggingface dataset:
<?php
  $n = intVal(trim(fgets(STDIN)));
  $first = str_split(trim(fgets(STDIN)));
  $fix = [];
  foreach($first as $k=>$v){
    if(array_key_exists($v, $fix)){
      $fix[$v] += 1;
    }else{
      $fix[$v] = 1;
    }
  }
  // echo "fix" . PHP_EOL;
  // print_r($fix);
  for($i = 1; $i < $n; $i++){
     $next = str_split(trim(fgets(STDIN)));
     $next_count_values = array_count_values($next);
    //  echo "next: ". PHP_EOL;
    //  print_r($next_count_values);
     foreach($fix as $k=>$v){
      //  echo "key:value = $k:$v" . PHP_EOL;
       if(array_key_exists($k, $next_count_values)){
         // echo "$k はfixに存在するので更新" . PHP_EOL;
         $fix[$k] = min($fix[$k], $next_count_values[$k]);
       }else{
        //  echo "$k はfixに存在しないので消去" . PHP_EOL;
         unset($fix[$k]);
       }
     }
  }
  // print_r($fix);
  ksort($fix);
  $ans = "";
  foreach($fix as $k=>$v){
    for($i=0; $i<$v; $i++){
      $ans .= $k;
    }
  }
  echo $ans . PHP_EOL;
?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include "stdio.h"

using namespace std;

#define mod 1000000007
#define int long long
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define psb push_back

const int maxn=1e3+5;
string mat[maxn];
int ans[maxn][maxn];

void solve()
{
    for(int i=0;i<maxn;i++)
        for(int j=0;j<maxn;j++)
            ans[i][j]=maxn*maxn;

    int n,m;
    cin>>n>>m;
    int sx,sy,dx,dy;
    cin>>sx>>sy>>dx>>dy;
    sx--; sy--; dx--; dy--;
    for(int i=0;i<n;i++){
        cin>>mat[i];
    }

    priority_queue<tuple<int,int,int> > q;
    q.push({0,sx,sy});
    ans[sx][sy]=0;//
    int dis,x,y;

    while(q.size())
    {
        tie(dis,x,y)= q.top();
        q.pop();
        dis=-dis;
        if(x == dx && y==dy)
        {
            cout<<ans[dx][dy]<<endl;
            return;
        }
        for(int i=x-2;i<=x+2;i++)
        {
            for(int j=y-2;j<=y+2;j++){
                if(i==x && j==y)
                    continue;
                if(i<0 || j<0 || i>=n || j>=m || mat[i][j]=='#')
                    continue;
                if((abs(i-x)==1 && j==y) || (abs(j-y)==1 && i==x))
                {
                    if(ans[i][j] > dis)
                    {
                        ans[i][j]=dis;
                        q.push({-dis,i,j});
                    }
                }
                else
                {
                    if(ans[i][j] > dis+1)
                    {
                        ans[i][j]=dis+1;
                        q.push({-dis-1,i,j});
                    }
                }
            }
        }
    }
    cout<<-1<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 12820
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s;
    cin>>s;
    ll k;cin>>k;
    string a[k];
    for(ll i=0;i<k;i++){
        a[i]="zzzzzz";
    }
    string sd;
    bool b;
    for(ll i=0;i<s.size();i++){
        sd=s[i];
        b=false;
        for(ll t=0;t<k;t++){
            if(sd==a[t]){
                t=k;
                b=true;
            }else if(sd<a[t]){
                b=true;
                for(ll y=k-1;y>=t+1;y--){
                    a[y]=a[y-1];
                }
                a[t]=sd;
                t=k;
            }
        }
        if(b){
            for(ll j=i+1;j<s.size() && b;j++){
                sd=sd+s[j];
                b=false;
                for(ll t=0;t<k;t++){
                    if(sd==a[t]){
                        t=k;
                        b=true;
                    }else if(sd<a[t]){
                        b=true;
                        for(ll y=k-1;y>=t+1;y--){
                            a[y]=a[y-1];
                        }
                        a[t]=sd;
                        t=k;
                    }
                }
            }
        }
    }
    cout<<a[k-1]<<endl;
     return 0;
}



Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


N = int(input())
div = factorization(N)

# print(div)
if N == 1:
    print(0)
    exit()

ans = 0
# print(div)
for d in div:
    c = d[1]
    i = 1

    while c >= 0:
        c -= i
        if c >= 0:
            ans += 1
        i += 1

print(ans)


Measured memory_bytes: 9428
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        ArrayList<Integer> b_list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            b_list.add(Integer.parseInt(sc.next()));
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0, a = 0; j < m; j++) {
                a = Integer.parseInt(sc.next());
                sum += a * b_list.get(j);
            }
            sum += c;
            if (sum > 0) {
                ans++;
            }
        }
        out.println(ans);
        sc.close();
        out.close();
    }

}

Measured memory_bytes: 36104
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    long long ans = 0;
    int n, k;
    vector<int> a, b, c;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> k;
        a.push_back(k);
    }
    for(int i = 0; i < n; i++){
        cin >> k;
        b.push_back(k);
    }
    for(int i = 0; i < n; i++){
        cin >> k;
        c.push_back(k);
    }
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    for(int i = 0; i < n; i++){
        decltype(a)::iterator p = lower_bound(a.begin(), a.end(), b[i]);
        decltype(c)::iterator q = upper_bound(c.begin(), c.end(), b[i]);
        ans += (p - a.begin()) * (c.end() - q);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1784
# include <iostream>

using namespace std;

//https://atcoder.jp/contests/abc089/tasks/abc089_b

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

    string result = "Three";

    for (int i=0;i<N;i++){
        string s;
        cin >> s ;
        
        if(s == "Y"){
            result = "Four";
            break;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import collections

def calc(n):
  cnt_2=0
  cnt_5=0
  while n%2==0 and cnt_2<18:
    cnt_2+=1
    n//=2
  while n%5==0 and cnt_5<18:
    cnt_5+=1
    n//=5
  return [cnt_2,cnt_5]

n=int(input())
dic=collections.defaultdict(int)
ans=0
for _ in range(n):
  tmp=input()
  if '.' in tmp:
    pos=tmp.index('.')
    d=len(tmp)-(pos+1)
    tmp=tmp[:pos]+tmp[pos+1:]+'0'*(9-d)
  else:
    tmp+='0'*9
  tmp=int(tmp)
  cnt_2,cnt_5=calc(tmp)
  dic[(cnt_2,cnt_5)]+=1
  if 18<=min(cnt_2*2,cnt_5*2):
    ans-=1
for a1,b1 in dic.keys():
  for a2,b2 in dic.keys():
    if min(a1+a2,b1+b2)>=18:
      ans+=dic[(a1,b1)]*dic[(a2,b2)]
print(ans//2)

Measured memory_bytes: 76712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

int main() {
	int N, K, Q; std::cin >> N >> K >> Q;
	std::vector<int> POINT(N);
	for(auto& r : POINT) r = -Q;
	std::vector<int> A(Q);
	for (auto& r : A) {
		std::cin >> r;
		POINT[r - 1] += 1;
	}
	for (auto& r : POINT) {
		if (r + K > 0)
			std::cout << "Yes" << std::endl;
		else
			std::cout << "No" << std::endl;
	}


}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
using namespace std;
 
int main()
{
   
    int n;
    cin>>n;
    int x=n%10;
    int y=(n/10)%10;
    int z=(n/100);
    if (x==7 || y==7 || z==7) {cout<<"Yes";} else cout<<"No";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  string s;
  cin >> s;
  int ans = 1e9;
  for(char c = 'a'; c <= 'z'; c++){
    int res = 0, cnt = 0;
    for(auto &e : s){
      cnt = c == e ? 0 : cnt + 1;
      res = max(res, cnt);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

#define INF (1<<30)

int dp[40];


int main(){
	dp[0]=1;	dp[1]=2;	dp[2]=4;
	int n;

	for(int i=3;i<30;i++){
		dp[i]= dp[i-1] + dp[i-2] + dp[i-3];
	}
	while(cin>>n, n){
		cout<<(dp[n-1]+3649)/3650<<endl;

		
	}



	return 0;
}



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

string Replace( string& String1, string String2, string String3 )
{
    string::size_type  Pos( String1.find( String2 ) );
    
    while( Pos != std::string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }
    
    return String1;
}

int main(void) {
    string input;
    getline(cin, input);
    Replace(input, "apple", "pcaeh");
    Replace(input, "peach", "alppe");
    Replace(input, "pcaeh", "peach");
    Replace(input, "alppe", "apple");
    cout << input << endl;
    return(0);
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  bool a = false, b = false, c = false, d = false;
  string s;
  cin >> s;
  rep(i, 0, s.size()) {
    if(s[i] == 'N') a = 1;
    else if(s[i] == 'W') b = 1;
    else if(s[i] == 'S') c = 1;
    else d = 1;
  }

  cout << (a == c && b == d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
c = [0 for i in range(n+1)]
c[0] = 3
ans = 1

for i in range(n):
  ans *= c[a[i]]
  ans %= mod
  c[a[i]] -= 1
  c[a[i]+1] += 1
print (ans)


Measured memory_bytes: 20908
#include <stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
  int a,b;
  char s[10];
  char t[10];
  char u[10];
  scanf("%s",s);
  scanf("%s",t);
  scanf("%d%d",&a,&b);
  scanf("%s",u);
  if(strcmp(s,u)==0){
    a--;
  }else{
    b--;
  }
  printf("%d %d",a,b);
  return 0;
}

Measured memory_bytes: 128
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.regex;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  auto n = s.length;

  auto r = 0L;
  foreach (i; 0..1<<(n-1)) {
    auto t = "";
    foreach (j; 0..n-1) {
      t ~= s[j];
      if (i.bitTest(j)) t ~= '+';
    }
    t ~= s[$-1];
    auto u = t.matchAll(r"\d+");
    r += u.map!(ui => ui[0].to!long).sum;
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


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

ll lcm(ll a,ll b){
  ll acopy=a,bcopy=b;
  while(acopy!=0 && bcopy!=0){
    if(acopy>bcopy){acopy%=bcopy;}
    else{bcopy%=acopy;}
  }
  return a*b/max(acopy,bcopy);
}

ll two(ll N){
  ll count=0;
  while(N%2==0){
    count++;
    N/=2;
  }
  return count;
}

int main() {
  ll N,M;
  cin>>N>>M;
  vector<ll> a(N);
  for(ll i=0;i<N;i++){
    cin>>a.at(i);
    a.at(i)/=2;
  }//整数列になった
  ll t=two(a.at(0));
  
  bool judge=true;
  for(ll i=1;i<N;i++){
    if(two(a.at(i))!=t){
      judge=false;
      break;
    }
  }
  
  if(judge==false){cout<<0<<endl;}
  else{
    for(ll i=0;i<N;i++){
      a.at(i)>>=t;
    }
    M>>=t;
    ll LCM=a.at(0);
    for(ll i=1;i<N;i++){
      LCM=lcm(a.at(i),LCM);
    if(LCM>M){cout<<0<<endl;break;}
    }
    if(M>=LCM){
      cout<<(M/LCM+1)/2<<endl;
    }
  }
}




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

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

  long ans = 0;

  for(int i=0; i<1000; i++){
    int nowi = i, cnt = 0;
    for(int j=s.size()-1; j>=0; j--){
      if(s[j] == (char)((int)'0'+(nowi%10))){
	if(++cnt > 2){
	  ans++;
	  break;
	}
	nowi /= 10;
      }
    }
  }
  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 3580
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: i32,
        k: i32,
        x: [i32; n],
    }

    let sum: i32 = x.into_iter().fold(0, |acc, x| acc + cmp::min(2 * (k-x).abs(), 2 * x));

    println!("{}", sum);
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
using i64 = int_fast64_t;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);
    
    int d, g; cin >> d >> g;
    vi p(d+1), c(d+1);
    rep1(i,d) cin >> p[i] >> c[i];

    //ボーナス利用パターン
    int ans_cnt = inf;
    for(int bit = 0; bit < (1<<d); ++bit) {
        ll points = 0;
        int cnt = 0;
        for(int i = 0; i < d; ++i) {
            if(!(bit&(1<<i))) continue;
            cnt += p[i+1];
            points += 100*(i+1)*p[i+1];
            points += c[i+1];
        }
        if(points >= g) chmin(ans_cnt, cnt);
    }

    //高得点から貪欲パターン
    ll points = 0;
    int cnt = 0;
    for(int i = d; points < g; ) {
        ++cnt;
        if(p[i]==1) {
            points += 100*i;
            points += c[i];
            --i;
        }
        else {
            points += 100*i;
            --p[i];
        } 
    }
    //debug(cnt);
    cout << min(ans_cnt, cnt) << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
  int N;
  cin >> N;
  double A[N];
  double sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += 1 / A[i];
  }

  cout << 1 / sum;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> arr(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<n;i++){
        ll x=0;
        while(i<n && arr[i]!=0){
            x+=arr[i];
            i++;
        }
        sum+=x/2;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,a,b) for(long long i=a; i<b;i++)
#define N 1000000007
#define MAX 100007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define PI 3.14159265358979323
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector< pair<ll,ll> > vpi;
const long double pi=4*atan(1.0);
vpi vii;
//ll tab[100002],n;

ll Xor(ll x, ll y)
{
   return (x | y) & (~x | ~y);
}

ll dx[8]={0,1,0,-1,1,-1,1,-1};
ll dy[8]={1,0,-1,0,1,-1,-1,1};

ll number_divisors(ll n)
{
   ll d;
    ll i;
    d=0;
    for(i = 1 ; i*i<n  ;++i)
        if(n%i == 0)
            {d+=2;}

    if(i*i == n)
        d++;

}

ll countDivisibles(ll A, ll B, ll M)
{

    if (A % M == 0)
        return (B / M) - (A / M) + 1;
    return (B / M) - (A / M);
}
bool ch (ll i,ll j,ll n, ll m)
{
    return (i>=0 && i<n && j>=0 && j<m);
}
vi cost,aux;
vector<ll> v1[MAX];
ll z[MAX],mini=1000000005,out=0;
void dfs(ll s)
{   if (z[s]) return;
 z[s] = 1;
 aux.PB(s);
 for (ll u=0;u<v1[s].size();u++)
    { dfs(v1[s][u]);}

 }

 // Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

// Function to find gcd of array of
// numbers
ll findGCD(ll arr[], ll n)
{
    ll result = arr[0];
    for (ll i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

int main()
{
//freopen("input.txt","r",stdin);
ll n,x,y,sum=0;
vi a,b;
cin>>n;
REP(i,0,n){
    cin>>x; a.PB(x);
}
REP(i,0,n){
    cin>>x; b.PB(x);
}
REP(i,0,n){
    if (a[i] > b[i]) sum+= a[i] - b[i];
}
cout<<sum;

       return 0;
}


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    map<string,int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    while(n--){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int d, t, s;
	cin >> d >> t >> s;
	puts(t * s >= d ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3628
import sys
#n=int(input())
#l = list(map(int,input().split()))
#a,b,c = map(int,input().split())

ly = []

for i in range(3):
    ly.append(list(map(int,input().split())))

lt = []

for i in range(3):
    l = []
    for j in range(3):
        l.append(ly[j][i])
    lt.append(l)

l = ly+lt + [[ly[0][0],ly[1][1],lt[2][2]]] + [[ly[0][2],ly[1][1],ly[2][0]]]

n = int(input())
nm = []
for i in range(n):
    s = int(input())
    nm.append(s)

for i in l:
    t = [0,0,0]
    if i [0] in nm:
        t[0] = 1
    if i [1] in nm:
        t[1] = 1
    if i [2] in nm:
        t[2] = 1
    if sum(t) == 3:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,cnt=0,i,x;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d",&x),cnt+=x;
	if (cnt>n) printf("-1\n");
	else printf("%d\n",n-cnt);
	return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<math.h>

int n[100010];
int main()
{
  int N;
  scanf("%d",&N);
  int temp;

  for(int x=1;x<105;x++){
    for(int y=1;y<105;y++){
      for(int z=1;z<105;z++){
        temp = x*x + y*y + z*z + x*y + y*z + z*x;
        n[temp]++;
      }
    }
  }
  
  for(int i=1;i<=N;i++){printf("%d\n",n[i]);}
}

Measured memory_bytes: 1988
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
struct L : vector<P> {
    L(const P &a = P(), const P &b = P()) {
        emplace_back(a); emplace_back(b);
    }
};
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

enum CCW_RESULT { CCW = +1, CW = -1, BEHIND = +2, FRONT = -2, ON = 0 };
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return CCW;      // counter clockwise
    if (cross(b, c) < -eps) return CW;      // clockwise
    if (dot(b, c) < 0) return BEHIND;       // c--a--b on line
    if (norm(b) < norm(c)) return FRONT;    // a--b--c on line | a=b
    return ON;                              // on segment | a=c | b=c
}
bool isecSS(const L &s, const L &t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

#include <iostream>
int main() {
    int q; cin >> q;
    while (q--) {
        vector<P> ps;
        for (int i = 0; i < 4; i++) {
            int x, y; cin >> x >> y;
            ps.emplace_back(x, y);
        }
        cout << isecSS(L(ps[0], ps[1]), L(ps[2], ps[3])) << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

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

bool done[100];
vector<vector<int> > edge;

int dfs(int v) {
	if(done[v])
		return 0;

	done[v] = true;

	int res = 1;
	for(int i = 0; i < edge[v].size(); ++i)
		chmax(res, dfs(edge[v][i]) + 1);

	done[v] = false;

	return res;
}

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

	for(int n; cin >> n, n;) {
		int num = 0;
		edge.clear();
		edge.resize(100);
		map<int, int> convert;
		for(int i = 0; i < n; ++i) {
			int a, b;
			cin >> a >> b;
			if(!convert.count(a))
				convert.insert(make_pair(a, num++));
			a = convert[a];

			if(!convert.count(b))
				convert.insert(make_pair(b, num++));
			b = convert[b];

			edge[a].push_back(b);
			edge[b].push_back(a);
		}

		int ans = 0;
		for(int i = 0; i < num; ++i) {
			memset(done, false, sizeof(done));
			chmax(ans, dfs(i));
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> f(n + 1, 1);
  for(int i = 2; i <= n; ++i) {
    if(f[i] == 1) {
      for(int j = i; j <= n; j += i) {
        int t = j, cnt = 0;
        while(t % i == 0) {
          cnt++;
          t /= i;
        }
        f[j] *= (cnt + 1);
      }
    }
  }
  long long ans = 0;
  for(int i = 1; i <= n; ++i) {
    ans += i * 1LL * f[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    bool A = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            
            if (i * j == N) {
                A = true;
            }
           
                
        }
        
    }
    if (A == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 3624
n, k = [int(x) for x in input().strip().split(" ")]
mod = pow(10, 9) + 7

ll = []
ks = []
cc = 0
last = 0
for i in range(n):
    i += 1
    if n//i < i:
        last = n//i
        break
    ll.append(n//i)
    ks.append(1)
    last = n//i
    cc += 1

while True:
    if last == 0:
        break
    if last >= len(ll):
        mm = last
    else:
        mm = ll[last]
    ll.append(last * (ll[last-1] - mm))
    ks.append((ll[last-1] - mm))
    last -= 1
n_l = len(ll)

for _ in range(k-2):
    nll = []
    m = sum(ll) % mod
    for i in range(n_l):
        x = n_l - i - 1
        nll.append((m * ks[i]) % mod)
        m -= (mod + ll[x]) % mod
    ll = nll[:]
print(sum(ll) % mod)


Measured memory_bytes: 127724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair< ll, pair<ll,ll> > 
#define pii pair< int, pair<int,int> >
ll power(ll a, ll b, ll n){
	ll res = 1ll;
	a %=n;
	while(b>0){
		if(b&1) res = (res*a)%n;
		a = (a*a)%n;
		b/=2;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,n,m,x,b,y,q,z;
    cin>>n;
    if(n == 1) cout<<0;
    else{
    	x = power(10,n,N);
    	y = power(9,n,N);
    	z = power(8,n,N);
    	ll ans = (x-(2*y)%N+ N)%N;
    	ans +=z;
    	ans%=N;
    	cout<<ans;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int dp[100004];
//int very_min=1e9+6;
/*int takingit()
{
    for(int j=i+1;j<=i+k;j++)
    {
        int value=abs(arr[j]-arr[i])+func(j,arr,n)
    }
 
}*/
int func(int i,int arr[],int n,int k)
{
    int very_min=1e9+6;
    if(i>=n-1-k)
    {
        dp[i]=abs(arr[n-1]-arr[i]);
        return dp[i];
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
   // dp[i]=min(abs(arr[i+1]-arr[i])+func(i+1,arr,n),abs(arr[i+2]-arr[i])+func(i+2,arr,n));
    //cout<<dp[i]<<"  ";
   //dp[i]=takingit(i,k,arr);
    for(int j=i+1;j<=i+k;j++)
    {
       int ref=abs(arr[j]-arr[i])+func(j,arr,n,k);
        if(ref<very_min)
        {
            very_min=ref;
        }
    }
    dp[i]=very_min;
    return dp[i];
}
 
int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<100004;i++)
    {
        dp[i]=-1;
    }
        func(0,arr,n,k);
   /* for(int i=0;i<n;i++)
    {
        cout<<dp[i]<<endl;
    }*/
   // cout<<counttt<<endl;
    cout<<dp[0];
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll c[200005]={0};
vector< int > g[200005];
void dfs(int cur, int pre=-1){
    for(int next : g[cur]){
        if(next == pre) continue;
        c[next] += c[cur];
        dfs(next,cur);
    }
}
int main(void){
    int n,q; cin >> n >> q;
    rep(i,n-1) {
        int a,b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,q){
        ll p,x; cin >> p >> x;
        p--; c[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << c[i] << endl;
    }
}




Measured memory_bytes: 24320
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
using namespace std;

vector<short> plus_[5001],minus_[5001];

int main(){
	int N,M,A,B,X;
	cin>>N>>M;
	for(int i=0;i<=N;i++){
		plus_[i].assign(i+2,0); minus_[i].assign(i+2,0);
	}
	for(int i=0;i<M;i++){
		cin>>A>>B>>X; A--; B--;
		plus_[A][B]++; plus_[A+X+1][B]--;
		minus_[A][B]--; minus_[A+X+1][B+X+1]++;
	}
	for(int i=0;i<N;i++){
		int sum=0;
		for(int j=0;j<N-i;j++){
			sum += plus_[j+i][i];
			plus_[j+i][i] = sum;
		}
	}
	for(int i=0;i<N;i++){
		int sum=0;
		for(int j=0;j<N-i;j++){
			sum += minus_[i+j][j];
			minus_[i+j][j] = sum;

		}
	}

	int ans=0;
	for(int i=0;i<N;i++){
		int sum=0;
		for(int j=0;j<=i;j++){
			sum += plus_[i][j];
			if(sum>0) ans++;
			sum += minus_[i][j];
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    double a, b, h, m;
    double tmpA, tmpB, tmpC;
    double pi = acos(-1);
    double kekka;

    cin >> a >> b >> h >> m;

    tmpA = (60 * h + m) / 720 * 2 * pi;
    tmpB = m / 60 * 2 * pi;
    tmpC = tmpA - tmpB;

    kekka = sqrt(a * a + b * b - 2 * a * b * cos(tmpC));
    cout << setprecision(10) << kekka;
}

Measured memory_bytes: 4168
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;

  vector<ll> x(n);
  rep(i,n) cin >> x[i];

  ll ans = LLONG_MAX;
  for(int i = 1;i <= 100; i++)
  {
    ll sum = 0;
    for(int j = 0;j < n;j++)
    {
      sum += abs(i - x[j]) * abs(i - x[j]);
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 998244353;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> robots;
    for(long i{0}, x, d; i++ < N; robots.emplace_back(x, x + d))cin >> x >> d;
    sort(robots.begin(), robots.end(), greater<>());
    vector<pair<long, unsigned long>> v;
    for(const auto& i : robots){
        unsigned long r{1};
        while(!v.empty() && v.back().first < i.second && ((r *= v.back().second) %= MOD))v.pop_back();
        v.emplace_back(i.first, r + 1);
    }
    cout << accumulate(v.begin(), v.end(), 1UL, [](auto i, auto j){return i * j.second % MOD;}) << endl;
    return 0;
}

Measured memory_bytes: 7660
// atcoder/abc175/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> v(n);
    cin >> v;
    sort(v.begin(), v.end());

    lli cnt = 0;
    for (int i = 0; i < v.size(); ++i) {
      for (int j = i + 1; j < v.size(); ++j) {
        for (int k = j + 1; k < v.size(); ++k) {
          unless (v[i] < v[j]) continue;
          unless (v[j] < v[k]) continue;
          cnt += (v[i] + v[j] > v[k]);
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    string s;
    int n;
    cin >>n>> s;
    int ans = 0;
    for (int i = 0; i < n;i++) {
        int a[26] = {},m=0;
        for (int j = 0;j <= i;j++) {
            for (int k = i + 1;k < n;k++) {
                if (s[k] == s[j]) a[s[k]-'a']++;
            }
        }
        for (int l = 0; l < 26; l++) {
            if (a[l] != 0) m++;
        }
        ans = max(ans, m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

a1=A*X+B*Y
a2=C*max(X,Y)*2
a3=C*min(X,Y)*2+max((X-min(X,Y))*A,(Y-min(X,Y))*B)

print(min([a1,a2,a3]))

Measured memory_bytes: 3060
import java.util.Scanner;

//public class Main {
//	public static void main(String[] args) {
//		//141_A
//		Scanner sc = new Scanner(System.in);
//		String today = sc.next();
//		String[] weather = new String[3];
//		String ans ="";
//		weather[0] = "Sunny";
//		weather[1] = "Cloudy";
//		weather[2] = "Rainy";
//
//		if(today.equals(weather[0])) {
//			ans = weather[1] ;
//		} else if(today.equals(weather[1])) {
//			ans = weather[2] ;
//		} else if(today.equals(weather[2])) {
//			ans = weather[0] ;
//		}
//		System.out.println(ans);
//		// Scannerクラスのインスタンスをクローズ
//		sc.close();
//	}
//}

public class Main {
	public static void main(String[] args) {
		//141_A
		Scanner sc = new Scanner(System.in);
		String move = sc.nextLine();
		String[] moveLine = new String[100];
		moveLine = move.split("");
		boolean isFumiyasusa = false;
		String ans = "";
		for (int i = 1; i-1 < moveLine.length; i++) {
			if ((i) % 2 == 0) {
				if (moveLine[i-1].equals("L") || moveLine[i-1].equals("U") || moveLine[i-1].equals("D")) {
					isFumiyasusa = true;
				} else {
					isFumiyasusa = false;
					break;
				}
			} else {
				if (moveLine[i-1].equals("R") || moveLine[i-1].equals("U") || moveLine[i-1].equals("D")) {
					isFumiyasusa = true;
				} else {
					isFumiyasusa = false;
					break;
				}
			}
		}
		if (isFumiyasusa) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println(ans);
		// Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}

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

long long X[100005];
long long P[100005];

int N, S;
int pos;
vector<int> order1;

void dfs(int left1, int right1, int dir){
    if(left1 >= pos){
        for(int i = left1; i <= right1; i ++){
            order1.push_back(i);
        }
        return;
    }else if(right1 < pos){
        for(int i = right1; i >= left1; i --){
            order1.push_back(i);
        }
        return;
    }else if(P[left1] >= P[right1]){
        P[left1] += P[right1];
        //throw;
        long long add = X[right1]-X[left1];
        order1.push_back(right1);
        //printf("%d %d\n", left1, right1);
        dfs(left1, right1-1, 0);
    }else{
        P[right1] += P[left1];
        //throw;
        long long add = X[right1]-X[left1];
        //printf("%d %d\n", left1, right1);
        order1.push_back(left1);
        dfs(left1+1, right1, 1);
    }
}

int main(){
    scanf("%d%d", &N, &S);

    for(int i = 0; i < N; i ++){
        scanf("%lld%lld", &X[i], &P[i]);
    }
    pos = lower_bound(X, X+N, S)-X;
    if(pos == N){
        printf("%lld", S-X[0]);
        return 0;
    }else if(pos == 0){
        printf("%lld", X[N-1]-S);
        return 0;
    }
    X[N] = S;

    dfs(0, N-1, 0);

    order1.push_back(N);

    long long ans = 0;
    //printf("order1[%d]=%d X[]=%lld\n", 0, order1[0], X[order1[0]]);
    for(int i = 1; i < (int)order1.size(); i ++){
        //printf("order1[%d]=%d X[]=%lld\n", i, order1[i], X[order1[i]]);
        ans += abs(X[order1[i]]-X[order1[i-1]]);
    }
    //printf("\n");
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 6136
a,b,c = map(int,input().split())
ans = 0
for i in range(1000000000//5):
  if a%2 == 1 or b%2 == 1 or c%2 == 1:
    break
  a1 = b//2 + c//2
  b1= a//2 + c//2
  c1 = a//2 + b//2
  a = a1
  b = b1
  c = c1
  ans += 1
else:
  print(-1)
  exit()
print(ans)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	fct[0] = fct[1] = inv[1] = inv[cmx] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	for(ll x=fct[cmx], n=mod-2; n > 0; n >>=1, x = x*x %mod)
		if(n & 1) inv[cmx] = inv[cmx] * x %mod;
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nPk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[n-k] % mod;
	return ret;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	int mx1=0, mx2=0;
	rep(i, n){
		if(a[i] > mx1){ mx2 = mx2; mx1=a[i];}
		else if(a[i] > mx2) mx2=a[i];
	}
	rep(i, n){
		cout <<(a[i] == mx1? mx2: mx1 )<<"\n";
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    llin(n);
    llin(m);
    priority_queue<ll> a;
    ll p=0;
    FOR(i,0,n-1){
        cin >> p;
        a.push(p);
    }
    FOR(i,0,m-1){
        a.push(a.top()/2);
        a.pop();
    }
    ll k=0;
    FOR(i,0,n-1){
        k+=a.top();
        a.pop();
    }
    sal(k)
}


Measured memory_bytes: 1400
#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,string>;

int main(){
  ll N;
  cin >> N;
  
  vector<ll>A(N);
  rep(i,N)cin >> A[i];
  
  ll Q;
  cin >> Q;
  ll B,C;
  vector<int>HowMany(100000); //各数字が何個配列に入っているか
  rep(i,N){
    HowMany[A[i]]++;
  }
  
  ll sum = 0;
  rep(i,N){
    sum += A[i];
  }
  
  //この時点でsumには初期値が入っている
  
  rep(i,Q){ //クエリぶん処理
    cin >> B >> C;
    sum += (C - B) *HowMany[B];
    HowMany[C] += HowMany[B];
    HowMany[B] = 0;
    
    cout << sum << endl;
  }
}

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

using namespace std;

int n,f=0,ok=0;
uint64_t a[1000001],t=1,lim=1e18;

void nhap()
{
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        cin>>a[i];
        if (a[i]==0) f=1;
        if (f)
        {
            cout<<0;
            return;
        }
    }
    for (int i=1;i<=n;++i)
    {
        if (a[i]<=lim/t)
        {
            t*=a[i];
        }
        else
        {
            cout<<-1;
            return;
        }
    }
    cout<<t;
}

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


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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int a, b;
  std::cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout("Possible");
  } else {
    cout("Impossible");
  }
}


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

int gcd(long int a, long int b){
  if(a%b!=0){
    a%=b;
    swap(a,b);
    b=gcd(a,b);
  }
  return b;
}

int main(){
  long int a,b,c;
  cin>>a>>b;
  if(a<b) swap(a,b);
  cout<<a*b/gcd(a,b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll MOD=1000000007;
const ll E=1e18;

ll gcd(ll a,ll b){
  while(a%b){a%=b; swap(a,b);}
  return b;
}

bool same(pll a,pll b,pll c,pll d){
  b.F-=a.F; b.S-=a.S;
  d.F-=c.F; d.S-=c.S;
  if(b.S==0 && d.S==0){return true;}
  if(b.S==0 || d.S==0){return false;}
  ll g=gcd(abs(b.F),abs(b.S));
  b.F/=g; b.S/=g;
  if(b.S<0){b.S*=-1; b.F*=-1;}
  g=gcd(abs(d.F),abs(d.S));
  d.F/=g; d.S/=g;
  if(d.S<0){d.S*=-1; d.F*=-1;}
  return b==d || (b.F==0 && d.F==0);
}


int main(){
  ll n;
  cin>>n;
  vector<pll> A(n);
  const ll MX=1LL<<n;
  for(auto &I:A){cin>>I.F>>I.S;}
  vector<ll> dp(MX,0);
  vector<int> dp2(MX);
  vector<ll> bitcount(MX,0);
  for(int i=0;i<MX;i++){
    for(int j=0;j<n;j++){bitcount[i]+=i>>j&1;}
    bitcount[i]/=2;
  }
  for(int i=0;i<n;i++){
    for(int t=i+1;t<n;t++){
      for(auto &I:dp2){I=0;}
      dp2[0]=1;
      for(ll j=1;j<MX;j++){
	ll B=-1;
	for(int k=0;k<n;k++){
	  if(j>>k&1){B=k; break;}
	}
	for(int k=B+1;k<n;k++){
	  if(j>>k&1 && dp2[j^(1LL<<B)^(1LL<<k)] && same(A[i],A[t],A[B],A[k])){dp2[j]=1;}
	}
      }
      for(int j=0;j<MX;j++){
	if(dp2[j]){dp[j]=bitcount[j]*(bitcount[j]-1)/2;}
      }
    }
  }
  for(int i=0;i<MX;i++){
    ll z=(MX-1)^i;
    for(int k=z;k>0;k=(k-1)&z){
      dp[i^k]=max(dp[i^k],dp[i]+dp[k]);
    }
  }
  cout<<dp.back()<<endl;
  

  return 0;
}



Measured memory_bytes: 4148
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = 0;
        }
        if(n==1) {
            System.out.println("a");
            return;
        }
        rec(a, 1);
    }
    public static void rec(int[] a, int from) {
        int max = a[0];
        for(int i=1; i<from; i++) {
            max = Math.max(max, a[i]);
        }
        for(int i=0; i<=max+1; i++) {
            a[from] = i;
            if(from==a.length-1) {
                output(a);
            }
            else {
                rec(Arrays.copyOf(a, a.length), from+1);
            }
        }
    }
    public static void output(int[] a) {
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<a.length; i++) {
            sb.append((char)('a'+a[i]));
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 46024