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

int main() {
  int n,k;
  std::string s;
  char last = '0';
  cin >> n >> k >> s;
  int a[114514]={0};
  int j=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'&&last=='1'){
      j++;
      a[j]=a[j-1]+1;
      last='0';
    }else if(s[i]=='0'){
      a[j]++;
    }else if(s[i]=='1'&&last=='0'){
      j++;
      a[j]=a[j-1]+1;
      last='1';
    }else if(s[i]=='1'){
      a[j]++;
    }
  }
  if(j<2*k)cout << n <<endl;
  else{
    int res=a[2*k-1];
    for(int i=0;2*i<=j-2*k-1;i++){
      if(res<a[2*k+2*i+1]-a[2*i])res=a[2*k+2*i+1]-a[2*i];
    }
    if(j%2==0&&a[j]-a[j-2*k]>res)res=a[j]-a[j-2*k];
    cout << res <<endl;
  }
}


Measured memory_bytes: 896
#include<stdio.h>
#define MAX 500001

int a[MAX];
int h;

void build_M_Heap(){
  int i;
  for(i = h/2; i >= 1; i--){
    M_Heapify(i);
  }
}

void M_Heapify(int i){
  int l, r;
  int largest;
  int v;
  
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= h && a[r] > a[largest]) largest = r;

  if(largest != i){
    v = a[i];
    a[i] = a[largest];
    a[largest] = v;
    M_Heapify(largest);
  }
}

int main(){
  int i;

  scanf("%d", &h);
  for(i = 1; i <= h; i++){
    scanf("%d", &a[i]);
  }

  build_M_Heap();

  for(i = 1; i <= h; i++){
    printf(" %d", a[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 3752
n = int(input())
V = E = 0
for i in range(1, n+1): V += i * (n - i + 1)
for _ in range(n-1):
    a, b = map(int, input().split())
    if a > b: a, b = b, a
    E += a * (n - b + 1)
print(V - E)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    char a, b;
    cin >> a >> b;
    cout << ((a=='H') != (b=='H')?'D':'H') << endl;
    return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int n, k;
int a[1000000];
int s, t;
int main()
{
	cin >> n >> k;
	while(n*k!=0)
	{
		s=0;
		for(int i=0; i<k; i++)
		{
			cin >> a[i];
			s+=a[i];
			t=s;
		}
		for(int i=k; i<n; i++)
		{
			cin >> a[i];
			t=t+a[i]-a[i-k];
			s=max(s, t);
		}
		cout << s << endl;
		cin >> n >> k;
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-6)
#define xx first
#define yy second
#define ln 17
#define off 2

#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 998244353LL
#define INF 1000000000000000000LL
#define maxn 300005

int dp[305][305][305][2] ;

string s ;

int cnt[405] ;

int f(int i, int takenone, int k ,int fl)
{
    if(takenone < 0) return 0 ;
    if( i==1 ) return 1 ;
    if( dp[i][takenone][k][fl] != -1 ) return dp[i][takenone][k][fl] ;

    int ret = f(i-1,takenone,k,0) ;

    if( cnt[i] != 0 )
    {
        ret = (ret + f(i,takenone-1,k,1) )%mod ;

        if( fl==0 ) for(int j=1 ; j<=cnt[i] && j<=k ; j++) ret = (ret + f(i-1,takenone+j,k-j,0) )%mod ;

    }
    else{
        ret = ( ret + f(i,takenone-1,k,0) )%mod ;
    }
//    cout<<i<<" "<<takenone<<" "<<k<<" "<<fl<<" : "<<ret<<endl ;
    return dp[i][takenone][k][fl] = ret ;
}

int main()
{
    FASTIO ;

    int k ;

    cin>>s>>k ;

    while( s.size() > 0 && s.back() == '0' ) s.pop_back() ;

    reverse(s.begin() , s.end()) ;

    while( s.size() > 0 && s.back() == '1' ) s.pop_back() ;

    reverse(s.begin() , s.end()) ;

    if( s.size() == 0 )
    {
        cout<<"1"<<endl ;
        return 0 ;
    }

    int n = 0 ;

    for(int i=0 ; i<s.size() ; i++)
    {
        if( s[i]=='0' )
        {
            n++ ;
            for(int j=i-1 ; j>=0 ; j--)
            {
                if( s[j] == '1' ) cnt[n]++ ;
                else break ;
            }
        }
    }

    k = min(k,(int)s.size()-n) ;

    memset(dp,-1,sizeof(dp)) ;

    int last = 0 ;

    for(int i=(int)s.size() - 1 ; i>0 ; i-- )
    {
        if( s[i]=='1' ) last++ ;
        else break ;
    }

    int ans = 0 ;

//    cout<<s<<endl ;
//    cout<<n<<" "<<last<<endl ;
//    for(int i=1 ; i<=n ; i++) cout<<cnt[i]<<" " ;
//    cout<<endl ;

    for(int i=0 ; i<=last && i<=k ; i++) ans = ( ans + f(n,i,k-i,0) )%mod ;

    cout<<ans<<endl ;

    return 0 ;
}


Measured memory_bytes: 225384
n,m = map(int,input().split())
h = [int(x) for x in input().split()]

result = [1]*n

for _ in range(m):
    a, b = map(int,input().split())
    if h[a-1] < h[b-1]:
        result[a-1] = 0
    elif h[a-1] > h[b-1]:
        result[b-1] = 0
    else:
        result[a-1] = 0
        result[b-1] = 0
print(result.count(1))

Measured memory_bytes: 20052
l, r = map(int, input().split())
if r//2019 - l//2019 > 0:
    print(0)
else:
    newL = l%2019
    newR = r%2019
    minM = 2019
    index = newL
    while index < newR+1:
        index2 = index+1
        while index2 < newR+1:
            if minM > (index*index2)%2019:
                minM = (index*index2) % 2019
            index2+=1
        index+=1
    print(minM)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(26);
	for (int i = 0; i < N; ++ i) {
		string p;
		cin >> p;
		++ A[p[0]-'A'];
	}
	int r = 0;
	for (;;) {
		sort(A.rbegin(), A.rend());
		int c = K;
		for (int i = 0; i < 26; ++ i) {
			if (A[i] > 0) if (-- A[i], --c == 0) break;
		}
		if (c) break;
		++ r;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	foreach (line; stdin.byLine) {
		auto a = line.split.map!(to!int);
		auto b = readln.split.map!(to!int);
		int[10] al, bl;
		int hit;
		foreach (i; 0..4) {
			al[a[i]]++;
			bl[b[i]]++;
			if (a[i] == b[i]) hit++;
		}
		int blow;
		foreach (i; 0..10) {
			blow += min(al[i], bl[i]);
		}
		writeln(hit, " ", blow-hit);
	}
}

Measured memory_bytes: 1112
#include <stdio.h>
int main(void) {
	
	int N, N1, N2  = 0, i, j = 1;

	scanf("%d", &N);

	N1 = N;

	for (i = 100; i != 0; i /= 10) {
		N2 += (N1 / i) * j;
		N1 %= i;
		j *= 10;
	}

	if (N == N2) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  
A,B=map(sorted,(A,B))

if N % 2 == 1:
  mA, mB = A[N//2],B[N//2]
  print(mB-mA+1)
else:
  mA, mB = (A[N//2-1]+A[N//2])/2,(B[N//2-1]+B[N//2])/2
  print(int((mB-mA)/0.5+0.5)+1)

Measured memory_bytes: 28496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin>>p[i];
    ans+=p[i];
  }
  sort(p,p+n);
  cout<<ans-p[n-1]/2;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

#define INF 10000000

int dx[4] = {1,0,-1,0} , dy[4] = {0,-1,0,1};
queue<tuple<int,int,int>> que;
vector<vector<int>> d(1010,vector<int>(1010));

int main(){
  int H,W;
  cin >> H >> W;  
  char c;
  for (int i = 0; i < H; i++) {
    for (int l = 0; l < W; l++) {
      cin >> c;
      d[i][l] = INF;
      if(c == '#'){
        que.emplace(i,l,0);
      }  
    }
  }


  ll ans = 0;
  ll x,y,t;

  while(que.size()){
    tie(y,x,t) = que.front(); que.pop();
    if(d[y][x] > t){
      d[y][x] = t;
      ans = max(ans,t);
      for (int i = 0; i < 4; i++) {
        int nx = x + dx[i] , ny = y + dy[i];
        if(0 <= nx && nx < W && 0 <= ny && ny < H)que.emplace(ny,nx,t+1);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 53832
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep_zero(i, n) for(int i=0; i<n; i++)
#define rep(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int x, y; cin >> x >> y;
    if(y>4*x || y< 2*x){
        cout << "No" << endl;
    }else if(y%2 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int r=read(),n=read();
		if(r==0&&n==0) break;
		
		int xl[n],xr[n],h[n];
		
		REP(i,n){
			xl[i]=read();
			xr[i]=read();
			h[i]=read();
		}
		
		int maxheight[2*r]={0};
		
		REP(i,n){
			for(int j=-r;j<=r;j++){
				if(j<=xr[i]&&j>=xl[i]&&j+1<=xr[i]&&j+1>=xl[i]){
					maxheight[j+r] = max(maxheight[j+r],h[i]);
				}
			}
		}
		
		//REP(i,2*r) cout << maxheight[i];
		//cout << endl;
		
		float ans=0.000;
		while(true){
			bool flag=true;
			REP(i,2*r){
				int x1=abs(i-r);
				int x2=abs(i+1-r);
				if(r*r-x1*x1 >= (maxheight[i]+r-ans)*(maxheight[i]+r-ans) || r*r-x2*x2 >= (maxheight[i]+r-ans)*(maxheight[i]+r-ans)){
					flag = false;
					break;
				}
			}
			if(flag==false){
				cout << fixed << setprecision(5) << ans << endl;
				break;
			}
			else ans+=0.00001;
		}
		
	}
}

Measured memory_bytes: 3264
N = int(input())
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
l = prime_factorize(N)
ans = 0
for k,v in Counter(l).items():
  i = 1
  while v>=i:
    v-=i
    ans += 1
    i += 1
    
print(ans)

Measured memory_bytes: 82192
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x;
	x = 10 * b + c;
	if (x % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main() {
  int a,b,c;
  cin >> a >> b;
  c = (a + b) / 2;
  if ((a % 2 == 1 && b % 2 == 0)||(a % 2 == 0 && b % 2 == 1))
    c ++;
  cout << c << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: [i64; 3],
    }
    println!("{}", if s[0] <= s[2] && s[2] <= s[1] {"Yes"} else {"No"});
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

signed main() {
    int S;
    cin >> S;
    cout << "0 0 ";
    int k = 1e9;
    int x2 = k;
    int y3 = (S + k - 1) / k;
    int x3 = 1;
    int y2 = k * y3 - S;
    cout << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

Measured memory_bytes: 256
open System 
open System.Text

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): 'a = LanguagePrimitives.GenericZero
    let inline FromOne(): 'a = LanguagePrimitives.GenericOne
    let inline FromInt32 (n: int): 'a = fromInt n

let R() = Console.ReadLine()

let f (p: int array) =
    p
    |> Array.fold(fun (min', cnt) x -> 
        if x < min' then 
            x, cnt + 1
        else 
            min', cnt) (p.[0], 1)
    |> snd 

let N = R()
let P = R().Split() |> Array.map (string >> int) 

f P 
|> printfn "%i"

Measured memory_bytes: 54180
<?php
//error_reporting(0);
list($X,$Y,$Z,$K) =  explode(" ",trim(fgets(STDIN)));
$A =  explode(" ",trim(fgets(STDIN)));
$B =  explode(" ",trim(fgets(STDIN)));
$C =  explode(" ",trim(fgets(STDIN)));

rsort($A);
rsort($B);
rsort($C);

$q = new SplPriorityQueue();
$q->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
$usedidx[]=array();

$i=$j=$k=0;
$q->insert(getkey($i,$j,$k),$A[$i]+$B[$j]+$C[$k]);
$usedidx[getkey($i,$j,$k)]=1;
for($l=0;$l<$K;$l++) {
  $v = $q->extract();
  list($i,$j,$k) = explode("_",$v['data']);
  printf("%d\n",$v["priority"]);
  if (!isset($usedidx[getkey($i+1,$j,$k)]) && isset($A[$i+1])) {
    $q->insert(getkey($i+1,$j,$k),$A[$i+1]+$B[$j]+$C[$k]);
    $usedidx[getkey($i+1,$j,$k)]=1;
  }
  if (!isset($usedidx[getkey($i,$j+1,$k)]) && isset($B[$j+1])) {
    $q->insert(getkey($i,$j+1,$k),$A[$i]+$B[$j+1]+$C[$k]);
    $usedidx[getkey($i,$j+1,$k)]=1;
  }
  if (!isset($usedidx[getkey($i,$j,$k+1)]) && isset($C[$k+1])) {
    $q->insert(getkey($i,$j,$k+1),$A[$i]+$B[$j]+$C[$k+1]);
    $usedidx[getkey($i,$j,$k+1)]=1;
  }
}
function getkey($i,$j,$k)
{
  return $i."_".$j."_".$k;
}


Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
const ll mod=1e9+7;
priority_queue<int>l;
priority_queue<int,vector<int>,greater<int> >r;
int main()
{
    int q,op,x,y;
    scanf("%d",&q);
    ll sum=0,sum1=0,sum2=0;
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&op);
        if(op==1)
        {
            scanf("%d%d",&x,&y);
            sum+=y;
            if(l.empty()||x<l.top())
                sum1+=x,l.push(x);
            else
                sum2+=x,r.push(x);
            if(l.size()>r.size()+1)
                sum1-=l.top(),sum2+=l.top(),r.push(l.top()),l.pop();
            if(r.size()>l.size())
                sum1+=r.top(),sum2-=r.top(),l.push(r.top()),r.pop();
        }
        else
        {
            printf("%d %lld\n",l.top(),sum+l.top()*l.size()-sum1+sum2-r.size()*l.top());
        }
    }
    return 0;
}


Measured memory_bytes: 3452
def sumArray(ary)
  sum = 0
  ary.each do |a|
    sum += a
  end
  return sum
end

N,L = gets.split(/\s/).map {|s|s.to_i}
roopList = gets.split(/\s/).map {|s|s.to_i}

# 区切っては長さをチェックし…を繰り返す。
# 試行回数はN-1回
# × 左端を切って、右端を切って…を繰り返せば良い
# → 条件を満たす２本の接続ポイントを見つければ、あとはその手前から
# 切っていき、次に後ろから順に切っていき、最後に見つけたポイントを
# 切ることで「確実」に条件を満たす切断が可能となる

#####
k = -1
for i in 1..N-1 do
  if(sumArray(roopList[(i-1)..i]) >= L)then
    k = i
    break
  end
end

if(k==-1)then
  puts "Impossible"
  exit
end

puts "Possible"
ans = []
ans += (1..k-1).to_a if(k > 1)
ans += (k+1..N-1).to_a.reverse if(k < N-1)
ans << k
puts ans


Measured memory_bytes: 13708
/* AOJ 0048
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0048
 *
 */

#include <stdio.h>

typedef struct TData Data;

struct TData {
    char* fName;
    float fWeight;
};

Data cat[] = {
    {"light fly", 0.00,},
    {"fly", 48.00,},
    {"bantam", 51.00,},
    {"feather", 54.00,},
    {"light", 57.00,},
    {"light welter", 60.00,},
    {"welter", 64.00,},
    {"light middle", 69.00,},
    {"middle", 75.00,},
    {"light heavy", 81.00,},
    {"heavy", 91.00,},
};


int main(){
    int i;
    int count = sizeof(cat)/sizeof(Data);
    float input;

    while(scanf("%f", &input)==1){
        for(i=count-1;i>-1; i--){
            if(cat[i].fWeight < input){
                printf("%s\n", cat[i].fName);
                break;
            }
        }
    }

    return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

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

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

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

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

string s;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  int ans = 0;
  REP(i, s.size()) {
    int j = i;
    while ((s[j] == 'A') || (s[j] == 'T') || (s[j] == 'C') || (s[j] == 'G')) {
      j++;
    }
    CHMAX(ans, j-i);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

count = 0
l = []

for s in Counter(S).most_common():
    if count <= s[1]:
        l.append(s[0])
        count = s[1]
    else:
        break

l.sort()
for s in l:
    print(s)


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

main(){
	fastio;
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> r,g,b;
	rep(i,0,n){
		if(s[i]=='R')
			r.pb(i);
		else if(s[i]=='G')
			g.pb(i);
		else
			b.pb(i);
	}
	int ans=0;
	rep(i,0,n-2){
		rep(j,i+1,n-1){
			int x,y;

			if(s[i]=='R')
				x=1;
			else if(s[i]=='G')
				x=2;
			else
				x=3;

			if(s[j]=='R')
				y=1;
			else if(s[j]=='G')
				y=2;
			else
				y=3;

			if(6%(x*y)==0){
				int yo=6/(x*y);
				if(yo==1){
					ans+=(r.end()-lower_bound(r.begin(),r.end(),j+1));
					if(2*j-i<n && s[2*j-i]=='R')
						ans--;
				}
				else if(yo==2){
					ans+=(g.end()-lower_bound(g.begin(),g.end(),j+1));
					if(2*j-i<n && s[2*j-i]=='G')
						ans--;
				}
				else if(yo==3){
					ans+=(b.end()-lower_bound(b.begin(),b.end(),j+1));
					if(2*j-i<n && s[2*j-i]=='B')
						ans--;
				}
			}

		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26412
# https://atcoder.jp/contests/abc095/tasks/arc096_a

A, B, C, X, Y = list(map(int, input().split(" ")))

cost = 0
if A + B > 2 * C:
    cost += min(X, Y) * C * 2
    if X > Y:
        cost += (X - Y) * min(A, C*2)
    else:
        cost += (Y - X) * min(B, C*2)
else:
    cost += X * A + Y * B

print(int(cost))


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

int main()
{
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << r * r * M_PI << " ";
    cout << fixed << setprecision(6) << 2 * r * M_PI << endl;
    return 0;
}


Measured memory_bytes: 3252
N = int(input())
XL = [tuple(map(int, input().split())) for _ in range(N)]

XL.sort(key=lambda a: (a[0] + a[1], a[0] - a[1]))

ans = 0
R = -10**18
for x, l in XL:
    if R <= x - l:
        ans += 1
        R = x + l
print(ans)


Measured memory_bytes: 30972
#include <iostream>
#include <cstdio>
using namespace std;
int n,score, nout,ining;
int base[4];
string s;
int main(){
	cin >> n;
	while(1){
		cin >> s;
		if(s=="HIT"){
			score+=base[3];
			base[3]=base[2];
			base[2]=base[1];
			base[1]=1;
		}else if(s=="HOMERUN"){
			score+=1+base[1]+base[2]+base[3];
			base[1]=base[2]=base[3]=0;
		}else if(s=="OUT"){
			nout++;
			if(nout==3){
				if(ining==n)break;
				ining++;
				cout << score<< endl;
				nout=0;
				score=0;
				base[1]=base[2]=base[3]=0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    ll ans;
    if (n & 1){
        ans = 2*n;
    }
    else ans = n;
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
  int N, K, Q, A, i, j;
  scanf("%d %d %d", &N, &K, &Q);
  int ai[N];
  for(i = 0; i < N; i ++){
    ai[i] = K;
  }
  for(i = 0; i < Q; i ++){
    scanf("%d", &A);
    /*for(j = 0; j < N; j ++){
      if(j != A-1){
        ai[j] = ai[j]-1;
      }
    }*/
    ai[A-1] = ai[A-1]+1;
  }


  for(i = 0; i < N; i ++){
    if(ai[i]-Q <= 0){
      printf("No\n");
    }
    else{
      printf("Yes\n");
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
//#include <stdio.h>
//#include <cmath>
//#include <algorithm>
//#include <iostream>
//#include <vector>
//#include <cstring>
#define pb push_back
#define ll long long
#define pi 3.1415926
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=998244353;
const int nmax=201234;

int m,d,res;

int main()
{
    scanf("%d%d",&m,&d);
    for(int i=1;i<=m;++i){
        for(int j=22;j<=d;++j){
            if(j%10<2)
                continue;
            else if((j/10)*(j%10)==i)
                ++res;
        }
    }
    printf("%d\n",res);
    return 0;
}
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);


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

int main(){
	
	int N, T;
	cin >> N >> T;//経路数と制限時間
	int c, t;
	int x = 1000;
	int flag = 0;
	
	for(int i=0; i<N; i++){
		cin >> c >> t;//コストと時間を入力
		if(t <= T){	//時間が許容範囲内の場合
			if(x > c){
				x = c;
			}
			flag = 1;
		}else{
		}
	}
	
	if(flag > 0){
		cout << x << endl;
	}else{
		cout << "TLE" <<endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se 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; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
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;
}

// 2 dimentional vector
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]<<endl;
    }
    return s;
}

ll atama(ll n){
    while(n > 9){
        n /= 10;
    }
    return n;
}
ll keta(ll n){
    string s = to_string(n);
    return s.size();
}

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

    ll n;
    cin>>n;
    ll ans=0;


    REP(x,1,n+1){
        ll start = x%10;
        if(start==0)continue;
        ll last = atama(x);
        ll test = start*10+last;
        while (test<=n){
            if(keta(test)==2){
                ans ++;
            }else{
                ans +=  min( (n+10-test)/10 ,  (ll) pow(10,keta(test)-2));
            }
            test /= 10;
            test *= 100;
            test += last;
        }
        //nが一桁のとき注意！！！！
        if(start==last){
            if(start<=n){
                ans++;
            }
        }
//        dbg(x);
//        dbg(ans);
    }

    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b, x;
    cin >> x >> a >> b;
    if (fabs(x - a) > fabs(x - b))
    {
        cout << "B";
    }
    else
    {
        cout << "A";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX-10;
const ll MOD = 1e9+7;

bool used[112345];
bool dfs(const vector<vint>& g,int v,vector<Pii>& p,vint& par,bool odd){
  if(used[v]) return true;
  used[v]=true;
  bool ret=true;
  for(int u:g[v]){
    if(used[u])continue;
    ret &= dfs(g,u,p,par,!odd);
    par[u]=v;
    p[v].first = max(p[v].first,p[u].first-1);
    p[v].second = min(p[v].second,p[u].second+1);
  }
  ret &= p[v].first<p[v].second||(p[v].first==p[v].second&&((p[v].first&1)==odd));
  return ret;
}

void dfs2(const vector<vint>& g,int v,vector<Pii>& p,vint& par){
  if(par[v]<0){
    p[v].second = p[v].first;
  }else{
    if(p[v].first<=p[par[v]].first-1){
      p[v].first = p[v].second = p[par[v]].first-1;
    }else{
      p[v].first = p[v].second = p[par[v]].first+1;
    }
  }
  for(int u:g[v]){
    if(par[v]==u)continue;
    dfs2(g,u,p,par);
  }
}

int main() {
  int N;cin >> N;
  vector<vint> g(N);
  repeat(i,N-1){
    int A,B;cin >> A >> B;
    A--;B--;
    g[A].push_back(B);
    g[B].push_back(A);
  }
  vector<Pii> P(N);
  repeat(i,N){
    P[i]={-INF,INF};
  }
  int K;cin >> K;
  int r;
  repeat(i,K){
    int V,p;cin >> V >> p;V--;
    P[V] = {p,p};
    r=V;
  }
  vint par(N,-1);
  bool isok = dfs(g,r,P,par,P[r].first&1);
  cout <<(isok? "Yes":"No")<<endl;
  if(!isok)return 0;
  dfs2(g,r,P,par);
  repeat(i,N){
    cout << P[i].first<<endl;
  }
  return 0;
}


Measured memory_bytes: 17024
#include<stdio.h>
int main()
{
	int n,t[101],m,p[101],x[101],a=0,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&t[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++)
		scanf("%d%d",&p[i],&x[i]);

	for(i=0;i<n;i++)
		a+=t[i];
	for(i=0;i<m;i++)
		printf("%d\n",a-t[p[i]-1]+x[i]);
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;

vector<int> v;

int f[3][3];
int main(){
    int n, m, x;
    cin >> n >> m;
    int minn = 10e6+100;
    for(int i=0; i<n; ++i){
        cin >> x;
        m-=x;
        minn = min (minn, x);
    }
    int ans = n;
    ans += m/minn;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
lli dp[1<<21][21+1];
int main(){
//IOS;
lli n,i,j;
cin>>n;
int a[n][n];
for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        cin>>a[i][j];
    }
}
memset(dp,0,sizeof(dp));
dp[0][0]=1;
lli bit=1<<n;
//cout<<bit<<endl;
for(i=0;i<bit;i++){
    for(j=0;j<n;j++){
        int man=__builtin_popcountll(i);
        int x=1<<j;
        if(a[man][j]&&(x^i))
            dp[x|i][man+1]=(dp[x|i][man+1]+dp[i][man])%mod;
    }
}
cout<<dp[bit-1][n]<<endl;
}


Measured memory_bytes: 360704
#include <bits/stdc++.h>
#define RANGE(i,n) for(ll i=0;i<n;i++)
typedef long long ll;

using namespace std;

vector<ll> neighbor(vector<ll> &arr, ll pos){
  vector<ll> neighbors;
  if (pos <= arr[0]){
    neighbors.push_back(arr[0]);
    return neighbors;
  }else if(pos >= arr.back()){
    neighbors.push_back(arr.back());
    return neighbors;
  }else{
    ll left_id = 0;
    ll right_id = arr.size()-1;
    while(right_id - left_id > 1){
      ll mid_id = (left_id + right_id) / 2;
      if(arr[mid_id] <= pos) left_id = mid_id;
      else right_id = mid_id;
    }
    neighbors.push_back(arr[left_id]);
    neighbors.push_back(arr[right_id]);
    return neighbors;
  }
}

signed main() {
  ll A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> s(A);
  vector<ll> t(B);
  RANGE(i,A)cin >> s[i];
  RANGE(i,B)cin >> t[i];
  RANGE(i,Q){
    ll x;
    cin >> x;
    vector<ll> yashiro_cand = neighbor(s, x);
    vector<ll> tera_cand = neighbor(t, x);

    ll min_route = LLONG_MAX;
    for (ll yashiro:yashiro_cand){
      for (ll tera:tera_cand){
        ll route = min(abs(x-yashiro) + abs(yashiro-tera),
            abs(x-tera) + abs(tera-yashiro));
        min_route = min(min_route, route);
      }
    }
    cout << min_route << endl;
  }
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println(Math.min(N * A, B));
        }
    }
}


Measured memory_bytes: 22356
//{{{
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

int T;
int n, m;
int x;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> x)
    {
        cout << (x ^ 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
X, Y = map(int, input().split())

result = 0

def reward(x):
	if x == 3:
		return 100000
	elif x == 2:
		return 200000
	elif x == 1:
		return 300000
	else:
		return 0

result += reward(X) + reward(Y)
if X == 1 and Y == 1:
	result += 400000

print(result)


Measured memory_bytes: 3316
a, b, c = map(int, input().split())
modL=[0]

while True:
    amari = (modL[len(modL)-1]+a)%b
    if amari == c:
        print("YES")
        break
    elif amari in modL:
        print("NO")
        break
    else:
        modL.append(amari)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define N 5000
#define INF 1000000000000000LL
typedef long long LL;
using namespace std;
int nd[N], nx[N], g[N], a[N], d[N], cnt = 2, S, T, n;
LL c[N];

void link(int x, int y, LL z) {
    nd[cnt] = y, nx[cnt] = g[x], c[cnt] = z, g[x] = cnt++;
    nd[cnt] = x, nx[cnt] = g[y], c[cnt] = 0, g[y] = cnt++;
}

bool bfs() {
    memset(d, -1, sizeof(d));
    queue<int> q;
    q.push(S), d[S] = 0;
    while (!q.empty()) {
        int tmp = q.front();
        q.pop();
        for(int p = g[tmp]; p; p = nx[p])
            if (d[nd[p]] == -1 && c[p]) {
                d[nd[p]] = d[tmp] + 1;
                q.push(nd[p]);
            }
    }
    return d[T] != -1;
}

LL dfs(int u, LL f) {
    if (u == T || f == 0) return f;
    LL ret = 0;
    for(int p = g[u]; p; p = nx[p])
        if (d[nd[p]] == d[u] + 1 && c[p]) {
            LL w = dfs(nd[p], min(f, c[p]));
            c[p] -= w, c[p ^ 1] += w, f -= w;
            ret += w;
        }
    if (!ret) d[u] = -1;
    return ret;
}

LL dinic() {
    LL ret = 0;
    while (bfs()) ret += dfs(S, INF);
    return ret;
}

void make_edge() {
    S = 0, T = n + 1;
    for(int i = 1; i <= n; i++) {
        if (a[i] >= 0) link(i, T, a[i]);
        if (a[i] < 0) link(S, i, -a[i]);
    }
    for(int i = 1; i <= n; i++)
        for(int j = 2 * i; j <= n; j += i)
            link(i, j, INF);
}

int main() {
    cin >> n;
    LL ans = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], ans += a[i] * (a[i] > 0);
    make_edge();
    cout << ans - dinic() << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1ll)
    r=(r*a)%m;
    b=b/2ll;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{
    ll n;
    cin>>n;
    string x;
    cin>>x;
    vi dp(200001,0);
    rep(i,1,200001)
    {
        ll j=i;
        ll c=0;
        while(j>0)
        {
            if(j%2!=0)c++;
            j/=2;
        }

        dp[i]=1+dp[i%c];
    }
    ll  m1=0,m2=0;
    ll o=0;
    rep(i,0,n)if(x[i]=='1')o++;
    if(o==0)
    {
        rep(i,0,n)cout<<"1\n";
        return 0;
    }
    if(o!=1)
    {
        rep(i,0,n)
        {
        if(x[i]=='1')m1+=modexp(2ll,n-1-i,o-1),m2+=modexp(2ll,n-1-i,o+1);
        m1%=(o-1);
        m2%=(o+1);
        }
    }
    else
    {
        rep(i,0,n)
        {
        if(x[i]=='1')m2+=modexp(2ll,n-1-i,o+1);

        m2%=(o+1);
        }
    }
   // cout<<o<<" "<<m1<<" "<<m2<<endl;
    rep(i,0,n)
    {
        if(x[i]=='1'&&o!=1)cout<<1ll+dp[(m1-modexp(2ll,n-1-i,o-1)+(o-1))%(o-1)]<<endl;
        else if(x[i]=='1')cout<<"0\n";
        else cout<<1ll+dp[(m2+modexp(2ll,n-1-i,o+1)+(o+1))%(o+1)]<<endl;
    }


}


Measured memory_bytes: 5240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  VI T(N);
  rep(i,N) cin>>S[i]>>T[i];
  string X;
  cin>>X;
  int ans=0;
  int F=0;
  rep(i,N){
    if(F) ans+=T[i];
    if(S[i]==X) F=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def f(i):
    global ans
    if i == h + w:
        cnt = 0
        for j in range(h):
            for l in range(w):
                if s[j] == 0 and s[h + l] == 0 and c[j][l] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1
        return
    s[i] = 1
    f(i + 1)
    s[i] = 0
    f(i + 1)

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
s = [0] * (h + w)
ans = 0
f(0)
print(ans)

Measured memory_bytes: 70312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin >> n >> x;
    int mini = 1 << 20;
    int sum = 0;
    int tmp;
    for(int i = 0;i < n;++i)
    {
        cin >> tmp;
        sum += tmp;
        mini = min(mini,tmp);
    }
    x = x - sum;
    cout << n + x / mini << '\n';
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Tue 14/07/2020
 * 14:26:46.34
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    for(int i = 1; i <= 9; ++i) {
        if(n % i == 0) {
            if((n / i) <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int N;
int x[10],y[10];

double dist(int i,int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx+dy*dy,0.5);
}

void solve() {
    double sum = 0.0;
    int factorial = 1;
    cin >> N;
    for(int i=1;i<=N;i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> v(N);
    for(int i=0;i<N;i++) {
        v[i] = i + 1;
    }
    do {
        for(int i=0;i<N-1;i++) {
            sum += dist(v[i],v[i+1]);
        }
    } while(next_permutation(v.begin(),v.end()));
    for(int i=2;i<=N;i++) {
        factorial *= i;
    }
    cout << fixed << setprecision(10) << sum/factorial << endl;
    return;
}

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










Measured memory_bytes: 512
N = gets.chomp

ns = N.reverse.chars.map(&:to_i) + [0]
ans, c = 0, 0
(0 ... N.length).each do |i|
  d = ns[i] + c
  c = 0
  if d >= 6 || (d == 5 && ns[i + 1] >= 5)
    ans += 10 - d
    c = 1
  else
    ans += d
  end
end
puts ans + c

Measured memory_bytes: 72220
import math
import fractions

A,B,C,D=map(int,input().split())
E=C*D//(fractions.gcd(C,D))
def P(A,B,Q):
	if A%Q==0:
		return B//Q-A//Q+1
	else:
		return B//Q-A//Q
print(B-A+1-(P(A,B,C))-(P(A,B,D))+(P(A,B,E)))

Measured memory_bytes: 5432
def prime(n):
    prime_flag = [0 for i in range(n + 1)]
    prime_list = []
    for i in range(2, n + 1):
        if prime_flag[i] == 0:
            prime_list.append(i)

            temp = 1
            while temp * i <= n:
                prime_flag[temp * i] = 1
                temp += 1
    return prime_list


prime_list = prime(10000)

answer = []

while True:
    n = int(input())
    if not n:
        break
    left = 0
    right = 0
    count = 2
    ans = 0
    while True:
        if n == count:
            ans += 1

        if left == right == len(prime_list) - 1:
            break
        elif count + prime_list[right + 1] <= n and right != len(prime_list) - 1:
            right += 1
            count += prime_list[right]
        else:
            if left == right:
                left += 1
                right += 1
                count = prime_list[left]
            else:
                count -= prime_list[left]
                left += 1

    answer.append(ans)

for i in answer:
    print(i)


Measured memory_bytes: 5716
import sys
def II(): return int(sys.stdin.readline())

def main(): 
    ans = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
    N = II()
    print(' '.join([str(t) for t in ans[:N]]))

main()

Measured memory_bytes: 3064