akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

ll dp[205][205][205];

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	reverse(all(a));
	int l=2,r=2;
	for(int i=0;i<n;i++){
		if(l%a[i]){
			l+=(a[i]-l%a[i]);
		}
		r-=r%a[i];
		if(l>r){
			cout<<-1;
			return;
		}
		r+=a[i]-1;
	}
	int flag=l,flag2=r;
	for(int i=n-1;i>=0;i--){
		flag-=flag%a[i];
		flag2-=flag2%a[i];
	}
	if(flag==2){
		cout<<l<<' '<<r;
	}
	else{
		cout<<-1;
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb emplace
#define pi pair <int, int>
#define f first
#define s second
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

char G[150][150];
int h, w, dist[150][150];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
queue <pi> q;

void bfs() {
    memset(dist, -1, sizeof(dist));
    pi source = make_pair(1, 1);
    dist[source.f][source.s] = 0;
    q.pb(source.f, source.s);
    while (q.size()) {
        int y = q.front().f;
        int x = q.front().s;
        q.pop();
        for(int i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny > h || ny < 1 || nx > w || nx < 1) continue;
            if (G[ny][nx] == '#') continue;
            if (dist[ny][nx] == -1) {
                q.emplace(ny, nx);
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int white = 0;
    cin >> h >> w;
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            cin >> G[i][j];
            if (G[i][j] == '.') ++white;
        }
    }
    bfs();
    if (dist[h][w] == -1) {
        cout << -1;
        time;
    }
    else {
        cout << white - dist[h][w] - 1;
        time;
    }
}

Measured memory_bytes: 3996
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    unsigned long long a[n];
    for(int i=0;i<n;i++)cin >> a[i];

    bool flg = true;
    int cnt = -1;
    while(flg){
        cnt++;
        for(int i=0;i<n;i++){
            if(a[i]%2!=0){
                flg = false;
                break;
            }
            a[i] /= 2;
        }
    }
    cout << cnt << endl;
}


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

vector<long long> divisor(long long n)
{
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(n / i);
            if (n != 1)
                ret.push_back(i);
        }
    }
    return ret;
}

ll gcd(ll m, ll n)
{
    if (m < n)
    {
        ll tmp = m;
        m = n;
        n = tmp;
    }

    while (1)
    {
        ll mod = m % n;
        if (mod == 0)
            return n;
        m = n;
        n = mod;
    }
}

int main()
{
    ll a, b;
    cin >> a >> b;
    vector<ll> c = divisor(gcd(a, b)), d;
    // for (ll i = 1; i * i <= min(a, b); i++)
    //     if (a % i == 0 && b % i == 0)
    //         c.push_back(i);
    // if (a == b)
    //     c.push_back(a);
    sort(c.begin(), c.end());
    // rep(i, c.size()) cout << c[i] << endl;
    for (ll i = 0; i < c.size(); i++)
    {
        ll flag = 0;
        for (ll j = 0; j < d.size(); j++)
        {
            if (gcd(c[i], d[j]) != 1)
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
            d.push_back(c[i]);
    }
    // rep(i, d.size()) cout << d[i] << endl;
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 3696
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	chunks := strings.Split(sc.Text(), " ")
	m, _ := strconv.Atoi(chunks[1])

	type city struct {
		pref int
		id   string
	}

	cities := []*city{}
	cityIdxByYear := make(map[int]int)
	years := []int{}

	for i := 0; i < m; i++ {
		sc.Scan()
		chunks := strings.Split(sc.Text(), " ")
		pref, _ := strconv.Atoi(chunks[0])
		year, _ := strconv.Atoi(chunks[1])
		cities = append(cities, &city{pref: pref})
		cityIdxByYear[year] = i
		years = append(years, year)
	}

	sort.IntSlice(years).Sort()
	idxByPref := make(map[int]int)

	for _, y := range years {
		city := cities[cityIdxByYear[y]]
		idxByPref[city.pref]++
		idx := idxByPref[city.pref]

		city.id = fmt.Sprintf("%06d%06d", city.pref, idx)
	}

	for _, c := range cities {
		fmt.Println(c.id)
	}
}


Measured memory_bytes: 22164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = 0;
		long max = 0;
		long sum = 0;
		for(int i = 0; i < N; i++) {
			long A = sc.nextInt();
			if (i == 0) {
				min = A;
				max = A;
				sum = A;
			}
			else {
				if (A < min)	min = A;
				if (A > max)	max = A;
				sum = sum + A;
			}
		}
		System.out.println(min + " " + max + " " + sum);
	}
}



Measured memory_bytes: 42544
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  auto div = divisor(X);
  rep(A, 1001) {
    for (int d : div) {
      int B = A - d;
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << ' ' << B << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n; cin >>n;
  vector<int> a(n),b(n),c(n);
  rep(i, n) cin >>a.at(i); rep(i, n) cin >>b.at(i); rep(i, n) cin >>c.at(i);
  sort(all(a)); sort(all(c));
  ll res = 0;
  rep(i, n){
    int ok = -1, ng = a.size();
    while (abs(ok-ng)>1){
      int mid = (ok+ng)/2;
      if (a[mid] < b[i]) ok = mid;
      else ng = mid;
    }
    ll x = ok+1;
    ok = c.size(), ng = -1;
    while (abs(ok-ng)>1){
      int mid = (ok+ng)/2;
      if (c[mid] > b[i]) ok = mid;
      else ng = mid;
    }
    ll y = n - ok;
    res += x * y;
  }
  cout <<res <<endl;
}


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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int a,b;
  cin>>a>>b;
  cout<<a*b;
}


Measured memory_bytes: 3644
n = gets.to_i
a = gets.split.map( &:to_i )
a = [ 0 ] + a + [ 0 ]

t = 0
for i in 1...a.size do
  t += ( a[ i ] - a[ i - 1 ] ).abs
end

for i in 1..n
  x = ( a[ i ] - a[ i - 1 ] ).abs
  y = ( a[ i + 1 ] - a[ i ] ).abs
  z = ( a[ i + 1 ] - a[ i - 1 ] ).abs
  puts ( t - ( x + y ) + z )
end



Measured memory_bytes: 12548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[4],i,t,m,ans,per;
    for(i=0; i<3; i++)
        cin>>a[i];
    sort(a,a+3);
    t=a[2]-a[1];
    a[0]=a[0]+t;
    m=a[2]-a[0];
    ans=m/2;
    if(m%2!=0)
        ans=ans+2;
    per=ans+t;
    cout<<per<<endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main(){
    int n;cin >>n;
    UnionFind uni(n);
    vector<pair<P,int>>c(n);
    vector<pair<int,P>>e;
    for (int i = 0; i < n; ++i) {
        int x,y;cin >>x>>y;
        x--;y--;
        c[i].second=i;
        c[i].first.first=x;
        c[i].first.second=y;
    }
    sort(all(c));
    for (int i = 0; i < n-1; ++i) {
        e.push_back({c[i+1].first.first-c[i].first.first,{c[i].second,c[i+1].second}});
    }
    for (int i = 0; i < n; ++i) {
        swap(c[i].first.first,c[i].first.second);
    }
    sort(all(c));
    for (int i = 0; i < n-1; ++i) {
        e.push_back({c[i+1].first.first-c[i].first.first,{c[i].second,c[i+1].second}});
    }
    sort(all(e));
    ll ans=0;
    for(auto i:e){
        if(!uni.same(i.second.first,i.second.second)){
            ans+=i.first;
            uni.unite(i.second.first,i.second.second);
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 7968
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int preans;
    preans = min({(a-1)%10, (b-1)%10, (c-1)%10, (d-1)%10, (e-1)%10});
    preans += 1;

    int ans = 0;
    ans += 4 + (a-1)/10 + (b-1)/10 + (c-1)/10 + (d-1)/10 + (e-1)/10;
    ans *= 10;
    ans += preans;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')




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

main() {
    int N,M,X,Y; cin >> N >> M >> X >> Y; bool can =false;
    int A[N]; rep(i,N) cin >> A[i];
    int B[M]; rep(i,M) cin >> B[i];
    sort(A,A+N);
    sort(B,B+M);
    if(A[N-1]<B[0]){
        for(int i=A[N-1]+1;i<=B[0];i++){
            if(i>X && i<=Y)can=true;
        }
    }
    else can =false;
    if(can)cout << "No War"<< endl;
    else cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int N;	cin >> N;
	string s;	cin >> s;
	int am_w[N+1];
	memset(am_w, 0, sizeof(am_w));
	reps(i,N)	{
		if (s[i-1]=='W')	am_w[i]=am_w[i-1]+1;
		else am_w[i]=am_w[i-1];
	}
	// 
	// reps(i,N)	cout << am_w[i] ;
	// cout << endl;


	int ans = 300000;
	rep(i,N)	{
		int tmp = am_w[i]+(N-i-1)-(am_w[N]-am_w[i+1]);
		if (ans > tmp)	ans = tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1796
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int x[52], y[52];
    for(int i=0; i<n; i++) cin>>x[i]>>y[i];
    int ans=n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) continue;
            int p=x[i]-x[j], q=y[i]-y[j];
            int cnt=n;
            for(int k=0; k<n; k++){
                for(int l=0; l<n; l++){
                    if(p==x[k]-x[l] && q==y[k]-y[l]) cnt--;
                }
            }
            ans=min(ans, cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;
    int ret = Inf;
    for(int i = 0;i <= max(X,Y);i++) {
        int a = max(0,X - i);
        int b = max(0,Y - i);
        ret = min(ret,i * C + A * a + B * b);
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
def f(n):
    if n % 2:
        return 3 * n + 1
    else:
        return n // 2

s = ii()
d = defaultdict(int)
d[s] = 1

while True:
    if d[f(x)] == 1:
        print()
    d[f(x)] += 1
    x = f(x)
'''

n = ii()
if n == 3 or n == 5 or n == 7:
    print('YES')
else:
    print('NO')




Measured memory_bytes: 9364
N,M = map(int,input().split())
S = []
T = []
for _ in range(N):
  a,b = map(int,input().split())
  S.append( (a,b) )
for _ in range(M):
  a,b = map(int,input().split())
  T.append( (a,b) )
for (a,b) in S:
  ans = 0
  best = 0
  for i in range(M):
    c,d = T[i]
    here = abs(a-c)+abs(b-d)
    if ans == 0 or best > here:
      ans = (i+1)
      best = here
  print(ans)

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

using namespace std;

int h, w, k;
int cnt, ans;

int main() {

    scanf("%d %d %d", &h, &w, &k);
    vector<vector<char>> map(h, vector<char>(w, 0));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            scanf(" %c", &map[i][j]);
        }
    }

    for (int mask_h = 0; mask_h < (1 << h); ++mask_h) {
        for (int mask_w = 0; mask_w < (1 << w); ++mask_w) {
            cnt = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if (((mask_h >> i) & 1) == 0 && ((mask_w >> j) & 1) == 0 && map[i][j] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3784
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))

if X < Y and x[-1] < Y and X < y[0] and x[-1] < y[0] :
    print('No War')
else:
    print('War')


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

vector<long long> make_divisors(long long n){
    vector<long long> divisors;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i*i != n) divisors.push_back(n/i);
        }
    }
    // sort(divisors.begin(), divisors.end());
    return divisors;
}

void Main(){
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i]; SORT(A);
    VI exist(1000001,0);

    int ans = 0;
    REP(i,N){
        if(exist[A[i]] == 0){
            if(!(i<N-1 && A[i]==A[i+1])) ans++;
        }
        if(i>0 && A[i]==A[i-1]) continue;
        for(int j=A[i]; j<=1000000; j+=A[i]){
            exist[j] = 1;
        }
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 8740
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int M1,D1,M2,D2;
    cin >> M1 >> D1 >> M2 >> D2;
    int X1 = M1 * 100 + D1;
    int X2 = M2 * 100 + D2;
    if (M1 != M2) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
k = int(input())

flag = False

resid  = 7
if resid%k==0:
    i = -1
    flag = True
else:
    for i in range(k):
        resid = (resid*10+7)%k
        if resid == 0:
            flag = True
            break

if flag:
    print(i+2)
else:
    print(-1)

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int count = 0;

		while(true) {
			int x = scan.nextInt();
			if (x == 0)
				break;
			count++;
			System.out.println("Case " + count + ": " + x);
		}
	}

}

Measured memory_bytes: 41060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  double stack[128];
  int n,i;
  char str[128],*adr;
  //int l;
  while(fgets(str,sizeof(str),stdin)!=NULL){
    adr=strtok(str," \n");
    n=0;
    for(i=0;i<128;i++) stack[i]=0;
    do{
      if(strcmp(adr,"+")==0){
	stack[n-2]+=stack[n-1];
	n--;
      }else if(strcmp(adr,"-")==0){
	stack[n-2]-=stack[n-1];
	n--;
      }else if(strcmp(adr,"*")==0){
	stack[n-2]*=stack[n-1];
	n--;
      }else if(strcmp(adr,"/")==0){
	stack[n-2]/=stack[n-1];
	n--;
      }else{
	stack[n]=atof(adr);
	n++;
      }
      adr=strtok(NULL," \n");
    }while(adr!=NULL);
    
    printf("%f\n",stack[0]);
  }
  return 0;
}

Measured memory_bytes: 576
#include <stdio.h>


int main(int argc, char **argv)
{
  char s[3];
  int i,nedan;
  nedan = 700;
  scanf("%s",s);
  for(i = 0 ; i < 3 ; i++){
    if(s[i] == 'o')
      nedan = nedan + 100;
  }
  printf("%d\n",nedan);

  return 0;
}


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

int main() {
  int A;
  int B;
  int C;
   cin >> A >> B >> C;
  
  std::swap(A,B);
  std::swap(A,C);
  
  cout << A << endl;
  cout << B << endl;
  cout << C << endl;
}

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

// varibable settings
// #define int long long
const int INF=1e9;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}


signed main() {
  int n;cin>>n;
  if (n>=24){
    cout << 0 << endl;
    return 0;
  }

  vi d(n);
  vector<int> cnt(15);
  int mcnt = 0;
  rep(i, n){
    cin>>d[i];
    cnt[d[i]]++;
    chmax(mcnt, cnt[d[i]]);
  }
  dump(d);
  if (n>=13){
    // mind = 2は無理
    // mind = 1が達成可能かどうか
    // 重なっている点がないかどうか
    // d[i]で同一のものが３点以上あるとだめ
    if (mcnt>=3 || cnt[0]>=1){
      cout << 0 << endl;
    }
    else{
      cout << 1 << endl;
    }

    return 0;
  }


  int ans = 0;
  rep(mask, 1<<n){
    vector<int> exist(n+1, 0);
    rep(i, n){
      if (mask&(1<<i)){ exist[i+1] = d[i]; }
      else{ exist[i+1] = 24-d[i]; }
    }
    sort(all(exist));

    int mind = INF;
    rep(u, sz(exist)){
      int v = (u+1)%sz(exist);
      int d = abs(exist[u]-exist[v]);
      chmin(mind, min(d, 24-d));
      if (mind<ans) break;
    }
    chmax(ans, mind);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
a = sorted(a)
A = a[0]
B = a[1]
C = a[2]
if A%2 == 0 and B%2 == 0 and C%2 == 0:
  ans = (C-A)/2 + (C-B)/2
elif A%2 == 0 and B%2 == 0 and C%2 == 1:
  ans = (C-A-1)/2 + (C-B-1)/2 +1
elif A%2 == 0 and B%2 == 1 and C%2 == 0:
  ans = (C-A)/2 + (C-B+1)/2 +1
elif A%2 == 1 and B%2 == 0 and C%2 == 0:
  ans = (C-A+1)/2 + (C-B)/2 +1
elif A%2 == 1 and B%2 == 1 and C%2 ==0:
  ans = (C-A-1)/2 + (C-B-1)/2 +1
elif A%2 == 1 and B%2 == 1 and C%2 ==1:
  ans = (C-A)/2 + (C-B)/2
elif A%2 == 1 and B%2 == 0 and C%2 ==1:
  ans = (C-A)/2 + (C-B+1)/2 +1
elif A%2 == 0 and B%2 == 1 and C%2 ==1:
  ans = (C-A+1)/2 + (C-B)/2 +1
print(int(ans))

Measured memory_bytes: 3064
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = stdin.toString().trim().split('\n');

var S = parseInt(input[0], 10);
var h = Math.floor(S / 3600);
var m = Math.floor(S % 3600 / 60);
var s = S % 60;
console.log([h, m, s].join(':'));

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

// 迷走してる

int main() {
  ll n;
  cin >> n;
  vector<ll> g[n];
  ll a, b;
  vector<pair<int, int>> edge(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    edge[i] = make_pair(a, b);
  }
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());  // cを大きい順でソートしておく

  vector<int> deg(n);  // i番目にどの数字を入れるか
  int m = 0;           // 一番次数が大きい頂点を記録しておく
  for (int i = 0; i < n; i++) {
    if (g[m].size() < g[i].size()) m = i;
  }

  // BFSする
  queue<int> q;
  vector<bool> went(n);
  int count = 0;
  q.push(m);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    went[now] = true;

    deg[now] = v[count];
    count++;

    for (auto x : g[now])
      if (!went[x]) q.push(x);
  }

  ll sum = 0;
  for (int i = 0; i < n - 1; i++) {
    // 端点に書いてある数字を比較して、小さい方を合計に足す
    sum += min(deg[edge[i].first], deg[edge[i].second]);
  }

  // 出力
  cout << sum << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << deg[i] << " ";
  }
  cout << deg[n - 1] << endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - 1;
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (a[a[i]] == i) {
                c++;
            }
        }
        System.out.println(c / 2);
    }
}

Measured memory_bytes: 33300
import java.util.*;
class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	int n;
	while(true){
	    n = sc.nextInt();
	    if(n==0) break;

	    int[] milk = new int[n];
	    for(int i=0; i<n; i++)
		milk[i] = sc.nextInt();
	    Arrays.sort(milk);

	    long cost = 0;
	    for(int i=0; i<n; i++)
		for(int k=0; k<i; k++){
		    //System.out.println(i+" "+k);
		    cost += milk[k];
		}

	    System.out.println(cost);
	}
    }
}
	    
	    

Measured memory_bytes: 44904
#include <stdio.h>
 
void trace(int A[], int N[]){
int i;
for(i=0;i<N;i++){
	if(i>0){
		printf(" ");
	}
	printf("%d",A[i]);
}
	printf("\n");
}
 
void insertionSort(int A[], int N[]){
	int j,i,v;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}
int main(void) {
    int N,i,j;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++){
    	scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
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; }

int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int w, h;

void dfs(vector< vector<int> > &isisland, vector< vector<bool> > &vvisited, int x, int y) {
    // ここで島の色塗りを行う
    vvisited[y][x] = true;
    for(int i = 0; i < 8; ++i) {
        int nx = x+dx[i]; int ny = y+dy[i];
        if(nx >= 0 && nx < w && ny >= 0 && ny < h) {
            if(isisland[ny][nx] == 1 && !vvisited[ny][nx]) {
                dfs(isisland, vvisited, nx, ny);
            }
        }
    }
}

int main() {
    while(1) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        else {
            vector< vector<int> > island(h, vector<int>(w, 0));
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; ++j) {
                    cin >> island[i][j];
                }
            }

            vector< vector<bool> > visited(h, vector<bool>(w, false));
            int total = 0;
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; ++j) {
                    if(island[i][j] == 1 && !visited[i][j]) {
                        total++;
                        dfs(island, visited, j, i);
                    }
                }
            }
            cout << total << endl;
        }
    }    
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

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

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;


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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int k; cin >> k;
    string s; cin >> s;

    if (s.size() > k) {
        s = s.substr(0, k);
        s += "...";
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3612
# coding: utf-8
N=int(input())
F=[]
P=[]
for i in range(N):
    row=list(map(int,input().split()))
    F.append(row)

for i in range(N):
    row=list(map(int,input().split()))
    P.append(row)

ans=-10**10

for i in range(1,2**10):
    IB=list(format(i,'010b'))
    uriage=0
    for j in range(N):
        cnt=0
        for k in range(10):
            if F[j][k]==int(IB[k])==1:
                cnt+=1
        uriage+=P[j][cnt]
    ans=max(ans,uriage)

print(ans)


Measured memory_bytes: 3188
import kotlin.math.*

fun main() {
    println(solve())
}

val solve: () -> Any = {
    val S = readString()
    if (S == "RSR") 1
    else S.count { it == 'R' }
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = this.toDouble().pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

Measured memory_bytes: 34548
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>	
#include<limits>
#include<ctime>
#include<stack>	
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
	
typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}

int main() {
	ll a[5],mins=9,x,ans=0;
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(a[i]%10!=0){
			mins=min(a[i]%10,mins);
		}
		if(a[i]%10==mins){
			x=i;
		}
	}	
	for(int i=0;i<5;i++){
		if(i==x){
			ans+=a[i];
		}
		else{
			a[i]=((a[i]+9)/10)*10;
			ans+=a[i];
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>

template <class T>
std::vector<intmax_t> score(const std::vector<int> &a) {
  size_t N=a.size()/3;
  std::priority_queue<int, std::deque<int>, T> q;
  intmax_t sum=0;
  for (size_t i=0; i<N; ++i) {
    sum += a[i];
    q.emplace(a[i]);
  }

  std::vector<intmax_t> res{sum};
  for (size_t i=0; i<N; ++i) {
    sum += a[N+i];
    q.emplace(a[N+i]);
    sum -= q.top();
    q.pop();
    res.emplace_back(sum);
  }

  return res;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(3*N);
  intmax_t sum=0;
  for (size_t i=0; i<3*N; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  std::vector<intmax_t> sa=score<std::greater<int>>(a);
  std::reverse(a.begin(), a.end());
  std::vector<intmax_t> sb=score<std::less<int>>(a);
  std::reverse(sb.begin(), sb.end());

  intmax_t res=-1e14;
  for (size_t i=0; i<sa.size(); ++i)
    res = std::max(res, sa[i]-sb[i]);

  printf("%jd\n", res);
}


Measured memory_bytes: 4092
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <numeric>
const int MAXN = 105;
const int MAXS = 20;
int idx[MAXN];
int P[MAXN];
char S[MAXN][MAXS];
int N;

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf(" %s%d", S[i], &P[i]);
    }
    std::iota(idx, idx+N, 0);
    std::sort(idx, idx+N, [&](int l, int r) {
        int scp = strcmp(S[l], S[r]);
        if (scp != 0) {
            return scp < 0;
        }
        return P[l] > P[r];
    });
    for (int i = 0; i < N; ++i) {
        printf("%d\n", idx[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <std::uint_fast64_t Modulus>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 a;

    constexpr ModInt(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator-(const ModInt rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator*(const ModInt rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator/(const ModInt rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using mint = ModInt<MOD>;

long long modPow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

template <typename T>
using Vec = vector<T>;
template <typename T>
using VVec = vector<vector<T>>;
using LL = long long;
int main() {
    int N;
    cin >> N;
    Vec<int> v(N);
    REP(i, N) { cin >> v[i]; }
    sort(ALL(v));
    double ans = v[0];
    REP(i, N - 1) {
        ans = (double)(ans + (double)v[i + 1]) / 2.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
		long te = 0;
      	for(int i = 0;i<=num;i++){
          if(i%3==0 || i%5==0){
          }else{
            te += i;
          }
        }
      	System.out.println(te);
    }
}

Measured memory_bytes: 35740
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

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

	int n, k;
	cin >> n >> k;

	vi A(26);

	string p;
	REP(i, n) {
		cin >> p;
		A[p[0] - 'A']++;
	}

	int ans = 0;
	bool flag = false;
	while (true) {
		DESCSORT(A);
		REP(i, k) {
			if (A[i] == 0) {
				flag = true;
				break;
			}
			A[i]--;
		}

		if (flag) break;
		ans++;
	}

	cout << ans << "\n";
	return 0;
}

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

#define MAX ((int)(1e5)*2+100)

int N, A[MAX];
map<int,int> ma;
int main(){
	
	int count = 0, two = 1;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		ma[A[i]]++;
	}
	
	sort(A,A+N);
	
	for(;A[N-1] >= two; two*=2);
	
	for(int i = N-1; i >= 0; i--){
		for(;A[i]*2 < two; two/=2);//cout<<i<<" "<<A[i]<<" "<<two<<endl;
		if(A[i] == two-A[i]){
			if(ma[A[i]] >= 2){
				ma[A[i]] -= 2;
				count++;
			}
		} else if(ma[A[i]]&&ma[two-A[i]]){
			ma[two-A[i]]--;
			ma[A[i]]--;
			count++;
		}
	}
	
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 19712
# -*- coding: utf-8 -*-
import numpy as np

if __name__ == "__main__":
    # input
    a = [0, 0, 0]
    b = [0, 0, 0]

    for i in range(3):
        a[i], b[i] = map(int, input().split())

    a.extend(b)
    a = np.array(a)

    flag = True
    for i in range(1, 5):
        num = np.sum(i == a)
        if num > 2:
            flag = False

        elif num == 0:
            flag = False

    if flag is True:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 21620
def solve(i, m)
  if m == 0
    return true
  end
  if i >= $n
    return false
  end
  return solve(i+1, m) || solve(i+1, m - $arr[i])
end

$n = gets.to_i
$arr = gets.split.map(&:to_i)
q = gets
m_arr = gets.split.map(&:to_i)
m_arr.each do |m|
  if solve(0, m)
    puts "yes"
  else
    puts "no"
  end
end


Measured memory_bytes: 6864
m,a,N=0,[],gets.chomp.to_i
2.times{|i|a[i]=gets.split(' ').map(&:to_i)}
N.times{|i|m=[m, a[0].slice(0,i+1).inject(:+)+a[1].slice(i,N-i).inject(:+)].max}
puts m

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

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

 int main() {
   int N, a;
   cin >> N;
   map<int, int> count;

   rep(i, N) {
     cin >> a;
     count[a - 1]++;
     count[a]++;
     count[a + 1]++;
   }

   int ans = 0;
   rep(i, 100000) {
     ans = max(ans, count[i]);
   }

   cout << ans << endl;
 }


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N, M;
  cin >> N >> M;
  vec A(N);
  ll total = 0;
  REP(i, N) {
    cin >> A[i];
    total += A[i];
  }

  double min = total / double(4 * M);
  //   debug(min);

  SORT(A);

  if (A[N - M] < min) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

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

int main(){
    string n;
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n.size();i++){
        int x = n.at(i) - '0';
        ans += x;
        //printf("%d = %d\n", x, ans);
        ans %= 9;
    }

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

Measured memory_bytes: 3356