akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<map>
#include<string>
using namespace std;

set<int> alp[10];
map<char,int> m;
set<int>::iterator ite;

set<int> parse(string s){
  int p = 0, l = s.size();
  set<int> a,b,res;

  if(!s.size())return res;
  for(int i=l-1;i>=0;i--){
    if(s[i]==')')p++;
    if(s[i]=='(')p--;
    if(!p && ('a'<=s[i] && s[i]<='z' && s[i]!='c')){
      a = parse(s.substr(0,i));
      b = parse(s.substr(i+1,l-i-1));
      if(s[i] == 'u'){
	for(ite = a.begin();ite!=a.end();ite++)res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)res.insert(*ite);
	return res;
      }
      if(s[i] == 'i'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)!=b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 'd'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 's'){
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)
	  if(a.find(*ite)==a.end())res.insert(*ite);
	return res;
      }
    }
  }

  if(s[0] == 'c'){
    a = parse(s.substr(1,l-1));
    for(ite = alp[0].begin();ite!=alp[0].end();ite++)
      if(a.find(*ite)==a.end())res.insert(*ite);
    return res;
  }
  if(s[0] == '(' && s[l-1] == ')')return parse(s.substr(1,l-2));
  return alp[m[s[0]]];
}

int main(){
  char c;
  int n,tmp;
  string str;

  while(cin >> c >> n){
    m.clear();
    for(int i=0;i<6;i++)alp[i].clear();
    while(c != 'R'){
      m[c] = m.size();
      for(int i=0;i<n;i++){
	cin >> tmp;
	alp[m[c]].insert(tmp);
	alp[0].insert(tmp);
      }
      cin >> c >> n;
    }
    cin >> str;
    
    set<int> ans = parse(str);
    if(ans.empty())cout << "NULL\n";
    else{
      set<int>::iterator ansend = --(ans.end());
      for(ite = ans.begin();ite!=ansend;ite++)cout << *ite << " ";
      cout << *ansend << endl;
    }
  }
}     

Measured memory_bytes: 0
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  bool ans = true;
  if (a == b && b == c)
  {
    ans = false;
  }
  if (a != b && b != c && c != a)
  {
    ans = false;
  }
  cout << (ans ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
 
ll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); 
  int a,b;
  cin>>a>>b;
  ll ans = 1LL*a*b;
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)      for (int i = 1;i<=(int)(n);i++)
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         neli            printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define         pb             push_back
#define         ppb            pop_back
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef double                db;
typedef long double           ldb;

int pos(int arr[], int n, int x)
{
    int i;
    for (i = 1; i <= n; i++)
        if (arr[i] == x)
            return i;
}

int main()
{
    FIO;
    int a,b,c;cin>>a>>b>>c;
    if((a+b+c)>=22)
        puts("bust");
    else
        puts("win");
	return 0;
}


Measured memory_bytes: 256
import numpy as np

n=int(input())

def fact(m):
    factor1=[0] * m
    for j in range(2,m+1):
        factor = [0] * j
        for i in range(2,int(np.sqrt(j)+2)):
            while j % i == 0:
                j//=i
                factor[i-1]+=1
        factor[j-1]+=1
        for k in range(len(factor)):
            factor1[k]+=factor[k]
    return factor1
ans=1
mod=1000000007
for i in fact(n)[1:]:
    if i!=0:
        ans*=(i+1)
        ans%=mod

print(ans)





Measured memory_bytes: 12484
o = list(input())
e = list(input())
if len(o) > len(e):
    l =[o[0]]
    for i in range(len(e)):
        l.append(e[i])
        l.append(o[i + 1])
else:
    l = []
    for i in range(len(e)):
        l.append(o[i])
        l.append(e[i])
print(*l, sep="")

Measured memory_bytes: 38256
/*
  Contest 114
  B - 754
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    std::string s;
    std::getline(std::cin, s);
    int min = 1e+8;
    for (std::size_t i = 0; i < s.size() - 2; ++i) {
        const int x = std::stoi(s.substr(i, 3));
        min = std::min(std::abs(753 - x), min);
    }
    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>

int main(){
    int N,i;
    float ans,a;
    ans = 0;
    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%f",&a);

        ans += 1/a;
    }
    printf("%f",1/ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k =0;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k-1] =='A'){
        s[k-1] = 'a';
    }else if(s[k-1]== 'B'){
        s[k-1] = 'b';
    }else if(s[k-1]== 'C'){
        s[k-1] = 'c';
    }
    cout << s;
}

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

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> A(N);

    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    int idx = 0;
    int ans = 0;
    while(idx < N-1){
        ans++;
        idx += K-1;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int ans=0;
    for(int i=1;i<n+1;i++){
        int c=i;
        int sum=0;
        while(true){
            if(c/10==0){
                sum+=c;
                break;
            }
            else{
                sum+=c%10;
                c/=10;
            }
        }
        if(sum>=a&&sum<=b) ans+=i;
    }   
    cout << ans << endl;
}

Measured memory_bytes: 384
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        mut n: u64,
    }

    let mut hm = HashMap::new();
    let mut divisor = 2;
    while n > 1 {
        // println!("n, divisor: {}, {}", n, divisor);
        if n % divisor == 0 {
            let counter = hm.entry(divisor).or_insert(0);
            *counter += 1;
            n /= divisor;
        } else if divisor * divisor > n {
            let counter = hm.entry(n).or_insert(0);
            *counter += 1;
            break;
        } else {
            divisor += 1;
        }
    }
    // println!("{:?}", hm);

    let mut ans = 0;
    for (_, v) in hm.iter() {
        // println!("v: {}", v);
        let mut a = *v;
        let mut b = 1;
        while a >= b {
            a -= b;
            b += 1;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n;
    rep(i,0,n){
        cin>>p;
        if(p%2==0){
            if(p%3&&p%5){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;


}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 0
min_a = 10**9+1
flg = False
for i in range(n):
    ans += abs(a[i])
    if a[i] <= 0:
        flg = not flg
    min_a = min(min_a, abs(a[i]))

if flg:
    ans -= 2*min_a

print(ans)


Measured memory_bytes: 19980
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M, K) = nextIntList()
    val A = nextLongList()
    val B = nextLongList()
    var i = 0
    var j = 0
    var k = 0L
    while (i < N) {
        if (k + A[i] <= K) {
            k += A[i++]
        } else {
            break
        }
    }
    while (j < M) {
        if (k + B[j] <= K) {
            k += B[j++]
        } else {
            break
        }
    }
    var ans = i + j
    while (i > 0 && j < M) {
        k -= A[--i]
        while (j < M) {
            if (k + B[j] <= K) {
                k += B[j++]
            } else {
                break
            }
        }
        if (ans < i + j) ans = i + j
    }
    println(ans)
}

Measured memory_bytes: 81888
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(dp[N][W])


Measured memory_bytes: 120300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

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

ll lcm(ll c, ll d){
    ll g = gcd(c,d);
    ll l = c/g*d;//最小公倍数
    return l;
}

int main() {
  int x;
  cin >> x;
  int l = lcm(x, 360);
  cout << l / x << endl;
  return 0;
} 

Measured memory_bytes: 3640
# coding: utf-8
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f(N, K, A):
    m = [[0] * N for _ in range(N)]
    for i in range(N):
        m[i][i] = 1
    k = K
    a = A

    def mulmod(a, b):
        m = [[0] * N for _ in range(N)]
        for i, r, in enumerate(a):
            for j, c in enumerate(zip(*b)):
                m[i][j] = sum(x * y for x, y in zip(r, c)) % mod
        return(m)

    while k > 0:
        if k & 1:
            m = mulmod(m, a)
        a = mulmod(a, a)
        k >>= 1

    return(sum(sum(x) for x in m) % mod)

N, K = map(int, input().split()) # 1 <= N <= 50, 1 <= K <= 10^18
a = [list(map(int, input().split())) for _ in range(N)]

print(f(N, K, a))


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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if(a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if(a < b) a = b; }

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}


int64 calc(int64 a, int64 b, int64 x) {
    int64 greed = 0;
    greed = (x / b) + (x % b) / a + x % b % a;
    vector<int64> dp(x+1, INF);
    REP(i, x+1) dp[i] = i;
    REP(i, x+1) {
        if (i - a >= 0)
            chmin(dp[i], dp[i-a]+1);
    }
    REP(i, x+1) {
        if (i - b >= 0)
            chmin(dp[i], dp[i-b]+1);
    }
//    cout << a << " " << b << " " << x << ": " << greed << ", " << dp[x] << endl;
    return dp[x] - greed;
}

int main(void) {
//    FOR(i, 2, 100) {
//        FOR(j, i+1, 100) {
//            FOR(k, j+1, 2*j) {
//                int64 ret = calc(i, j, k);
//                if (ret != 0) {
//                    cout << i << " " << j << " " << k << endl;
//                    break;
//                }
//            }
//        }
//    }
    int64 A, B;
    cin >> A >> B;
    int64 C = (B+A-1)/A*A;
    if (C-B+1 > C/A) {
        cout << C << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3104
/*
      Ashraful Islam Paran
      27-August-2020
      19:56:18
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i <= 0; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, i, j, cnt = 0, l, x;
    cin >> n;
    x = n + 1;
    f(n)
    {
        cin >> j;
        if (j < x)
        {
            cnt++;
            x = j;
        }
    }
    cout << cnt << endl;

    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>

int main(){
  int n,A[100];
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=n-1;i>0;i--){
    printf("%d ",A[i]);
  }
  
  printf("%d\n",A[i]);

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

void swap(int *a, int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}
int gcd(int a, int b) {
	return b == 0? a: gcd(b, a % b);
}
int main(void) {
	int x, y;
	scanf("%d%d",&x, &y);
	if (x < y) {
		swap(&x, &y);	
	}
	printf("%d\n", gcd(x,y));
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#define NMAX 100001
#define qMAX 50000
 
int S[NMAX];
int T[qMAX];
 
int binarySearch(int n,int key) {
    int left = 0;
    int right = n;
    int mid;
     
    while (left < right) {
        mid = (left + right) / 2;
        if (S[mid] == key) {
            return 1;
        } else if (key < S[mid]) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return 0;
}
 
int main(void)
{
    int n, i, j, q, cnt;
     
    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf(" %d", &S[i]);
    }
 
    scanf("%d", &q);
    for (i = 0; i < q; ++i) {
        scanf(" %d", &T[i]);
    }
 
    cnt = 0;
    for (i = 0; i < q; ++i) {
        cnt += binarySearch(n, T[i]);
    }
    printf("%d\n", cnt);
     
    return 0;
}


Measured memory_bytes: 2304
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
using namespace std;
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/
/**********************************************************************
Main
**********************************************************************/
int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}
/**********************************************************************
Functions
**********************************************************************/


Measured memory_bytes: 256
import java.util.Scanner;

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

        int sl=s.length();
        int pl=p.length();
        char S[] = new char[sl];
        char P[] = new char[pl];

        for(int i=0;i<sl;i++){
            S[i]=s.charAt(i);
        }
        for(int i=0;i<pl;i++){
            P[i]=p.charAt(i);
        }
        int i,count=0;
        boolean t=false;
        for(i=0;i<sl;i++){
            count=0;
            for(int j=0;j<pl;j++){
                if(S[(i+j)%sl]==P[j]){
                    count++;
                }
            }
            if(count==pl){
                break;
            }
        }
        if(count==pl){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26364
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    int a, b;
    cin >> a >> b;

    cout << max({a + b, a - b, a * b}) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ipair = pair<int, int>;

int main() {
    int N; cin >> N;

    multimap<int, int> mp;
    for (int i = 0; i < N; ++i) {
        int a, b; cin >> a >> b;
        mp.insert(make_pair(b, a));
    }

    int ct  = 0;
    string res = "Yes";
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ct += itr->second;
        if (ct > itr->first) {
            res = "No";
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    cout<<(n-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int n, k;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	while(cin >> n >> k)
	{
		int x;
		int ans = 0;
		FOR(i, 0, n)
		{
			cin >> x;
			if(x >= k) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

const int N = 3e2 + 5;
const int K = 3e2 + 5;

int dp[N][K] , n , m , C[N][N] , mod , k , S[N][K];

void Add(int &x , int y) {
	if((x += y) >= mod)
	x -= mod;
}

bool vis[N][K] , vis2[N][K];

int solve(int x , int y);

int sum(int x , int y) {
	if(vis2[x][y]) return S[x][y];
	if(!x || y > k) return 0;
	vis2[x][y] = 1;
	S[x][y] = (sum(x , y + 1) + solve(x , y)) % mod;
	return S[x][y];
}

int solve(int x , int y) {
	if(!x) return 0;
	if(x == 1) return 1;
	if(vis[x][y]) return dp[x][y];
	vis[x][y] = 1;
	for(int i = 1;i < x;++ i) {
		Add(dp[x][y]  , 1LL * C[x - 2][i - 1] * solve(x - i , y) % mod * sum(i , y + 1) % mod);
	}
	return dp[x][y];
}

int main() {
	scanf("%d%d%d" , &n , &k , &mod);
	
	for(int i = 0;i <= n;++ i) 
	for(int j = 0;j <= i;++ j) 
	C[i][j] = ((!j) ? 1 : ((C[i - 1][j - 1] + C[i - 1][j]) % mod));
	
	printf("%d\n" , solve(n + 1 , 0));
}

Measured memory_bytes: 1536
#include <iostream>
int main()
{
  int a, b;
  while (std::cin >> a >> b) {
    int c = a + b, r = 1;
    while (c >= 10) {
      c /= 10;
      r += 1;
    }
    std::cout << r << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	string s, t;
	cin >> s >> t;

	for (LL i = 0; i < n; ++i) {
		cout << s[i] << t[i];
	}
	cout << endl;

}

Measured memory_bytes: 256
n = int(input())
d = len(str(n))
ans = 0
cnt = 0
for a in range(1, n + 1):
    s = str(a)
    if s[-1] != '0':
        if d >= 3:
            l, r = 0, n + 1
            while r - l > 1:
                m = (l + r) // 2
                m -= 1
                st = str(m).zfill(d - 2)
                b = int(s[-1] + st + s[0])
                if b <= n:
                    l = m + 1
                else:
                    r = m + 1
            ans += l
            t = 10
            for i in range(d - 3):
                ans += t
                t *= 10
        if int(s[-1] + s[0]) <= n:
            ans += 1
        if s[0] == s[-1] and int(s[0]) <= n:
            ans += 1
print(ans)


Measured memory_bytes: 44844
s = input()
K = int(input())
after = []
rem = K
for i in range(len(s)-1):
    if s[i] == 'a':
        after.append('a')
        continue
    c = ord('z') - ord(s[i]) + 1
    if c <= rem:
        rem -= c
        after.append('a')
    else:
        after.append(s[i])

last = ord(s[-1])
if rem > 0:
    last += rem%26
    if last > ord('z'):
        last -= 26
after.append(chr(last))

print(''.join(after))

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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	char cc;
	ll a,b,c;cin>>a>>b>>cc>>c;
	b=b*100+c;
	cout<<a*b/100<<endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main(void)
{
	int cnt[26];
	char ch;
	int i;

    //配列cntのすべてに0を代入
	for (i = 0; i < 26; i++){
		cnt[i] = 0;
	}

	while (scanf("%c", &ch) != EOF){
		//isalphはchがアルファベットなら真を返す
		if (isalpha(ch)){
			//もしchが小文字ならとそれ以外
			if (islower(ch)){
				cnt[ch - 'a']++;
			}else {
				cnt[ch - 'A']++;
			}
		}
	}

	for (i = 0; i < 26; i++){
		printf ("%c : %d\n", 'a' + i, cnt[i]);
	}

	return (0);
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> r;
  cout << r * r;
  return 0;
}


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

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

  int x, a; cin >> x >> a;
  if( x < a ) cout << 0 << '\n';
  if( x >= a ) cout << 10 << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  int prev = H[0];
  int max = 0;
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if (H[i] <= prev) {
      cnt++;
    } else {
      if (cnt > max) {
        max = cnt;
      }
      cnt = 0;
    }
    prev = H[i];
  }
  if (cnt > max) {
    max = cnt;
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 640
i=list(map(int,input().split()))
N, Y =i[0], i[1]

x,y,z = -1,-1, -1
for i in range(N+1):
    for j in range(N- i+1):
        k = N - i - j
        if 10000*i +5000*j +1000*k == Y:
                x,y,z = i, j, k
                break
print("{} {} {}".format(x,y,z))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string,int>mp;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		string a;
		cin>>a;
		mp[a]--;
	}
	
	int ans=0;
	for(auto x:mp){
		ans=max(ans,x.second);
	}
	
	cout<<ans<<endl;
}

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

int main()
{
    char Line[19];
    int Value;

    std::priority_queue<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

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

#define ll long long

using namespace std;

int x,y,s;

int main(){
    while(1){
        scanf("%d %d %d",&x,&y,&s);
        if(x==0 && y==0 && s == 0) break;

        int p = 100 * s /(100+x);
        int max=0;
        for(int i=1;i<=(s+1)/2;i++){
            for(int j= p-i;j < s; j++){
                 int x1 = i *(100 + x)/100;
                 int x2 = j *(100 + x)/100;
                 if(x1 + x2 == s){
                     int sum = i *(100 + y)/100 + j *(100 + y)/100;
                     if(max < sum) max = sum;
                 }
            }
        }

        printf("%d\n",max);
    }

}


Measured memory_bytes: 3224
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int m, k; cin >> m >> k;
	if (pow(2, m) <= k)cout << -1 << endl;
	else if (m == 0)cout << "0 0" << endl;
	else if (m == 1)
	{
		if (k == 0)cout << "0 1 1 0" << endl;
		else cout << -1 << endl;
	}
	else
	{
		rep(i, pow(2, m))
		{
			if (i == k)continue;
			cout << i << " ";
		}
		cout << k << " ";
		rrep(i, pow(2, m))
		{
			if (i == k)continue;
			cout << i << " ";
		}
		cout << k;
	}
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        int out = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            if(i % 2 == 0 && a[i] % 2 == 1) out++;
        }
        System.out.println(out);
        scan.close();
    }
}


Measured memory_bytes: 27116
#include<bits/stdc++.h>
using namespace std;
const int maxn=2000007;
bitset<maxn> dp;
int main(){
	dp[0]=1;
	int n,sum=0,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		sum+=x;
		dp=dp|(dp<<x);
	}
	for(int i=(sum+1)>>1;i<=sum;i++){
		if(dp[i]) {
			cout<<i;
			break;
	    }
    }
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int F[110][20];
int P[110][20];

signed main()
{   
    int N; cin>>N;
    REP(i,N) REP(j,10){
        cin>>F[i][j];
    }
    REP(i,N) REP(j,11){
        cin>>P[i][j];
    }
    
    int ans=-1e18;
    for(int S=1;S<(1<<10);S++){
        int sum=0;
        REP(i,N){
            int cnt=0;
            REP(j,10) if(S>>j&1 and F[i][j]) cnt++;
            sum+=P[i][cnt];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}


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

void convert(int timestamp) {
    int h = 0, m = 0, s = 0;

    h = timestamp / 3600;
    timestamp %= 3600;
    m = timestamp / 60;
    timestamp %= 60;
    s = timestamp;

    cout << h << ":" << m << ":" << s << endl;
}


int main() {
    int timestamp = 0;
    cin >> timestamp;
    convert(timestamp);

    return 0;
}

Measured memory_bytes: 3080
#!/usr/bin/env python3
from collections import Counter


def combi(n):
  return n*(n-1)//2

def solve(n,a):
  d = Counter(a)
  patterns = dict((k,combi(v)) for k,v in d.items())
  patterns_sum = sum(patterns.values())
  ans = [0]*n
  for i in range(n):
    ans[i] = patterns_sum - patterns[a[i]] + combi(d[a[i]]-1)
  return ans



def main():
  N = int(input())
  a = list(map(int,input().split()))
  ans = solve(N,a)
  for i in range(len(ans)):
    print(ans[i])
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 38972
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    Q = NI()
    LR = [NLI() for _ in range(Q)]

    def is_prime(n):
        if n == 1:
            return False
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True

    cumsum = [0 for _ in range((10**5)+10)]
    cnt = 0
    for n in range(1,len(cumsum)):
        cumsum[n] = cumsum[n-1]
        if is_prime(n):
            if is_prime((n+1)//2):
                cumsum[n] += 1
    
    for q in range(Q):
        print(cumsum[LR[q][1]] - cumsum[LR[q][0]-1])
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 29140
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
int main()
{
	ld a, b;

	cin >> a >> b;

	ld ans = a * b * 100;

	cout << ((ll)ans)/100;
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char x,y;
  cin >> x >> y;
  char ans;
  if(x>y) ans = '>';
  else if(x<y) ans = '<';
  else ans = '=';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define child 2*v
#define tm (tl+tr)/2
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e5 + 10; 

vector<int> g[N],tin(N,0),tout(N,0),trav;
int dp[N],timer = 0,n,q;
vector<int> seg_tree(8*N,0),lazy(8*N,0);

int dfs(int u,int p=-1){
   tin[u] = timer++;
   trav.pb(u);
   dp[u] = 1;
   for(auto &v : g[u]){
      if(v != p){
         dp[u] += dfs(v,u);
      }
   }
   trav.pb(u);
   tout[u] = timer++;
   return dp[u];
}

void push(int v){
   seg_tree[child] += lazy[v];
   lazy[child] += lazy[v];
   seg_tree[child+1] += lazy[v];
   lazy[child+1] += lazy[v];
   lazy[v] = 0;
}

void update(int v,int tl,int tr,int l,int r,int val){
   if(l > r) return;
   if(tl == l and tr == r){
      seg_tree[v] += val;
      lazy[v] += val;
   }else{
      push(v);
      update(child,tl,tm,l,min(tm,r),val);
      update(child+1,tm+1,tr,max(tm+1,l),r,val);
   }
}

int get(int v,int tl,int tr,int l,int r){
   if(l > r) return 0;
   if(l<=tl and tr <=r){
      return seg_tree[v];
   }
   push(v);
   return get(child,tl,tm,l,min(tm,r))+get(child+1,tm+1,tr,max(tm+1,l),r);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n >> q;
   int u,v;
   f(i,1,n){
      cin >> u >> v;
      g[u].pb(v);
      g[v].pb(u);
   }
   dfs(1);
   while(q--){
      int a,b;
      cin >> a >> b;
      update(1,0,2*n-1,tin[a],tout[a],b);
   }
   int ans[n+1];
   f(i,1,n+1){
      // cout << tin[i] << ' ' << tout[i] << '\n';
      ans[i] = get(1,0,2*n-1,tin[i],tin[i]);
      // ans[i] = ans[i]/2;
      cout << ans[i] << ' ';
   }
   // cout << get(1,0,2*n-1,1,6) << '\n';
   return 0;
}

Measured memory_bytes: 56180
/**
*    author:  yuya1234
*    created: 08.07.2020 11:49:06
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  string s;
  cin>>n>>s;

  int a[26],b[26];
  MEMSET(a,0);
  MEMSET(b,0);

  REP(i,n)a[s[i]-'a']++;

  int cnt=0,ans=0;
  REP(i,SZ(s)-1)
  {
    if(a[s[i]-'a']!=0)
    {
      a[s[i]-'a']--;
      b[s[i]-'a']++;
    }

    cnt=0;
    REP(i,26)
    {
      if(a[i]>0 && b[i]>0)cnt++;
    }
    ans=max(ans,cnt);
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
int main(void){
	double x1,x2,y1,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt(pow((x2-x1),2)+pow((y2-y1),2)));
	return 0;
}

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

 struct node{

  struct node *right,*left,*parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n,k,i;
  char str[15];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&k);
      insert(k);
    }else if(strcmp(str,"print")==0){


      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

  }



  return 0;
}

void insert(int k){
  Node y,x,z;

  y= NIL; //x's parent
  x=root;
  z=malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    
  }
  z->parent = y;
  if(y==NIL){
    root=z;

  }else{
    if(z->key < y->key){
      y->left =z;
    }else{
      y->right =z;
    }

  }


}

void inorder(Node x){
  if(x == NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

void preorder(Node x){
  if(x == NIL) return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);


}



Measured memory_bytes: 25140
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   
#define rep(i,l,r) for( i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;
ll gcd(ll a ,ll b){
	if(b==0) return a;
	else return gcd(b ,a%b);
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
   		int k , x ;
  		cin >> k >> x ;
  		//cout << max(-1000000,x-k+1)<<"\n";
 	 	for(int i = max(-1000000,x-k+1) ; i<=min(1000000, x+k-1);i++){
       		cout << i << " ";
     	}
      return 0;
   
}


Measured memory_bytes: 256
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";

fn solve(x: i64, y: i64) {
    let g1: Vec<i64> = vec![1, 3, 5, 7, 8, 10, 12];
    let g2: Vec<i64> = vec![4, 6, 9, 10];
    let g3: Vec<i64> = vec![2];
    if g1.contains(&x) && g1.contains(&y) {
        println!("{}", YES)
    } else if g2.contains(&x) && g2.contains(&y) {
        println!("{}", YES)
    } else if g3.contains(&x) && g3.contains(&y) {
        println!("{}", YES)
    } else {
        println!("{}", NO)
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut x: i64;
    x = scanner.next();
    let mut y: i64;
    y = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(x, y)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

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

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

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

  vector<deque<int>> v(h);

  int idx = 0;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j) {
      if (v[idx].size() == w) idx++;

      if (idx & 1) v[idx].push_front(i);
      else v[idx].push_back(i);
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << v[i][j] << (j + 1 == w ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 384
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
	//#include <algorithm>
	//#include <functional>
	//#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	//#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
using namespace std;


int main() {

	int n;
	cin >> n;
	vector<vector<int>> a(10, vector<int>(10, 0));
	int sum = 0;
	//int digit;
	int m = 0;
	int k = 0;

	for (int i = 1; i < n + 1; i++) {
		//cout << i << endl;
		//digit = 0;
		k = i;
		while (k != 0) {
			m = k;
			k /= 10;
			//digit++;
		}
		a[m][i % 10] += 1;
	}

	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			sum += a[i][j] * a[j][i];
		}
	}

	cout << sum;

	return 0;

}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
arr = []
N.times do
  arr << gets.split.map(&:to_i)
end
arr.sort!{|arr1, arr2| arr1[0] <=> arr2[0]}
m = 0
price = 0
loop do
  a, b = arr.shift
  if b + m >= M
    price += (M - m) * a
    break
  else
    price += a * b
    m += b
  end
end
puts price

Measured memory_bytes: 12536
from sys import stdin, stdout
input = lambda: stdin.readline()
write = stdout.write

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    AB.sort(key=lambda x: x[1])
    cuts, p = 1, AB[0][1]
    for a, b in AB:
        if a >= p:
            cuts += 1
            p = b
    print(cuts)

main()


Measured memory_bytes: 18048
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N):
    for j in range(N-i-1):
        s=0
        for I,J in zip(X[i],X[j+i+1]):
            s+=(I-J)**2
        if (int(s**.5))**2 == s:
            ans+=1
print(ans)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ptr=0,res=0,flg=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<2*n;i++){
        if(a[ptr]==2){
            ++res;
            flg=1;
            break;
        }
        ptr = a[ptr]-1;
        ++res;
    }
    if(flg==1)
        cout << res << endl;
    else 
        cout << -1 << endl;
}


Measured memory_bytes: 640
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define RANDOM srand(time(NULL));

#define MOD 1000000007
#define NAX 1000005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll solve()
{
    ll n;
    cin>>n;

    pair<string,ll> a[n];
    FOR(i,0,n)
    cin>>a[i].ff>>a[i].ss;

    string str;
    cin>>str;

    ll pos = -1;
    FOR(i,0,n)
    {
        if(a[i].ff==str)
        pos = i;
    }

    ll ans = 0;
    FOR(i,pos+1,n)
    ans += a[i].ss;
    cout<<ans<<"\n";
    return 0;
}


int main()
{
    FAST;
    
    ll t=1;
    // cin>>t;
    
    while(t--!=0)
    {
        ll stat = solve();
    }
    return 0;
}


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

string S;
int b;

bool equa(int& p);
bool form(int& p);


bool equa(int& p) {
    bool b1 = form(p);
    p++;
    bool b2 = form(p);
    return b1 == b2;
}

bool form(int& p) {
    if(S[p] == '-' && S[p+1] != '>') {
        p++;
        return not form(p);
    } else if(S[p] == 'T') {
        p++;
        return true;
    } else if(S[p] == 'F') {
        p++;
        return false;
    } else if('a' <= S[p] && S[p] <= 'k') {
        return (b >> (S[p++]-'a')) & 1;
    } else if(S[p] == '(') {
        p++;
        bool v1 = form(p);
        if(S[p] == '*') {
            p++;
            v1 &= form(p);
        } else if(S[p] == '+') {
            p++;
            v1 |= form(p);
        } else if(S[p] == '-' && S[p+1] == '>') {
            p += 2;
            bool v2 = form(p);
            v1 = !v1 || v1 && v2;
        }
        p++;
        return v1;
    }
}

int main() {
    while(cin >> S, S != "#") {
        bool f = true;
        for(int i=0; i<1<<11; ++i) {
            int p = 0;
            b = i;
            f &= equa(p);
        }
        cout << (f ? "YES" : "NO") << endl;
    }
}


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

int main(void)
{
	int i;
	char str[22];
	scanf("%s", str);
	
	for (i = strlen(str) - 1; i >= 0; i--) {
		printf("%c", str[i]);
	}
	printf("\n");
	return (0);
}

Measured memory_bytes: 524