akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist

N = int(input())
G = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append((v-1, w))
    G[v-1].append((u-1, w))

dist = bfs()
ans = [0]*N

for i in range(N):
    if dist[i]%2==0:
        ans[i] = 1

for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 94928
#include<bits/stdc++.h>
using namespace std;
int n;int t[10005];int ans;
int main(){
  cin>>n;
  int i,j,k;
  for(i=0;i<n-1;i++) cin >> t[i];
  ans=t[n/2-1];
  for(i=0;i<n/2-1;i++) ans=min(ans,t[i]+t[i+n/2]);
  
  int dp[2][2][5005];
  int inf=1<<28;
  fill(dp[0][0],dp[0][0]+5005,inf);
  fill(dp[0][1],dp[0][1]+5005,inf);
  fill(dp[1][0],dp[1][0]+5005,inf);
  fill(dp[1][1],dp[1][1]+5005,inf);
  dp[0][0][1]=0;
  dp[0][1][0]=0;
  
  for(i=0;i<n-1;i++){
    for(j=0;j<=n/2;j++){
      dp[(i+1)%2][0][j+1]=min(dp[(i+1)%2][0][j+1],dp[i%2][0][j]);
      dp[(i+1)%2][0][j+1]=min(dp[(i+1)%2][0][j+1],dp[i%2][1][j]+t[i]);
      dp[(i+1)%2][1][j  ]=min(dp[(i+1)%2][1][j  ],dp[i%2][1][j]);
      dp[(i+1)%2][1][j  ]=min(dp[(i+1)%2][1][j  ],dp[i%2][0][j]+t[i]);
    }
    fill(dp[i%2][0],dp[i%2][0]+5005,inf);
    fill(dp[i%2][1],dp[i%2][1]+5005,inf);
  }
  

  cout << min(dp[i%2][0][n/2],dp[i%2][1][n/2]) << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n;
bitset<N*N>b;
int main()
{
    b.set(0,1);
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        sum+=x;
        b|=b<<x;
    }
    for(int i=sum/2+sum%2;;i++)
        if(b[i])
    {
        printf("%d\n",i);
        return 0;
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;

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

	int n; cin >> n;
	vector<pair<int, int>> v(n);
	for(int i = 0; i < n; ++i) cin >> v[i].first;
	for(int i = 0; i < n; ++i) cin >> v[i].second;
	
	int result = -1e9;
	for(int mask = 0; mask < (1 << n); ++mask) {
		int x = 0, y = 0;
		for(int i = 0; i < n; ++i) {
			if(mask & (1 << i)) {
				x += v[i].first;
				y += v[i].second;
			}
		}
		result = max(result, x - y);
	}
	cout << result << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 200
int main(){
    char c[N];
    int s[N], top = 0;
    int x, y;
    while(scanf("%s", c) != EOF){
        if(c[0] == '+'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = x + y;
        }
        else if(c[0] == '-'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = y - x;
        }
        else if(c[0] == '*'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = x * y;
        }
        else{
            x = atoi(c);
            top++;
            s[top] = x;
        } }
    printf("%d\n", s[top]);
    return 0;
                }


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

int main()
{
	char s[27];
	cin>>s;
	int n,r=0;
	n=strlen(s);
	for(int i=0; i<n; i++){
		  for(int j=i+1; j<n; j++) if(s[i]==s[j])r++;
		}
	if(r!=0) cout<<"no"<<endl;
	else cout<<"yes"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,d,sum;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld%lld",&a,&b);
        c=a*b;
        d=sqrt(c);
        if(d*(d+1)<c)
            sum=d*2-1;
        else if(d*d==c)
        {
            if(a==b)
                sum=(d-1)*2;
            else
                sum=(d-1)*2-1;
        }
        else
            sum=(d-1)*2;
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 256
import heapq as hp
n, m = map(int, input().split())
list_A = list(map(int, input().split()))
 
a_q = []
for i in list_A:
    hp.heappush(a_q, -1*i)
    
for i in range(m):
    tmp = hp.heappop(a_q)
    tmp = hp.heappush(a_q, int(tmp/2))
    
print(-sum(a_q))

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n, x, y; cin>>n>>x>>y;
	x = x-1; y= y-1;
	vector<int> ans(n,0);
	REP(i,n-1){
		FOR(j,i+1,n){
			int k = min(j-i,abs(i-x)+abs(j-y)+1);
			ans[k]++;
		}
	}
	FOR(i,1,n) cout<<ans[i]<<endl;
    return 0;
}

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

#define int long long

signed main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}



Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val h, w = sc.nextInt
    sc.nextLine
    val s = new Array[Array[Char]](h)
    for (i <- 0 until h) {
      s(i) = sc.nextLine.toCharArray
    }

    // 上下左右
    val DI = Array(-1, 0, 1, 0)
    val DJ = Array(0, -1, 0, 1)

    var ans = true
    for (si <- 0 until h; sj <- 0 until w) {
      if (s(si)(sj) == '#') {
        // 自身が#ならば、周囲に#があるかをチェック
        var count = 0
        for (i <- 0 until 4) {
          val ni = si + DI(i)
          val nj = sj + DJ(i)
          if (
            ((ni >= 0 && ni < h) && (nj >= 0 && nj < w)) // 枠内に収まる
              && s(ni)(nj) == '#' // 到達不可能マス
          ) {
            count += 1
          }
        }
        if (count == 0) ans = false
      }
    }
    println(if (ans) "Yes" else "No")
  }
}


Measured memory_bytes: 27352
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  cout << (a*b%2==0 ? "No" : "Yes") << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        mut a: [i64; n]
    }

    let mut ans = 0i64;
    for i in 0..n-1 {
        ans += a[i] / 2;
        a[i] %= 2;
        if a[i] == 1 && a[i+1] > 0 {
            ans += 1;
            a[i+1] -= 1;
        }
    }
    ans += a[n-1] / 2;
    println!("{}", ans);
}


Measured memory_bytes: 3720
from collections import defaultdict

N, M = map(int, input().split())
H = list(map(int, input().split()))

AB = [list(map(int, input().split())) for _ in range(M)]

temp = [0] * N

# dic = defaultdict(int)
lst = [True] * N
for a, b in AB:
    # if a <= b:
    #     dic[(a, b)] += 1
    # else:
    #     dic[(b, a)] += 1

    lst[a - 1] = False
    lst[b - 1] = False

for a, b in AB:
    # if a <= b:
    #     if dic[(a, b)] >= 2:
    #         continue
    # else:
    #     if dic[(b, a)] >= 2:
    #         continue

    temp[a - 1] = max(temp[a - 1], H[b - 1])
    temp[b - 1] = max(temp[b - 1], H[a - 1])


cnt = 0
for i in range(N):
    if H[i] > temp[i] or lst[i]:
        cnt += 1

print(cnt)


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

int main()
{
    int i,d,j,k,n=0,m;
    string s; cin>>s;
    for(i=0;i<4;i++)
    {
        if(s[i]=='+') n++;
        else n--;
    }
    cout<<n;

}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let a: i64 = s.next().unwrap().parse().unwrap();
	let b: i64 = s.next().unwrap().parse().unwrap();
	let c: i64 = s.next().unwrap().parse().unwrap();
	let d: i64 = s.next().unwrap().parse().unwrap();
	let v = vec![a * d, a * c, b * d, b * c];
	println!("{}", v.iter().max().unwrap());
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e7+9;
int main()
{
    FASTINOUT;
    int ans=0,y;
    int x;
    cin>>x;
    set<int>s;
    for (int i=0;i<x;i++){
        cin>>y;
        if (i==0){
            ans++;
            s.insert(y);
            continue;
        }
        if (*s.begin()>y)
            ans++;
        s.insert(y);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> vec(n);
    for (int i = 0; i < q; ++i) {
        int val;
        cin >> val;
        vec[--val]++;
    }
    for (int i = 0; i < n; ++i) {
        if (q - vec[i] >= k) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 1024
N,X,M = gets.split.map &:to_i
A = [p]*M
I = [p]*M
H = {0=>0,X=>1}
S = [0,s=X]
A[0] = I[0] = 0
I[X] = n=1
A[1] = x=X
while M > n+=1
  M>x*=x or x%=M
  break  if I[x]
  I[x] = n
  A[n] = x
  S[n] = s+=x
end
exit 0&p(S[N]) if S[N]
exit 0&p(s) if x==0
i = I[x]
L = A[i...n]
T = S[i...n]
d = T[0] - L[0]
q,r = (N-i).divmod L.size
p q*(s-d) + T[r]

Measured memory_bytes: 16260
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,m,k;
    cin>>n>>m>>k;
    string s[n];
    for(int i=0;i<n;i++)
    cin>>s[i];
    int lim1=(1 << n);
    int lim2=(1 << m);
    int ans=0;
    for(int i=0;i<lim1;i++)
    {
        for(int j=0;j<lim2;j++)
        {
            string temp[n];
            for(int i=0;i<n;i++)
            temp[i]=s[i];
            for(int i1=0;i1<n;i1++)
            {
                for(int j1=0;j1<m;j1++)
                {
                    //cout<<i<<" "<<i1<<" "<<j<<" "<<j1<<"\n";
                    if((i&(1 << i1))||(j&(1 << j1)))
                    temp[i1][j1]='@';
                }
            }
            int c=0;
            //print2d(temp,n-1,m-1);
            //cout<<"\n";
            for(int i1=0;i1<n;i1++)
            {
                for(int j1=0;j1<m;j1++)
                {
                    if(temp[i1][j1]=='#')
                    c++;
                }
            }
            if(c==k)
            ans++;
        }
    }
    cout<<ans;
}

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

using namespace std;

int main()
{
  int A, B, K; cin >> A >> B >> K;

  vector<int> cd;
  for (int i = min(A, B); i >= 1; --i) {
    if (A % i == 0 and B % i == 0) cd.push_back(i);
  }

  cout << cd.at(K-1);
}

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

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

  int sSize = s.size();
  vector<char> ans;

  for(char i = 'a'; i <= 'z'; i++){
    for(int j = 0; j < sSize; j++){
      if(i == s[j]) break;
      if(s[j] != i && j == sSize-1){
        ans.push_back(i);
      }
    }
  }

  if(ans.empty()){
    cout << "None" << endl;
  }

  else{
    sort(ans.begin(), ans.end());

    cout << ans[0] << endl;

  }

  return 0;

}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a,b;cin>>a>>b;
	if(a <= 8 && b <= 8){
		cout << "Yay!";
	}else{
		cout << ":(";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, tar, tmp1, tmp2, tmp3;
    long long int c=0;
    cin >> n;
    tar=sqrt(n-1);

    for(int i=1; i<=tar; i++)
    {
        tmp1=(n-1)/i;
        tmp2=tmp1*2-1;
        tmp3=tmp2-((i-1)*2);
        c+=tmp3;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 1000005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int X,Y;
ll f[MAXN],res;

ll inv(ll a){
	ll x1 = 1, b1 = a, x2 = 0, b2 = MOD;
	while (b2) {
		ll q = b1/b2;
		b1-=q*b2, x1-=q*x2;
		swap(x1,x2);
		swap(b1,b2);
	}
	return ((x1%MOD)+MOD)%MOD;
}

ll cnk(ll n, ll k){
	if(k > n) return 0;
	ll q = (inv(f[k])*inv(f[n - k]))%MOD;
	return (f[n]*q)%MOD;
}

int main(){
	scanf("%d %d",&X,&Y);
	f[0] = 1;
	for(int i=1; i<=1e6; i++)
		f[i] = (f[i-1]*i)%MOD;
	for(int i=0; i<=X; i++){
		int remX = X-i, remY = Y-2*i;
		if(remX == remY*2) res = (res+cnk(i+remY,i))%MOD;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 8064
N = int(input())
H = list(map(int, input().split()))
ans = 0
L = 0
count = 0
for i in range(N):
    if L >= H[i]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
    L = H[i]
ans = max(ans, count)
print(ans)


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

int main(){
    int n, i;
    cin >> n;
    int a[n], b[n];
    for(i=0; i<n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a+n);
    for(i=0; i<n; i++){
        if(b[i] >= a[n/2]){
            cout << a[n/2-1] << '\n';
        }else{
            cout << a[n/2] << '\n';
        }
    }
    return 0;
}

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

int main() {
  long long H, W;
  cin >> H >> W;

  if (H == 1 || W == 1) {
    cout << "1" << endl;
    return 0;
  }

  long long k = W / 2, g = W / 2;
  if (W % 2 != 0) {
    k++;
  }

  long long sum = 0;
  for (long long i = 1; i <= H; i++) {
    if (i % 2 == 0) {
      sum += g;
    } else {
      sum += k;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, a, b;
  cin >> N;
  if (N == 2){
	cin >> a >> b;
  }
  if (N == 1){
	cout << "Hello World" << endl;
  }
  else{
    cout << a + b << endl;
  }
    
  return 0;
}
  
    
   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int>a(3);
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a.begin(),a.end());
  if(a[0]==a[1])cout<<a[2]<<endl;
  else cout<<a[0]<<endl; 
}


Measured memory_bytes: 256
// Or Plus Max.cpp: 定义控制台应用程序的入口点。
// XG_Zepto, 7/4/2018. All rights reserved.

// #include "stdafx.h"
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define maxn 2000100
using namespace std;
int n,a[maxn],f[maxn][2],ans[maxn];
void work(int x,int y){
	if (f[x][0]==y||f[x][1]==y) return;
	if (a[f[x][1]]<a[y]){
		f[x][1]=y;
		if (a[f[x][0]]<a[f[x][1]]) swap(f[x][0],f[x][1]);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<(1<<n);i++){
		cin>>a[i];f[i][0]=i;
	}
	for (int x=0;x<(1<<n);x++)
		for (int j=0;j<n;j++){
			if ((x>>j)&1) continue;
			work(x|(1<<j),f[x][0]);
			work(x|(1<<j),f[x][1]);
		}
	for (int i=1;i<(1<<n);i++){
		ans[i]=max(ans[i-1],a[f[i][0]]+a[f[i][1]]);
		cout<<ans[i]<<endl;
	}
//	system("PAUSE");
    return 0;
}

Measured memory_bytes: 10240
_, *A = map(int, open(0).read().split())

ret = 0
for a in A:
    if a == 2:
        ret += 1
    else:
        if a % 2 == 0:
            continue
        else:
            flag = True
            for i in range(3, int(a**0.5)+2, 2):
                if a % i == 0:
                    flag = False
                    break
            if flag:
                ret += 1
                
print(ret)


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

string N;

int main() {
    cin >> N;

    int tmp;
    rep(i, N.size()) {
        string s { N[i] };
        tmp += stoi(s);
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        // 出力
        if(n < 10){
            System.out.println(n);
            return;
        }
        if(n < 100){
            System.out.println(9);
            return;
        }
        if(n < 1000){
            System.out.println(n-90);
            return;
        }
        if(n < 10000){
            System.out.println(909);
            return;
        }
        if(n < 100000) {
            System.out.println(n - 10000 + 910);
            return;
        }
        System.out.println(90909);
    }
}


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

using namespace std;
#define ll long long

#define PI 3.14159265358979323846

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double ang = abs(30.0 * h - (5.5 * m));

	double ans = a * a + b * b - 2.0 * a * b * cos(ang * PI / 180.0);

	ans = sqrt(ans);

	cout << fixed << setprecision(20) << ans << "\n";


	return 0;

}

Measured memory_bytes: 4180
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		int Q=stdIn.nextInt();
		Deque<Character> ans=new ArrayDeque<Character>();
		for(int i=0;i<S.length();i++){
			ans.add(S.charAt(i));
		}
		boolean key=false;
		for(int i=0;i<Q;i++){
			int q=stdIn.nextInt();
			if(q==1)
				if(key==false)
					key=true;
				else
					key=false;
			else{
				int f=stdIn.nextInt();
				char a=stdIn.next().charAt(0);
				if((f==1&&key==false)||(f==2&&key)){
					ans.addFirst(a);
				}
				else{
					ans.add(a);
				}
			}
		}
		int x=ans.size();
		if(key){
			for(int i=0;i<x;i++){
				System.out.print(ans.pollLast());
			}
			System.out.println();
		}
		else{
			for(int i=0;i<x;i++){
				System.out.print(ans.poll());
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 158744
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll a,b,v,w,t;
cin>>a>>v>>b>>w>>t;
ll dis=abs(a-b);
if(v<w)
{
    cout<<"NO"<<endl;
}
else if(t*(v-w)>=dis)
{
    cout<<"YES"<<endl;
}
else
{
    cout<<"NO"<<endl;
}
return 0;
}


Measured memory_bytes: 3644
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<pl, ll>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll a, b, i,j;
    cin>>a>>b;
   ll ans= (a*b)/__gcd(a,b);

   cout<<ans;
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int H, W;
    scanf("%d %d", &H, &W);
    while( !( H == 0 && W == 0)){
        for(int i = 0; i < W; ++i){
            printf("#");
        }
        printf("\n");
        for(int i = 0; i < H - 2; ++i){
             printf("#");
             for(int j = 0; j < W -2; ++j){
                 printf(".");
             }
             printf("#");
             printf("\n");
        }
        for(int i = 0; i < W; ++i){
            printf("#");
        }
        printf("\n");
        printf("\n");
        scanf("%d %d", &H, &W);
    }
    return 0;
}

Measured memory_bytes: 1000
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-06-05 12:52:44
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

#if __cplusplus >= 201703L
template <class Ch, class Tr, class Tuple, std::size_t... Is>
void tuple_out(std::basic_ostream<Ch, Tr>& os, const Tuple& tp, std::index_sequence<Is...>) {
  ((os << (Is ? ", " : "(") << std::get<Is>(tp)), ...) << ")";
}

template <class Ch, class Tr, class... Args>
auto& operator<<(std::basic_ostream<Ch, Tr>& os, const std::tuple<Args...>& tp) {
  tuple_out(os, tp, std::index_sequence_for<Args...>{});
  return os;
}
#endif

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class Compare>
std::ostream& operator<<(std::ostream& os, const std::set<T, Compare>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U, class Compare>
std::ostream& operator<<(std::ostream& os, const std::map<T, U, Compare>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  string s; cin >> s;
  for (char c : s) {
    if (c == '?') {
      cout << 'D';
    } else {
      cout << c;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll iro[114514],cc[3];
vector<ll> pat[114514];
signed main(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	for(ll i=0;i<m;i++){
		ll ta,tb;
		cin>>ta>>tb;
		pat[ta].pb(tb);
		pat[tb].pb(ta);
	}
	queue<ll> que;
	que.push(1);
	iro[1]=1;
	cc[1]++;
	while(!que.empty()){
		ll cx = que.front();que.pop();
		for(ll i=0;i<pat[cx].size();i++){
			ll cy = pat[cx][i];
			if(iro[cy]==0){
				iro[cy]=3-iro[cx];
				cc[iro[cy]]++;
				que.push(cy);
			}
			else if(iro[cx]+iro[cy]!=3){
				cout<<n*(n-1)/2 - m<<endl;
				return 0;
			}
		}
	}
	cout<<cc[1]*cc[2]-m<<endl;
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(void)
{
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    int G=A+B+C+D;
    int H=0;
    int I=2000;
    if(A<I)
    {
        I=A;
    }
    if(B<I)
    {
        I=B;
    }
    if(C<I)
    {
        I=C;
    }
    if(D<I)
    {
        I=D;
    }
    H+=G-I;
    if(E<F)
    {
        H+=F;
    }
    else
    {
        H+=E;
    }
    cout<<H<<endl;
    return 0;
}


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

int main(void){
    int n; cin >> n;
    vector<int> p(n);
    vector<int> tmp(n);
    
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    tmp = p;
    
    sort(p.begin(), p.end());
    
    int flag = 0;
    string ans = "YES";
    for(int i = 0; i < n; i++){
        if(p.at(i) != tmp.at(i)){
            flag++;
        }
        
        if(flag == 3){
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    
       
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

//		long ans = 0;
//		double ans = 0.0;
		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);
//		double waru = 1000000007;


//		long n = sc.nextLong();
//		long m = sc.nextLong();
//		long k = sc.nextLong();

		int n = sc.nextInt();
		int m = sc.nextInt();
//		int k = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

		boolean f = false;

//		String[] s = new String[n];

//		int[] a = new int[n];
//		int[] b = new int[n];
//		long[] a = new long[n];
//		long[] b = new long[n];
//		int[][] a = new int[n][m];

//		for (int i = 0; i < n; i++) {
//			a[i]= sc.nextInt();
//		}

//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}




		if(n==m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}







//		System.out.println(ans);

		sc.close();
	}


}

Measured memory_bytes: 23764
#include<stdio.h>
int a[100001];
int com[100001],x[100001],y[100001],b[100001];
int B=2000;
int n,q;
void put(int a[100001]);
int min(int a,int b);
void update(int i,int x);
void find(int s,int t);
int main(void){
  put(a);
  int i;
  scanf("%d %d",&n,&q);
  for(i=0;i<q;i++){
    scanf("%d %d %d",&com[i],&x[i],&y[i]);
    if(com[i]==0)
      update(x[i],y[i]);
    else if(com[i]==1)
      find(x[i],y[i]);
  }
  return 0;
}
int min(int a,int b){
  if(a<=b)
    return a;
  else
    return b;
}
void update(int i,int x){
  int j;
  a[i]=x;
  b[i/B]=2147483647;
  for(j=i-i%B;j<min(i-i%B+B,n);j++){
    b[i/B]=min(b[i/B],a[j]);
  }
}
void find(int s,int t){
  int ans=2147483647;
  int j;
  for(j=s;j<=t;){
    if(j%B==0 && j+B<=t-1){
      ans=min(ans,b[j/B]);
      j+=B;
    }else{
      ans=min(ans,a[j]);
      j++;
    }
  }
  printf("%d\n",ans);
}
void put(int a[100001]){
  int i;
  for(i=0;i<100001;i++)
    a[i]=2147483647,b[i]=2147483647;
}

Measured memory_bytes: 2552
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main(void){
	
	int n, k, l, tmp, br, a[100000],gud;
	br = 0;
	gud = 0;

	cin >> n;

	for (k = 0; k < n; k++) {
		cin >> a[k];
		if (a[k] == 1) {
			cout << "1\n";
			br = 1;
		}
		if (br == 1)break;
	}

	while(1) {

		sort(a, a + n);

		if (a[0] == a[n - 1])break;

		for (l = 1; l < n; l++) {
			tmp = a[l] % a[0];
			if (tmp != 0) {
				a[l] = tmp;
			}
			else {
				a[l] = a[0];
			}
			
		}

	/*	for (l = 0; l < n; l++) {
			cout << a[l] << " ";
		}*/
		cout << "\n";
	}

	sort(a, a + n);

	cout << a[n - 1] << "\n";


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> m;
    m[a]++;
    m[b]++;
    m[c]++;
    if (m[5] == 2 && m[7] == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        cout << s[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int N = s.size();
  int cnt = 0, score = 0;
  REP(i, N) {
    bool ok = (cnt + 1) <= i - cnt;
    if (ok) {
      cnt++;
      if (s[i] == 'g')
        score++;
    } else if (s[i] == 'p' && !ok) {
      score--;
    }
    //    DEBUG(cnt);
  }
  print(score);
}

Measured memory_bytes: 512
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int F[45]={0};
int f(int n){
	if (n==1||n==0) return F[n]=1;
	if (F[n]) return F[n];
	else return F[n]=f(n-1)+f(n-2);
}
main(){
	int n;scanf("%d",&n);
	printf("%d\n",f(n));
}



Measured memory_bytes: 3228
#include <cstdio>

int m,nmin,nmax,p[200];

int main(){
	while(scanf("%d%d%d",&m,&nmin,&nmax), m != 0){
		for(int i = 0; i < m; i++){
			scanf("%d",&p[i]);
		}
		int gap = -1, n = 0;
		for(int i = nmin; i <= nmax; i++){
			int tmp = p[i-1] - p[i];
			if(tmp >= gap){
				gap = tmp;
				n = i;
			}
		}
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 2656
import collections

n = int(input())


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


sieve = eratosthenes(n)

res = 0
for k in range(1, n + 1, 2):
    counter = collections.Counter()
    for i in range(1, k):
        if sieve[i]:
            while k % i == 0:
                counter[i] += 1
                k //= i
    p = 1
    for v in counter.values():
        p *= v + 1
    if p == 8:
        res += 1

print(res)

Measured memory_bytes: 3316
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  int N; cin >> N;
  map<string, bool> U;
  rep(i, N) {
    string s; cin >> s;
    U[s] = true;
  }

  bool closed = true;
  int M; cin >> M;
  rep(i, M) {
    string T; cin >> T;
    if (U[T] == false) {
      cout << "Unknown " << T << endl;
    }
    else {
      cout << (closed ? "Opened" : "Closed") << " by " << T << endl;
      closed ^= true;
    }
  }

  return 0;
}

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

using namespace std;

string S;

int main(void) {
	cin >> S;

	int N = S.size();

	for (int i = 0; i < N; i++) {
		cout << "x";
	}cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    ret, max_h = 0, A[0]
    for n in range(N):
        if max_h > A[n]:
            ret += max_h - A[n]
            max_h = A[n] + (max_h - A[n])
        else:
            max_h = max(max_h, A[n])
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  char c;
  in3(a, c, b);
  if(c == '+')
    out(a + b);
  else
    out(a - b);
  memi;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val against = (for(_ <- 0 until m) yield
    io.StdIn.readLine().split(' ').map(_.toInt) match {
      case Array(a, b) => (a-1, b-1)
    }).sortWith{case (x, y) => x._2 < y._2}

  var end = 0
  var count = 0
  for ((a,b) <- against) {
    if (end <= a) {
      end = b
      count += 1
    }
  }

  println(count)
}

Measured memory_bytes: 64496
s = gets.chomp.to_i
arr = [0]*3

if s >= 3600
	arr[0] = s / 3600
	s = s % 3600
end

if s >= 60
	arr[1] = s / 60
	s = s % 60
end

arr[2] = s

answer = arr.join(":")
puts answer

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

int main(){
  string s; cin >>s;
  int a=0, b=0, c=0;
  int n = s.size();
  rep(i,n){
    if(s[i]=='a') a++;
    else if(s[i]=='b') b++;
    else c++;
  }
  if(abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                ans += i;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

#define ll long long

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

	int n;
	cin >> n;
	
	ll g = 0;
	for (int i = 1; i < n+1; i++)
	{
		ll j = floor(n / i);
		g += j * (j + 1)*i / 2;
	}
	cout << g<<endl;
	return 0;
}


Measured memory_bytes: 3596
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/debug.hpp"

// https://codeforces.com/blog/entry/68809
void debug_print(int x) {cerr << x;}
void debug_print(long x) {cerr << x;}
void debug_print(long long x) {cerr << x;}
void debug_print(unsigned x) {cerr << x;}
void debug_print(unsigned long x) {cerr << x;}
void debug_print(unsigned long long x) {cerr << x;}
void debug_print(float x) {cerr << x;}
void debug_print(double x) {cerr << x;}
void debug_print(long double x) {cerr << x;}
void debug_print(char x) {cerr << '\'' << x << '\'';}
void debug_print(const char *x) {cerr << '\"' << x << '\"';}
void debug_print(const string &x) {cerr << '\"' << x << '\"';}
void debug_print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void debug_print(const pair<T, V> &x) {cerr << '{'; debug_print(x.first); cerr << ','; debug_print(x.second); cerr << '}';}
template<typename T> void debug_print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), debug_print(i); cerr << "}";}

void debug_print_() {cerr << "]\n";}
template <typename T, typename... V>
void debug_print_(T t, V... v) {debug_print(t); if (sizeof...(v)) cerr << ", "; debug_print_(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; debug_print_(x)
#else
#define debug(x...)
#endif
#line 3 "d.cpp"

int main() {
  ll a, b, n;
  cin >> a >> b >> n;

//  rep(x, n+1) {
//    ll l = a*x/b;
//    ll r = a*(x/b);
//    debug(x, l, r, l-r);
//  }

  ll x = min(b-1, n);
  cout << a*x/b - a*(x/b) << el;
}


Measured memory_bytes: 3640