akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  vector<LL> A(N);
  REP(i,N){
    cin >> A[i];
  }
  map<LL, LL> maps;

  vector<LL> B(N + 1);
  B[0] = 0;
  FOR(i, 1,N+1){
    B[i] = B[i - 1] + A[i-1];
    maps[B[i]] = 0;
  }
  REP(i, N+1)
  {
    maps[B[i]]++;
  }
  LL sum = 0;

  for(auto itr = maps.begin(); itr != maps.end(); ++itr) {
    LL N = itr->second;
    sum += N * (N - 1) / 2;
  }

  cout << sum << endl;
}


Measured memory_bytes: 15872
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp
#include <iostream>
#include <vector>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

// 素数判定 O(root(n))
bool is_prime(int n) {

  if(n == 1) {
    return false;
  }

  for(int i = 2; i * i <= n; i++) {
    if ( n % i == 0 ) 
      return false;
  }

  return true;

}


int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  int ans = 0;
  for(int i = 0; i < N; i++) { 
    int n;
    cin >> n;
    if( is_prime(n) ) { ans++; }
  }


  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {


            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0]);
            long k = long.Parse(str[1]);

            var list = new SortedDictionary<int, long>();

            for(int i = 0; i < n; i++)
            {
                string[] strer = Console.ReadLine().Split(' ');
                int key = int.Parse(strer[0]);
                int vla = int.Parse(strer[1]);
                if (list.ContainsKey(key))
                {
                    list[key] += vla;
                }
                else
                {
                    list[key] = vla;
                }
                
            }
            
            long u = 0;
            
            foreach(var s in list)
            {
                u = s.Value;
                if(u >= k)
                {
                    Console.WriteLine(s.Key);
                    break;
                }
                else
                {
                    k -= u;
                }

            }


        }
    }
}


Measured memory_bytes: 22968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ret = N;
		long r = ret - K * (N / K);
		ret = Math.min(ret, r);
		ret = Math.min(ret, Math.abs(r - K));
		System.out.println(ret);
	}
}


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


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

Measured memory_bytes: 3900
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node *Node;
Node head;
void delete(Node);
int main(){
  int n,i,flag,key;
  char inst[12];
  Node index;
  scanf("%d",&n);
  head = (Node *)malloc(sizeof(Node));
  head->next = head;
  head->prev = head;
  for(i=0;i<n;i++){
    scanf("%s",inst);
    if( 'F' == inst[6] ){
      delete(head->next);
    }
    else if( 'L' == inst[6]){
      delete(head->prev);
    }
    else{
      scanf("%d",&key);
      if( 'i' == inst[0]){
    Node tmp;
    tmp = (Node *)malloc(sizeof(Node));
    tmp->key = key;
    tmp->next = head->next;
    head->next->prev = tmp;
    head->next = tmp;
    tmp->prev = head;
      }
      else{
    index = (Node *)malloc(sizeof(Node));
    index = head->next;
    while( index != head && index->key != key){
      index = index->next;
    }
    if( index == head ){
      continue;
    }
    delete(index);
      }
    }
  }
  index = head->next;
  flag = 0;
  while(index != head){
    if( flag > 0){
      printf(" ");
    }
    flag++;
    printf("%d",index->key);
    index = index->next;
  }
  printf("\n"); 
  return 0;
}
void delete(Node tmp){
  tmp->next->prev = tmp->prev;
  tmp->prev->next = tmp->next;
  free(tmp);
}


Measured memory_bytes: 32960
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

struct SegmentTree {
	std::vector<int> seg;
	bool f = true; // t : min, f : max
	int sz = 1, n = 0;
	
	SegmentTree(int n, bool f) : n(n), f(f) {
		while(sz < n) sz *= 2;
		seg.assign(sz * 2 - 1, (f ? n : -1));
	}
	
	int update(int k, int x) {
		k += sz - 1;
		seg[k] = x;
		
		while(k) {
			k = (k - 1) / 2;
			
			if(f) seg[k] = std::min(seg[2 * k + 1], seg[2 * k + 2]);
			else seg[k] = std::max(seg[2 * k + 1], seg[2 * k + 2]);
		}
	}
	
	int get(int a, int b, int k, int l, int r) {
		if(b<=l||r<=a) return (f ? n : -1);
		if(a<=l&&r<=b) return seg[k];
		
		if(f) return std::min(get(a, b, 2 * k + 1, l, (l + r) / 2), get(a, b, 2 * k + 2, (l + r) / 2, r));
		else return std::max(get(a, b, 2 * k + 1, l, (l + r) / 2), get(a, b, 2 * k + 2, (l + r) / 2, r));
	}

	int get(int a, int b) {
		return get(a, b, 0, 0, sz);
	}
	
	void p() {
		for(int i = 0; i < n; i++) cout << get(i, i + 1) << " ";
		cout << endl;
	}
};

int main(){
	int n; cin >> n; std::vector<i64> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	std::vector<std::vector<i64>> li(n, std::vector<i64>(2, -1));
	{
		SegmentTree seg(n, 0);
		for(int i = 0; i < n; i++) {
			li[i][0] = seg.get(0, a[i]); seg.update(a[i] - 1, i);
		}
	}
	
	{
		SegmentTree seg(n, 1);
		for(int i = n - 1; i >= 0; i--) {
			li[i][1] = seg.get(0, a[i]); seg.update(a[i] - 1, i);
		}
	}
	
	i64 ans = 0;
	for(i64 i = 0; i < n; i++) {
		ans += (i - li[i][0]) * a[i] * (li[i][1] - i);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int a, b, c, m, d;
  cin >> a >> b >> c;

  m = max(max(a, b), c);
  d = m - a + m - b + m - c;

  if (d % 2 == 0)
    cout << d / 2 << endl;
  else
    cout << (d + 3) / 2 << endl;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);
const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vi a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  unordered_map<ll, ll> m[2];
  m[0][0] = 1;
  for (ll i = 0; i < n; i++) {
    ll i0 = i % 2;
    ll i1 = (i + 1) % 2;

    m[i1].clear();
    for (pii p : m[i0]) {
      ll x = p.first % n;
      ll y = (p.first / n) % n;
      ll z = (p.first / n / n) % n;
      if (x == a[i]) {
        (m[i1][(x + 1) + y * n + z * n * n] += p.second) %= mod;
      }
      if (y == a[i]) {
        (m[i1][x + (y + 1) * n + z * n * n] += p.second) %= mod;
      }
      if (z == a[i]) {
        (m[i1][x + y * n + (z + 1) * n * n] += p.second) %= mod;
      }
    }

    if (i == n - 1) {
      ll ans = 0;
      for (auto p : m[i1]) {
        ans = (ans + p.second) % mod;
      }
      cout << ans << endl;
      return 0;
    }
  }
}


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

const int MAXN=100010;

int N,M,f[MAXN],ans;
int is[MAXN];

int find(int x){
    return f[x]?f[x]=find(f[x]):x;
}

void Union(int x,int y){
    int fx=find(x),fy=find(y);
    if(fx!=fy)
        f[fx]=fy;
    return;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>N>>M;
    
    while(M--){
        int X,Y,Z;
        cin>>X>>Y>>Z;
        Union(X,Y);
    }
    
    for(int i=1;i<=N;i++)
        is[find(i)]=1;
        
    for(int i=1;i<=N;i++)
        ans+=is[i];
        
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 1152
from collections import Counter
n = int(input())
s = input()
c = Counter(s)
ans = c['R']*c['G']*c['B']
for i in range(n-2):
    for j in range(i+1, n-1):
        if n <= 2*j-i:
            continue
        if s[i] != s[j] and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
            ans -= 1

print(ans)


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n,m;
    while(cin>>n>>m,n*m){
        vector<int> v(m,0);
        rep(i,n){
            int a,b;cin>>a>>b;
            a--;
            chmax(v[a],b);
        }
        ll res=0;
        rep(i,m)res+=v[i];
        cout<<res<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,K; cin>>N>>K;
    set<char> D;
    rep(k,0,K){
        int d; cin>>d;
        D.insert(d+'0');
    }

    int64_t n=N;
    while(1){
        string S=to_string(n);

        bool findAns=true;
        for(auto s:S){
            if(D.count(s)) findAns=false;
        }

        if(findAns) break;
        n++;
    }

    cout<<n<<endl;
}

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


int main(){
int N,L;
  cin >> N >> L;
  
  if(L>=0)
    cout << (L*2+N)*(N-1)/2 << endl;
  else if(L<0 && L+N-1>=0)
    cout << (L*2+N-1)*N/2 << endl;
  else
    cout <<(L*2+N-2)*(N-1)/2 << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long gcd(long n,long m){
	if (m == 0) return n;
	return gcd(m, n % m);
}

long lcm(long n, long m) {
	return m / gcd(n, m)*n;
}

int main() {
	long a,b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " ";
		cout << lcm(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  vector<int> N;
  for(int i=0; i<3; i++){
    int in;
    cin >> in;
    N.push_back(in);
  }
  sort(N.begin(), N.end());
  int A = N[0];
  int B = N[1];
  int C = N[2];
  if((B-A) % 2 == 0)
    cout << C - B + (B-A)/2 << endl;
  else
    cout << C - B + (B-A)/2 + 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 500005;
const ll MOD = 998244353;
ll fac[MAXN], invfac[MAXN];
ll binom(ll a, ll b) {
	if (b < 0) return 0;
	if (b > a) return 0;
	return (((fac[a] * invfac[b]) % MOD) * invfac[a - b]) % MOD;
}
ll modex(ll a, ll p, ll m = MOD) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
ll pown[MAXN], powm[MAXN];
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	invfac[MAXN - 1] = modex(fac[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = invfac[i + 1] * (i + 1) % MOD;
	int n, m;
	scanf("%d%d", &n, &m);
	powm[0] = pown[0] = 1;
	for (int i = 1; i <= n; ++i) powm[i] = powm[i - 1] * (m + 1) % MOD;
	for (int i = 1; i <= m; ++i) pown[i] = pown[i - 1] * (n + 1) % MOD;
	ll ans = pown[m] * powm[n] % MOD;
	for (int k = 1; k <= min(n, m); ++k) {
		ll v = binom(m, k) * fac[n] % MOD * invfac[n - k] % MOD * pown[m - k] % MOD * powm[n - k] % MOD;
		if (k & 1) ans -= v;
		else ans += v;
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	printf("%lld\n", ans);
}


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

class dice{	
public:
	int d[7];
	int set();
	int E();
	int W();
	int N();
	int S();
	int R();//?°´???????????¢
	int C(int *,int *,int *,int *);//??\??????????????????
};
int dice::set(){
	for(int i=1;i<=6;i++){
		cin>>d[i];
	}
	return 0;
}
int dice::C(int *w,int *x,int *y,int *z){
	int a[4];
	a[0]=*w;
	a[1]=*x;
	a[2]=*y;
	a[3]=*z;
	*w=a[3];
	*x=a[0];
	*y=a[1];
	*z=a[2];
	return 0;
}
int dice::E(){
	C(&d[1],&d[3],&d[6],&d[4]);
	return 0;
}
int dice::W(){
	C(&d[1],&d[4],&d[6],&d[3]);
	return 0;
}
int dice::N(){
	C(&d[1],&d[5],&d[6],&d[2]);
	return 0;
}
int dice::S(){
	C(&d[1],&d[2],&d[6],&d[5]);
	return 0;
}
int dice::R(){
	C(&d[2],&d[4],&d[5],&d[3]);
	return 0;
}
int main(){
	dice D;
	D.set();
	char m[110];
	cin>>m;
	for(int j=0;;j++){
		if(m[j]=='E'){
			D.E();
			continue;
		}
		if(m[j]=='W'){
			D.W();
			continue;
		}
		if(m[j]=='N'){
			D.N();
			continue;
		}
		if(m[j]=='S'){
			D.S();
			continue;
		}
		break;
	}
	cout<<D.d[1]<<endl;
	return 0;
}

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

using namespace std;

int main(void)
{
    int cc;
    int dd;
    int ee;
    
    cin >> cc >> dd >> ee;
    
    if(cc < dd && dd < ee)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    


   return 0;
}



Measured memory_bytes: 3104
N = int(input())
jisyo = {}
for i in range(N):
  a = input()
  if a not in jisyo:
    jisyo[a] = 1
  else:
    jisyo[a] +=1
M = int(input())
for i in range(M):
  b = input()
  if b not in jisyo:
    jisyo[b] = -1
  else:
    jisyo[b] -=1
maxi = 0
for i,k in jisyo.items():
  if maxi < k:
    maxi = k
print(maxi)

Measured memory_bytes: 9148
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

bool vis[200010];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  if (k <= (n + 1) / 2) {
    int v = (n + 1) / 2;
    int j = 0, l = n * 2 - 1;
    bool prog = false;
    for (int i = 0; i < n; ++i) {
      if (!prog) {
        int a = i * 2, b = n * 2 - v - i;
        if (a < b) {
          cout << (a + k) << ' ' << (b + k) << ' ' << (n * 2 + i + k) << '\n';
          vis[a] = vis[b] = true;
        } else
          prog = true;
      }
      if (prog) {
        while (vis[j]) ++j;
        while (vis[l]) --l;
        cout << (j + k) << ' ' << (l + k) << ' ' << (n * 2 + i + k) << '\n';
        vis[j] = vis[l] = true;
      }
    }
  } else
    cout << "-1\n";

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 2432
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N = int(input())

A = []
for i in range(N):
	A.append(int(input()))
B = copy.deepcopy(A)
A.sort()
a_max = max(A)

for i in range(N):
	if B[i] == a_max:
		print(A[-2])
	else:
		print(A[-1])

Measured memory_bytes: 88796
loop do
  n = gets.to_i
  exit if n == 0

  convmap = Hash.new
  n.times do
    conv = gets.chomp.split(" ")
    convmap[conv[0]] = conv[1]
  end

  src = []
  m = gets.to_i
  m.times do
    src << gets.chomp
  end

  res = src.map{ |val|
    convmap.has_key?(val) ? convmap[val] : val
  }.join("")

  puts res

end

Measured memory_bytes: 16464
#include <iostream>
#include <vector>
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define max(a,b) a < b ? b : a
#define min(a,b) a > b ? b : a
using namespace std;

int main(){
    int n;
    int tmp;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    tmp = h[0];
    reps(i,1,n){
        tmp = max(tmp,h[i]);
        if(tmp > h[i] + 1){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string S, T;
	
	cin >> S >> T;
	
	int len = S.length();
	
	for(int i=0; i<len; i++){
		if(S == T){
			cout << "Yes";
			return 0;
		}
		S = S.back() + S.substr(0, len-1);
	}
	
	cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
using namespace std;

void solve(int test){
	ll n;
	cin>>n;
	ll a[n], sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum += a[i];
		sum %= mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		sum = (sum - a[i] + mod) % mod;
		ans += (a[i] * sum) % mod;
		ans %= mod;
	}
	cout<<ans;
}
  
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k - t);
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define int long long
#define pii pair<long long, long long>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;


int N,M;
int solve(){
    int threshold = M/N;
    for (int i = threshold; i > 0; --i)
    {
        if ( M%i == 0 ) return i;
    }
}

signed main(){
    cin>>N>>M;
    int ans = solve();

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

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#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--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

#define deg_to_rad(deg) ((deg)*M_PI / 180.0)

// const int MOD = 998244353;

void Main()
{
    string N;
    cin >> N;
    REP(i, N.size())
    {
        if (N.at(i) == '9')
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    long long int H;
    cin >> H;

    long long int ans = 1;
    long long int cnt = 1;
    while (H > 1) {
        H /= 2;
        ans += pow(2, cnt);
        cnt += 1;
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){ 
	char A;
	int card[4][13],n,B,i; 
	for(i = 0 ; i < 52 ; i++){ 
		card[i / 13][(i % 13) + 1] = 0; 
	} 
	cin>>n; 
	for(i = 1 ; i <= n ; i++){ 
		cin>>A>>B; 
		switch(A){ 
		case 'S': 
			card[0][B] = 1; 
			break; 
		case 'H': 
			card[1][B] = 1; 
			break; 
		case 'C': 
			card[2][B] = 1; 
			break; 
		case 'D': 
			card[3][B] = 1; 
			break; 
		}  
	}
	for(i = 0 ; i < 52 ; i++){ 
		switch(i / 13){ 
		case 0: 
			if (card[0][(i % 13) + 1] == 0){ 
				cout<<"S "<<(i % 13) + 1<<endl; 
			} break;
		case 1: 
			if (card[1][(i % 13) + 1] == 0){ 
				cout<<"H "<<(i % 13) + 1<<endl; 
			} break;
		case 2: 
			if (card[2][(i % 13) +1] == 0){ 
				cout<<"C "<<(i % 13) + 1<<endl; 
			} break;
		case 3: 
			if (card[3][(i % 13) + 1] == 0){ 
				cout<<"D "<<(i % 13) + 1<<endl; 
			} break;
		} 
	}
	return 0; 
} 


Measured memory_bytes: 3104
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;

int box[100001];

int main(){

  lll ii,jj,kk;
  vector<int> ret;
  lll n;

  cin >> n;

  vector<lll> a(n);
  lll sum;
  
  memset(box,0,sizeof(box));
  sum = 0;

  for(ii=0;ii<n;ii++){

    cin >> a[ii];
    box[a[ii]]++;
    sum += a[ii];

  }
  
  lll q;

  cin >> q;

  lll b,c;

  //for(jj=1;jj<=4;jj++){
  //
  //  cout << box[jj] << endl;
  //
  //}
  
  for(ii=0;ii<q;ii++){

    cin >> b >> c;

    sum -= b * box[b];
    sum += c * box[b];

    box[c] += box[b];
    box[b] =  0     ;




    //cout << "=========" << endl;
    //
    //for(jj=1;jj<=4;jj++){
    //  cout << box[jj] << endl;
    //}
    //
    //cout << "=========" << endl;
    
    cout << sum << endl;
    
  }


  return 0;
}


Measured memory_bytes: 4572
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100000;
const ll LINF = 1LL<<61;

int main()
{
    int n;
    cin >> n;
    V<ll> a(n);
    rep(i,n) cin >> a[i];
    auto dp = make_vec(n+1, 2, 0LL);
    dp[0][0] = 1000;
    rep(i,n)
    {
        int ni = i+1;
        //売却
        ll x = (dp[i][1] / 1000) * a[i] + dp[i][1] % 1000;
        chmax(dp[ni][0], dp[i][0]);
        chmax(dp[ni][0], x);
        //購入
        ll y = (dp[i][0] / a[i] * 1000) + dp[i][0] % a[i];
        chmax(dp[ni][1], dp[i][1]);
        chmax(dp[ni][1], y);
    }
    // cout << dp << endl;
    cout << dp[n][0] << endl;

    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n,k,q;
 cin>>n>>k>>q;
 vector<long long int>a(n,k);
 for(int i=0;i<q;i++)
 {
     int u;
     cin>>u;
     u--;
     a[u]++;
 }
 vector<long long int>ans;
 for(int i=0;i<n;i++)
 {
     long long int temp= a[i]-k;
     long long int can=q-temp;
      ans.push_back(k-can);
 }

 for(int i=0;i<ans.size();i++)
 {
     if(ans[i]<=0)
     cout<<"No"<<endl;
     else cout<<"Yes"<<endl;
 }
 return 0;
}


Measured memory_bytes: 2292
// ALDS1_8_B: Binary Search Tree 2

use std::cell::RefCell;
use std::rc::Rc;
use std::str::FromStr;

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

enum BST {
    Node { key: i64, left: Rc<RefCell<BST>>, right: Rc<RefCell<BST>> },
    Nil
}

impl BST {
    fn new() -> BST {
        BST::Nil
    }
    fn insert(&mut self, k: i64) {
        match *self {
            BST::Nil => {
                *self = BST::Node {
                    key:k,
                    left: Rc::new(RefCell::new(BST::Nil)),
                    right: Rc::new(RefCell::new(BST::Nil)),
                }
            },
            BST::Node { ref mut key, ref mut left, ref mut right } => {
                if k < *key {
                    left.borrow_mut().insert(k);
                } else {
                    right.borrow_mut().insert(k);
                }
            }
        }
    }
    fn find(&self, k: i64) -> bool {
        match *self {
            BST::Nil => { 
                false
            },
            BST::Node { ref key, ref left, ref right} => {
                if k < *key {
                    left.borrow().find(k)
                } else if k > *key {
                    right.borrow().find(k)
                } else {
                    true
                }
            }
        }
    }
    fn preorder(&self) {
        match *self {
            BST::Nil => {},
            BST::Node { ref key, ref left, ref right } => {
                print!(" {}", *key);
                left.borrow().preorder();
                right.borrow().preorder();
            }
        }
    }
    fn inorder(&self) {
        match *self {
            BST::Nil => {},
            BST::Node { ref key, ref left, ref right } => {
                left.borrow().inorder();
                print!(" {}", *key);
                right.borrow().inorder();
            }
        }
    }
}

fn main() {
    let n = scan::<usize>();
    let mut t = BST::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut it = s.split_whitespace();
        let com = it.next().unwrap();
        if com == "find" {
            let x = it.next().unwrap().parse::<i64>().ok().unwrap();
            if t.find(x) {
                println!("yes");
            } else {
                println!("no");
            }
        } else if com == "insert" {
            let x = it.next().unwrap().parse::<i64>().ok().unwrap();
            t.insert(x);
        } else if com == "print" {
            t.inorder();
            println!();
            t.preorder();
            println!();
        }
    }
}


Measured memory_bytes: 41892
#include<stdio.h>

#define H 251
#define NIL -2000000001
/*
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}
*/

int main(){
  int i,j,n;
  int A[H];
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    A[i]=NIL;
  }
  
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(A[i/2]!=NIL){
     printf("parent key = %d, ",A[i/2]);
    }
    if(i*2<=n && A[i*2]!=NIL){
      printf("left key = %d, ",A[i*2]);    
    }  
    if(i*2+1<=n && A[i*2+1]!=NIL){
      printf("right key = %d, ",A[i*2+1]); 
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <sstream>
#include <map>
using namespace std;
typedef long long ll;

int m[] = {
	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

ll ytod(int y){
	ll days = 0;
	int a = y / 4 - y / 100 + y / 400;
	return (y - a) * 365 + a * 366;
}

ll mtod(int y, int mo){
	ll day = 0;
	for(int i = 0; i < mo - 1; i++){
		day += m[i];
		if(i == 1 && (y % 4 == 0 && (y % 400 == 0 || y % 100 != 0))) day++;
	}
	return day;
}

ll get_day(int a, int b,int c){
	ll day = ytod(a - 1) + mtod(a, b) + c;
	return day;
}

int main(){
	int a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		if(a == -1 && b == -1 && c == -1 && d == -1 && e == -1 && f == -1) break;
		ll day1 = get_day(a, b, c);
		ll day2 = get_day(d, e, f);
		cout << day2 - day1 << endl;;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int x = 0;
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++)
		if (S[i] == 'R')
			x += 1;
	if (x == 2)
		if (S[1] == 'R')
			cout << "2" << "\n";
		else
			cout << "1" << "\n";
	else
		cout << x << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin>>n;
  vector<int>hm(26,0);
  string s;cin>>s;
  for(int i=0;i<s.size();i++)hm[s[i]-'a']++;
  for(int i=1;i<n;i++){
    string t;cin>>t;
    vector<int> gm(26,0);
    for(int j=0;j<t.size();j++)gm[t[j]-'a']++;
    for(int j=0;j<26;j++){
      hm[j]=min(hm[j],gm[j]);
    }
  }
  string ans="";
  for(int i=0;i<26;i++){
    for(int j=0;j<hm[i];j++){
      char c='a'+i;
      ans+=c;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    string s;
    cin >>s;
    int sum;
    char p[3];
    for(int i=0; i<1<<3;i++){
            sum=s[0]-'0';
        for (int j=0;j<3;j++){
            if(i>>j&1){
                sum+=s[3-j]-'0';
                p[2-j]='+';
            }else{
                sum-=s[3-j]-'0';
                p[2-j]='-';
            }
        }
        if(sum==7){
            cout <<s[0]<<p[0]<<s[1]<<p[1]<<s[2]<<p[2]<<s[3]<<"=7"<<endl;
            return 0; 
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N, K;
	cin >> N >> K;

	int L[50];
	rep(i, N) cin >> L[i];

	sort(L, L + N);
	reverse(L, L + N);

	int kotae = 0;
	rep(i, K) {
		kotae += L[i];
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

const int MIN = -118;
const int MAX = 119;

pair<int, int> solve(int x) {
    for (int a = MIN; a <= MAX; a++) {
    for (int b = MIN; b <= MAX; b++) {
      int ret = pow(a, 5) - pow(b, 5);
      if (ret == x) {
        pair<int, int> ret = {a, b};
        return ret;
      }
    }
  }
  pair<int, int> ret = {0, 0};
  return ret;
}

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

  pair<int, int> ans = solve(X);
  cout << ans.first << " " << ans.second << endl;
}


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

using namespace std;


int main(){
  long long n;
  cin >> n;
  if(n==0){
      cout << 0 << endl;
      return 0;
  }
  else if(n%2==1){
      cout << 0 << endl;
      return 0;
  }
  long long cnt1=0;
  long long cnt2=0;
  long long m=n/2;
  cnt1+=m;
  long long s=2;
  while(m>=s){
      cnt1+=m/s;
      s*=2;
  }
  long long t=5;
  while(m>=t){
      cnt2+=m/t;
      t*=5;
  }
  
  cout << setprecision(30);
  cout <<  min(cnt1,cnt2) << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
cnt = 0
res = [0] * n
for i,t in enumerate(s):
    if t == 'R':
        cnt += 1
    elif cnt > 0:
        res[i-1] += (cnt+1)//2
        res[i] += cnt//2
        cnt = 0
# print(*res)
for i in reversed(range(n)):
    if s[i] == 'L':
        cnt += 1
    elif cnt > 0:
        res[i+1] += (cnt+1)//2
        res[i] += cnt//2
        cnt = 0
print(*res)

Measured memory_bytes: 73528
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

class Edge {
    int to;
    int cost;

    Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

class Pair implements Comparable<Pair> {
    int cost;
    int index;

    Pair(int cost, int index) {
        this.cost = cost;
        this.index = index;
    }

    public int compareTo(Pair p2) {
        return cost - p2.cost;
    }
}
 
public class Main {
    static final int INF = 1000000;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        List<List<Edge>> g = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            List<Edge> tmp = new ArrayList<>();
            for(int j = 0; j < n; j++) {
                int a = sc.nextInt();
                if(a >= 0) tmp.add(new Edge(j, a));
            }
            g.add(tmp);
        }

        int[] mincost = new int[n];
        boolean[] used = new boolean[n];
        for(int i = 0; i < n; i++) {
            mincost[i] = INF;
            used[i] = false;
        }
        mincost[0] = 0;
        int res = 0;

        PriorityQueue<Pair> que = new PriorityQueue<>();
        que.add(new Pair(0, 0));
        while(!que.isEmpty()) {
            Pair p = que.poll();
            int v = p.index;
            if(used[v]) continue;
            used[v] = true;
            res += mincost[v];

            for(int i = 0; i < g.get(v).size(); i++) {
                Edge e = g.get(v).get(i);
                if(mincost[e.to] > e.cost) {
                    mincost[e.to] = e.cost;
                    que.add(new Pair(mincost[e.to], e.to));
                }
            }
        }

        System.out.println(res);
 
        sc.close();
    }
}


Measured memory_bytes: 41632
#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>;
const int MOD=1000000007;

int main() {
  int n;
  cin >> n;
  int ans;
  if(n/10==0) ans=n;
  else if(n/100==0) ans=9;
  else if(n/1000==0) ans=n-90;
  else if(n/10000==0) ans=909;
  else if(n/100000==0) ans=n-90-9000;
  else ans=90909;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int x,y,z,box;
   scanf("%d %d %d",&x,&y,&z);
   box=x;
   x=y;
   y=box;
   box=x;
   x=z;
   z=box;
   printf("%d %d %d",x,y,z);
   return 0;
}

Measured memory_bytes: 1696
import fractions
N, M = list(map(int, input().split()))
S = input()
T = input()
d = fractions.gcd(N,M)
n = N//d
m = M//d
for i in range(d):
    if S[i*n] != T[i*m]:
        flag = False
        break
    else:
        flag = True
if flag:
  print((N*M)//d)
else:
  print(-1)

Measured memory_bytes: 65260
N=int(input())
W=[]
for i in range(N):
    W.append(list(map(int,input().split())))

W.sort (key=lambda x:x[1])

sum=0

for i in range(N):
    sum+=W[i][0]
    if sum>W[i][1]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 53720
/*
* @author:  codancer
* @createTime:  2020-06-29, 11:14:13
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
const int N = 1e4+10;
int main(){
	int n;
	cin>>n;
	ll ans=0;
	rep(j,1,n){
		ll k=n/j;
		ans+=k*(j+k*j)/2;
	}
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>>  a(n, vector<int>(m));

    for (int i = 0; i < m; i++) {
        cin >> b[i]; //>> a[i];
    }

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

    int nOk = 0;
    for (int i = 0; i < n; i++) {
        int res = 0;
        for (int j = 0; j < m; j++) {
            res += a[i][j] * b[j];
        }
        if (res+c > 0) {
            nOk++;
        }


        //res += b[i] * a[i];
    }

    cout << nOk << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001,INF=1<<30;
int dp[MAX];

int solve(int u,vector<int> &s){
    if(dp[u]!=INF) return dp[u];
    int ans=INF;
    for(int i=0;i<s.size();i++){
        int a=s[i];
        if(u<a) continue;
        ans=min(ans,solve(u-a,s)+1);
    }
    return dp[u]=ans;
}

int main(){

    int N,M;cin>>N>>M;
    vector<int> c(M);
    
    for(int i=0;i<=50000;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    
    for(int i=0;i<M;i++){
        cin>>c[i];
        dp[c[i]]=1;
    }
    
    cout<<solve(N,c)<<endl;
}




Measured memory_bytes: 5628
using System;
using  System.Linq;

public class Test
{
	public static void Main()
	{
bool flag = true;
		var s = Console.ReadLine().ToCharArray().Select(c=>c-'a'+1).ToArray();
		var t = Console.ReadLine().ToCharArray().Select(c=>c-'a'+1).ToArray();
int[] ToReplace = new int[27];
int[] FromReplace = new int[27];
if(s.Length==t.Length){
                for(int i=0;i<s.Length;i++){
                   if(ToReplace[s[i]] == 0)
ToReplace[s[i]] = t[i];
                   if(FromReplace[t[i]] == 0)
FromReplace[t[i]] = s[i];
if(ToReplace[s[i]] != t[i] || FromReplace[t[i]] != s[i]){
flag = false;
}
                }
}
  Console.WriteLine(flag?"Yes":"No");
	}
}

Measured memory_bytes: 19040
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
char ax[105];

int main()
{
    int n,x,i,a=0,b=0;
    scanf("%d",&n);
    scanf("%s",&ax);
    for(i=0;i<n;i++){
        if(ax[i]==')'){
            if(a==0)printf("(");
            else a--;
        }
        if(ax[i]=='('){
            a++;
           }
    }
    printf("%s",ax);
    for(i=0;i<a;i++)printf(")");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    forn(i,n) cin >> a[i];
    ll sum = 0;
    sort(a.begin(),a.end());
    int i;
    for(i=0;i<k;i++){
        sum += a[i];
    }
    cout << sum << endl;
}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int x,y,z; cin >> x >> y >> z;
	cout << (x-z)/(y+z) << endl;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n,cnt;
   cin>>n;
   vector<int> x(n),y;

   rep(i,0,n){
      cin>>x[i];
      y.push_back(x[i]);
   }
   
   sort(all(x));
   cnt = n / 2;

   rep(i,0,n){
      if(y[i] < x[cnt]) cout<<x[cnt]<<'\n';
      else if(y[i] >= x[cnt]) cout<<x[cnt-1]<<'\n';
   }
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

struct Nbase {
    int base;
    int sz = 1;
    long long Max = 1e18;

    Nbase(int k = 2){
        base = k;
        while(Max != 0){
            Max /= abs(base);
            sz++;
        }
    }

    //繰り返し二乗法
    long long EX(long long x,long long n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }
    
    vector<int> Xor_all_2(long long n){
        vector<int> ret(sz,0);
        long long modf = 2;
        for(int i = 0; i < sz; i++){
            ret[i] = (((n+1)/modf)*(modf/2))%2+max(((n+1)%modf-modf/2)%2,(long long)0);
            ret[i] %= 2;
            if(n%modf == n) break;
            modf *= 2;
        }
        return ret;
    }

    vector<int> to_np(long long num){
        vector<int> ret(sz);
        long long subtraction = EX(base,sz-1);
        for(int i = sz-1; i >= 0; i--){
            long long quotient = num/subtraction;
            ret[i] = quotient;
            num -= ret[i]*subtraction;
            subtraction /= base;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(base,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz-1; i >= 0; i--){//!sz -> sz-1
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }

    void remove(vector<int>& num){
        num.resize(sz);
        for(int i = sz-1; i > 0; i--){
            if(num[i] == 0) num.pop_back();
            else break;
        }
    }
};

int main(){
    Nbase base = 2;
    ll a,b;
    cin >> a >> b;
    vector<int> A = base.Xor_all_2(max(a-1,(ll)0));
    vector<int> B = base.Xor_all_2(b);
    a = base.re_n(A);
    b = base.re_n(B);
    cout << (a^b) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long n, long long m, long long d) {
  double ans;
  if (d == 0) {
    ans = (double)(m - 1) / n;
  } else {
    ans = 2.0 * (n - d) / (n * n) * (m - 1);
  }
  printf("%.10f\n", ans);
}

int main() {
  long long n;
  scanf("%lld", &n);
  long long m;
  scanf("%lld", &m);
  long long d;
  scanf("%lld", &d);
  solve(n, m, d);
  return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    
    for (int i = 0; ; i++) {
        stringstream ss;
        ss << i;
        string s; ss >> s;
        int n = s.size();
        bool found = 0;
        for (int j = 0; j <= N - n; j++) {            
            bool ok = 1;
            for (int k = j; k < j + n; k++) {
                if (d[k] != s[k-j] - '0') {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                found = 1;
                break;
            }
        }
        if (!found) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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


    return 0;

}


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

int main() {
  int64_t a,b,c,k,ans=0; cin >> a >> b >> c >> k;
  if(k <= a) ans = k*1;
  else if(k > a && k <= a+b) ans = a;
  else if(k > a+b) ans = a + (k-a-b) * -1;
  cout << ans << endl;
}

Measured memory_bytes: 3620
sa, sb, sc = readlines.map(&:chomp).map{|s| s.split('')}
arr=sa
while !arr.empty?
    next_p=arr.shift
    case next_p
    when 'a'
        arr=sa
    when 'b'
        arr=sb
    when 'c'
        arr=sc
    end
end
puts next_p.upcase

Measured memory_bytes: 1788
#include <iostream>

#define int long long

signed main() {
  std::string s;
  std::cin >> s;

  int n = s.length();
  
  int k;
  std::cin >> k;

  for(int i = 0; i < n-1; i++) {
    int need = 'z' - s[i] + 1;
    if(need <= k && need != 26) {
      s[i] = 'a';
      k -= need;
    }
  }

  s[n-1] = (char) ('a' + ((int) (s[n-1] - 'a') + k)%26);
  std::cout << s << std::endl;
}



Measured memory_bytes: 512