akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(k,i,n) for(int i = (k); i < (int)(n); i++)
typedef pair<int,int> Pii;
typedef long long ll;
typedef tuple<int,int,int> Ti;

int main(){
    int n,m,l,q;
    cin>>n>>m>>l;
    vector<vector<Pii>> gr(n,vector<Pii>());
    vector<vector<Pii>> d(n,vector<Pii> (n,Pii(MOD,MOD)));
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        if(c>l) continue;
        gr[a-1].push_back(Pii(b-1,c));
        gr[b-1].push_back(Pii(a-1,c));
    }
    cin>>q;
    rep(s,n){
        vector<bool> seen(n,false);
        
        priority_queue<Ti,vector<Ti>,greater<Ti>> que;
        que.push(Ti(0,0,s));
        while(!que.empty()){
            int ex,ct,nd;

            tie(ex,ct,nd)=que.top();
            que.pop();
            if(seen[nd]) continue;
            d[s][nd]=Pii(ex,ct);
            seen[nd]=true;
            for(auto p:gr[nd]){
                ll b=p.first, c=p.second;
                if(seen[b]) continue;

                Pii x=d[s][nd];
                if(d[s][nd].second+c>l){
                    x.first+=1;
                    x.second=c;
                }
                else x.second+=c;
                if(d[s][b]>x){
                    d[s][b]=x;
                    que.push(Ti(d[s][b].first,d[s][b].second,b));
                }
            }
        }
    }
    rep(i,q){
        int s,t;
        cin>>s>>t;s--;t--;
        if(d[s][t].first==MOD) cout<<-1<<endl;
        else cout<<d[s][t].first<<endl;
    }

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string t1, t2, t3;
    cin >> t1 >> t2 >> t3;
    cout << "A" << t2[0] << "C" << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


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

	if(n%10 == int(n/100))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;	
}

Measured memory_bytes: 256
import itertools

N=int(input())
L=list(map(int,input().split()))

if len(L)<3:
    print(0)
    
else:
    count = 0
    for i in itertools.combinations(L, 3):
        
        if i[0]!=i[1] and i[0]!=i[2] and i[1]!=i[2] :
            if i[0] + i[1] > i[2] and i[2] + i[1] > i[0] and i[0] + i[2] > i[1]:
                
                count+=1
                
    print(count)


Measured memory_bytes: 67704
from collections import deque
N,M=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

siru=[-1]*(N-1)#2~~N
que=deque([0])

while que:
    #print(que)
    now=que.popleft()
    nexlist=G[now]
    for nex in nexlist:
        if nex==0:
            continue
        if siru[nex-1]==-1:
            siru[nex-1]=now
            que.append(nex)
X=siru.count(-1)
if X>=1:
    print("No")
else:
    print("Yes")
    for num in siru:
        print(num+1)


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

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

s = int(input())
i = 1
As = set()
As.add(s)
prev = s
while True:
    i += 1
    if prev % 2:
        s = 3 * prev + 1
    else:
        s = prev // 2
    if s in As:
        print(i)
        break
    As.add(s)
    prev = s
8




Measured memory_bytes: 7880
#!/usr/bin/env python3
K, A, B = map(int, input().split())

if A + 2 >= B:
    print(K + 1)
    exit()

n = A - 1
print(1 + n + (K - n) // 2 * (B - A) + (K - n) % 2)

#  def f(n):
#      return (1 + n) // A <= (K - n) // 2
#
#
#  ok = 0
#  ng = int(10**9 + 1)
#  while ng - ok > 1:
#      m = (ok + ng) // 2
#      if f(m):
#          ok = m
#      else:
#          ng = m
#
#  print(1 + ok + (B - A) * ((1 + ok) // A))


Measured memory_bytes: 2940
n = int(input())
A = list(input().split())
for i in range(n):
    A[i] = int(A[i])
m = int(input())
B = list(input().split())
for i in range(m):
    B[i] = int(B[i])

def solve(x,y):
    if x==n:
        S[y] = 1
    else:
        solve(x+1,y)
        if y+A[x] < 2001:
            solve(x+1,y+A[x])
            
S = [0]*2001

solve(0,0)
    
for i in range(m):
    if S[B[i]] == 1:
        print("yes")
    else:
        print("no")




Measured memory_bytes: 5640
/// Kazuki Hoshino
/// Lost July

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, a[201010], l=inf, r=-inf, ans=0;

ll val(ll x)
{
    ll res = 0;
    rep(i, 1, n){
    res+= abs(a[i]-x);
    }
    return res;
}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n;

rep(i, 1, n){
cin >> a[i];
a[i]-=i;
l = min(l, a[i]);
r = max(r, a[i]);
}
int m;

sort(a+1, a+n+1);

ans = min(val(a[n/2]), val(a[(n+1)/2]));
ans = min(ans, val(a[(n-1)/2]));

cout << ans << endl;


return 0;}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_c
// https://atcoder.jp/contests/abc073/tasks/abc073_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K, L;
    cin >> N >> M;
    UnionFind uf(N + M);
    REP(i, N) {
        cin >> K;
        REP(j, K) {
            cin >> L;
            uf.unite(L - 1, M + i);
        }
    }
    bool flag = true;
    REP(i, N - 1) {
        if (!uf.same(M, M + i + 1)) {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc105/tasks/abc105_a

#[allow(unused)]
use std::cmp::{max, min, Ordering};
#[allow(unused)]
use std::collections::{HashSet, VecDeque};
use std::io;
use std::io::{BufRead, Read, Write};
use std::str::FromStr;

/* Input macro */

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused, non_snake_case)]
pub fn solve<R: BufRead, W: Write>(mut io: Io<R, W>) {
    let input = io.read_all();
    input! {
        source = input,
        N: usize,
        K: usize,
    }

    let res = min(N % K, 1);
    io.println(res);
}

#[allow(dead_code)]
fn main() {
    let stdin = io::stdin();
    let stdin_lock = stdin.lock();
    let stdout = io::stdout();
    let stdout_lock = stdout.lock();

    let io = Io {
        reader: stdin_lock,
        writer: stdout_lock,
    };

    solve(io);
}

/* IO helpers */

pub struct Io<R, W>
where
    R: BufRead,
    W: Write,
{
    pub reader: R,
    pub writer: W,
}

#[allow(dead_code)]
impl<R, W> Io<R, W>
where
    R: BufRead,
    W: Write,
{
    fn println<T: std::fmt::Display>(&mut self, value: T) {
        writeln!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn print<T: std::fmt::Display>(&mut self, value: T) {
        write!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn debug<T: std::fmt::Debug>(&mut self, value: T) {
        writeln!(&mut self.writer, "{:?}", value).expect("Unable to write");
    }

    fn next<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("Unable to parse")
    }

    fn nexts<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }

    fn read_all(&mut self) -> String {
        let mut res = String::new();
        self.reader.read_to_string(&mut res).unwrap();
        res
    }
}

/* Structure helpers */

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    while(cin >> n){
        vi a(n), b(n);
        REP(i, n) cin >> a[i];
        REP(i, n) cin >> b[i];
        vi less, more;
        REP(i, n) {
            if (a[i] < b[i]) less.push_back(b[i] - a[i]);
            if (b[i] < a[i]) more.push_back(a[i] - b[i]);
        }
        ll sum = accumulate(ALL(less), 0ll);
        int ans = less.size();
        sort(ALL(more));
        while(sum > 0 && more.size() > 0) {
            sum -= more.back(); more.pop_back();
            ans ++;
        }
        if (sum > 0) ans = -1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = (v[0] + v[1]) / 2;
    for (int i = 2; i < N; i++) {
        ans += v[i];
        ans /= 2;
    }
    cout << setprecision(10) << fixed << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  while(1){
    int n,r;cin>>n>>r;
    if(!(n||r))break;
    vector<int> a(n);
    iota(a.rbegin(),a.rend(),1);
    REP(i,r){
      int p,c;cin>>p>>c;
      vector<int> t(n);
      REP(j,c)t[j]=a[j+p-1];
      REP(j,p-1)t[j+c]=a[j];
      FOR(j,c+p-1,n)t[j]=a[j];
      swap(a,t);
    }
    cout<<a[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
s = gets.chomp.split('')
at = ["A","T","C","G"]
cnt = 0
max_cnt = 0
s.each do |i|
  if at.include?(i)
    cnt += 1
    if cnt > max_cnt
      max_cnt = cnt
    end
  else
    cnt = 0
  end
end
puts max_cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 15;
const ll bits = 15;
const ll mod = 1e9+7;


ll cntbit(ll n){

    ll ans = 0;

    while(n){
        ans+=n&1;
        n>>=1;
    }

    return ans;
}

bool check(ll mask,vector< vector<ll>>&arr,vector< vector<ll> >&brr,ll n){

    for(int i=0;i<n;i++){
        if((mask & (1<<i)) == (1<<i)){
            for(int j=0;j<arr[i].size();j++){
                if(brr[i][j]!= ((1<<arr[i][j] & mask)==(1<<arr[i][j]))){
                    return false;
                }
            }
        }
    }

    return true;
}


int main(){
    ll n;
    cin>>n;

    ll mask = 1<<n;

    vector< vector<ll> >arr(n),brr(n);

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int x,y;

        while(a--){
            cin>>x>>y;
            arr[i].push_back(x-1);
            brr[i].push_back(y);
        }

    }

    ll ans = 0;

    for(int i=0;i<mask;i++){
        if(check(i,arr,brr,n)) ans = max(ans,cntbit(i));
    }

    cout<<ans;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long        
using namespace std;
 
void scan()
{
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
 
}
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
 
int main() 
{
    scan();     
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    k--;
    s[k] = tolower(s[k]);
    cout << s;
}     
//JUDGE_ID: 295965SY
//Tis I

Measured memory_bytes: 3576
program ComparingStrings

  implicit none

  integer a,b
  integer comeout
  integer i

  read *, a,b
  ! print * , a, b
  comeout = 0
  if ( a>b ) then
    do i = 1, a
      comeout = comeout + b * (10 ** (i-1))
      ! print *, comeout
    end do
  else
    do i = 1, b
      comeout = comeout + a * (10 ** (i-1))
      ! print *, comeout
    end do
  end if

  print '(i0)', comeout


end program


Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

long long factorial(long long n, long long mod) {
    long long ret = 1;
    for (long long i = 1; i <= n; i++) {
        ret = (ret * i) % mod;
    }
    return ret;
}

long long inv_mod(long long n, long long mod) {
    long long a = n % mod, b = mod - 2, ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

long long nPr(long long n, long long r, long long mod) {
    long long ret = 1;
    for (long long i = n; i >= n - r + 1; i--) {
        ret = ret * (i % mod) % mod;
    }
    return ret;
}

long long nCr(long long n, long long r, long long mod) {
    return nPr(n,r,mod) * inv_mod(factorial(r,mod),mod) % mod;
}

long long nHr(long long n, long long r, long long mod) {
    return nCr(n+r-1,r,mod);
}

int main ()
{
    ll N; cin >> N;
    int cnt[5] = {};
    REP(i,N) {
        string S; cin >> S;
        if (S.front() == 'M') cnt[0]++;
        if (S.front() == 'A') cnt[1]++;
        if (S.front() == 'R') cnt[2]++;
        if (S.front() == 'C') cnt[3]++;
        if (S.front() == 'H') cnt[4]++;
    }

    ll ans = 0;
    for (int i = 0; i < (1 << 5); i++) {
        int d = 0;
        REP(j,5) if ((i >> j) & 1) d++;
        if (d != 3) continue;
        ll add_t = 1;
        REP(j,5) if ((i >> j) & 1) {
            add_t *= cnt[j];
        }
        ans += add_t;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
int judge(ll a){
string s;
cout<<a<<endl;
fflush(stdout);
cin>>s;
if(s[0]=='V')return -1;
if(s[0]=='M')return 1;
return 0;
}
int main(){
  ll mid,x;
  cin>>x;
  datas rp,lp;
  rp=lp=datas(0,judge(0));
  if(rp.second<0)return 0;
  rp.first=x;
  while(1){
    mid=(rp.first+lp.first)/2;
    x=judge(mid);
    if(x<0)return 0;
    if((x+rp.second+mid-rp.first)%2){
      lp=datas(mid,x);
    }else{
      rp=datas(mid,x);
    }
  }
  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int mul = a * b;
    if(mul % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, k; cin >> n >> k;
	vector<Int> a(n), f(n);
	for(auto &i:a) cin >> i;
	for(auto &i:f) cin >> i;
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	Int l = -1, r = 1'000'000'000'000;
	while(l + 1 < r){
		Int m = (l + r) / 2;
		Int t = 0;
		for(Int i=0; i<n; ++i){
			t += max<Int>((a[i] * f[i] - m + f[i] - 1) / f[i], 0);
		}
		if(t <= k) r = m;
		else l = m;
//		cout << m << " " << t << "\n";
	}
	cout << r << "\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    a %= MOD, b %= MOD;
    return a * calc_pow(b, MOD - 2) % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % MOD);
}

int main() {
    init_fact(300000);

    ll n, m, k;
    cin >> n >> m >> k;

    ll ret = calc_div(m * (n - 1) * (n + 1), 3 * n * m - 3) + calc_div(n * (m - 1) * (m + 1), 3 * n * m - 3);
    ret *= calc_comb(k, 2), ret %= MOD;
    ret *= calc_comb(n * m, k), ret %= MOD;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2560
N,K=map(x->parse(Int,x),split(readline()))
S=chomp(readline())
p='-'
ans=LR=RL=0
for c=S
	if p=='-'
		p=c
	elseif p==c
		ans+=1
	else
		if p=='L'
			LR+=1
		else
			RL+=1
		end
		p=c
	end
end
t=min(LR,RL)
println(ans+(t<K?min(max(LR,RL),K)-t+2t:2K))


Measured memory_bytes: 166868
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long d[333][333],dd[333][333],n,m,l,q;
int main()
{
	cin>>n>>m>>l;
	for(int i=0;i<330;i++)
	{
		for(int j=0;j<330;j++)
		{
			d[i][j]=1e18;
			dd[i][j]=1e9;
		}
	}
	for(int i=0;i<m;i++)
	{
		long long a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		d[a][b]=c;
		d[b][a]=c;
	}
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(d[i][j]<=l)
			{
				dd[i][j]=1;
			}
		}
	}
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				dd[i][j]=min(dd[i][j],dd[i][k]+dd[k][j]);
			}
		}
	}
	cin>>q;
	while(q--)
	{
		long long s,t;
		cin>>s>>t;
		s--;
		t--;
		if(dd[s][t]>=1e9)
		{
			cout<<-1<<endl;
			continue;
		}
		cout<<dd[s][t]-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![s: String, t: String];
    let mut s: Vec<_> = s.chars().collect();
    s.sort();
    let mut t: Vec<_> = t.chars().collect();
    t.sort();
    t.reverse();
    let ans = {
        if s < t {
            "Yes"
        } else {
            "No"
        }
    };
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {

	int i = 0, j;
	int data[10000][2];
	
	while (1) {
		scanf("%d %d", &data[i][0],&data[i][1]);
		if (data[i][0] == 0 && data[i][1]==0) {
			break;
		}
		else {
			i++;
		}
	}
	
	for (j = 0; j <= i; j++) {
		if (data[j][0] != 0 || data[j][1] != 0) {
			if (data[j][0] > data[j][1]) {
				printf("%d %d\n", data[j][1], data[j][0]);
			}
			else {
				printf("%d %d\n", data[j][0], data[j][1]);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2600
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 1e5 + 10;
int best[N], h[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &h[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    best[x] = max(best[x], h[y]);
    best[y] = max(best[y], h[x]);
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (h[i] > best[i]) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int a,b;std::cin>>a>>b;
    std::cout<<(13<=a?b:6<=a?b/2:0)<<'\n';
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        ans += i%d == 0;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc165_b
{
    class Program
    {
        static void Main(string[] args)
        {
            double x = double.Parse(Console.ReadLine()); //少数を扱うのでdouble型へ
            double bank = 100;                           //預金額bank
            int count = 0;                               //何年後か


            while(bank<x)　　　　
            {
               bank= Math.Truncate(bank* 1.01);
                count++;
            }
            Console.WriteLine(count);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27480
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
#define N 100005
#define mod 1000000007
int n, m, x[N];
struct Matrix
{
	int A[3][3];
	Matrix(){memset(A, 0, sizeof A);}
	Matrix operator * (const Matrix &b)const
	{
		Matrix c;
		for (int i = 0; i < 3; i++)
			for (int k = 0; k < 3; k++)
				for (int j = 0; j < 3; j++)
					c.A[i][j] = (c.A[i][j] + (ll)A[i][k] * b.A[k][j]) % mod;
		return c;
	}
	void Init()
	{
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				A[i][j]=1;
		A[0][1] = A[2][1] = A[2][2]=2;
		A[1][0] = 0;
	}
}ans, now, oth, mat, one;
void Pow(int k)
{
	now = one;
	mat.Init();
	while (k)
	{
		if (k & 1)
			now = now * mat;
		mat = mat * mat;
		k >>= 1;
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &x[i]);
	x[++m] = n;
	oth.Init();
	oth.A[2][1] = oth.A[2][0] = 0;
	oth.A[2][2] = 1;
	for (int i = 0; i < 3; i++)
		one.A[i][i] = 1;
	ans.A[0][0] = 1;
	Pow(x[1]);
	ans = ans * now;
	for (int i = 1; i < m; i++)
		{
			ans = ans * oth;
			Pow(x[i + 1] - x[i] - 1);
			ans = ans * now;
		}
	printf("%d\n", ans.A[0][2]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  string S;
  cin >> S;
  if(S[5] == '1' || S[6] > '4') {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
strings = gets.chomp.chars

count_now = 0
count_max = 0

strings.each_with_index do |string, index|
  if string == "A" || string == "C" || string == "G" || string == "T"
    count_now += 1
    if count_now > count_max
      count_max = count_now
    end
  else
    count_now = 0
  end
end

puts count_max

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
const double esp=1e-9;
const ll mod=1e9+7;
char s[maxx],s1[maxx],s2[maxx];
int main(){
    scanf("%s",s+1);
    int k; cin>>k;
    int n; n=strlen(s+1);
    if(n==1){
        cout<<k/2<<endl;
        return 0;
    }
    if(s[1]==s[n]){
        ll cnt=0,tot=0,ans=0,res=0,f=0;
        for(int i=2;i<=n;i++){
            if(s[i]==s[i-1]){
                if(i==n) f=1;
                cnt++,i++;
            }
        }
        if(f==1){
            cout<<cnt*k<<endl;
            return 0;
        }
        f=0;
        s[0]=s[n];
        for(int i=1;i<=n;i++){
            if(s[i]==s[i-1]) {
                if(i==n) f=1;
                tot++,i++;
            }
        }
        //cout<<tot<<" "<<f<<endl;
        if(f) ans=(cnt+tot)*(k/2)+(cnt)*(k&1);
        else ans=cnt+(tot)*(k-1);
        cout<<ans<<endl;
        return 0;
    }
    ll cnt=0,f=0;
    for(int i=2;i<=n;i++){
        if(s[i]==s[i-1]){
            cnt++,i++;
        }
    }
    cout<<cnt*k<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int main() {
    long l, r;
    cin >> l >> r;
    int cnt[2019] = {0};
    long q = l / 2019,
         ama = l % 2019,
         dq = (r - l) / 2019,
         dama = (r - l) % 2019;
        
    if (dq >= 2) {
        for (auto &c:cnt) c = 2;
    } else if (dq == 1) {
        for (auto &c : cnt) c = 1;
        for (int i=ama; i<=ama+dama; i++) cnt[i%2019]++;
    } else {
        for (int i = ama; i <= ama + dama; i++) cnt[i % 2019]++;
    }
    int best = 2019;
    for (int i=0; i<2019; i++) {
        for (int j=0; j<=i; j++) {
            if ((i != j && cnt[i] && cnt[j]) || (i == j && cnt[i] == 2))
                best = min(best, (i * j) % 2019);
        }
    }
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

		ll n, a, b;
		cin>>n>>a>>b;
		cout<<min(a * n, b);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int S=s.size(),T=t.size();
    for(int i=S-T;i>=0;i--){
        if(s[i]==t[0] || s[i]=='?'){
            bool b=1;
            for(int j=0;j<T;j++)if(s[i+j]!='?' && s[i+j]!=t[j])b=0;
            if(b){for(int j=0;j<T;j++)if(s[i+j]=='?')s[i+j]=t[j];
                for(int j=0;j<S;j++)if(s[j]=='?')s[j]='a';
                cout<<s<<endl;
                return 0;
            }
        }
    }
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}

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

const int N = 200010;

int left[N], a[N];
int vis[N];
int n, m;

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0; i < N; ++ i){
		left[i] = i;
	}
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
		-- left[a[i]];
	}
	for (int i = 0; i < N; ++ i){
		for (int j = std::max(left[i] + 1, 1); j <= i; ++ j){
			++ vis[j];
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++ i){
		cnt += vis[i] ? 1 : 0;
	}
	while (m --){
		int x, y;
		scanf("%d%d", &x, &y);
		++ left[a[x]];
		if (left[a[x]] > 0){
			cnt -= vis[left[a[x]]] ? 1 : 0;
			-- vis[left[a[x]]];
			cnt += vis[left[a[x]]] ? 1 : 0;
		}
		a[x] = y;
		-- left[y];
		if (left[y] >= 0){
			cnt -= vis[left[y] + 1] ? 1 : 0;
			++ vis[left[y] + 1];
			cnt += vis[left[y] + 1] ? 1 : 0;
		}
		printf("%d\n", n - cnt);
	}
	return 0;
}

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

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<int> a(m,0);
  for(int i=0; i<n; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int l;
      cin >> l;
      a[l-1]++;
    }
  }
  int cnt=0;
  for(int i=0; i<m; i++){
    if(a[i]==n) cnt++;
  }
 cout << cnt << endl;
}
      
  
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {



      int d,t,s; cin >> d >> t >> s;

      double t1 = d*1.0/s;

      if(t1 > t ) cout << "No" << endl;
      else cout << "Yes" << endl; 
      //cout << t1 << endl;
    
    
  return 0; 
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <math.h>

#define DICE_SIZE 6

class Dice
{
private:
	int eyes[DICE_SIZE];
public:
	Dice(int e1, int e2, int e3, int e4, int e5, int e6)
	{
		eyes[0] = e1;
		eyes[1] = e2;
		eyes[2] = e3;
		eyes[3] = e4;
		eyes[4] = e5;
		eyes[5] = e6;
	}

	int GetEye(int i)
	{
		return eyes[i];
	}

	void Roll(char c)
	{
		switch (c)
		{
		case 'E':
		case 'e':
			ToEest();
			break;

		case 'N':
		case 'n':
			ToNorth();
			break;

		case 'S':
		case 's':
			ToSouth();
			break;

		case 'W':
		case 'w':
			ToWest();
			break;

		default:
			break;
		}
	}

	void ToEest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[3];
		eyes[1] = temp[1];
		eyes[2] = temp[0];
		eyes[3] = temp[5];
		eyes[4] = temp[4];
		eyes[5] = temp[2];
	}

	void ToNorth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[1];
		eyes[1] = temp[5];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[0];
		eyes[5] = temp[4];
	}

	void ToSouth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[4];
		eyes[1] = temp[0];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[5];
		eyes[5] = temp[1];
	}

	void ToWest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[2];
		eyes[1] = temp[1];
		eyes[2] = temp[5];
		eyes[3] = temp[0];
		eyes[4] = temp[4];
		eyes[5] = temp[3];
	}

	void TurnClockWise()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[0];
		eyes[1] = temp[2];
		eyes[2] = temp[4];
		eyes[3] = temp[1];
		eyes[4] = temp[3];
		eyes[5] = temp[5];
	}
};

int main()
{
	int e1, e2, e3, e4, e5, e6;
	scanf("%d %d %d %d %d %d", &e1, &e2, &e3, &e4, &e5, &e6);
	Dice dice1(e1, e2, e3, e4, e5, e6);
	scanf("%d %d %d %d %d %d", &e1, &e2, &e3, &e4, &e5, &e6);
	Dice dice2(e1, e2, e3, e4, e5, e6);

	// 上下二面を合わせる
	for (int i = 0; i < 4; i++)
	{
		if (dice1.GetEye(0) == dice2.GetEye(0) &&
			dice1.GetEye(5) == dice2.GetEye(5)) break;
		dice1.Roll('N');
	}
	if (dice1.GetEye(0) != dice2.GetEye(0) ||
		dice1.GetEye(5) != dice2.GetEye(5))
	{
		for (int i = 0; i < 4; i++)
		{
			if (dice1.GetEye(0) == dice2.GetEye(0) &&
				dice1.GetEye(5) == dice2.GetEye(5)) break;
			dice1.Roll('E');
		}
	}
	if (dice1.GetEye(0) != dice2.GetEye(0) ||
		dice1.GetEye(5) != dice2.GetEye(5))
	{
		std::cout << "No" << std::endl;
		return 0;
	}

	// その他4面を合わせる
	for (int i = 0; i < 4; i++)
	{
		if (dice1.GetEye(1) == dice2.GetEye(1) &&
			dice1.GetEye(2) == dice2.GetEye(2) &&
			dice1.GetEye(3) == dice2.GetEye(3) &&
			dice1.GetEye(4) == dice2.GetEye(4)) break;
		dice1.TurnClockWise();
	}
	if (dice1.GetEye(1) != dice2.GetEye(1) ||
		dice1.GetEye(2) != dice2.GetEye(2) ||
		dice1.GetEye(3) != dice2.GetEye(3) ||
		dice1.GetEye(4) != dice2.GetEye(4))
	{
		std::cout << "No" << std::endl;
		return 0;
	}
	std::cout << "Yes" << std::endl;


}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    multiset<pll> s;
    ll ans = 0;
    ll res = 0;
    ll t = 0;
    while (a --) {
    	cin >> t;
    	s.insert({t, -1});
	}
	while (b --) {
		cin >> t;
		s.insert({t, -2});
	}
	while (c --) {
		cin >> t;
		s.insert({t, -3});
	}
	while (s.size() && (x + y) > 0) {
		auto X = *s.rbegin();
		ll val = X.F, T = -X.S;
		s.erase(s.find(X));
		if (T == 1) {
			if (x && res <= x + y - 1) {
				x --;
				ans += val;
			}
			continue;
		}
		if (T == 2) {
			if (y && res <= x + y  - 1) {
				y --;
				ans += val;
			}
			continue;
		}
		if (res + 1 > x + y) continue;
		res ++;
		ans += val;
	}
	cout << ans;
    return (0);
}

Measured memory_bytes: 19072
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

double R;
const double PI = acos(-1);

void solve() {
  for(int de = 1; ; ++de) {
    int s = 1;
    int e = (PI+R) * de;
    while(e - s > 1) {
      int nu = (s + e)/2;
      int tmp = (double)nu/de;
      if(tmp > PI) e = (int)nu;
      else         s = (int)nu;
    }
    if(fabs((double)s/de - PI) <= R) {
      cout << s << "/" << de << endl;
      return;
    }
    if(fabs((double)e/de - PI) <= R) {
      cout << e << "/" << de << endl;
      return;
    }
  }
}
/*void solve() {
for(int de = 1; ; ++de) {
 for(int nu = 1; ; ++nu) {
      double tmp = (double)nu/de - PI;
      if(fabs(tmp) <= R) {
	cout << nu << "/" << de << endl;
	return;
      } else if(tmp > R) {
	break;
      }
    }
 }
 }*/

main() {
  while((cin >> R) && R != 0.0) {
    solve();
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

	    int N = sc.nextInt();
	    int A[] = new int[N];
	    
	    long sum = 0;
	    
	    for(int i=0; i<N; i++) {
	    	A[i] = sc.nextInt();
	    	sum += A[i];
	    }
	    
	    long min = Long.MAX_VALUE;
	    long temp = 0;
	    for (int i=0; i<N; i++) {
	    	temp += A[i];
	    	if (Math.abs(sum - 2*temp)<min) {
	    		min = Math.abs(sum - 2*temp);
	    	}
	    }
	    
	    System.out.println(min);
	}

}

    
    

Measured memory_bytes: 60520