akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    unordered_map<string, int> md;
    md["SUN"] = 7;
    md["MON"] = 6;
    md["TUE"] = 5;
    md["WED"] = 4;
    md["THU"] = 3;
    md["FRI"] = 2;
    md["SAT"] = 1;

    string d;

    std::cin >> d;

    return md[d];
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int t[5];
  cin >> t[0]>>t[1]>>t[2]>>t[3]>>t[4];
  int loss[4];
  int minloss=10;
  int lastorder=0;
  int time=0;
  for(int i=0;i<5;i++){
    loss[i] = t[i]%10;
    if(0 < loss[i] && loss[i] < minloss){
      minloss = loss[i];
      lastorder = i;
    }
  }
  for(int j = 0;j<5;j++){
    if(j==lastorder) time += t[lastorder];
    else if (t[j]%10==0) time += t[j];
    else time += (t[j]-t[j]%10 +10);
  }

  cout << time << endl;
  return 0;
}


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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(ll i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)
/* cout << fixed << setprecision(12) << ans << endl;*/
#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

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


int main()
{
 boost;
 ll h,w;
 cin >> h >> w;
 vector<vector<char> > mat(h, vector<char> (w) );
 forn(i,0,h)
 forn(j,0,w)
 cin >> mat[i][j];
vector<vector<ll> > dp(h, vector<ll> (w,0) );
dp[0][0]=1;

 forn(i,0,h)
 forn(j,0,w)
 {
 	if(mat[i][j]=='#')
 	continue;
 	else 
 	{ if(i-1 >=0)
 	  {
 	  	dp[i][j]+=(dp[i-1][j])%MOD;
 	  	dp[i][j]=(dp[i][j])%MOD;
	  }
	   if(j-1 >=0)
 	  {
 	  	dp[i][j]+=(dp[i][j-1])%MOD;
 	  	dp[i][j]=(dp[i][j])%MOD;
	  }
	  
 		
	}
 }
 
 cout << dp[h-1][w-1]%MOD;
}






Measured memory_bytes: 9088
import java.util.Scanner;
import java.util.Arrays;

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

        int[][] dp = new int[s.length()+1][t.length()+1];
        for(int row = 1 ; row <= s.length() ; row++) {
            for(int col = 1 ; col <= t.length() ; col++) {
                if(s.charAt(row-1) == t.charAt(col-1)){
                    dp[row][col] = dp[row-1][col-1]+1;
                } else {
                    dp[row][col] = Math.max(dp[row-1][col], dp[row][col-1]);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        int row = s.length();
        int col = t.length();
        for( ; row > 0 && col > 0;) {
            if(dp[row][col] == dp[row-1][col]){
                row--;
            } else if(dp[row][col] == dp[row][col-1]){
                col--;
            } else {
                sb.append(s.charAt(row-1));
                row--;
                col--;
            }
        }
        System.out.println(sb.reverse().toString());
    }
}


Measured memory_bytes: 87864
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

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

C = [0]*N
A = [[0 for i in range(M)]for j in range(N)]

idxs = [i for i in range(N)]

ptn = []

for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] = tmp[0]
    for j in range(M):
        A[i][j] = tmp[1+j]


for i in range(1 << len(idxs)):
    output = []
    for j in range(len(idxs)):
        if ((i >> j) & 1) == 1:
            output.append(idxs[j])
    ptn.append(output)

ans = -1
mans = 10000000000000

for p in ptn:
    cnt = [0]*M
    for i in p:
        for j in range(M):
            cnt[j] += A[i][j]

        if min(cnt) >= X:
            tmpans = 0
            for k in p:
                tmpans += C[k]
            if tmpans < mans:
                ans = p
                mans = tmpans

if mans == 10000000000000:
    print(-1)
else:
    print(mans)


Measured memory_bytes: 10144
class UnionFind:
  def __init__(self, num):
    self.rank = [0]*num
    self.par = [i for i in range(num)] #基準(par = parentのpar)
    self.n   = num

  def find_set(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find_set(self.par[x]) #自分じゃなきゃ親を探す
      return self.par[x]

  def union(self, x, y):
    x = self.find_set(x)
    y = self.find_set(y)
    if x == y:
      return
    if self.rank[x] > self.rank[y]: #ランクの高い方に基準を合わせる
      self.par[y] = x
    else:
      self.par[x] = y
      if self.rank[x] == self.rank[y]:
        self.rank[y] += 1

  def same(self, x, y):
    return self.find_set(x) == self.find_set(y)

N, Q = map(int, input().split())
uf = UnionFind(N)

for i in range(Q):
  C, X, Y = map(int, input().split())

  if C == 0:
    uf.union(X, Y)

  elif C == 1:
    print(1 if uf.same(X, Y) else 0)
  else:
    print(uf.find_set(X))

#計算量O(logn)経路圧縮とrankを用いた計算量
#-経路圧縮：葉から根へたどる際に通過したノードの親ポインタを根にする
#-rank：木を合併する際に、ノードの高さの高い方に低い方が結合しにいく

#処理の流れ
#same:  入力受け取り→親が同じ？→true/false
#unite: 高さがどっちが高いか？→高い方へ結合



Measured memory_bytes: 6048
#include <iostream>

using namespace std;

int main()
{
    int c=1,x,box[10000],i=0;
    while(i<=10000){
        cin >> x;
        if(x==0){
            break;
        }
        box[i]=x;
        i++;
    }
    for(int ii =0;ii<i;ii++){
        cout << "Case " << c << ": " << box[ii] << endl;
        c++;
    }
}


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

#define fi first
#define se second
#define CLR(A, X) memset(A, X, sizeof(A))
typedef long long LL;
typedef pair<int, int> PII;

const int N = 2e5+5;
char s[N];
int vis[30];

LL C(LL x) {
    return x*(x-1)/2;
}

int main() {
    scanf("%s", s);
    int l = strlen(s);
    for(int i = 0; i < l; i++) vis[s[i]-'a']++;
    LL ans = C(l)+1;
    for(int i = 0; i < 26; i++) ans -= C(vis[i]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod =1000000007;
int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double ans;
    cout << fixed << setprecision(10);
    if(a*a*b > 2 * x){
        cout<<atan((a * b * b)/(2*x)) *180/M_PI<<endl;
    }
    else{
        cout<<atan((2*(a*a*b -x)) / (a*a*a)) * (180/M_PI) <<endl;
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    for(int i=0;i<5;i++)
    {
        cin>>x;
        if(x==0)
        {
            cout<<i+1;
        }
    }
  	return 0;
}







Measured memory_bytes: 3544
N, M = map(int, input().split())
A = list(map(int, input().split()))
cut = sum(A) / (4 * M)

A = sorted(A, reverse=True)
cand_A = A[:M]
new_cand = []
for i in range(len(cand_A)):
  if cand_A[i] - cut < 0:
    new_cand.append(0)
  else:
    new_cand.append(1)
    
if 0 in new_cand:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var leftEast = 0;
            var rightWest = 0;

            for(int i = 1; i < n; i++)
            {
                if(s[i] == 'W')
                {
                    rightWest++;
                }
            }

            var ans = n - 1 - rightWest - leftEast;
            for(int i = 0; i < n - 1; i++)
            {
                if (s[i] == 'E')
                {
                    leftEast++;
                }
                if(s[i + 1] == 'W')
                {
                    rightWest--;
                }
                var now = n - 1 - rightWest - leftEast;
                if(now < ans)
                {
                    ans = now;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
    return 0;
}

Measured memory_bytes: 256
use ::std::collections::HashSet;

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

fn read_vec<T: ::std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    ::std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

pub fn main() {
    let N: i64 = read();
    let As: Vec<i64> = read_vec();
    if N == 1 {
        println!("{}", As[0].abs());
        return;
    }
    let is_include_0 = As.iter().any(|&v| v == 0);
    let is_odd: i64 = As.iter().map(|&v| if v < 0 {1} else {0}).sum();
    let sum: i64 = As.iter().map(|&v| v.abs()).sum();
    if is_include_0 || is_odd % 2 == 0 {
        println!("{}", sum);
    } else {
        let sub = As.iter().map(|&v| v.abs()).min().unwrap();
        println!("{}", sum - sub * 2);
    }
}



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

int main(){

    int s,i,j,ans=0;
    cin >> s;

    int a[1000000];

    a[0] = s;

    for(i=1 ; ans == 0 ; i++){
        if(s%2 == 0){
            a[i] = s/2;
            s = a[i];
        }else{
            a[i] = 3*s+1;
            s = a[i];
        }

        for(j=i-1 ; j>=0 ; j--){
            if(a[i] == a[j]){
                ans = i+1;
            }
        }

        
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int x,y,z;
  int N,Y;
  cin >> N >> Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(N-i-j<0)continue;
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


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

int main() {
  int abc[3];
  std::cin >> abc[0] >> abc[1] >> abc[2];
  std::sort(abc, abc + 3);
  if (abc[0] == abc[1] and abc[1] == abc[2]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

double sumhalf(vector<double> v, double p) {
  if (p == 1)
    return (v[0] + v[1]) / 2;
  else
    return (sumhalf(v, p - 1) + v[p]) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
	cout<<sumhalf(v,n-1)<<endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def main():
    N, *A = map(int, read().split())
    ans = [0] * (N + 1)
    for a in A:
        ans[a] += 1
    ans = list(map(str, ans))
    print('\n'.join(ans[1:]))
    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 51048
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from math import gcd

a,b,c,d=nii()

a_c=(a-1)//c
b_c=b//c

a_d=(a-1)//d
b_d=b//d

lcm=(c*d)//gcd(c,d)
a_lcm=(a-1)//lcm
b_lcm=b//lcm

print((b-a+1)-(b_c-a_c)-(b_d-a_d)+(b_lcm-a_lcm))

Measured memory_bytes: 9120
#include <iostream>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    string ans = "NO";
    rep (i, a*b) {
        if (i*a % b == c) {
            ans = "YES";
            break;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int cnt = 700;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == 'o')
        {
            cnt += 100;
        }
    }
    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 256
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int n,v[1<<18|5],w[1<<18|5],fa,m,dp[1<<9|5][100005],q,a,b,cnt,V[15],W[15],tov[1<<9|5],tow[1<<9|5],lg[1<<10],ans;
int lowbit(int now)
{
    return now&(-now);
}
signed main()
{
    ios::sync_with_stdio(false);
    for(int i=0;i<=9;++i)
    {
        lg[1<<i]=i;
    }
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>v[i]>>w[i];
    }
    m=sqrt(n);
    for(int i=1;i<=m;++i)
    {
        for(int j=100000;j>=w[i];--j)
        {
            dp[i][j]=max(dp[i>>1][j],dp[i>>1][j-w[i]]+v[i]);
        }
        for(int j=w[i]-1;j>=0;--j)
        {
            dp[i][j]=dp[i>>1][j];
        }
    }
    cin>>q;
    while(q--)
    {
        cin>>a>>b;
        if(a<=m)
        {
            cout<<dp[a][b]<<endl;
        }
        else
        {
            fa=a;
            cnt=0;
            while(fa>m)
            {
                ++cnt;
                V[cnt]=v[fa];
                W[cnt]=w[fa];
                fa>>=1;
            }
            ans=0;
            ans=max(ans,dp[fa][b]);
            for(int i=1;i<1<<cnt;++i)
            {
                tow[i]=tow[i^lowbit(i)]+W[lg[lowbit(i)]+1];
                tov[i]=tov[i^lowbit(i)]+V[lg[lowbit(i)]+1];
                if(tow[i]<=b)
                {
                    ans=max(ans,dp[fa][b-tow[i]]+tov[i]);
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

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

int main(){
   string a;cin>>a;
   int b=0;
   for(char c:a){
       if(((b&1)==0&&c=='A')||((b&1)&&c=='Z'))b++;
       }
       if(b&1)b--;
       b/=2;
       if(b==0){puts("-1");return 0;}
       for(int i=0;i<b;i++){
	   cout<<"AZ";
	   }
	   cout<<endl;
    }

Measured memory_bytes: 3132
SA = list(input())
SB = list(input())
SC = list(input())
T = 'a'
for i in range(300):
    if T == 'a':
        if len(SA)==0:
            print ('A')
            break
        else:
            T = SA.pop(0)
    if T == 'b':
        if len(SB)==0:
            print ('B')
            break
        else:
            T = SB.pop(0)
    if T == 'c':
        if len(SC)==0:
            print ('C')
            break
        else:
            T = SC.pop(0)  
        

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
bool b[10];
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i * m + j * n - i * j * 2 == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()


def is_pal(s):
    for i in range(len(s)//2):
        if s[i] != s[-(i+1)]:
            return False
    return True


N = len(S)
if is_pal(S) and is_pal(S[:(N - 1)//2]) and is_pal(S[(N + 3)//2-1:]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	unordered_map<string, int> m;
	int n;
	cin >> n;
	
	while(n--) {
		string ver;
		cin >> ver;
		m[ver]++;
	}
	
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
  
	return 0;
}


Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,k,s;vector<int> ans;
signed main(){
  cin>>n>>k>>s;
  ans.resize(n);
  int m = 1000000000;
  if(s != m){
    rep(i,k)ans[i] = s;
    repd(i,k,n)ans[i] = m;
  }else{
    rep(i,k)ans[i] = m;
    repd(i,k,n)ans[i] = 1;
  }
  rep(i,n)cout << ans[i] << (i == n-1 ? endn : " ");
}


Measured memory_bytes: 2048
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;

fn main() {
    let s = str2vec(&input_line_str());
    println!("{}{}{}", s[0], s.len() - 2, *s.last().unwrap());
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[125252];

int cnt[125252];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    ll ans = 1;
    cnt[0] = 3;
    REP(i,n){
        int v = a[i];
        ans *= cnt[v];
        ans %= MOD;
        cnt[v]--; cnt[v+1]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10 ** 9 + 7

s = k * ((k - 1) // 2)
if (k - 1) % 2 != 0:
    s += (k - 1) // 2 + 1

res = 0
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        if a_list[i] > a_list[j]:
            if i < j:
                res += s + k
            else:
                res += s

res %= mod
print(int(res))

Measured memory_bytes: 41452
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
using ll = long long;
const ll mod = 1000000007;
using namespace std;

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	ll ans = 0;
	for( int i = 0; i < 60; ++i ){
		ll nll = 0, eins = 0;
		for( int k = 0; k < n; ++k ){
			if( a[k] & (1ll<<i) ) ++eins;
			else ++nll;
		}
		ll res = ( n*(n-1)/2 - eins*(eins-1)/2 - nll*(nll-1)/2 + mod ) % mod;
		res *= ( (1ll<<i) % mod );
		ans += res;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')
    {
        cout<<s<<"es\n";
    }
    else cout<<s<<"s\n";
	return 0;
}


Measured memory_bytes: 3644
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

int main()
{
    int h, w;
    cin >> h >> w;
    int m;
    cin >> m;
    int hcnt[300010] = {};
    int wcnt[300010] = {};
    set<pair<int, int>> s;
    for (int i = 0; i < m; i++)
    {
        int hi, wi;
        cin >> hi >> wi;
        hi--;
        wi--;
        s.insert(make_pair(hi, wi));
        hcnt[hi]++;
        wcnt[wi]++;
    }
    vector<pair<int, int>> sortedHcnt;
    vector<pair<int, int>> sortedWcnt;
    for (int i = 0; i < h; i++)
    {
        if (hcnt[i] > 0)
            sortedHcnt.push_back(make_pair(hcnt[i], i));
    }
    for (int i = 0; i < w; i++)
    {
        if (wcnt[i] > 0)
            sortedWcnt.push_back(make_pair(wcnt[i], i));
    }
    sort(sortedHcnt.begin(), sortedHcnt.end());
    sort(sortedWcnt.begin(), sortedWcnt.end());
    int ans = 0;
    int sh = sortedHcnt.size();
    int sw = sortedWcnt.size();
    for (int i = sh - 1; i >= 0; i--)
    {
        if (sortedHcnt[i].first != sortedHcnt[sh - 1].first)
        {
            break;
        }
        for (int j = sw - 1; j >= 0; j--)
        {
            if (sortedWcnt[j].first != sortedWcnt[sw - 1].first)
            {
                break;
            }
            int res = sortedHcnt[i].first + sortedWcnt[j].first;
            if (s.find(make_pair(sortedHcnt[i].second, sortedWcnt[j].second)) != s.end())
            {
                res--;
                ans = max(ans, res);
            }
            else
            {
                cout << res << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 28064
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=100010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
int n,ans;
signed main(){
	cin>>n;
	repeat(i,1,n+1){
		if(i%3==0 || i%5==0);
		else ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/



signed main()
{
    fast;
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<bool>dp(k+1,false);
    for(int i=1;i<=k;i++)
    {
        for(auto x:a)
        {
            if(i-x>=0)
            {
                if(dp[i-x]==0)
                {
                    dp[i]=1;
                }
            }
        }
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}   

Measured memory_bytes: 3668
#include<cstdio>
#include<cstring>
#define N 100001
int a[N],b[N],c[N],d[N],i,j,m,n,s[N];
inline void one(int*x){for(i=1;i<=n;i++)x[i]=i;}
inline void inv(int*x,int*y)
{
    for(i=1;i<=n;i++)s[y[i]]=i;
    memcpy(x+1,s+1,n<<2);
}
inline void mul(int*x,int*y,int*z)
{
    for(i=1;i<=n;i++)s[i]=y[z[i]];
    memcpy(x+1,s+1,n<<2);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)scanf("%d",a+i),c[a[i]]=i;
    for(i=1;i<=n;i++)scanf("%d",b+i),d[b[i]]=i;
    for(mul(c,c,b),mul(c,c,a),mul(c,c,d),one(d),j=--m/6,m%=6;j;j>>=1,mul(c,c,c))if(j&1)mul(d,d,c);
    for(inv(c,d),mul(a,a,d),mul(a,c,a),mul(b,b,d),mul(b,c,b);m;m--)inv(c,a),memcpy(a+1,b+1,n<<2),mul(b,b,c);
    for(int i=1;i<=n;i++)printf("%d%c",a[i],i==n?'\n':' ');
    return 0;
}

Measured memory_bytes: 2688
n=int(input())
g=[[] for i in range(1+n)]
v=[0]*(1+n)
dist=[0]*(1+n)
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a].append([b,c])
    g[b].append([a,c])

def dfs(p):  # p = [node, 0]
    while p:
        cur, depth=p.pop()
        v[cur]=1
        dist[cur]=depth
        for nb in g[cur]:
            if v[nb[0]]==0:
                p.append([nb[0],depth+nb[1]])
    return

q,k=map(int,input().split())
dfs([[k,0]])

for i in range(q):
    x,y=map(int,input().split())
    print(dist[x]+dist[y])

Measured memory_bytes: 100164
#include <iostream>

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

using namespace std;

int main()
{
    int ans;
    rep(i,5){
        int x;
        cin>>x;
        if(x==0){
            ans =i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int coin;
    while(~scanf("%d",&coin)){
        int i,j,happiness;
        i=coin/500;
        coin-=i*500;
        happiness=i*1000;
        j=coin/5;
        happiness+=j*5;
        printf("%d\n",happiness);
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265358979323846;

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

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

class DXorSum2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
		int arr[n];
        ll res = 0;
        vi dp(20, -1);
        int prev = 0;
        f(i, n){
            int x; in>>x;
            f(j, 20){
                if(x&(1<<j)) prev = max(prev, dp[j]+1), dp[j] = i;
            }
            res += i-prev+1;
        }
        out<<res;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	DXorSum2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	ll n;
	cin>>n;
	ll work[100][2];
	work[0][0]=0;
	work[0][1]=0;
	ll tmp=1;
	int msb=1;
	while(true){
		if(msb%2==0){
			work[msb][0]=work[msb-1][0]-tmp;
			work[msb][1]=work[msb-1][1];
		}
		else{
			work[msb][1]=work[msb-1][1]+tmp;
			work[msb][0]=work[msb-1][0];
		}
		//cout<<work[msb][0]<<" "<<work[msb][1]<<endl;
		if(work[msb][0]<=n && n<=work[msb][1])break;
		tmp*=2;
		msb++;
	}

	for(;msb>0;msb--){
		if(work[msb][0]<=n && n<=work[msb][1] && !(work[msb-1][0]<=n && n<=work[msb-1][1])){
			cout<<1;
			if(msb%2==1)n-=tmp;
			else n+=tmp;
		}
		else cout<<0;
		tmp/=2;
	}
	cout<<endl;



	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;

    if ( S == U) {
        A--;
    }
    else {
        B--;
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 3612
n = input()

#print(n[-1])
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("bon")


Measured memory_bytes: 8916
#include<bits/stdc++.h>
using namespace std;
int art[1000];
int ars[1000];
int main(){

string s,t;
cin>>s>>t;
for(int i=0;i<s.length();i++) ars[i]=s[i]-'a';
for(int i=0;i<t.length();i++) art[i]=t[i]-'a';

sort(ars,ars+s.length());
sort(art,art+t.length());

string ss="",tt="";
for(int i=0;i<s.length();i++) ss+=(ars[i]+'a');
for(int i=t.length()-1;i>=0;i--) tt+=(art[i]+'a');
//cout<<ss<<endl;
//cout<<tt<<endl;
if(ss<tt) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

void fft(vector<complex<double>>&a,int inverse){
  int n=a.size();
  if(n==1)return;
  vector<complex<double>>va,vb;
  for(int i=0;i<n/2;i++){
    va.push_back(a[2*i]);
    vb.push_back(a[2*i+1]);
  }
  fft(va,inverse);fft(vb,inverse);
  complex<double>now=1,zeta=polar(1.0,inverse*2.0*acos(-1)/n);
  for(int i=0;i<n;i++){
    a[i]=va[i%(n/2)]+now*vb[i%(n/2)];
    now*=zeta;
  }
}

vector<int>multiply(vector<int>a,vector<int>b){
  int sz=1;while(sz<2*a.size()+1)sz*=2;
  vector<complex<double>>na(sz,0),nb(sz,0);
  for(int i=0;i<a.size();i++)na[i]=a[i];
  for(int i=0;i<b.size();i++)nb[i]=b[i];
  vector<int>res(sz,0);
  fft(na,1);
  fft(nb,1);
  for(int i=0;i<sz;i++)na[i]=na[i]*nb[i];
  fft(na,-1);
  for(int i=0;i<sz;i++)res[i]=(int)round(na[i].real()/sz);
  return res;
}

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

  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<int>a(100001);
  for(int i=0;i<N;i++)a[A[i]]++;
  auto ans=multiply(a,a);
  ll res=0;
  int c=0;
  for(int i=ans.size()-1;i>=0;i--){
    if(c+ans[i]>M)res+=(M-c)*i,c=M;
    else res+=ans[i]*i,c+=ans[i];
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 23908
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = 0;

    string E869120 = "E869120";
    rep(i,n){
        string s; cin >> s;
        if(s == E869120)ans++;
    }

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



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


int main(){

    int N;
    cin >> N;
    long int a[N],b[N],c[N];
    for(int i = 0 ; i < N ; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<int>> hapiness(N,vector<int>(2));

    hapiness[0][1] = a[0];
    hapiness[0][2] = b[0];
    hapiness[0][3] = c[0];

    for(int i = 1; i < N; i++){
        hapiness[i][1] = max(hapiness[i-1][2],hapiness[i-1][3]) + a[i];
        hapiness[i][2] = max(hapiness[i-1][1],hapiness[i-1][3]) + b[i];
        hapiness[i][3] = max(hapiness[i-1][1],hapiness[i-1][2]) + c[i];
    }
    
    cout << max(hapiness[N-1][1],max(hapiness[N-1][2],hapiness[N-1][3])) << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c < a+b) {
    cout << "No" << endl;
    return 0;
  }
  ll x = 4 * a * b;
  ll y = (c-a-b)*(c-a-b);
  if(x < y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

void solveA(){
  int a,b,c;
  cin >> a >> b >> c;

  cout << min(b/a,c) << endl;
}
void solveB(){
  int a,b,k;
  cin >> a >> b >> k;
  vector<int> vec;
  int cnt=0;
  int i;

  for(i=1;i<=100;i++){
    if(a%i==0 && b%i==0){
      vec.push_back(i);
    }
  }

  sort(vec.begin(),vec.end(),greater<int>());

  cout << vec[k-1] << endl;
}
void solveC(){

}

void solveD(){
}

int main(){
  solveB();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    
    int n=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            if(500*i+100*j<=x&&x-50*c<=500*i+100*j){
                ++n;
            }
        }
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : Longest Path on Grid
// Contest : CodeChef - TSEC January Codeathon
// URL : https://www.codechef.com/TJCN2019/problems/TSECJC06
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    vi v(2*n);
    
    for(auto &x:v) cin >> x;
    sort(all(v));
    
    ll sum = 0;
    repr(i,(2*n)-2,0) sum += min(v[i],v[i+1]),i--;
    cout << sum;
}

int main(){
    IOS;
    solve();
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N + 1,100010);
    for(int i = 0; i < N - 1; i++) {
        cin >> A.at(i + 1);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += min(A.at(i), A.at(i + 1));
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3636
N=int(input())
a=list()
for _ in range(N):
  A,B=map(int,input().split())
  a.append((B,A))
a.sort()
t=0
for i in range(N):
  t+=a[i][1]
  if t>a[i][0]:
    print("No")
    exit()
print("Yes")


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

namespace ABC115_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = sss[0];
            var k = sss[1];
            var num = new List<int>();
            for (var i = 0; i < n; i++)
            {
                num.Add(int.Parse(Console.ReadLine()));
            }
            num.Sort();
            var min = int.MaxValue;
            for (var i = 0; i < n - k + 1; i++)
            {
                var t = num[i + k - 1] - num[i];
                min = Math.Min(t, min);
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 18140
#include <iostream>

using namespace std;

int main() {
	int a, b;
	string op;
	cin >> a >> op >> b;
	while (op != "?") {
		int ans;
		if (op == "+")
			ans = a + b;
		else if (op == "-")
			ans = a - b;
		else if (op == "*")
			ans = a * b;
		else if (op == "/")
			ans = a / b;
		cout << ans << endl;
		cin >> a >> op >> b;
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//?????°??¨??????????????°???????????????
		int people = sc.nextInt();
		int ivent = sc.nextInt();

		int num = Integer.MAX_VALUE;

		//?????°??????????????????
		int[] wakasagi = new int[people+1];
		Arrays.fill(wakasagi, 0);

		int max = 0;
		//????????¨???
		for(int $ = 0; $ < ivent; $++) {
			int entryNum = sc.nextInt(); //?????????????????????
			int wakasagiNum = sc.nextInt(); //?????????????????°


			wakasagi[entryNum] += wakasagiNum;

			if(num == entryNum){
                max = 0;
                for(int i = 1;i <= people; i++) max = Math.max(max, wakasagi[i]);
                for(int i = 1;i <= people; i++){
                    if(wakasagi[i] == max){
                        num = i;
                        System.out.println(num + " " + max);
                        break;
                    }
                }
            }else{

                if(max > wakasagi[entryNum]){
                    System.out.println(num + " " + max);
                }else if(max < wakasagi[entryNum]){
                    max = wakasagi[entryNum];
                    num = entryNum;
                    System.out.println(num + " " + max);
                }else if(max == wakasagi[entryNum]){
                    if(num < entryNum){
                        System.out.println(num + " " + max);
                    }else{
                        num = entryNum;
                        System.out.println(num + " " + max);
                    }
                }

            }


		}
	}
}

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

using namespace std;

using ll = long long;

bool Check(auto cnt, const int h, const int w) {
    const int n1 = floor(h / 2.0) * floor(w / 2.0);
    const int n2 = floor((h * w - n1 * 4) / 2.0);

    for (auto &it : cnt)
        if (it.second % 2 == 1) {
            --it.second;
            break;
        }
    for (auto &it : cnt)
        if (it.second % 2 == 1) return false;

    int x2 = 0;
    for (auto &it : cnt) {
        if (it.second == 2) {
            ++x2;
            it.second = 0;
        }
    }
    if (n2 < x2) return false;

    for (auto &it : cnt) {
        if (0 < it.second && it.second % 4 != 0) {
            ++x2;
            it.second -= 2;
        }
    }
    if (n2 < x2) return false;

    // すべて4の倍数
    int x1 = 0;
    for (auto &it : cnt) {
        if (0 < it.second && it.second % 4 == 0) {
            x1 += it.second / 4;
            it.second = 0;
        }
    }
    if (2 * (n2 - x2) + 4 * n1 != 4 * x1) return false;

    return true;
}

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

    int h, w;
    char a;

    cin >> h >> w;
    map<char, int> cnt;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            cin >> a;
            ++cnt[a];
        }

    if (Check(cnt, h, w)) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256