akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   ll N, W;
   cin >> N >> W;
   vector<vector<ll>> dp(N + 1, vector<ll>(100001, INF));
   dp.at(0).at(0) = 0;
   vector<ll> w(N), v(N);
   rep(i, 0, N) cin >> w.at(i) >> v.at(i);

   for (int i = 0; i < N; i++) {
     for (int j = 0; j < 100001; j++) {
       if (j < v.at(i)) dp.at(i + 1).at(j) = dp.at(i).at(j);
       else dp.at(i + 1).at(j) = min(dp.at(i).at(j), dp.at(i).at(j - v.at(i)) + w.at(i));
     }
   }

   ll res = 0;

   rep(i, 0, 100001) if (dp.at(N).at(i) <= W) res = i;
   cout << res << endl;
 }


Measured memory_bytes: 80256
#include <iostream>
using namespace std;
void call(int n) {
	for (int i = 1; i <= n;i++) {
		if (i % 3 == 0) { cout << " " << i; continue; }
		int temp = i;
		while (temp) {
			if (temp % 10 == 3) { cout << " " << i; break; }
			temp /= 10;
		}
	}
	cout << endl;
}
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	call(n);
}

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

int main(int argc, char *argv[]) {
    long n, w;
    
    cin >> n >> w;
    
    long weights[n+1];
    long values[n+1];
    long dp[n+1][w+1];
    
    for (long i = 0; i < n; i++) {
        cin >> weights[i+1];
        cin >> values[i+1];
    }
    
    for (long i = 0; i < w + 1; i++) {
        dp[0][i] = 0;
    }
    
    for (int i = 1; i < n + 1; i++) {
        for (int j = 0; j < w + 1; j++) {
            if (j < weights[i]) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - weights[i]] + values[i]);
            }
        }
    }
    
    cout << dp[n][w] << endl;
    
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  for(auto&& e:a)cin>>e;
  boost::sort(a);
  bool ok = true;
  for(auto&& i:irange(0,n-1)) {
    if(a[i] == a[i+1]) ok = false;
  }
  cout<<(ok?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;
int main()
{
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0) cout<<"1";
    else if(b==0) cout<<"2";
    else if(c==0) cout<<"3";
    else if(d==0) cout<<"4";
    else if(e==0) cout<<"5";
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef pair<int,int> pr;
typedef vector<pr> vp;
queue<int> qu;
const int INF=1<<30;
vp bridge[100];
int search(int from,int now,bool ret){
	int minium=INF;
	if(ret){
		int sum=0;
		REP(j,bridge[now].size()){
			int next=bridge[now][j].second,dist=bridge[now][j].first;
			if(next==from) continue;
			if(bridge[next].size()==1) continue;
			sum+=search(now,next,1);
				sum+=dist;
			sum+=dist;
		}
		return sum;
	}
	REP(i,bridge[now].size()){
		if(bridge[now][i].second==from) continue;
		int sum=0;
		REP(j,bridge[now].size()){
			int next=bridge[now][j].second,dist=bridge[now][j].first;
			if(next==from) continue;
			if(bridge[next].size()==1) continue;
			sum+=search(now,next,i!=j);
			if(i!=j)
				sum+=dist;
			sum+=dist;
		}
		minium=min(minium,sum);
	}
	return minium;
}
int main() {
	int N,a,b,t;
	while(cin >> N && N){
	REP(i,N-1){
		cin >> a >> b >> t;
		bridge[a].push_back(pr(t,b));
		bridge[b].push_back(pr(t,a));
	}
	cout << search(0,1,0) << endl;
	REP(i,100)
		while(!bridge[i].empty()) bridge[i].pop_back();
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1200
#include <functional>
#include <iostream>
template <class Key,class T,class Compare = std::less<Key>>
struct Splay{
  Compare comp;
  size_t sz;

  struct node{
    node *left, *right;
    node *parent;
    T key;
    T value;
    node(const Key& key = T(),const T& val = T()) : left(nullptr), right(nullptr),key(key),value(val){}
    ~node(){}
  };

  node* root;

  void zig(node* x){
    node * p = x->parent;
    p->left = x->right;
    if(x->right) x->right->parent = p;
    if(p->parent){
      if(p->parent->left == p) p->parent->left = x;
      else                     p->parent->right = x;
    }
    else{
      root = x;
    }
    x->parent = p->parent;
    x->right = p;
    p->parent = x;
  }

  void zag(node * x){
    node * p = x->parent;
    p->right = x->left;
    if(x->left) x->left->parent = p;
    if(p->parent){
      if(p->parent->left == p) p->parent->left = x;
      else                     p->parent->right = x;
    }
    else{
      root = x;
    }
    x->parent = p->parent;
    x->left = p;
    p->parent = x;
  }

  void splay(node* x){
    while(x->parent){
      if(!x->parent->parent){
        if(x->parent->left == x){
          zig(x);
        }
        else{
          zag(x);
        }
        return;
      }
      //zig zig
      else if(x->parent->parent->left == x->parent && x->parent->left == x){
        zig(x->parent);
        zig(x);
      }
      //zig zag
      else if(x->parent->parent->left == x->parent && x->parent->right == x){
        zag(x);
        zig(x);
      }
      //zag zag
      else if(x->parent->parent->right == x->parent && x->parent->right == x){
        zag(x->parent);
        zag(x);
      }
      // zag zig
      else{
        zig(x);
        zag(x);
      }
    }
  }
public:
  Splay() : root(nullptr){}
  std::pair<Key,T> get_root(){
    if(!root) return {Key(),T()};
    return {root->key,root->value};
  }

  void insert(const Key & key, const T & val){
    node * z = root;
    node * p = nullptr;
    while(z){
      p = z;
      if(comp(z->key,key)) z = z->right;
      else z = z->left;
    }
    z = new node(key,val);
    z->parent = p;

    if(!p) root = z;
    else if(comp(p->key,key)) p->right = z;
    else p->left = z;

    splay(z);
    sz++;
  }

  bool count(const Key& key){
    node *z = root;
    while(z){
      if(comp(z->key,key)) z = z->right;
      else if(comp(key,z->key)) z = z->left;
      else return 1;
    }
    return 0;
  }
};

#include <iostream>
using namespace std;
using i64 = long long;

int st[26];

i64 hasshh(const string& s){
  i64 res = 1;
  for(char c : s){
    res = res * 4 + st[c - 'A'];
  }
  return res;
}

int main(){
  st['A' - 'A'] = 0;
  st['C' - 'A'] = 1;
  st['G' - 'A'] = 2;
  st['T' - 'A'] = 3;
  Splay<long long,int> tree;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    string s,t;
    cin >> s >> t;
    if(s.front() == 'i'){
      tree.insert(hasshh(t),1);
    }
    else{
      cout << (tree.count(hasshh(t)) ? "yes" : "no") << endl;
    }
  }
}



Measured memory_bytes: 29912
from functools import lru_cache

@lru_cache()
def eat(n, x):  # n = number of levels, return = number of patties
    #print(n,x)
    if n == 0:
        if x == 1:
            return 1  # 1 = patty
    if x == 1:
        return 0  # 0 = bun
    elif x <= 1 + thickness[n - 1]:
        return eat(n - 1, x - 1)
    elif x <= 1 + thickness[n - 1] + 1:
        return patties[n - 1] + 1
    elif x <= 1 + thickness[n - 1] + 1 + thickness[n-1]:
        return patties[n - 1] + 1 + eat(n - 1, x - 1 - thickness[n-1] - 1)
    else:
        return patties[n - 1] + 1 + patties[n - 1]

N,X = map(int, input().split())

thickness = [0] * (N+1)
thickness[0] = 1
for i in range(1,N+1):
    thickness[i] = 1 + thickness[i-1] + 1 + thickness[i-1] + 1
patties = [0] * (N+1)
patties[0] = 1
for i in range(1,N+1):
    patties[i] = patties[i-1] + 1 + patties[i-1]

print(eat(N,X))


Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s,k="keyence";
    cin >> s;
    ll count=0;
    for (ll i=0;i<s.size();i++){
        if (s[i]==k[count]){
            count++;
        }else{
            break;
        }
    }
    if (count==k.size()){
        cout << "YES" << endl;
        return 0;
    }else{
        for (ll i=s.size()-1;i>s.size()-k.size()+count-1;i--){
            if (s[i]!=k[k.size()-s.size()+i]){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll x;
  cin >> x;
  ll k=1;
  while(x*k%360) {
    k++;
  }
  cout << k << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(size_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> v(3, 0);
    ll ans = 1;
    for(size_t i = 0; i < n; i++) {
        ans *= count(all(v), a[i]);
        ans %= MOD;
        if(ans == 0) {
            cout << ans << endl;
            return 0;
        } else {
            (*find(all(v), a[i]))++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int flag=0;
	int num[11]={0};
	int haiku[3];
	for(int i=0;i<3;i++){
		int a;
		scanf("%d",&a);
		num[a]++;
		haiku[i]=a;
	}
	if(num[5]==2&&num[7]==1){
	  printf("YES\n");
    }
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll arr[100001],dp[100001],i,ans;
	for(i=0 ; i<n ; i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;
	for(i=1;i<100001;i++)
	{
		dp[i]=1e9;
	}
	for(i=0;i<n;i++)
	{
		dp[i+1]=min(dp[i+1],abs(arr[i]-arr[i+1])+dp[i]);
		dp[i+2]=min(dp[i+2],abs(arr[i]-arr[i+2])+dp[i]);
	
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<long long, int> P;
bool conmPair(const P& firstP, const P& secondP) {
  return firstP.first < secondP.first;
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  long long ans = 0;
  cin >> n >> m;
  vector<P> shop(n);
  for (int i = 0; i < n; ++i)  {
    cin >> shop[i].first >> shop[i].second;
  }
  sort(shop.begin(), shop.end(), conmPair);

  for (int i = 0; i < n; i++) {
    ans += shop[i].first * min(m, shop[i].second);
    m -= shop[i].second;
    if (m <= 0) break;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
st = []
for _ in range(n):
    s = list(map(str, input().split()))
    s[1] = int(s[1])
    st.append(s)
x = input()

st = reversed(st)

sum = 0
for kyoku in st:
    if kyoku[0]  == x:
        break
    else:
        sum += kyoku[1]

print(sum)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  int n,k,x,y;
  int dif=0;
  int ans=0;

  scanf("%d%d%d%d",&n,&k,&x,&y);

  if(k<n){
    dif=n-k;
  }

  ans=x*n+(y-x)*dif;

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main () {
  	string s;
  	cin >> s;
	int y = 0, m = 0, d = 0;
  	y = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + s[3] - '0';
   	m = (s[5] - '0') * 10 + s[6] - '0';
  	d = (s[8] - '0') * 10 + s[9] - '0';
  
  	if (y < 2019) {
      cout << "Heisei";
      return 0;
    }
  	if (y > 2019) {
      cout << "TBD";
      return 0;
    }
  	if (m <= 4) {
      cout << "Heisei";
      return 0;
    }
    else {
      cout << "TBD";
      return 0;
    }
}


Measured memory_bytes: 256
#include <cstdio>

int N, M, C;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N * M; ++i) {
		char s[2];
		scanf("%1s", s);
		C += *s == '#';
	}
	puts(C == N + M - 1 ? "Possible" : "Impossible");
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}
template<typename T>
T gcd(T a, T b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b)) * b;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double sum = 0;
  VI a(n);
  rep(i, n) {
    cin >> a[i];
  }
  int g = 1;
  rep(i, n) {
    g = lcm<int>(g, a[i]);
  }
  rep(i, n) {
    sum += g / a[i];
  }
  double ans = (double)g / sum;
  cout.precision(15);
  out(ans);
  return 0;
}


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

use proconio::input;

fn f(a: i64, b: i64, x: i64) -> i64 {
    (((a * x) as f64 / (b as f64)).floor() - a as f64 * (x as f64 / b as f64).floor()) as i64
}

fn main() {
    input! {
        a: i64,
        b: i64,
        n: i64,
    }

    let ans = if n >= b - 1 {
        f(a, b, b - 1)
    } else {
        f(a, b, n)
    };
    println!("{}", ans);
}


Measured memory_bytes: 2668
/*
 * FileName:     C
 * CreatedDate:  2020-05-30 13:32:31 +0900
 * LastModified: 2020-05-30 13:44:02 +0900
 */

#include <stdio.h>
int gcd(int a, int b){
    int r;
    while(a%b!=0){
        r = a%b;
        a = b;
        b = r;
//        printf("(a,b,r)=(%d,%d,%d)\n",a,b,r);
    }
    return b;
}
int main(void){
    int a,b;scanf("%d %d",&a,&b);
    int g = gcd(a,b);
//    printf("%d\n",g);
    printf("%ld\n",(long int)a*(long int)b/(long int)g);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if (S.length()<=K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0,K)+"...");
		}
	}
}

Measured memory_bytes: 38596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	int ans = 0;
	cin >> n >> k;
	while (n > 0) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	cnt := 1
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	s := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		s[i] = sc.Text()
	}
	sort.Strings(s)

	for i, _ := range s {
		switch {
		case i == n-1:
			break
		default:
			if s[i] != s[i+1] {
				cnt++
			}

		}

	}
	fmt.Println(cnt)
}


Measured memory_bytes: 8392
n,m = map(int,input().split())
drink=[]
for _ in range(n):
  a,b = map(int,input().split())
  drink.append((a,b))
drink.sort(reverse=1)

ans = 0
while m>0:
  a,b = drink.pop(-1)
  ans += a*min(m, b)
  m -= b
print(ans)



Measured memory_bytes: 16908
#include"bits/stdc++.h"
#include"math.h"
using namespace std;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using vi=vc<int>;

const ll mod=1e9+7;
const ll INF = 1e18;

  
int main(){
  int a;cin >> a;
  if(a%2==0) cout << a/2-1 ;
  else cout << a/2 ;
}

    

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
minus = 0
plus = 0
fact = [0] * (N+1)
fact[0] = 1
pow_fact = [0] * (N+1)
pow_fact[0] = 1
fa = 1
for i in range(1, N+1):
    fa *= i
    fa %= mod
    fact[i] = fa
    pow_fact[i] = pow(fa, mod-2, mod)
b = pow_fact[K-1]
for i in range(N-K+1):
    a = fact[N-i-1]
    c = pow_fact[N-i-K]
    comb = (a*b*c) % mod
    minus += (A[i] * comb) % mod
    plus += (A[-i-1] * comb) % mod
print((plus - minus) % mod)

Measured memory_bytes: 14980
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, H[20];

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(H[i]));
        if (i < N - 1) {
            scanf(" ");
        }
    }

    size_t max = 0;
    size_t count = 0;

    for (size_t i = 0; i < N; i++) {
        if (max <= H[i]) {
            count++;
            max = H[i];
        }
    }

    printf("%zu", count);

    return 0;
}


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char& s) {
    string res = "'";
    res += s;
    res += "'";
    return res;
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (i) res += ", ";
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define int long long
#define fi first
#define se second
#define pii pair<int, int>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define ld long double

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if (!x) cout << i + 1;
    }
}


Measured memory_bytes: 3636
s = gets.chomp.split('').sort
t = gets.chomp.split('').sort {|a, b| b <=> a }
ans = 'No'
if s.join == t.join
  ans = 'No'
elsif t.join.include?(s.join)
  ans = 'Yes'
else
  for i in 0..s.length-1 do
    for j in 0..t.length-1 do
      if s[i] < t[j]
        ans = 'Yes'
        break
      end
    end
  end
end


puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K,S;cin>>N>>K>>S;
  long IR=S%1000000000+1;
  vector<long>A(N,IR);
  for(long i=0;i<N;i++){
    if(i<=K-1)A[i]=S;
  }
  for(long i=0;i<N;i++)cout<<A[i]<<" ";
}

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

int main(){
    int n,m;
    cin>>n;
    vector<int> t(n),r(n);
    for(int i=0;i<n;i++){
        cin>>t.at(i);
        r.at(i)=t.at(i);
    }
    cin>>m;
    vector<int> p(m),x(m);
    for(int i=0;i<m;i++) cin>>p.at(i)>>x.at(i);
    for(int i=0;i<m;i++){
        int ans=0;
        for(int k=1;k<=n;k++){
            if(p.at(i)==k) r.at(k-1)=x.at(i);
            ans+=r.at(k-1);
            r.at(k-1)=t.at(k-1);
        }
        cout<<ans<<endl;
    }
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (65 <= n && n <= 90) cout << 1 << endl;
	else if (97 <= n && n <= 122) cout << 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

signed main(){
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = h1 * 60 + m1,t2 = h2 * 60 + m2;
	cout << t2 - t1 - k << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N ;
  vector<ll> A ;
  A.pb(0);

  ll ans = 0;
  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
    ans += (abs(A[A.size()-1] - A[A.size()-2]));
  }
  ans += abs(A[A.size()-1]);
  
  rep(i,N){
    cout << ans - abs(A[i] -A[i+1]) -abs(A[i+1]-A[i+2]) + abs(A[i]-A[i+2]) << endl;
  }
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 2164
n=int(input())
ans=1
rec=[True]*(n+1)
for i in range(2,n+1):
    if rec[i]:
        x=1
        for j in range(1,n+1):
            y=j
            if y%i==0:
                rec[y]=False
            while y%i==0:
                x+=1
                y=y//i
        ans=(ans*x)%1000000007
print(ans)

Measured memory_bytes: 65844
open Printf
open Scanf

let id x = x

let solve n m =
  let la = List.init m @@ fun _ -> scanf "%d " id in
  let pd = n - List.fold_left (+) 0 la in
  if pd >= 0 then pd else -1

let () =
  scanf "%d %d " solve |> printf "%d\n"


Measured memory_bytes: 6332
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        
            if (str.charAt(2) == str.charAt(3) ){
            	if (str.charAt(4) == str.charAt(5) ){
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
             }else {
              System.out.println("No");
            }
    }
 }


 

Measured memory_bytes: 22612
var n,i,j,x,y,t,ans,lx,ly,lt:longint;
begin
  read(n);lx:=0;ly:=0;lt:=0;
  for i:=1 to n do
  begin
    read(t,x,y);
    ans:=t-(lt+abs(x-lx)+abs(y-ly));
    if (ans>=0) and (ans mod 2=0) then begin lx:=x;ly:=y;lt:=t;end
    else begin writeln('No');halt;end;
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <vector>
#include <string>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define BR cout << endl;
#else
#define DEBUG(s) 
#define dump(x)  
#define BR 
#endif
using namespace std;

typedef unsigned int   UI;
typedef unsigned long  UL;
typedef long long      LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef pair<int, int> PII;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

template<class T> inline T sqr(T x) {return x*x;}

int main() {
	int n, cnt = 1;
	cin >> n;
	switch(n) {
		case 4:
		cnt = 2*3;
		break;
		case 6:
		cnt = 2*2*3;
		break;
		case 8:
		cnt = 24;
		break;
		case 9:
		cnt = 2*2*3*3;
		break;
		case 10:
		cnt = 2*2*2*2*3;
		break;
		case 12:
		cnt = 2*2*3*5;
		break;
		default:
		REP(i,1,n) cnt *= 2;
		break;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int N,K; cin >> N >> K;
	int R,S,P; cin >> R >> S >> P;
	string T; cin >> T;
	int ans = 0;
	//vector<int> turn(N+5);
	for (int i = 0; i < N; ++i) {
		if (i>=K&&T[i]==T[i-K]) T[i] = ' ';
		else if (T[i]=='r') ans += P;
		else if (T[i]=='p') ans += S;
		else ans += R;
	}
	cout << ans;			
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
struct Dice{
    int s[6];
    void roll(char c){
        int tmp;
        if(c=='N'){
            tmp=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=tmp;
        }
        if(c=='E'){
            tmp=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=tmp;
        }
        if(c=='W'){
            tmp=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=tmp;
        }
        if(c=='S'){
            tmp=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=tmp;
        }
        if(c=='R'){
            tmp=s[1];
            s[1]=s[2];
            s[2]=s[4];
            s[4]=s[3];
            s[3]=tmp;
        }
    }
    int top(){
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};


int main(void){
    Dice d;
    int n,t,f;
    
    for(int i=0; i<6; i++) cin>>d.s[i];
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>t>>f;
        if(d.left()==t) d.roll('E');
        if(d.right()==t) d.roll('W');
        while(d.top()!=t) d.roll('N');
        while(d.front()!=f) d.roll('R');
        cout<<d.right()<<endl;
    }
    return 0;
}



Measured memory_bytes: 3116
Digits = list(map(int, input().split()))
Digits.sort()

dif1 = Digits[2] - Digits[1]
dif2 = Digits[2] - (Digits[0] + dif1)
if dif2 % 2 == 0:
    print(int(dif1 + dif2 / 2))
else:
    print(int(dif1 + dif2 // 2 + 2))

Measured memory_bytes: 3060
from collections import Counter
from itertools import combinations

n = int(input())
s = [input()[0] for _ in range(n)]
lc = Counter(s)

con = []
for c in 'MARCH':
    if c in lc:
        con.append(lc[c])

ans = 0
for a, b, c in combinations(con, 3):
    ans += a * b * c

print(ans)


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

int N, K, T, U, V, L;
int DL[10001];

int main() {
    cin >> N >> K >> T >> U >> V >> L;
    for (int i = 0; i < N; i++) {
        int D; cin >> D;
        DL[D]++;
    }

    vector<bool> used(L+1, false);
    int count = 0, s;
    bool flag = false;
    for (int i = 0; i < L; i++) {
        if (DL[i] > 0) count++;
        if (flag) {
            if (count > K) s = i, count = K;
            used[i] = true;
        } else if (count > 0) {
            used[i] = true;
            flag = true;
            s = i;
            count--;
        }
        if (flag && s + V * T == i + 1) flag = false;
    }

    double ans = 0;
    for (int i = 0; i < L; i++)
        ans += used[i] ? 1./V : 1./U;
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 3272
n=int(input())
l=list(map(int,input().split()))
c=0
if n<3:
    print(0)
else:
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            if l[i]==l[j]:
                continue
            for k in range(j+1,n):
                if l[k]==l[i] or l[k]==l[j]:
                    continue
                if l[k]+l[i]>l[j] and l[i]+l[j]>l[k] and l[k]+l[j]>l[i]:
                    c+=1
    print(c)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
#include <math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    lol sum=0,a,n,maxv=-INF,minv=INF;
    cin>>n;    
    rep(i,n){
	cin>>a;
	sum+=a;
	maxv=max(maxv,a);
	minv=min(minv,a);
    }
    cout<<minv<<" "<<maxv<<" "<<sum<<'\n';

    return 0;
}



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

int main() {
	long n, m;
	long l[100000], r[100000];
	//bool ok[100010];
	long
		min = -1, max = 1000000;
	cin >> n >> m;
	/*for (int i = 0; i < m; i++)
	{
		ok[i] = true;
	}*/
	for (int i = 0; i < m; i++)
	{
		cin >> l[i] >> r[i];
		if (l[i] > min)
		{
			min = l[i];
		}
		if (r[i] < max)
		{
			max = r[i];
		}
	}
	//cout << max << "," << min << endl;
	//if (max > n)max = n;
	//cout << max - min+1<<endl;
	/*if (min < n)
	{
		cout << "0" << endl;
		return 0;
	}
	if (max > n)
	{
		max = n;
	}*/
	if (min > max)
	{
		cout << "0" << endl;
		return 0;
	}
	cout << max - min + 1 << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200
int n;
int L[MAXN+5],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2;i++)
		scanf("%d",&L[i]);
	sort(L+1,L+n*2+1);
	for(int i=1;i<=2*n;i+=2)ans+=L[i];
	printf("%d",ans);
}

Measured memory_bytes: 256
# coding: utf-8

def array2d(d1, d2, init = None):
    return [[init for _ in range(d2)] for _ in range(d1)]


def solve(N, W, v, w):
    # dp[i][k]: 0~i?????????item????????????????????????????????????k??¨??????????????????????????´??????max value
    # return: max(dp[N-1][*])
    # dp[i][k] = max(dp[i-1][k], dp[i-1][k-w[i]] + v[i])
    # dp[i][k] = v[i](k==w[i]), 0(otherwise)
    dp = array2d(N, W + 1)
    for k in range(0, W + 1):
        dp[0][k] = v[0] if k == w[0] else 0
    for i in range(1, N):
        for k in range(0, W + 1):
            dp[i][k] = dp[i-1][k]
            if k - w[i] >= 0:
                dp[i][k] = max(dp[i][k], dp[i-1][k-w[i]] + v[i])
    return max(dp[-1])



def main():
    N, W = map(int, input().split())
    v = [None] * N
    w = [None] * N
    for i in range(N):
        v[i], w[i] = map(int, input().split())
    print(solve(N, W, v, w))

main()

Measured memory_bytes: 27656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

void dfs(const int& i, const int& c, vector<vector<pair<int, ll>>>& edge, vector<int>& color) {
  if (color[i] != -1) return;

  color[i] = c;
  for (auto itr = edge[i].begin(); itr != edge[i].end(); itr++) {
    int nextColor = c;
    if (itr->second % 2 != 0) nextColor = c ^ 1;
    dfs(itr->first, nextColor, edge, color);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> color(n, -1);
  vector<vector<pair<int, ll>>> edge(n);
  rep(i, n-1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    edge[u-1].push_back(make_pair(v-1, w));
    edge[v-1].push_back(make_pair(u-1, w));
  }

  dfs(0, 0, edge, color);

  rep(i, n) {
    cout << color[i] << endl;
  }

  return 0;
}


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

int main()

{
    string s;
    cin >>s;
    int k=s.length()-1;
    if(s[k]=='s')
    { for(int i=0; i<=k; i++)
    {

        cout << s[i];
    }
    cout << "es" ;

    }
    else
    { for(int i=0; i<=k; i++)
    {

        cout << s[i];
    }
    cout << "s" ;


    }




}


Measured memory_bytes: 3624
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    S, T = LS()

    print(T + S)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9072
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 


int main() {
	int N; cin >> N;
	vector<string> S(N);
	map<string, int> p;
	rep(i, N) { cin >> S[i]; p[S[i]]++;}

	int mx = 0;
	rep(i,N) { mx = max(mx,p[S[i]]);}
	cout << endl;
	for (auto i = p.begin(); i != p.end();i++) {
		if (i->second == mx) cout << i->first << endl;
	}
}

Measured memory_bytes: 26752
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int getSum(const vec<int, 2>& sum, int y, int x, int K, int parity) {
  int ys[3] = {y, y + K, 2 * K};
  int xs[3] = {x, x + K, 2 * K};
  int res = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if ((i + j) % 2 == parity) {
        int cnt = sum[ys[i]][xs[j]];
        if (i > 0) cnt -= sum[ys[i - 1]][xs[j]];
        if (j > 0) cnt -= sum[ys[i]][xs[j - 1]];
        if (i > 0 && j > 0) cnt += sum[ys[i - 1]][xs[j - 1]];
        res += cnt;
      }
    }
  }
  return res;
}

void sum2d(vec<int, 2>& sum) {
  int H = sum.size(), W = sum[0].size();
  for (int i = 1; i < H; i++)
    for (int j = 1; j < W; j++)
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
}

int main() {
  int N, K;
  while (cin >> N >> K) {
    vec<int, 2> sumB = make_v(2 * K + 1, 2 * K + 1, 0);
    vec<int, 2> sumW = make_v(2 * K + 1, 2 * K + 1, 0);
    for (int i = 0; i < N; i++) {
      int x, y;
      char c;
      cin >> x >> y >> c;
      x %= 2 * K;
      y %= 2 * K;
      if (c == 'B') {
        ++sumB[x + 1][y + 1];
      } else {
        ++sumW[x + 1][y + 1];
      }
    }
    sum2d(sumB);
    sum2d(sumW);
    int res = 0;
    for (int y = 0; y <= K; y++) {
      for (int x = 0; x <= K; x++) {
        int score1 = getSum(sumB, y, x, K, 0) + getSum(sumW, y, x, K, 1);
        res = max(res, score1);
        int score2 = getSum(sumW, y, x, K, 0) + getSum(sumB, y, x, K, 1);
        res = max(res, score2);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  string S;
  cin >> S;
  cout << S.substr(0, 3) << endl;
}


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

        ll n;
        cin>>n;
        ll arr[n];
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+n);
        ll ch=arr[0];ll ans=0;
        ll bada=arr[n-1];
        ans+=(bada-ch);
        if(n>2){
        for(int i=1;i<n/2;i++)
        {
            ll x=bada-arr[i];
            ll y=arr[n-i-1]-ch;
            ans+=(x+y);
            bada=arr[n-i-1];
            ch=arr[i];
        }
        if(n%2==1)
        {
            ans=ans+max(abs(arr[(n)/2]-ch),abs(bada-arr[(n)/2]));
        }}
        cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1532
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) { return cost < b.cost; }
	bool operator>(const P &b) { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) { return cost < b.cost; }
	bool operator>(const E &b) { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
struct A {
	int x, y, z;
};
bool operator<(A a, A b) {
	return a.z < b.z;
}
A a[400000];
int dat[800000];
void add(int x, int y) {
	while (x <= m) {
		dat[x] += y;
		x += x & -x;
	}
}
int sum(int x) {
	int sum = 0;
	while (x > 0) {
		sum += dat[x];
		x -= x & -x;
	}
	return sum;
}
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		a[i].z = a[i].y - a[i].x + 1;
	}
	sort(a, a + n);
	int t = 0;
	for (int i = 1; i <= m; i++) {
		int ans = 0;
		ans += n - t;
		for (int j = i; j <= m; j += i) {
			ans += sum(j);
		}
		for (; t < n&&a[t].z == i; t++) {
			add(a[t].x, 1);
			add(a[t].y + 1, -1);
		}
		cout << ans << endl;
	}
}

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

int main()
{
	int N;
	double A, B;
	while(cin >> N && N != 0)
	{
		A = 0;
		B = 0;
		
		double temp;
		for(int i = 0; i < N; ++i)
		{
			cin >> temp;
			A += temp * temp;
			B += temp;
		}
		
		A /= N;
		B /= N;
		
		cout << fixed << setprecision(8) << sqrt(A - B * B) << endl;
	}

    return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#define MAX 5000
using namespace std ;
 
vector<int> a, b, c;
int n, ma, mb;
int search(int sumA, int sumB, int sumC, int st, int opt){
    if(sumC>=opt){return opt;}   
    if((sumA+a[st])*mb==(sumB+b[st])*ma){
        if(sumC+c[st]<opt){opt=sumC+c[st];}
        if(st==n-1){return opt;}
        return min(opt, search(sumA, sumB, sumC, st+1, opt));
    }
    else{
        if(st==n-1){return opt;}
        opt=min(search(sumA, sumB, sumC, st+1, opt), opt);
        return min(opt, search(sumA+a[st], sumB+b[st], sumC+c[st], st+1, opt));
    }
}
int main(void){
    int opt=MAX;
    cin>>n>>ma>>mb;
    int ai,bi,ci;
    for(int i=0;i<n;i++){
        cin>>ai>>bi>>ci;
        a.push_back(ai);
        b.push_back(bi);
        c.push_back(ci);
    }
    opt=search(0,0,0,0,opt);
    if(opt>=MAX) opt=-1;
    cout<<opt<<endl;
}

Measured memory_bytes: 384