akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;




int main(){
    long double a, b;
    cin >> a >> b;
    long double res = a * b;
    ll r = (ll)res;
    cout << r << endl;
}


Measured memory_bytes: 3200
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
    long long k,n;
    cin >> k >> n;
	
  	vector<long long> a;
    long long d,dis=0;
    cin >> d;
    a.push_back(d);
  	for(int i=1;i<n;i++){
      cin >> d;
      a.push_back(d);
     if(dis<a[i]-a[i-1])  dis = a[i]-a[i-1]; 
     if(i==n-1 && dis<k-a[n-1]+a[0])  dis = k-a[n-1]+a[0];
    }
    cout << k-dis << endl;
    return 0;
}

Measured memory_bytes: 4888
#include<bits/stdc++.h>
using namespace std;
int n,l[45],L[45],a,d[5]={5,7,5,7,7};
string s;
 
int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=1;i<=n;i++){
      cin>>s,l[i]=s.size();
      L[i]=L[i-1]+l[i];
    }
    a=0;
    for(int i=1;i<=n;i++){
      int x=0,s=i;
      for(int j=i;j<=n;j++){
    if(L[j]-L[s-1]==d[x])x++,s=j+1;
    if(!a&&x==5)a=i,cout<<a<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3144
import numpy as np

c = np.array([list(map(int, input().split())) for i in range(3)])

x = [0] * 3
y = [0] * 3

for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]
flag = True

for i in range(3):
    for j in range(3):
        if x[i] + y[j] != c[i][j]:
            flag = False

print("Yes" if flag else "No")



Measured memory_bytes: 20392
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll solve(int* a, int n){
  ll cnt = 0;
  bool be = false;
  for(int i=0; i<n; i++){
    if(be){
      cnt += a[i] / 2;
      if(a[i] % 2) {
        be = false;
        cnt++;
      }
      else{
        if(a[i]) be = true;
        else be = false;
      }
    }
    else{
      cnt += a[i] / 2;
      if(a[i] % 2) be = true;
      else be = false;
    }
  }

  return cnt;
}

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

  ll ans = solve(a, n);
  reverse(a, a+n);
  ans = min(ans, solve(a, n));

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


Measured memory_bytes: 640
use std::collections::HashSet;
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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! {
        n: usize,
        items: [String; n],
    }
    let mut set = HashSet::new();
    for item in items {
        set.insert(item);
    }

    println!("{}", set.len());
}


Measured memory_bytes: 22696
def main():
    n, m = map(int, input().split())
    Ton, Fr1 = set(), set()
    for _ in range(m):
        a, b = map(int, input().split())
        if b==n:
            Ton.add(a)
        if a==1:
            Fr1.add(b)

    print('POSSIBLE' if Ton&Fr1 else 'IMPOSSIBLE')

main()

Measured memory_bytes: 19024
// Let Go Your Earthly Tether , Enter The Void , Empty And Become Wind

#include<bits/stdc++.h>

#define all(x) x.begin() , x.end()

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pll = pair<ll , ll> ;

const int MAXN = 200 * 1000 + 19 ;

ll n , a[MAXN] , k , sum = 0 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        cin >> n >> k ;
        for (int i = 0 ; i < n ; i ++)
                cin >> a[i] ;
        sort(a , a + n , greater<ll>()) ;
        for (int i = 0 ; i < min(k , n) ; i ++)
                a[i] = 0 ;
        for (int i = 0 ; i < n ; i ++)
                sum += a[i] ;
        cout << sum ;
        return (0) ;
}


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

ll H;

ll solve(ll h) {
	if (h == 1) return 1;

	return 1 + 2 * solve(h / 2);
}

int main(){

	cin >> H;

	ll ans = solve(H);

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n;
vector<ll> a;

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

	cin >> n;

	for (int i = 0;i < n;i++){
		ll tmp; cin >> tmp;
		a.push_back(tmp);
	}

	sort(a.begin(),a.end());

	ll midx = upper_bound(a.begin(),a.end(), a[n-1]/2) - a.begin();
	if(abs(a[midx]-a[n-1]/2) > abs(a[midx-1]-a[n-1]/2)) midx--;
	if(midx == n-1) midx--;
	

	cout << a[n-1] << " " << a[midx] << endl;

	return 0;

}


Measured memory_bytes: 1400
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

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

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

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

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
print(1110-n)



Measured memory_bytes: 76976
def solve():
    ans = []
    for x, y in s:
        if(num[x]>num[y]): x, y = y, x
        num[x]+=1
        num[y]-=1
        ans.append(x)
        if num[y]<0: return False
    return ans
from collections import defaultdict
import sys
n, a, b, c = map(int, input().split())
num = defaultdict(int)
s = [input() for _ in range(n)]
num['A'] = a
num['B'] = b
num['C'] = c
id = ['A', 'B', 'C']
id.sort(key = lambda x:num[x])
if a+b+c == 0:
    print('No')
    sys.exit()
elif a+b+c == 1:
    ans = solve()
    if ans: 
        print('Yes')
        print(*ans, sep = '\n')
    else:
        print('No')
elif a+b+c == 2:
    ans = []
    flag = True
    for i, (x, y) in enumerate(s):
        if num[x]>num[y]: x, y = y, x
        if num[x]==num[y] and i < n-1:
            if y == s[i+1][0] or y == s[i+1][1]:
                x, y = y, x
        num[x]+=1
        num[y]-=1
        ans.append(x)
        if num[y]<0:
            flag = False
    if flag:
        print('Yes')
        print(*ans, sep = '\n')
    else:
        print('No')
elif num[id[0]] == 0 and num[id[1]] == 0 and (s[0]==id[0]+id[1] or s[0]==id[1]+id[0]):
    print('No')
else:
    ans = solve()
    print('Yes')
    print(*ans, sep = '\n')
     





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

int main()
{
    string s;
    int n, h, H, i;
    while(cin >> s)
    {
        if(s == "-")
            break;
        cin >> n;
        H = 0;
        for(i = 0; i < n; i++)
        {
            cin >> h;
            H += h;
        }
        H %= s.size();
        cout << s.substr(H) << s.substr(0, H) << endl;
    }

    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  vector<int> a(5);
  vector<int> b(5);
  rep(i, 0, 5) {
    cin >> a.at(i);
    b.at(i) = a.at(i) %10;
    if(b.at(i) == 0)
      b.at(i) = 10;
  }
  int min = 1e5;
  int mini;
  rep(i, 0, 5) {
    if(b.at(i) < min) {
      mini = i;
      min = b.at(i);
    }
  }
  int ans = 0;
  rep(i, 0, 5) {
    if(i != mini)
      ans += ((a.at(i)+10-1)/10)*10;
    else
      ans += a.at(i);
  }
  cout << ans << "\n";

}


Measured memory_bytes: 256
//JOI2017 Sugoroku
//20181204
//F_Naru
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int max=0;
  int a;
  int cnt=1;
  for(int i=0; i<N; i++){
    cin >> a;
    if(a==1) cnt++;
    else{
      if(cnt>max) max=cnt;
      cnt=1;
    }
  }
  if(cnt>max) max=cnt;  
  cout << max << endl;
}



Measured memory_bytes: 3120
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, K;
    scan(N, K);
    auto s = readln.split.to!(int[]);
    auto T = readln.chomp;
    auto gcp = ['r': 0, 's': 1, 'p': 2];
    auto hist = new int[](N);
    hist[] = -1;
    long ans;
    foreach (int i, ch ; T) {
        auto x = gcp[ch];
        if (i >= K && hist[i - K] == (x + 2) % 3) {
            continue;
        }
        ans += s[(x + 2) % 3];
        hist[i] = (x + 2) % 3;
    }
    debug {
        writeln(hist);
    }
    writeln(ans);
}

int[] eratos(int N) {
    auto s = new bool[](N);
    s[] = true;
    s[0] = s[1] = false;

    for (int p = 2; p*p < N; p++) {
        if (s[p]) for (int d = p*p; d < N; d += p) {
            s[d] = false;
        }
    }

    return iota(N).filter!(i => s[i]).array;
}


struct ModComb {
    int _N;
    long[] _fact, _factinv;
    long _mod;

    this(int n, long mod = 1_000_000_007L) {
        _N = n;
        _fact = new long[](_N + 1);
        _factinv = new long[](_N + 1);
        _mod = mod;

        _fact[0] = 1;
        foreach (i ; 1 .. _N + 1) {
            _fact[i] = (_fact[i-1] * i) % mod;
        }

        _factinv[_N] = _powmod(_fact[_N], mod - 2);
        foreach_reverse (i ; 0 .. _N) {
            _factinv[i] = (_factinv[i+1] * (i+1)) % mod;
        }
    }

    long c(int n, int k) {
        if (k < 0 || k > n) return 0;
        return f(n) * finv(n - k) % _mod * finv(k) % _mod;
    }

    long p(int n, int r) {
        if (r < 0 || r > n) return 0;
        return f(n) * finv(n - r) % _mod;
    }

    long f(int n) {
        return _fact[n];
    }

    long finv(int n) {
        return _factinv[n];
    }

    long _powmod(long x, long y) {
        return y > 0 ? _powmod(x, y>>1)^^2 % _mod * x^^(y & 1) % _mod : 1;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2812
n ,k= map(int,input().split())
h = list(map(int,input().split()))
#print(h)
inf = float("inf")
dp = [inf]*(n+1)
dp[0] = 0


for i in range(1,n):
    for j in range(1,k+1):
        if i-j >=0:
            dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))
            #print(dp)
print(dp[n-1])

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    int ans = a[0];
    for (int i=1; i<n; i++) ans = __gcd(ans, a[i]);
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;

const int MAXN = 1e6 + 10;

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    ll n, a, b;
    cin >> n >> a >> b;
    if(abs(a - b) % 2) {
        if(a > b) swap(a, b);
        // a <= b
        ll res1 = a + (b - a - 1) / 2;

        ll aa = n - b + 1;
        ll bb = n - a + 1;
        ll res2 = aa + (bb - aa - 1) / 2;

        cout << min(res1, res2) << endl;
    }
    else cout << abs(b - a) / 2 << endl;


    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e6;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int t;
  cin >> t;
  if(t >= 30){
    cout <<"Yes" << '\n';
  } else{
    cout << "No" << '\n';
  }
} 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%i %i",&a,&b);
	if(a>=1 && a<=13 && b<=13 && b>=1)
	if(a==b){
		printf("Draw");
	}
	else if(a==1)
		printf("Alice");
	else if(b==1)
		printf("Bob");
	else if(b>a){
		printf("Bob");
	}
	else if(a>b)
		printf("Alice");
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long res = 0;
		int[][] stores = new int[n][2];
		
		for (int i = 0; i < n; i++) {
			stores[i][0] = sc.nextInt();
			stores[i][1] = sc.nextInt();
		}
		
		Arrays.sort(stores, (a , b) -> (a[0] - b[0]));
		
		for (int i = 0; i < n; i++) {
			long buy = Math.min(m, stores[i][1]);
			res += (long)(buy * stores[i][0]);
			m -= (int)buy;
			if (m == 0) { break; }
		}
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 46340
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>

using namespace std;

#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
typedef long long ll;

const long long MOD = 998244353;


class ModuloCombination {
private:
    vector<ll> fact, fact_inv;

    static ll mod_pow(ll a, ll n) {
        if(n == 0) return 1;
        if(n % 2 == 0) return mod_pow((a * a) % MOD, n / 2);
        return (a * mod_pow(a, n - 1)) % MOD;
    }

public:
    ModuloCombination(ll N): fact(N + 1), fact_inv(N + 1) {
        fact[0] = 1;
        REP(i, 1, N + 1) fact[i] = (i * fact[i - 1]) % MOD;
        REP(i, 0, N + 1) fact_inv[i] = mod_pow(fact[i], MOD - 2);
    }

    ll operator()(ll n, ll r) {
        return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
    }
};


int main(){
    const long long MAX_N = 310000;
    long long N,A,B,K;
    cin >> N >> A >> B >> K;

    ModuloCombination C(N);

    long long count = 0;

    REP(r, 0, N + 1){
        if( A*r <= K && (K-A*r)%B == 0 ){
            long long b = (K - A*r) / B; // 青の数

            if(!(0 <= b && b <= N)) continue;
            long long r_c = C(N , r)%MOD;
            long long b_c = C(N , b)%MOD;
            count +=  (r_c * b_c)%MOD;
            count %=MOD;
        }
    }

    cout << count<< endl;
}

Measured memory_bytes: 4992
#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) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,r = 0,b = 0;
    string s;
    cin >> n >> s;
    rep(i, n){
        if (s[i] == 'R') {
            ++r;
        }else{
            ++b;
        }
    }
    if (r > b) {
        Yes;
    }else{
        No;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(10);
		   int n,k;
           cin>>n>>k;
           //a=b=c
           map<ll,ll> cnt;
           rep(i,1,n+1){
             cnt[i%k]++;
           }
           ll ans=0;
           rep(i,0,k){
            if((i+i)%k==0){
             ans+=cnt[i]*cnt[i]*cnt[k-i];
              if(i==0){
               ans+=cnt[i]*cnt[i]*cnt[i]; 
              }
            }
             //cout<<ans<<endl;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 9880
s = input()
K = int(input())


def brute_force(s, K):
    substring_set = set()

    # brute-force
    for start in range(len(s)):
        # 5まででよかった...
        for length in range(1, 6):
            substring = s[start:start+length]
            substring_set.add(substring)

    substring_list = sorted(list(substring_set))
    print(substring_list[K - 1])

brute_force(s, K)

Measured memory_bytes: 4592
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;
long long N, K;
 
int main() {
    cin >> N >> K;
    map<int, long long> mp;
    for(int i=0; i<N; ++i){
        int a, b; cin >> a >> b;
        mp[a]+=b; 
    }

    for(auto e: mp){
        if(K <= e.second){
            cout << e.first << endl;
            break;
        }
        K-=e.second;   
    }
    return 0;
}

Measured memory_bytes: 4224
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
int n, c, a[100010], v[100010], pr[100010], s[100010], ans;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>c;
	for(int i=1; i<=n; i++) cin>>a[i]>>v[i];
	for(int i=n; i>=1; i--) s[i]=s[i+1]+v[i];

	for(int i=1; i<=n; i++) pr[i]=pr[i-1]+v[i];
	for(int i=1; i<=n; i++) pr[i]-=a[i], pr[i]=max(pr[i], pr[i-1]);
	ans=pr[n];
	//cout<<pr[n]<<endl;
	for(int b=1; b<=n; b++) ans=max(ans, s[b]+pr[b-1]-2*(c-a[b]/*haha lol*/));
	//cout<<s[2]<<" "<<pr[1]<<" "<<a[2]<<endl;

	for(int i=1; i<=n; i++) pr[i]=pr[i-1]+v[i];
	for(int i=1; i<=n; i++) pr[i]-=2*a[i], pr[i]=max(pr[i], pr[i-1]);
	ans=max(ans, pr[n]);
	for(int b=1; b<=n; b++) ans=max(ans, s[b]+pr[b-1]-(c-a[b]/*haha lol*/));
	cout<<ans;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            list.Sort();
            var result = list[0] + list[1];
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007,INF=1001001001;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int h,w,n,a,b;
int cnt[11];
vpint vec,at;

bool ex(int x,int y){
    int pos=lower_bound(vec.begin(),vec.end(),pint(x,y))-vec.begin();
    return pos<vec.size() && vec[pos]==pint(x,y);
}

signed main(){
    cin>>h>>w>>n;
    rep(i,0,n){
        cin>>a>>b;a--,b--;
        repe(j,a-2,a){
            repe(k,b-2,b){
                if(j>=0&&k>=0&&j+2<h&&k+2<w){
                    at.pb(pint(j,k));
                }
            }
        }
        vec.pb(pint(a,b));
    }
    sort(at.begin(),at.end());
    at.erase(unique(at.begin(),at.end()),at.end());
    sort(vec.begin(),vec.end());
    cnt[0]=(h-2)*(w-2)-at.size();
    rep(i,0,at.size()){
        int x=at[i].fi,y=at[i].se;
        int nm=0;
        repe(j,x,x+2)repe(k,y,y+2){
            nm+=ex(j,k);
        }
        cnt[nm]++;
    }
    rep(i,0,10)cout<<cnt[i]<<endl;
    return 0;
}

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


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

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



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);
	bool st = ((s.front() == s.back()) ^ (n%2)) ? true: false;
	
	puts(st? "First":"Second");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>

using namespace std;

#define INF 2000000

int t[20][20];
int dp[150000];

void solve(int n) {
	for (int i=0; i<(1<<n); i++)
		dp[i] = INF;

	for (int i=0; i<n; i++)
		dp[1<<i] = t[i][0];

	for (int A=0; A<(1<<n)-1; A++) {
		for (int i=0; i<n; i++) {
			if (!(A>>i & 1)) {
				dp[A|(1<<i)] = min(dp[A|(1<<i)], dp[A]+t[i][0]);
				for (int j=1; j<=n; j++) {
					if (A>>(j-1) & 1) dp[A|(1<<i)] = min(dp[A|(1<<i)], dp[A]+t[i][j]);
				}
			}
		}
	}

	cout << dp[(1<<n)-1] << endl;
}

int main() {
	int n;

	cin >> n;
	while (n!=0) {
		for (int i=0; i<n; i++) {
			for (int j=0; j<=n; j++) {
				cin >> t[i][j];
			}
		}

		solve(n);

		cin >> n;
	}
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e16)

struct Edge {
  ll from, to, cost;
  Edge(ll from, ll to, ll cost) : from(from), to(to), cost(cost) {}
};
vector<Edge> edges;
vi dist;                            // 最短距離
bool bellman_ford(int nV, int s) {  // nVは頂点数、sは開始頂点
  dist = vi(nV, INF);
  dist[s] = 0;                        // 開始点の距離は0
  for (int i = 0; i < nV - 1; i++) {  // 負の閉路がない場合、nV回未満で更新が終わる
    for (Edge e : edges) {
      if (dist[e.to] > dist[e.from] + e.cost) {  // 距離更新
        dist[e.to] = dist[e.from] + e.cost;
        // if (i == nV - 1) return true;  // nV回目にも更新があるなら負の閉路が存在
      }
    }
  }
  return false;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  for (ll i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    edges.push_back(Edge(a - 1, b - 1, -c));
  }

  bellman_ford(N, 0);

  bool f = false;
  for (int i = 0; i < N; i++) {
    for (Edge e : edges) {
      if (dist[e.to] > dist[e.from] + e.cost) {  // 距離更新
        dist[e.to] = dist[e.from] + e.cost;
        if (e.to == N - 1) f = true;  // nV回目にも更新があるなら負の閉路が存在
      }
    }
  }
  
  if (f) {
    cout << "inf" << endl;
    return 0;
  }

  ll ans = -dist[N - 1];
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N, M, E, S, T, R;
	scanf("%d%d%d%d%d%d", &N, &M, &E, &S, &T, &R);
	vector<vector<bool> > g(N, vector<bool>(N, false));
	rep(i, M) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a][b] = g[b][a] = true;
	}
	vector<pii> roads(E);
	vi cs(E);
	int initst = 0;
	rep(i, E) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if(c == S)
			initst |= 1 << i;
		roads[i] = mp(a, b);
		cs[i] = c;
	}
	int ans = INF;
	vector<vector<vi> > dp(1 << E, vector<vi>(R+1, vi(N, INF)));
	dp[initst][0][S] = 0;
	rep(i, 1 << E) {
		vector<vi> dist(N, vi(N, INF));
		rep(j, N) {
			vi q, nq; vector<bool> vis(N, false);
			nq.push_back(j);
			vis[j] = true; dist[j][j] = 0;
			while(!nq.empty()) {
				q.swap(nq);
				while(!q.empty()) {
					int k = q.back(); q.pop_back();
					rep(l, N) if(!vis[l] && g[k][l]) {
						vis[l] = true;
						dist[j][l] = dist[j][k] + 1;
						nq.push_back(l);
					}
					rep(e, E) if(i >> e & 1) {
						int a = roads[e].first, b = roads[e].second;
						if(k == b) swap(a, b);
						if(k == a && !vis[b]) {
							vis[b] = true;
							dist[j][b] = dist[j][k] + 1;
							nq.push_back(b);
						}
					}
				}
			}
		}
		rep(j, R+1) rep(k, N) {
			int x = dp[i][j][k];
			if(x == INF) continue;
			rep(l, E) if(~i >> l & 1) {
				int c = cs[l];
				if(j + dist[k][c] <= R)
					amin(dp[i | 1 << l][j + dist[k][c]][c], x + dist[k][c]);
				if(dist[S][c] <= R)
					amin(dp[i | 1 << l][dist[S][c]][c], x + 1 + dist[S][c]);
			}
			if(j + dist[k][T] <= R)
				amin(ans, x + dist[k][T]);
			if(dist[S][T] <= R)
				amin(ans, x + 1 + dist[S][T]);
		}
	}
	if(ans == INF)
		puts("-1");
	else
		printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8920
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
ans = 0
from math import sqrt
for i in range(n):
  for j in range(i+1,n):
    dis = 0
    for k in range(d):
      dis += (x[i][k]-x[j][k])**2
    if sqrt(dis) == int(sqrt(dis)):
      ans += 1
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int ilog(ll n,ll k){
int cnt=0;
for(ll i=1;n%i==0;i*=k){
cnt++;
}cnt--;
return cnt;}

int main() {
  int n;cin>>n;
  veci a(n);
  rep(i,n)cin>>a[i];
  int b=INT_MAX;
  rep(j,n){b=min(b,ilog(a[j],2));cerr<<ilog(a[j],2)<<" ";}
  cout<<b<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var D = temp[0];
            var X = temp[1];

            var A = Enumerable.Range(1, N).Select(i => int.Parse(Console.ReadLine())).ToArray();
            
            foreach (var a in A)
            {
                var d = D - 1;
                X += 1 + d / a;
            }

            Console.WriteLine(X);
        }
    }
}


Measured memory_bytes: 13396
import sys


# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    a, b, c = map(int, input().split())
    print(solve(a, b, c))


def solve(a, b, c):

    if a == b:
        if a == c:
            return 'No'
        else:
            return 'Yes'

    if b == c:
        if a == c:
            return 'No'
        else:
            return 'Yes'

    if c == a:
        if a == b:
            return 'No'
        else:
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    main()


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int n,t,i,x,h;
    double max=0;
    double angle;
    scanf("%d %d",&n,&t);
    for(i=1;i<=n;i++){
        scanf("%d %d",&x,&h);
        angle=(double)h/(double)x;
        if(angle>=max)
        max=angle;
        
    }
    printf("%f\n",max*(double)t);
    
    
    
}


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

int main(){
  int N,X;
  cin>>N;
  int i=N;
  bool found=false;
  while(!found&&i<1000){ 
    if(i/100==(i%100)/10&&(i%100)/10==(i%100)%10){
      X=i;
      found=true;
      }
    i++;
    }
  cout<<X<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<cstdlib>

#define LOOP(n,cnt) for(int cnt=0;cnt<n;++cnt)

using namespace std;

template <typename TYPE>
void printArray(TYPE* array, int size){
  LOOP(size,i) cout << array[i] << "\t" << flush;
  cout << endl;
}

int StringToInt(string str){
  return atoi(str.c_str());
}

#define MAX_W 50
#define MAX_H 50
int w,h,c[MAX_W][MAX_H];
int count = 0;

void dfs(int sy, int sx){
  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      int y = sy+i;
      int x = sx+j;
      if(y>=0 && x>=0 && y<h && x<w){
	if(c[y][x] == 1){
	  c[y][x] = 0;
	  dfs(y,x);         
	}
      }
    }
  }
}

int main(){
  while(true){
    cin >> w;
    cin >> h;
    count = 0;
    if(w == 0 && h == 0) break;
    LOOP(h,y){
      LOOP(w,x){
	cin >> c[y][x];
      }    
    }
    
    LOOP(h,y){
      LOOP(w,x){
	if(c[y][x] == 1){
	  count++;
	  dfs(y,x);
	}
      }    
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1348
-module('Main').
-export([main/1]).

main(_) -> 
    {ok, [S]} = io:fread("", "~s"),
    {ok, [T]} = io:fread("", "~s"),
    Ans = find_answer(S, T),
    io:format("~p~n", [Ans]),
    halt().

find_answer(S, T) ->
    TLength = string:length(T),
    NumOfSubstring = string:length(S) - TLength,
    lists:min(lists:map(fun(X) ->
                                Sliced = string:slice(S, X, TLength),
                                num_of_difference(Sliced, T)
                        end,
                        lists:seq(0, NumOfSubstring))).

num_of_difference([], []) ->
    0;
num_of_difference([H1|T1], [H2|T2]) ->
    case H1 /= H2 of
        true ->
            1 + num_of_difference(T1, T2);
        false ->
            num_of_difference(T1, T2)
    end.


Measured memory_bytes: 27024
#include <stdio.h>
#define MAX 100
#define INFTY 2000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim(void);

int main(){
  int i, j, e;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d", &e);
      if(e == -1){
	M[i][j] = INFTY;
      }
      else M[i][j] = e;
    }
  }
  printf("%d\n", prim());
  return 0;
}

int prim(){
  int u, minv, d[MAX], p[MAX], color[MAX], i, v, sum = 0;

  for(i = 0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0;i < n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v < n;v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0;i < n;i++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }
  return sum;
}

Measured memory_bytes: 636
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

typedef long long ll;
typedef double db;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const db PI = acos(-1);
const ll MOD = 1e9 + 7, INF = LLONG_MAX;
const ll N = 1000 + 10;

ll arr[N];

void test_case();

int main() {
	fast_io();
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	ll n, t, a;
	cin >> n >> t >> a;
	db diff = INF;
	ll ind = -1;
	for (ll i = 0; i < n; ++i) {
		cin >> arr[i];
		db curr = t - 0.006 * arr[i];
		if (abs(curr - a) < diff) {
			diff = abs(curr - a);
			ind = i + 1;
		}
	}
	cout << ind << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 10;
const int MAX_W = 10;
const int MAX_N = 30;

const char dcs[] = {'R', 'U', 'L', 'D'};
const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1};

/* typedef */

typedef vector<int> vi;

/* global variables */

int h, w, n;
int flds[MAX_H][MAX_W];
int jps[MAX_N];
vi nbrs[MAX_N][4];
bool used[MAX_N];

/* subroutines */

bool rec(int k, int id, int di0) {
  if (k == n - 1) return true;

  int dis[] = { di0, (di0 + 3) % 4, (di0 + 1) % 4 };

  for (int i = 0; i < 3; i++) {
    vi& nbr = nbrs[id][dis[i]];

    for (vi::iterator vit = nbr.begin(); vit != nbr.end(); vit++) {
      int v = *vit;
      if (! used[v]) {
	used[v] = true;
	jps[k] = dis[i];
	if (rec(k + 1, v, dis[i])) return true;
	used[v] = false;
	break;
      }
    }
  }

  return false;
}

/* main */

int main() {
  cin >> h >> w;

  n = 0;
  int st, di;

  for (int y = 0; y < h; y++) {
    string line;
    cin >> line;

    for (int x = 0; x < w; x++)
      switch (line[x]) {
      case '.': flds[y][x] = -1; break;
      case 'o': flds[y][x] = n++; break;
      case 'R': flds[y][x] = st = n++; di = 0; break;
      case 'U': flds[y][x] = st = n++; di = 1; break;
      case 'L': flds[y][x] = st = n++; di = 2; break;
      case 'D': flds[y][x] = st = n++; di = 3; break;
      }
  }
  
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) {
      int id = flds[y][x];
      if (id >= 0)
	for (int di = 0; di < 4; di++) {
	  int x0 = x + dxs[di], y0 = y + dys[di];
	  while (x0 >= 0 && x0 < w && y0 >= 0 && y0 < h) {
	    if (flds[y0][x0] >= 0)
	      nbrs[id][di].push_back(flds[y0][x0]);
	    x0 += dxs[di];
	    y0 += dys[di];
	  }
	}
    }

  memset(used, false, sizeof(used));
  used[st] = true;
  rec(0, st, di);

  for (int i = 0; i < n - 1; i++) cout << dcs[jps[i]];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1224
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map(String::toInt).sortedBy { it }
    val longest = l[n - 1]
    var others = 0
    for (i in 0 until n - 1) {
        others += l[i]
    }
    println(if (longest < others) "Yes" else "No")
}


Measured memory_bytes: 37860
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int n;
    cin>>n;
    map<string,ll>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }

    ll cnt=0;

    for(auto i=mp.begin();i!=mp.end();i++)
    {
        ll x=i->second;
        //cout<<x<<endl;
        x--;
        cnt+=(x*(x+1))/2;
    }


    cout<<cnt<<endl;


    return 0;
}


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

void fnInput(int& rnShtHand, int& rnLngHand, int& rnHour, int& rnMinute)
{
  cin >> rnShtHand >> rnLngHand >> rnHour >> rnMinute;
}

double fnClockHandsDist(int nShtHand, int nLngHand, int nHour, int nMinute)
{
  static const double pi = 3.141592653589793;

  double nShtAngl = (nHour + (nMinute / 60.0)) / 12 * 360;
  double nLngAngl = (nMinute / 60.0) * 360;
  double nDiffAngl = abs(nShtAngl - nLngAngl);
  if (nDiffAngl > 180)
    nDiffAngl = 360 - nDiffAngl;

  double nHandsDist = nShtHand * nShtHand + nLngHand * nLngHand 
                      - 2 * nShtHand * nLngHand * cos(2 * pi * nDiffAngl / 360);
  return sqrt(nHandsDist);
}
  
int main()
{
  int nShtHand, nLngHand, nHour, nMinute;

  fnInput(nShtHand, nLngHand, nHour, nMinute);
  cout << fixed << setprecision(10) << fnClockHandsDist(nShtHand, nLngHand, nHour, nMinute);
  cout << endl;

  return 0;
}

Measured memory_bytes: 4140
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	cnt := 0
	for i := 0; i < 3; i++ {
      if s[i] == '1' {
			cnt++
		}
	}
	
	fmt.Println(cnt)
	
}

Measured memory_bytes: 512
ans=0
q,h,s,d=map(int,input().split())
n=int(input())
l=[(q,q*8,0.25),(h,h*4,0.5),(s,s*2,1),(d,d,2)]
l.sort(key=lambda x:-x[1])
while n>0:
    c=l.pop()
    ans+=c[0]*int(n//c[2])
    n-=c[2]*int(n//c[2])
    
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int i=5;
    if(N<105){
        i=0;
    }
    else if(N<135){
        i=1;
    }
    else if(N<165){
        i=2;
    }
    else if(N<189){
        i=3;
    }
    else if(N<195){
        i=4;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n,k;
	while(~getII(n,k)){
		if(n%k==0)
			puts("0");
		else
			puts("1");
	}
}


Measured memory_bytes: 256