akhauriyash/Code-Regression huggingface dataset:
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
int t[100];
int m;
int p[100], x[100];

int main(){
  cin >> n;
  rep(i, n) cin >> t[i];
  cin >> m;
  rep(i, m) cin >> p[i] >> x[i], p[i]--;
  rep(i, m) cout << accumulate(t, t + n, 0) - t[p[i]] + x[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> P(N, 0);
    for (int i = 0; i < N; ++i) cin >> P[i];
    int cnt = 0, n_min = 10000000;
    for (int i = 0; i < N; ++i) {
        n_min = min(n_min, P[i]);
        if (n_min >= P[i])  cnt++;
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 1152
from itertools import product
N = int(input())
F = []
for i in range(N):
    F.append([int(i) for i in input().split()])
P = []
for i in range(N):
    P.append([int(i) for i in input().split()])

ans = -float('inf')

def culc(F, P, l):
    ret = 0
    for i in range(N):
        c = sum([j == k == 1 for j, k in zip(F[i], l)])
        ret += P[i][c]
    return ret

for l in product([0,1],repeat=10):
    if sum(l) == 0:
        continue
    ans = max(ans, culc(F, P, l))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int st[100008];

int main(){
    int k,n,t,i,r;
    while(scanf("%d",&n),n){
        memset(st,0,400032);
        scanf("%d",&t);
        k=t;
        for(i=1;i<n;i++){
            scanf("%d",&t);
            if((k&1)^t){
                if(i&1){
                    k--;
                    if(k<0){st[0]=st[1]=0;k=1;}
                }else{
                    k++;
                    st[k]=i;
                }
            }
        }
        st[k+1]=n;r=0;
        for(i=0;i<=k;i+=2)
            r+=(st[i+1]-st[i]);
        printf("%d\n",r);
    }
    return 0;
}

Measured memory_bytes: 996
#include<stdio.h>
#include<string.h>

int main(void){
	int n,t,i,a,cpest = 1000000007,hiest = 0,c = 0;
	scanf("%d%d",&n,&t);
	for(i = 1;i <= n;i++){
		scanf("%d",&a);
		if(i == 1){cpest = a;}
		else{
			if(cpest > a){cpest = a;}
			if((a - cpest) > hiest){c = 1;hiest = a - cpest;}
			else if((a - cpest) == hiest){c++;}
		}
	}
	printf("%d\n",c);
	return 0;
}

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

void Main() {
    // input
    int X;
    cin >> X;


    // process


    // output
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

const ll MAX_N = 212345;
ll MOD = ll(1000000000+7);
ll fac2[MAX_N];

void init(){
    fac2[0] = 1ll;
    for(int i=1;i<MAX_N;i++){
        fac2[i] = (fac2[i-1]*2ll)%MOD;
    }
}

int main(void)
{
    init();
    ll N;
    cin >> N;
    map<pair<ll, ll>, pair<int, int>> umap;
    // pair<int, int> zpair = {0, 0};
    ll zero = MOD - 1;
    for(int i=0;i<N;i++){
        ll a, b;
        cin >> a >> b;
        if(a==0 && b==0){
            zero++;
            continue;
        }
        // if(a==0){
        //     zpair.first++;
        //     continue;
        // }
        // if (b==0){
        //     zpair.second++;
        //     continue;
        // }
        if(make_pair(a, b) < make_pair(0ll, 0ll)){
            a = -a;
            b = -b;
        }
        ll d = gcd(abs(a), abs(b));
        a /= d;
        b /= d;
        if(b>0){
            umap[{a, b}].first += 1;
        }else{
            umap[{-b, a}].second += 1;
        }
    }
    // ll answer = (fac2[zpair.first] + fac2[zpair.second] - 1ll) % MOD;
    ll answer = 1ll;
    for(auto& item:umap){
        answer *= (fac2[item.second.first]+fac2[item.second.second]-1ll) % MOD;
        answer %= MOD;
    }
    cout << (answer + zero) % MOD << endl;

    return 0;
}

Measured memory_bytes: 17648
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 3005;
const LL MOD = 1000000007;

int N;
char s[MAXN];
int dp[MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	s[0] = '<';
	cin >> N >> s + 1;
	for (int i = 1; i <= N; i++) dp[N][i] = 1;
	for (int i = N - 1; i >= 0; i--) {
		int sz = N - i;
		char ch = s[i];
		
		if (ch == '<') {
			int sum = 0;
			for (int j = sz; j >= 1; j--) {
				sum = (sum + dp[i + 1][j]) % MOD;
				dp[i][j] = sum;
//				cout << i << " " << j << " -> " << dp[i][j] << '\n';
			}
		}
		else {
			int sum = 0;
			for (int j = 2; j <= sz + 1; j++) {
				sum = (sum + dp[i + 1][j - 1]) % MOD;
				dp[i][j] = sum;
			}
		}
	}
	
	cout << dp[0][1] << "\n";
}


Measured memory_bytes: 35200
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  int tmp;
  if(b<10){
    tmp=a*10+b;
  }
  else if(b<100){
    tmp=a*100+b;
  }
  else{
    tmp=a*1000+b;
  }
  bool ans=false;
  for(int i=0;i<1000;i++){
    if(i*i==tmp){
      ans=true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan.split(" ");
    // int型へ変換
    var X = Long.parseLong(str[0]);
    var K = Long.parseLong(str[1]);
    var D = Long.parseLong(str[2]);

    long ans = 0;
    long syou = 0;
    long amari = 0;

    if ( X < 0 ){
      X = X * -1;
    }

    syou = X / D;
    amari = X % D;

    if ( syou < K ) {
      if ((K % 2 == 1) && (syou % 2 == 1)){
        ans = amari;
      } else if ( (K % 2 == 0) && (syou % 2 == 0)) {
        ans = amari;
      } else if ( (K % 2 == 0) && (syou % 2 == 1)) {
          ans = amari - D;
      } else if ( (K % 2 == 1) && (syou % 2 == 0)){
          ans = amari - D;
      }
      if (ans < 0) {
        ans = -1 * ans;
      }
    } else {
      ans = amari + ((syou-K) * D);
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35600
import bisect
import heapq
n,m=map(int,input().split())
py_i=[[int(x) for x in input().split()] for _ in range(m)]
y_p=[[] for i in range(n+1)]
for x,y in sorted(py_i):
    #print(x)
    y_p[x].append(y)
for x,y in py_i:
    z=bisect.bisect_right(y_p[x],y)
    print("%06d"%x+"%06d"%z)

#print(y_p)

Measured memory_bytes: 34436
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
ans = 0
for i in range(n):
    s = input()
    if s[0] == 'M':
        m += 1
    elif s[0] == 'A':
        a += 1
    elif s[0] == 'R':
        r += 1
    elif s[0] == 'C':
        c += 1
    elif s[0] == 'H':
        h += 1
lis = [m, a, r, c, h]
for i in range(len(lis) - 2):
    for j in range(i + 1, len(lis) - 1):
        for k in range(j + 1, len(lis)):
            ans += lis[i] * lis[j] * lis[k]
print(ans)




Measured memory_bytes: 3064
#複数の整数入力を受け付ける関数
def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

n,x = datain(2)
total,mindata = 0,1000000

for i in range(n):
    val = int(input())
    total += val

    if mindata > val:
        mindata = val

print(n+(x-total)//mindata)

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

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll n, m, i, j, k, q;

  string s, t;

  cin >> s >> t;

  n = sz(s), m = sz(t);

  ll a[26] = {0}, b[26] = {0};

  for(auto c : s){
    a[c - 'a']++;
  }
  for(auto c : t){
    b[c - 'a']++;
  }

  forn(0, 26, i){
    if(a[i] == 0 and b[i]){
      cout << "-1\n"; return 0;
    }
  }

  vl idx[26];

  forn(0, n, i){
    idx[s[i] - 'a'].pb(i);
  }  

  ll last = -1;
  ll ans = 0;
  ll step = 0;
  forn(0, m, i){
    auto now = lower_bound(all(idx[t[i] - 'a']), last);
    if(now == idx[t[i] - 'a'].end()){
      step++;
      last = idx[t[i] - 'a'][0];
    }else{
      last = *now;
    }
    last++;
    ans = max(ans, n * step + last + 1);
  }

  cout << ans - 1 << '\n';

  ktj();
}


Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double x = (a+b)/2.0;
		int ceilX = (int) Math.ceil(x);
		System.out.println(ceilX);
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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



int main()
{
    ll X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int main() {
	int n, q;
	cin >> n >> q;
	string ans;
	if (n >= 2 * q - 1) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int cnt = 0;
    boolean A = false;
    String ans = "Yes";
    char[][] paints = new char[H][W];
    for (int i = 0; i < H; i++) {
      paints[i] = sc.next().toCharArray();
    }
    int[] y = { 1, -1, 0, 0 };
    int[] x = { 0, 0, 1, -1 };

    loop: for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (paints[i][j] == '#') {
          cnt = 0;
          for (int k = 0; k < 4; k++) {
            A = false;
            int nextPointY = i + y[k];
            int nextPointX = j + x[k];
            if (nextPointY < 0 || nextPointY >= H || nextPointX < 0 || nextPointX >= W) {
              continue;
            }
            if (paints[nextPointY][nextPointX] == '#') {
              A = true;
              break;
            }
          }
          if (A == false) {
            ans = "No";
            break loop;
          }
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
a,b,c,k = list(map(int,input().split()))
ta = tb = tc = 0
s = a+b+c
a = s*(k//4)+a
b = s*(k//4)+b
c = s*(k//4)+c
for i in range(k%4):
    ta = a
    tb = b
    tc = c
    a = tb+tc
    b = ta+tc
    c = ta+tb
print(a-b if abs(a-b) < 10**18 else 'Unfair')

Measured memory_bytes: 3064
N, x = map(int,input().split())
a = sorted([int(i) for i in input().split()])
count = 0
if sum(a) == x:
    print(len(a))
else:
    for i in a:
        x = x-i
        if x<0:
            break
        count+=1
    if count == N:
        print(N-1)
    else:
        print(count)

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

int main() {
    char a;
    cin >> a;
    if (isupper(a)) cout << "A" << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <queue>
#include <stdlib.h>
using namespace std;

int main() {
    char com[20];
    int key;
    priority_queue<int> PQ;
    while(1) {
        cin >> com;
        if(com[0] == 'i') {
            cin >> key;
            PQ.push(key);
        }
        else if(com[1] == 'x') {
            cout << PQ.top() << endl;
            PQ.pop();
        }
        else if(com[0] == 'e') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 6968
#include<bits/stdc++.h>
using namespace std;
map<string,bool>a;
int n;
string s[1010];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    	cin>>s[i];
    a[s[1]]=1;
    for(int i=2;i<=n;i++)
    {
    	if(a[s[i]]==1){cout<<"No"<<endl;return 0;}
    	a[s[i]]=1;
    	if(s[i][0]!=s[i-1][s[i-1].size()-1])
    	{
    		cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007

int main(){
  int N;
  cin>>N;
  vector<int> A(N+2);
  for(int i=1;i<=N;i++){
    cin>>A.at(i);
  }
  A.at(0)=A.at(1);
  A.at(N+1)=A.at(N);

  int ans=1;
  int i=0;
  int slope=0;
  while(i<=N){
    if(A.at(i+1)>A.at(i)){
      if(slope==-1){
        ans++;
        i++;
        slope=0;
      }else{
        slope=1;
        i++;
      }
    }else if(A.at(i+1)<A.at(i)){
      if(slope==1){
        ans++;
        i++;
        slope=0;
      }else{
        slope=-1;
        i++;
      }
    }else{
      i++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>

typedef long long ll;
using namespace std;

ll n, m, k;
vector<int> g1[500000];
vector<int> g2[500000];
ll c1[500000];
ll c2[500000];

void dfs1(int v, int c)
{
    if (c1[v] == 0)
    {
        c1[v] = c;
        for (int i = 0; i < g1[v].size(); i++)
        {
            dfs1(g1[v][i], c);
        }
    }
}

void dfs2(int v, int c)
{
    if (c2[v] == 0)
    {
        c2[v] = c;
        for (int i = 0; i < g2[v].size(); i++)
        {
            dfs2(g2[v][i], c);
        }
    }
}
map<pair<int, int>, int > x;
signed main()
{
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        g1[a].push_back(b);
        g1[b].push_back(a);
    }
    for (int i = 0; i < k; i++)
    {
        ll a, b;
        cin >> a >> b;
        g2[a].push_back(b);
        g2[b].push_back(a);
    }
    ll f1 = 0, f2 = 0;
    for (int i = 1; i <= n; i++)
    {
        if (c1[i] == 0)
        {
            f1++;
            dfs1(i, f1);
        }
        if (c2[i] == 0)
        {
            f2++;
            dfs2(i, f2);
        }
        x[{c1[i], c2[i]}]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << x[{c1[i], c2[i]}] << " ";
    }
}


Measured memory_bytes: 47744
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nt: Vec<usize> = read_vec();
    let n = nt[0];
    let t = nt[1] / 2;
    let a: Vec<u32> = read_vec();
    let mut cnt = 0;
    let mut min = a[0];
    let mut d = 0;
    for i in 1..n {
        if a[i] < min {
            min = a[i];
        }
        if a[i] - min == d {
            cnt += 1;
        } else if a[i] - min > d {
            cnt = 1;
            d = a[i] - min;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long nodes = 0, edges = 0;
    for(long long i = 1; i <= n; i++){
        nodes = nodes + i * (n - i + 1);
    }
    for(long long i = 1; i < n; i++){
        long long u, v;
        cin >> u >> v;
        long long a = min(u, v), b = max(u, v);
        edges = edges + a * (n - b + 1);
    }
    cout << nodes - edges;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,Cou[1000];
void push(int);
int pop(void);
int main(){
  int n,m;
  top = 0;
  char in[100];
  while((scanf("%s",in))!= EOF){
    if(in[0]=='+'){
      n = pop();
      m = pop();
      push(n+m);
    }
    else if(in[0]=='-'){
      m = pop();
      n = pop();
      push(n-m);
    }
    else if(in[0]=='*'){
      n = pop();
      m = pop();
      push(n*m);
    }
    else{
      push(atoi(in));
    }
  }
  printf("%d\n",pop());
  return 0;
}
void push(int n){
  Cou[++top]=n;
}
int pop(){
  top--;
  return Cou[top+1];
}



Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

using namespace std;

typedef long long ll;

int main()
{
	ll N = 0, A = 0, B = 0;
	vector<ll> X;
	ll ret = 0;

	cin >> N >> A >> B;
	X.resize(N);

	Rep(i, N) {
		cin >> X[i];
	}

	Rep(i, N - 1) {
		ll dist = X[i + 1] - X[i];
		ret += min(dist * A, B);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans = min(b, a * n);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int inf=100000;

int main(){
  string s;
  cin>>s;
  int n=SIZE(s);
  vll a(n+1,0),c(1,1);
  REP(i,n-1){
    if(s[i]==s[i+1]){
      c[SIZE(c)-1]++;
    }
    else{
      c.push_back(1);
    }
  }
  ll ans=0;
  if(s[0]=='<'){
    for(int i=0;i<SIZE(c)-1;i+=2){
    ans+=max(c[i],c[i+1])*(max(c[i],c[i+1])+1)/2;
    ans+=min(c[i],c[i+1])*(min(c[i],c[i+1])-1)/2;
    }
    if(SIZE(c)%2==1){
      ans+=c[SIZE(c)-1]*(c[SIZE(c)-1]+1)/2;
    }
  }
  else{
    ans+=c[0]*(c[0]+1)/2;
    for(int i=1;i<SIZE(c)-1;i+=2){
    ans+=max(c[i],c[i+1])*(max(c[i],c[i+1])+1)/2;
    ans+=min(c[i],c[i+1])*(min(c[i],c[i+1])-1)/2;
    }
    if(SIZE(c)%2==0){
      ans+=c[SIZE(c)-1]*(c[SIZE(c)-1]+1)/2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6908
#include <stdio.h>

int main(void)
{
    int c;
    c = 0;
    char s[3];
    scanf("%s",&s);
    if(s[0] == '1') c++;
    if(s[1] == '1') c++;
    if(s[2] == '1') c++;
    printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 105;
int nums[N];
int n;

int sqr(int i) {
  return i*i;
}

int eval(int p) {
  int cost = 0;
  forx(i,n) {
    cost += sqr(p - nums[i]);
  }
  return cost;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  cin >> n;
  forx(i,n) cin >> nums[i];
  int ans = INF;
  for (int p = 1; p <= 100; ++p) {
    ans = min(ans, eval(p));
  }
  cout << ans << nl;
  return 0;
}



Measured memory_bytes: 256
main :: IO ()
main = do
    [sx, sy, tx, ty] <- map read . words <$> getLine
    putStrLn $ solve sx sy tx ty

solve :: Int -> Int -> Int -> Int -> String
solve sx sy tx ty = replicate dy 'U'
    ++ replicate (dx + 1) 'R'
    ++ replicate (dy + 1) 'D'
    ++ replicate (dx + 1) 'L'
    ++ "UL"
    ++ replicate (dy + 1) 'U'
    ++ replicate (dx + 1) 'R'
    ++ replicate (dy + 1) 'D'
    ++ replicate dx 'L'
    where
        dx = tx - sx
        dy = ty - sy


Measured memory_bytes: 1020
Num=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,121645100408832000,2432902008176640000,51090942171709440000,1124000727777607680000,25852016738884976640000,620448401733239439360000,15511210043330985984000000,403291461126605635584000000,10888869450418352160768000000,304888344611713860501504000000,8841761993739701954543616000000,265252859812191058636308480000000,8222838654177922817725562880000000,263130836933693530167218012160000000,8683317618811886495518194401280000000,295232799039604140847618609643520000000,10333147966386144929666651337523200000000,371993326789901217467999448150835200000000,13763753091226345046315979581580902400000000,523022617466601111760007224100074291200000000,20397882081197443358640281739902897356800000000,815915283247897734345611269596115894272000000000,33452526613163807108170062053440751665152000000000,1405006117752879898543142606244511569936384000000000,60415263063373835637355132068513997507264512000000000,2658271574788448768043625811014615890319638528000000000,119622220865480194561963161495657715064383733760000000000,5502622159812088949850305428800254892961651752960000000000,258623241511168180642964355153611979969197632389120000000000,12413915592536072670862289047373375038521486354677760000000000,608281864034267560872252163321295376887552831379210240000000000,30414093201713378043612608166064768844377641568960512000000000000,1551118753287382280224243016469303211063259720016986112000000000000,80658175170943878571660636856403766975289505440883277824000000000000,4274883284060025564298013753389399649690343788366813724672000000000000,230843697339241380472092742683027581083278564571807941132288000000000000,12696403353658275925965100847566516959580321051449436762275840000000000000,710998587804863451854045647463724949736497978881168458687447040000000000000,40526919504877216755680601905432322134980384796226602145184481280000000000000,2350561331282878571829474910515074683828862318181142924420699914240000000000000,138683118545689835737939019720389406345902876772687432540821294940160000000000000]

N, P = map(int, input().split())
A = list(map(int, input().split()))

tmp=0
total=0
for i in A:
    tmp+=i%2
R=N-tmp

K=1
for i in range(1,R+1):
    K+=Num[R]//(Num[R-i]*Num[i])


if(tmp%2==P):
    total=K
    for i in range(2,tmp+1,2):
        total+=(Num[tmp]//(Num[tmp-i]*Num[i]))*K
else:
    for i in range(1,tmp+1,2):
        total+=(Num[tmp]//(Num[tmp-i]*Num[i]))*K

print(total)

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const double pi = 3.141592653589793;

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

    int A,B,H,M;
    cin >> A >> B >> H >> M;

    long double hour=360.0*(H+(M/60.0))/12.0;
    long double minute=360.0*M/60.0;
    /*
    if(M==0)
    {
        if(H>6)
        {
            minute=360;
        }
    }
    if(H==0)    
    {
        if(M>=30)
        {
            hour=360;
        }
    }
 */
    long double ans;
    long double theta = abs(hour-minute);
    long double edge1, edge2;

    edge1=max(A,B)*sin(pi*theta/180);
    edge2=max(A,B)*cos(pi*theta/180)-min(A,B);
    
    long double tmp = edge1*edge1+edge2*edge2;
    ans=double(sqrt(tmp));



    cout << ans << endl;

 

 

    return 0;
}



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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    
    int last2 = 0;
    int last1 = 1;
    int brokenIndex = 0;

    for (int i = 1; i <= N; i++) {
        if (brokenIndex < M) {
            if (i == A[brokenIndex]) {
                last2 = last1;
                last1 = 0;
                brokenIndex++;
                continue;
            }
        }
        int tmp = (last2 + last1) % 1000000007;
//        cout << i << ":" << last2 << "," << last1 << "," << tmp << endl;
        last2 = last1;
        last1 = tmp;
    }
    cout << last1;
    return 0;
}

Measured memory_bytes: 892
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

//組み合わせ
const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    llong N;
    cin >> N;
    string S;
    cin >> S;
    llong ans=0;

    for(int i=0; i<S.size()-3+1; i++){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3196
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
    int N=int.Parse(str[0]);
    int M=int.Parse(str[1]);
    
    if(N==M){
    Console.WriteLine("Yes");
    }else{
    Console.WriteLine("No");
    
  }
    }
  }
}

Measured memory_bytes: 11092
def comb_mod(n, r, M):
    p = q = 1
    for i in range(r):
        p = p * (n - i) % M
        q = q * (i + 1) % M
    return p * pow(q, M - 2, M) % M


n, a, b = map(int, input().split())
M = 10 ** 9 + 7

res = (pow(2, n, M) - 1 - comb_mod(n, a, M) - comb_mod(n, b, M)) % M
print(res)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct FenwickTree{
    vector<T> fenwick;
    int  n;

    FenwickTree(int n):
        fenwick(vector<T>(n+1, 0)), n(n) {}

    T sum(int i) {
        if (!i) return 0;
        return fenwick[i] + sum(i-(i&-i));
    }

    T sum(int i, int j){
        // half-open Terval
        return sum(j-1) - sum(i-1);
    }

    void add(int i, T x) {
        if (i > n) return;
        fenwick[i] += x;
        add(i+(i&-i), x);
    }
};

//1-indexed
//  http://na-o-s.hateblo.jp/entry/2014/07/13/031143

vector<int32> c;
vector<vector<int32>> adj;

vector<int32> in,out;
int32 k = 0;
void dfs(int32 v, int32 p = -1){
    in[v] = k++;
    for(auto u : adj[v]){
        if(u == p)continue;
        dfs(u,v);
    }
    out[v] = k;
}

int64 f(int64 n){
    return n + (n) * (n - 1) / 2;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    c.resize(n);
    REP(i,n)cin >> c[i],c[i]--;
    adj.resize(n);
    REP(i,n-1){
        int32 a,b;
        cin >> a >> b;
        --a;--b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    in.resize(n);
    out.resize(n);
    dfs(0);
    // REP(i,n)cout << in[i] << " ";
    // cout << endl;
    vector<vector<int32>> vlist(n);
    FenwickTree<int32> fwk(n);
    REP(i,n)fwk.add(i+1,1);
    REP(i,n)vlist[c[i]].pb(i);
    REP(i,n){
        vector<pii> memo;
        int64 ans = f(n);
        sort(ALL(vlist[i]),[&](int32 a, int32 b){return in[a] > in[b];});
        for(auto v : vlist[i]){
            int32 mns = 1;
            for(auto u : adj[v]){
                if(in[u] < in[v])continue;
                int32 s = fwk.sum(in[u]+1,out[u]+1);
                ans -= f(s);
                mns += s;
            }
            fwk.add(in[v]+1,-mns);
            memo.emplace_back(in[v]+1,mns);
        }
        ans -= f(fwk.sum(1,n+1));
        for(auto p : memo){
            fwk.add(p.first,p.second);
        }
        ANS(ans);
    }
    return 0;
}

Measured memory_bytes: 39212
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

auto main() -> i32 {
	i32 x;
	scanf("%d", &x);
	puts(x >= 30 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 32500000;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);

ll n,freq[26];
string s;
ll dp[26];
vector<int> v;
ll calc(int idx){
    if(idx==26)return 1;
    ll&ret = dp[idx];
    if(ret!=-1)return ret;
    ret = (calc(idx+1)+((freq[idx])*calc(idx+1)%M)%M)%M;
    return ret;
}


signed main(){
    cin >> n;
    cin >> s;
    for(int i = 0 ; i < n ; i++){
        freq[s[i]-'a']++;
    }
    for(int i = 0 ; i < 26 ; i++){
        if(freq[i])v.push_back(i);
    }
    setDP(dp);
    cout << calc(0)-1 << endl;



}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int n, answer = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int count = 0;

        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0 && i % 2 != 0) count++;
        }

        if (count == 8) answer++;
    }
    cout << answer << endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int w[10],k[10], i, j, a, b, wscore = 0, kscore = 0;

  for(i = 0 ; i < 10 ; i++){
    scanf("%d",&w[i]);
  }
  for(i = 0 ; i < 10 ; i++){
    scanf("%d",&k[i]);
  }
  for(i = 0 ; i < 9 ; i++){
    for(j = i+1 ; j < 10 ; j++){
      if(w[j] > w[i]){
	a = w[i];
	w[i] = w[j];
	w[j] = a;
      }
    }
  }
  for(i = 0 ; i < 3 ; i++){
    wscore += w[i];
  }
  for(i = 0 ; i < 9 ; i++){
    for(j = i+1 ; j < 10 ; j++){
      if(k[j] > k[i]){
	b = k[i];
	k[i] = k[j];
	k[j] = b;
      }
    }
  }
  for(i = 0 ; i < 3 ; i++){
    kscore += k[i];
  }
  printf("%d %d\n",wscore,kscore);

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  int t; cin >> t;
  int sum[t+2] = {};
   rep(i,n){
     int ai,bi; cin >> ai >> bi;
     sum[ai]++; sum[bi]--;
   }
   rep(i,t+1){
     sum[i+1] += sum[i];
   }
   int ans = 0;
   rep(i,t+2){
     ans = max(ans,sum[i]);
   }
   cout << ans << "\n";
}


Measured memory_bytes: 3500
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int n,m;
	cin>>n>>m;
	map<int,int>ma;
	rep(i,n){
		int a;cin>>a;
		ma[a]++;
	}
	rep(i,m){
		int a,b;
		cin>>a>>b;
		ma[b]+=a;
	}
	int sum=0;
	for(auto it=ma.rbegin();it!=ma.rend();it++){
		sum+=it->first*min(n,it->second);
		n=max(0ll,n-it->second);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 12800
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  int k; cin >> k;
  priority_queue<string, vector<string>, greater<string>> q;
  set<string> st;
  rep(i,n){
    string t;
    for(int j=i;j<min(i+k,n);j++){
      t+=s[j];
      st.insert(t);
    }
  }
  for(auto c:st){
    q.push(c);
  }
  rep(i,k-1){
    q.pop();
  }
  cout << q.top() << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n;
cin>>n;
vector<ll> a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
ll lm=a.at(0);
    for(int i=1;i<n;i++){
     lm=lcm(lm,a.at(i));
}
cout<<lm<<endl;
}

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

int main(){
	string s;
	cin >> s;
	int ans1=0, ans2=0;
	for(int i=0; i<(int)s.length(); i++){
		if(i%2 == 0){
			if(s[i] == '0') ans1++;
			else ans2++;
		}else{
			if(s[i] == '1') ans1++;
			else ans2++;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

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

int main() {
  string n;
  cin >> n;
  if ( n[0] == n[1] && n[0] == n[2] ) {
    cout << "Yes" << endl;
  } else if( n[3] == n[1] && n[3] == n[2] ) {
    cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
<?php
// Here your code !

#$a = explode(",", trim(fgets(STDIN)));
#var_dump($a);

while($line = trim(fgets(STDIN))) {
  $line = explode(",", $line);
  $bmi = $line[1] / ($line[2] * $line[2]);
  if ($bmi >= 25) {
      printf("%d\n", $line[0]);
  }
}

Measured memory_bytes: 15280
#include <stdio.h>
#include <stdlib.h>

int main(){
    int a, b, result;
    scanf("%d %d", &a, &b);
    if (a < 10 && b < 10){
        result = a * b;
    }
    else{
        result = -1;
    }
    printf("%d", result);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) < abs(x-b)) {
        out("A");
    }
    else {
        out("B");
    }

    

    re0;
}

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

int main(void){
  int N, M, K;
  cin >> N >> M >> K;
  bool ans = false;
  for(int n=0;n<=N;n++){
    for(int m=0;m<=M;m++){
      if((N-n)*m+(M-m)*n == K){
        ans = true;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;
int main(){
    int n,m;
    cin >> n >> m;
    pair<int, string> sub[m];
    for(int i=0;i<m;i++) {
        cin >> sub[i].first >> sub[i].second;
        sub[i].first--;
    }

    pair<int, int> w[n];
    for(int i=0;i<n;i++){
        w[i].first=0;
        w[i].second=1;
    }

    int ac=0;
    int sum=0;
    for(int i=0;i<m;i++){
        if(w[sub[i].first].second){
            if(sub[i].second=="WA"){
                w[sub[i].first].first++;
            }else{
                ac++;
                sum+=w[sub[i].first].first;
                w[sub[i].first].second=0;
            }
        }  
    }

    cout << ac << ' ' << sum << endl;
}

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

enum color{WHITE, GRAY, BLACK};

int calc(vector<vector<int> >& G, vector<color>& state){
    int i_min = 0;
    int j_min = 0;
    for (int i = 0; i < G.size(); i++) {
        if (state[i] == WHITE || state[i] == BLACK) {
            continue;
        }
        bool is_black = true;
        for (int j = 0; j < G[i].size(); j++) {
            if (state[j] == WHITE){
                is_black = false;
                if (G[i][j] < G[i_min][j_min]) {
                    i_min = i;
                    j_min = j;
                }
            }
        }
        if (is_black) state[i] = BLACK;
    }
    state[j_min] = GRAY;
    return G[i_min][j_min];
}

int Prim(vector<vector<int> >& G) {
    vector<color> state(G.size(), WHITE);
    state[0] = GRAY;
    int ret = 0;

    for (int i = 0; i < G.size() - 1; i++) {
        ret += calc(G, state);
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> G[i][j];
            if (G[i][j] == -1) G[i][j] = 1e6;
        }
    }

    cout << Prim(G) << endl;

    return 0;
}

Measured memory_bytes: 3160
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
one=[0 for i in range(n)]
ans = "IMPOSSIBLE"
for i in a:
  if i[0] == 1:
    if one[i[1]] == 1:
      ans = "POSSIBLE"
      break
    else:
      one[i[1]] = 1
  elif i[1] == n:
    if one[i[0]] == 1:
      ans = "POSSIBLE"
      break
    else:
      one[i[0]] = 1
print(ans)

Measured memory_bytes: 53408
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int e = 4*1e6 + 69;
const int mod = 1e9 + 7;

ll a[e];
bitset<e>bits;

int main()
{
    ll n;
    cin >> n;
    bits[0] = 1;
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin >> x;
        bits |= (bits << x);
    }
    ll dem = 0;
    for(int i=1; i<=e; i++)
    {
        if(bits[i])
        {
            dem ++;
            a[dem] = i;
        }
    }
    cout << a[(dem + 1)/2];

}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
using namespace std;
typedef double db;
int a, b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	db sum=0;
	cin >> n;
	vector<db> a(n);
	vector<db> b(n);
	REP(i, n) {
		cin >> a[i];
		b[i] = 1 / a[i];
	}
	REP(i, n) {
		sum += b[i];
	}
	cout << 1 / sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int N;

int main(){
	cin >> N;
	vector<ll> v(N+1),u(N+1);
	for(int i=1;i<=N;i++){
		cin >> v[i];
		u[v[i]] = i;
	}
	int ans = 0,count = 1;
	for(int i=1;i<N;i++){
		if(u[i]<u[i+1]) count++;
		else{
			ans = max(ans,count);
			count = 1;
		}
	}
	ans = max(count,ans);
	cout << N - ans << endl;
	return 0;
}

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

int main(){
  int data[10010];
  while(1){
    int n; cin >> n;
    if( n == 0 ) break;
  
    int i,j;
    for( i = 1; i <= n; i++ )cin >> data[i];
    
    for( i = 1; i <= n; i++ ){
      for( j = 1; j < n; j++ ){
	if( data[j] > data[j+1]) swap( data[j],data[j+1] );
      }
    }
   
    long long time = 0,total = 0;
    
    for( i = 1; i <= n; i++ ){
      // cout << "i" << i << " ";
      total += data[i-1];
      // cout << "total" << total << " " << "data[i-1]" << data[i-1] << " ";
      time += total;
      // cout << "time" << " " << time << endl;
    }
    cout << time  << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main()
{
	int N;
	long long int X=0;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		if(i%3==0&&i%5==0){
		}
		else if(i%3==0){
		}
		else if(i%5==0){
		}
		else{	
		X=X+i;
		}
	}
		printf("%lld",X);
		
}



Measured memory_bytes: 3232