akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i]-c[i],i+1] for i in range(26)]
	ss.sort(reverse = True)
	data = i % 26
	sel[i] = ss[data-1][1]
	ans += s[i][data-1]

	for j in range(26):
		if j == data - 1:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j]
			ans -= c[j] * (i - day[i][j] + 1)



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = random.randrange(10)
		if sel[ima] != data+1:
			break
	data = po[data][1]-1
	ppp = 0
	for i in range(26):
		if ima == day[ima][i]:
			now = i
			break
	else:
		while True:
			now = random.randrange(26)
			if now != data:
				break 
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp += (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1

for i in sel:
	print(i)


Measured memory_bytes: 82460
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		String check;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while((check=br.readLine()) != null) {
			String[] str = new String[12];
			str = check.split(",");
			int[] hen = new int[12];
			int zen = 0;
			for(int i=0; i<12; i++) {
				hen[i] = Integer.parseInt(str[i]);
				if(i<10) zen += hen[i];
			}
			double time = (double)zen / (double)(hen[10]+hen[11]);
			int sum = 0;
			for(int i=0; i<10; i++) {
				sum+=hen[i];
				if(time*hen[10] <= sum) {
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 16880
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 500005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
string s;
map<char,int> zz;
void Solve() {
    cin >> s;
    for(int i = 0 ; i < s.length() ; ++i) zz[s[i]] = 1;
    if((zz['W'] ^ zz['E']) & 1) {puts("No");return;}
    if((zz['N'] ^ zz['S']) & 1) {puts("No");return;}
    puts("Yes");
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

#define int long long
#define rep(i,a,b) for(int i=a;i<=b;i++)

typedef pair<int,int> ii;
typedef vector<ii> vii;

vector<vii> g;
int n,m,l,r,d;
int val[100001],ok;
bool visited[100001];

void dfs(int v) {
	visited[v]=true;
	rep(i,0,(int)g[v].size()-1) {
		ii p=g[v][i];
		if(visited[p.first]) {
			if(val[p.first]!=val[v]+p.second) {
					ok=false;
		return;
			}
		}
		else {
			val[p.first]=val[v]+p.second;
			dfs(p.first);
		}
		
	} 
}

signed main() {
	cin >> n >> m;
	g.assign(n+1,vii()) ;
	memset(visited,false,sizeof(visited));
	rep(i,1,m) {
		cin >> l >> r >> d;
		g[l].push_back(make_pair(r,d));
		g[r].push_back(make_pair(l,-d));
	}
	rep(i,1,n) {
		if(!visited[i]) {
			ok=true;
			dfs(i);
			if(ok==false) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 19524
#include<stdio.h>
int main(void)
{
	int n,a,x[]={0,399,799,1199,1599,1999,2399,2799,3199},flg[10],cnt,cnt1,i,j;
	scanf("%d",&n);
	cnt=0;
	for(i=0;i<8;i++) flg[i]=0;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		for(j=0;j<9;j++){
			if(j==8){
				cnt++;
				break;
			}
			else if(x[j]<a&&x[j+1]>=a){
			//	printf("a=%d i=%d\n",a,i);
				flg[j]=1;
				break;
			}
		}
	}
//	 for(i=0;i<9;i++) printf("%d\n",x[i]);
	// for(i=0;i<8;i++) printf("%d\n",flg[i]);
	cnt1=0;
	for(i=0;i<8;i++){
		if(flg[i]==1) cnt1++;
	}
	if(cnt1==0) printf("1 ");
	else printf("%d ",cnt1);
	cnt1+=cnt;
	printf("%d\n",cnt1);
	//else printf("8\n");
	return 0;
}

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

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

    int ans = 1;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	
	string ans = "";
	
	for (int i = 0; i < n; i++) {
		ans += s[i];
		ans += t[i];
	}
	
	cout << ans << endl;	
}


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

/* これでもいいんだけどねーん　累積和の練習しましょ　そうしましょ ♬
int n;
cin>> n;
int a[2][n];
rep(i,2)rep(j,n) cin >> a[i][j];
vector<int> vec(n);
rep(j,n){
    int cnt=0;
    for(int k=0; k<=j; k++) cnt+=a[0][k];
    for(int l=j; l<n; l++) cnt+=a[1][l];
    vec[j]=cnt;
}
sort(vec.begin(), vec.end(), greater<int>());
cout << vec[0] << endl;
*/

int n;
cin >> n;
int a[110]={0}, b[110]={0};
cin >> a[1];
for (int i=2; i<=n; i++) {
    cin >> a[i];
    a[i]+= a[i-1];
}
cin >> b[1];
for (int i=2; i<=n; i++) {
    cin >> b[i];
    b[i]+= b[i-1];
}
int ans;
rep1(i,n) ans=max(ans, a[i]+b[n]-b[i-1]);
cout << ans << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s;
   cin>>s;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='?')s[i]='D';
   }
   cout<<s<<endl;
}


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

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

	int res = 0;
	for (int b = 0; b < N; ++b) {
		bool ok = true;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				int ri = (j - b + N) % N;
				int rj = (i + b) % N;

				if (s[i][j] != s[ri][rj]) { ok = false; }
			}
		}
		
		if (ok) { res += N; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 512
import heapq
X,Y,a,b,c=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

heapq.heapify(A)
if len(A)<X:
    while len(A)<X:
        heapq.heappush(A,0)
else:
    while len(A)>X:
        heapq.heappop(A)
        
heapq.heapify(B)
if len(B)<X:
    while len(B)<Y:
        heapq.heappush(B,0)
else:
    while len(B)>Y:
        heapq.heappop(B)
#print(A,len(A))

C.sort(reverse=True)
for i in range(c):
    if A[0]<B[0] and A[0]<C[i]:
        heapq.heappop(A)
        heapq.heappush(A,C[i])
    elif B[0]<=A[0] and B[0]<C[i]:
        heapq.heappop(B)
        heapq.heappush(B,C[i])
    else:
        break
A=list(A)
B=list(B)
print(sum(A)+sum(B))
#print(B,len(B))

Measured memory_bytes: 123560
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[string]int)
	for i := range s {
		m[string(s[i])]++
	}
	for k := range m {
		if m[k] != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=3005;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int n,Mod,Phi,Ans,C[N][N],S[N][N],p1[N],p2[N];
int mod(int x){return x>=Mod?x-Mod:x;}
void Prepare(){
	for(int i=0;i<N;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=mod(C[i-1][j-1]+C[i-1][j]);
	}
	S[0][0]=1;
	for(int i=1;i<N;i++){
		for(int j=1;j<=i;j++)S[i][j]=mod(S[i-1][j-1]+1ll*j*S[i-1][j]%Mod);
	}
	p1[0]=1;for(int i=1;i<N;i++)p1[i]=(p1[i-1]<<1)%Mod;
	p2[0]=1;for(int i=1;i<N;i++)p2[i]=(p2[i-1]<<1)%Phi;
}
int Pow(int x,int y){
	int ans=1;
	while(y){if(y&1)ans=1ll*ans*x%Mod;x=1ll*x*x%Mod;y>>=1;}
	return ans;
}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();Mod=read();Phi=Mod-1;Prepare();
	for(int k=0;k<=n;k++){
		int ans=0;
		for(int j=0;j<=k;j++)ans=mod(ans+1ll*S[k+1][j+1]*Pow(p1[n-k],j)%Mod);
		Ans=mod(Ans+1ll*ans*Pow(2,p2[n-k])%Mod*C[n][k]%Mod*(k&1?Mod-1:1)%Mod);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 59004
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    
    long long sum=0;
    int i=1;
    while(i<n){
        if(v[i] < v[i-1]){
            sum += v[i-1] - v[i];
            v[i] = v[i-1];
        }
        i++;
    }
    
    cout << sum << endl;
    
    
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n),tmp;
    vector<ll> mem(200001,0);
    queue<ll> q;

    rep(i,n) cin >> a[i];

    for(ll i = n; i >= 1; i --){

        if(mem[i]%2 == 1 && a[i-1] == 1){
            continue;
        }else if(mem[i]%2 == 0 && a[i-1] == 0){
            continue;
        }else{
            tmp = enum_divisors(i);
            q.push(i);
            rep(j,tmp.size()){
                mem[tmp[j]] ++;
            }
        }
    }

    cout << q.size() << endl;
    while(!q.empty()){
        cout << q.front() << " ";
        q.pop();
    }

    return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int MIN = 0, MAX = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		MAX = max(MAX, A[i]);
	}
	while (MIN < MAX) {
		int MID = ((MAX - MIN) / 2) + MIN;
		if (MID == 0) break;
		int num = 0;
		for (int i = 0; i < N; i++) num += (A[i] + MID - 1) / MID - 1;
		if (num <= K) MAX = MID;
		else MIN = MID + 1;
	}
	cout << MAX << endl;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B;

int main(){
	cin>>A>>B;
	if(A+B==15) cout<<"+"<<endl;
	else if(A*B==15) cout<<"*"<<endl;
	else cout<<"x"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

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

  int h, w;
  cin >> h >> w;

  REP (i, h) REP (j, w) {
    string s;
    cin >> s;
    if (s == "snuke") {
      cout << (char)(j+'A') << (i+1) << endl;
    }
  }
  
  return 0;
}


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

#define M 2000
void LCS(char[],char[]);

int main(int argc,char *argv[]){
  int i,n; 
  char a[M],b[M]; 
  
  scanf("%d",&n);
  for(i=0; i<n; i++)
    {
      scanf("%s",a);
      scanf("%s",b);
      LCS(a,b);
    }
  return 0;    
}
void LCS(char A[], char B[])
{
  int i,j,m,n;
    
    m = strlen(A);
    n = strlen(B);
    int a[m+1][n+1];
    
    for(i=0; i<=m; i++){
      for(j=0; j<=n; j++){
        a[i][j] = 0;
      }
    }
    
    for(i = 1; i <= m; i++){
      for(j = 1; j <= n; j++){
	if(A[i-1] == B[j-1])
	  a[i][j] = a[i-1][j-1] + 1;
	else if(a[i-1][j] >= a[i][j-1])
	  a[i][j] = a[i-1][j];
	else a[i][j] = a[i][j-1];
      }
    }
    printf("%d\n",a[m][n]);    
    
} 

Measured memory_bytes: 4524
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, r;
    cin >> n >> r;
    if(n < 10)
        cout << r + 100 * (10 - n);
    else
        cout << r;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n,a,b;
    cin >> n >> a>> b;
    ll loop = n / (a + b);
    ll m = n % (a + b);
    ll sum = loop* a + min(m, a);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3548
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let ans = if a.contains(&0) {
        0
    } else {
        let sum = a.iter().fold(Some(1i64), |acc, a_i| {
            acc.map(|x| x.checked_mul(*a_i)).flatten()
        });
        match sum {
            Some(x) if x <= 10i64.pow(18) => x,
            _ => -1,
        }
    };

    println!("{}", ans);
}


Measured memory_bytes: 4540
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2+5;

int n;
int m;
int vis[N];
int parent[N];
vector < int > adj[N];
vector < pair < int , int > > ed;

void clean(){
    for(int i = 1; i <= n; i++){
        parent[i] = i;
        vis[i] = 0;
    }
}

int getP(int u){
    if(u == parent[u])
        return u;
    return parent[u] = getP(parent[u]);
}

void join(int u , int v){
    u = getP(u);
    v = getP(v);
    if(u == v)
        return;
    parent[v] = u;
}


int main(){
    scanf("%d%d" , &n , &m);
    clean();
    for(int i = 1; i <= m; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        ed.push_back({u , v});
        join(u , v);
    }
    int cc = 0;
    for(int i = 1; i <= n; i++){
        int s = getP(i);
        if(!vis[s]){
            vis[s] = 1;
            cc++;
        }
    }
    int cntB = 0;
    for(int i = 1; i <= m; i++){
        //if we removed the ith edge
        clean();
        for(int j = 1; j <= m; j++){
            if(j == i)
                continue;
            int u  = ed[j - 1].first;
            int v  = ed[j - 1].second;
            join(u , v);
        }
        int c = 0;
        for(int j = 1; j <= n; j++){
            int s = getP(j);
            if(!vis[s]){
                vis[s] = 1;
                c ++;
            }
        }
        if(c == cc+1)
            cntB++;
    }
    printf("%d\n" , cntB);
}


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

int comp(const void *a,const void *b){
    return -strcmp((char*)a,(char*)b);
}

int main(void){
    char s[101],t[101];
    scanf("%s %s",s,t);
    qsort(s,strlen(s),1,strcmp);
    qsort(t,strlen(t),1,comp);
    if(strcmp(s,t) < 0)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 128
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int X,N;
  cin>>X>>N;
  int p[N];
  for(int i=0;i<N;i++){cin>>p[i];}
  int ans;
  int diff=0;
  bool exist=true;
  int X_=0;
  while(exist){
    for(int i=-1;i<=1;i=i+2){
      exist=false;
      X_=X+(i*diff);
      for(int j=0;j<N;j++){
        if(X_==p[j]){
          exist=true;
        }
      }
      if(!exist){
        break;
      }
    }
    diff++;
  }
  cout<<X_;

}

Measured memory_bytes: 3632
#include <cstdio>
#include <utility>
 
using namespace std;
 
int bubbleSort(int A[], int N) {
  int counter = 0;
  bool flag = true;
  for (int i = 0; flag; i++) {
    flag = false;
    for (int j = N - 1; j >= i + 1; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j - 1]);
        flag = true;
        counter++;
      }
    }
  }
  return counter;
}
 
int main() {
  int N, A[100];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  int counter = bubbleSort(A, N);
 
  for (int i = 0; i < N; i++) {
    if (i != N - 1)
      printf("%d ", A[i]);
    else
      printf("%d\n", A[i]);
  }
  printf("%d\n", counter);
}

Measured memory_bytes: 2676
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
 
		// 3桁の整数
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
 
		if (x % 10 == 7) {
			System.out.println("Yes");
			return;
		}
 
		x = x / 10;
 
		if (x % 10 == 7) {
			System.out.println("Yes");
			return;
		}
 
		x = x / 10;
 
		if (x == 7) {
			System.out.println("Yes");
			return;
		}
 
		System.out.println("No");
 
	}
 
}

Measured memory_bytes: 35748
until (m, f, r = gets.split.map(&:to_i)) == [-1,-1,-1]
  if m == -1 || f == -1
    puts "F"
    next
  end

  score = m + f
  case score
  when 80..100 then puts "A"
  when 65...80 then puts "B"
  when 50...65 then puts "C"
  when 30...50
    if r >= 50
      puts "C"
    else puts "D"
    end
  when 0...30 then puts "F"
  end
end

Measured memory_bytes: 8616
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

char str[110];

int main(){
	int k;
	scanf("%d", &k);
	scanf("%s", str);
	int l = strlen(str);
	if(l<=k){
		printf("%s\n", str);
	}
	else{
		for(int i=0; i<k; i++){
			printf("%c", str[i]);
		}
		printf("...\n");
	}

	
	return 0;
}

Measured memory_bytes: 1664
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

N = s_in()[::-1]
n = len(N)

dp1 = [0 for _ in range(n)]
dp1[0] = int(N[0])
# dp1[i] は i桁目を同じ値だけ使ったとしたときの最小値
dp2 = [0 for _ in range(n)]
dp2[0] = 10 - int(N[0])
# dp2[i] は i桁目を繰り上げたとしたときの最小値

for i, s in enumerate(N[1:]):
    i += 1

    m = int(s)
    dp1[i] = min(dp1[i-1] + m,      dp2[i-1] + (m+1))
    dp2[i] = min(dp1[i-1] + (10-m), dp2[i-1] + (10-m-1))

# print(dp1)
# print( dp2)
print(min(dp1[n-1], dp2[n-1]+1))


Measured memory_bytes: 84956
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,j,x=0,y;
	string s;
	map<string,ll> mp;
	cin>>n;
	while(n--)
	{
		cin>>s;
		mp[s]++;
		if(mp[s]>x)
		{
			x=mp[s];
		}
	}
	for(auto it : mp)
	{
		if(it.second==x)
		{
			cout<<it.first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 23936
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1, cnt = 0;
    for(int i = 1; i <= n; ++i){
        int num = i;
        int c = 0;
        while(num%2 == 0){
            num /= 2;
            ++c;
        }
        if(c > cnt){
            ans = i;
            cnt = c;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF=1e18+7;
const int maxn=2e5+5;

inline int calc(int x){
	if(x<2) return 2-x;
	return x&1;
}

inline int calc1(int x){
	if(!x) return 1;
	return (x+1)&1;
}

int n;
int a[maxn];
ll ans=INF;
ll pre[maxn],suf[maxn];
ll f[maxn][2],g[maxn][2];

int main(){
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i);
	FOR(i,0,n) pre[i]=(i)?(pre[i-1]+a[i]):(a[i]);
	ans=pre[n-1];
	for(int i=n-1;i>=0;--i) suf[i]=(i!=n-1)?(suf[i+1]+a[i]):(a[i]);
	FOR(i,0,n) f[i][0]=f[i][1]=g[i][0]=g[i][1]=INF;
	FOR(i,0,n){
		if(!i){
			f[i][0]=calc(a[i]);
			f[i][1]=calc1(a[i]);
		}else{
			f[i][0]=min(f[i-1][0]+calc(a[i]),pre[i-1]+calc(a[i]));
			f[i][1]=min(min(f[i-1][1]+calc1(a[i]),pre[i-1]+calc1(a[i])),f[i-1][0]+calc1(a[i]));
		}
	}
/*	puts("f");
	FOR(i,0,n) printf("%lld ",f[i][0]);
	puts("");
	FOR(i,0,n) printf("%lld ",f[i][1]);
	puts("");
*/	for(int i=n-1;i>=0;--i){
		if(i==n-1){
			g[i][0]=calc(a[i]);
			g[i][1]=calc1(a[i]);
		}else{
			g[i][0]=min(g[i+1][0]+calc(a[i]),suf[i+1]+calc(a[i]));
			g[i][1]=min(min(g[i+1][1]+calc1(a[i]),suf[i+1]+calc1(a[i])),g[i+1][0]+calc1(a[i]));
		}
	}
/*	puts("g");
	FOR(i,0,n) printf("%lld ",g[i][0]);
	puts("");
	FOR(i,0,n) printf("%lld ",g[i][1]);
	puts("");
*/	FOR(i,0,n){
		if(i!=n-1) ans=min(ans,f[i][0]+g[i+1][1]);
		if(i!=n-1) ans=min(ans,g[i+1][0]+f[i][1]);
		if(i!=n-1) ans=min(ans,f[i][0]+g[i+1][0]);
		if(i!=n-1) ans=min(ans,min(f[i][0],f[i][1])+suf[i+1]);
		else ans=min(ans,min(f[i][0],f[i][1]));
		if(i) ans=min(ans,min(g[i][0],g[i][1])+pre[i-1]);
		else ans=min(ans,min(g[i][0],g[i][1]));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    ll A,B,C,K,a,b,c;
    cin>>A>>B>>C>>K;
    if(K%2 == 0){
        cout<<A-B<<endl;
    }
    else{
        cout<<B-A<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=200200;
int n,u,v,x,y,len,fa[N],f[N],g[N],h[N],d[N];
ll ans=9e18;
vector<int>ve[N];
void add(int u,int v){ve[u].push_back(v);}
void dfs1(int u){
	f[u]=0;
	for(int v:ve[u])if(v!=fa[u])
		fa[v]=u,dfs1(v),f[u]=max(f[u],f[v]+1);
}
void upd(int L){
	ll pro=1;
	FOR(i,0,L-1) pro*=h[i],h[i]=0;
	ans=min(ans,pro);
}
void dfs2(int u){
	//cout<<u<<' '<<(int)ve[u].size()-(fa[u]>0)<<'\n';
	h[d[u]]=max(h[d[u]],(int)ve[u].size()-(fa[u]>0));
	for(int v:ve[u])if(v!=fa[u])
		fa[v]=u,d[v]=d[u]+1,dfs2(v);
}
void work(int x,int y){
	fa[x]=y;fa[y]=x;d[x]=d[y]=1;h[0]=2;
	dfs2(x);dfs2(y);upd(g[x]);
	//FOR(i,0,g[x]-1) cout<<h[i]<<' ';cout<<'\n';
}
int main(){
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d",&n);
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	FOR(i,1,n) fa[i]=0,dfs1(i),g[i]=f[i];
	x=1;
	FOR(i,2,n){
		if(g[x]>g[i]) x=i,y=0;
		else if(g[x]==g[i]) y=i;
	}
	if(!y){
		fa[x]=d[x]=0;
		dfs2(x);upd(g[x]);len=g[x]+1;
		for(int v:ve[x]) work(v,x);
	}
	else work(x,y),len=g[x];
	cout<<len<<' '<<ans<<'\n';
}

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();

		extgcd(a, b);
		System.out.println(x+" "+y);
	}
	
	static long x;
	static long y;
	static long extgcd (long a, long b) {
		long d = a;
		if (b != 0) {
			swap_xy();
			d = extgcd(b, a%b);
			swap_xy();
			y -= (a/b)*x;
		} else {
			x = 1; y = 0;
		}
		return d;
	}
	static void swap_xy() {
		long tmp=x;x=y;y=tmp;
	}

}

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

using namespace std;

int main(){
	int k,t; cin >> k >> t;
	priority_queue<int> cake;
	for(int i = 0; i < t; ++i){
		int temp; cin >> temp;
		cake.push(temp);
	}
	int next = 1;
	do{
		int now = cake.top(); cake.pop();
		next--;
		if(next != 0)cake.push(next);
		next = now;
	}while(!cake.empty());
	next--;
	cout << next << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll ans = 0;
  char a;
  while (cin >> a) {
    if (a == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, T;
	cin >> N >> T;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}
	vector<vector<int>> dp1(N + 1, vector<int>(T, 0));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < min(A[i], T); j++){
			dp1[i + 1][j] = dp1[i][j];
		}
		for (int j = A[i]; j < T; j++){
			dp1[i + 1][j] = max(dp1[i][j], dp1[i][j - A[i]] + B[i]);
		}
	}
	vector<vector<int>> dp2(N + 1, vector<int>(T, 0));
	for (int i = N - 1; i >= 0; i--){
		for (int j = 0; j < min(A[i], T); j++){
			dp2[i][j] = dp2[i + 1][j];
		}
		for (int j = A[i]; j < T; j++){
			dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - A[i]] + B[i]);
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < T; j++){
			ans = max(ans, dp1[i][j] + dp2[i + 1][T - 1 - j] + B[i]);
		}
	}
	cout << ans << endl;
}

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

bool Prime(int x)
{
    if (x < 2) return false;
    if (x == 2) return true;
    if (x % 2 == 0) return false;
    for (int i = 3; i * i <= x; i += 2)
        if (x % i == 0) return false;
    return true;
}

int main()
{
    int x; cin >> x;
    while (!Prime(x)) x++;
    cout << x << endl;
    return 0;
}


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

int gcd(int a,int b){
	while(a && b){
		if(a < b) b %= a;
		else a %= b;
	}
	return max(a,b);
}

int main(){
	int w,h,c;
	cin >> w >> h >> c;
	cout << w * h / gcd(w,h) / gcd(w,h) * c << endl; 
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <math.h>

#define N 50001

using namespace std;

int main(void){
	bool isprime[N];
	for(int i=0;i<N;i++) isprime[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) isprime[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		if(n==0)break;
		int count=0;
		for(int i=2;i<=n/2;i++){
			if(isprime[n-i]&&isprime[i])count++;
		}
		cout<<count<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  ll n = in();
  ll ans = 0;
  ll sum = 0;
  REP(i, n){
    ll d = in();
    ll c = in();
    sum += d * c;
    ans += c;
  }
  while(sum >= 10){
    ans += sum / 10;
    sum -= sum / 10 * 9;
  }

  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;
 
string its(int n){
    stringstream s;
    s << n;
    return s.str();
}
 
int main(){
    int n,m;
     
    while(cin >> n >> m ,n+m){
        vector<int> v;
        for(int i = 0 ; i < n ; i++) v.push_back(i+1);
     
        int cnt = 1,t = 0;
        string str;
         
        while(m--){
            bool check = false;
             
            cin >> str;
            if(cnt%15==0){
                if(str != "FizzBuzz"){
                    check = true;
                }
            }
            else if(cnt%3==0){
                if(str != "Fizz"){
                    check = true;
                }
            }
            else if(cnt%5==0){
                if(str != "Buzz"){
                    check = true;
                }
            }
            else{
                if(str!=its(cnt)){
                    check = true;
                }
            }
             
            if(check&&v.size() > 1){
                v.erase(v.begin()+t);
                t %= v.size();
            }
            else t = (t+1)%v.size();
                 
            cnt++;
        }
        for(int i = 0 ; i < v.size() ; i++){
            if(!i) cout << v[i];
            else cout << ' ' << v[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{
    int N,K;

    cin >> N >>K;


    vector<int> M(N);

    for(int i=0;i<N;i++){

        cin >> M[i]; 
    }


    sort(M.begin(),M.end());


    int count =0;


    for(int i=0;i<K;i++){

        count+=M[i]; 
    }


    cout << count << endl;


    return 0;



}

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

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

bool kaibun(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return t==s;
}

int main(void)
{
    string s; cin>>s;
    int n=s.size();
    if(kaibun(s) && kaibun(s.substr(0,(n-1)/2)) && kaibun( s.substr((n+1)/2 ) )) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;


map<char, int> inputMap;

void solve_main()
{
	DWORD N, B, A;
	DWORD ans;

	cin >> N >> A >> B;

	ans = min(N * A, B);

	cout << ans << endl;
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


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

using namespace std;

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

    return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.append(-1)
n = 0
cnt = 0
ans = 0
for a in A:
    if a == n:
        cnt += 1
    else:
        if cnt >= n:
            ans += cnt - n
        else:
            ans += cnt
        n = a
        cnt = 1
print(ans)

Measured memory_bytes: 63856
#include<iostream>
using namespace std;
int a[200000+5],a1[200000+5];
const int maxn=200000+5;
int cmp,res=-1,ans=-1;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		 ans=max(ans,a[i]); 
	}	
	for(int i=0;i<n;i++){
		if(a[i]==ans) cmp++;
	}
	for(int i=0;i<n;i++){
		if(a[i]!=ans){
			res=max(res,a[i]);
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]!=ans){
			cout<<ans<<endl;
		}
		else {
			if(cmp>1){
				cout<<ans<<endl;
			}
			else{
			   cout<<res<<endl;	
			}
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==ans){
		   	
		}
	}
}

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

//xはyで何回割れるか計算
int NIdx(long long x, long long y){
    int n = 0;
    while(x % y == 0){
        x = x / y;
        n++;
    }
    return n;
}


int main(){
    int N;
    long long a;
    int n = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        n += NIdx(a, 2);
    }
    cout << n;
    return 0;
}

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

int n,m;
int a[1123];


int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>n>>m;
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    bool res = (4*m*a[n-m]>=sum);
    cout << (res?"Yes":"No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

bool isLower(char c);
char toUpper(char c);

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

    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;

    if (isLower(s1[0])) s1[0] = toUpper(s1[0]);
    if (isLower(s2[0])) s2[0] = toUpper(s2[0]);
    if (isLower(s3[0])) s3[0] = toUpper(s3[0]);

    cout << s1[0] << s2[0] << s3[0] << endl;

    return 0;
}

bool isLower(char c)
{
    if ('a' <= c && c <= 'z') {
        return true;
    }

    return false;
}

char toUpper(char c)
{
    int dis = 'a' - 'A';

    return c - dis;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace  std;
const int NIL = -1;

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(NIL);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      if (rvnPrtyHeap[1] != NIL)
        cout << rvnPrtyHeap[1] << endl;

      rvnPrtyHeap[1] = NIL;
      fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,a[5];
  ll mx = 0;
  cin>>n;for(int i=0;i<5;i++){
    cin>>a[i];
    ll t = ceil((long double)n / a[i]);
    mx = max(mx, t);
  }
  cout<<mx+4ll<<endl;
  
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  string s;
  cin >> s;
  bool ans = false;
  rep(i,3){
    if(s.at(i) == '7') ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
using std::vector;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ; ) {
    if (h > n)
      break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

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

  shellSort(A, n);

  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if (i) printf(" ");
  }

  printf("\n");
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) {
    printf("%d\n", A[i]);
  }
  return 0;
}

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

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

  cout << fixed;
  cout << setprecision(5);
  int a;
  float sum = 0;
  for (int i = 0; i < n; i++) {
	cin >> a;
	sum += 1 / (float)a;
  }


  cout << 1 / sum << endl;




  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong k,a,b;
    cin >> k >> a >> b;
    for(llong i=1;i*k<=1000;i++){
        if(a <= i*k && b >= i*k){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc061/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int n, m, s;
vector<vector<pair<int, int> > > g;
vector<ll> dist;

void bellman_ford(){
    rep(i, n - 1){
        for(int j = 1; j <= n; j++){
            if(dist[j] == INF) continue;

            rep(k, g[j].size()){
                int next = g[j][k].first;
                if(dist[next] > dist[j] + g[j][k].second){
                    dist[next] = dist[j] + g[j][k].second;
                }
            }
        }
    }
    ll ans = dist[n];

    rep(i, n - 1){
        for(int j = 1; j <= n; j++){
            if(dist[j] == INF) continue;

            rep(k, g[j].size()){
                int next = g[j][k].first;
                if(dist[next] > dist[j] + g[j][k].second){
                    dist[next] = dist[j] + g[j][k].second;
                }
            }
        }
    }

    if(ans > dist[n]){
        cout << "inf" << "\n";
    }else{
        cout << -ans << "\n";
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    cin >> n >> m;
    s = 1;
    g.resize(n + 1);
    dist.resize(n + 1);
    rep(i, m){
        int a, b, d;
        cin >> a >> b >> d;
        d = -d;
        g[a].push_back(make_pair(b, d));
    }
    for(int i = 1; i <= n; i++){
        dist[i] = INF;
    }
    dist[s] = 0;

    bellman_ford();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char c[5];
int main () {
	scanf("%s",c);
	if (c[0]=='M') {printf("6\n");}
	else if (c[0]=='T'&&c[1]=='U') {printf("5\n");}
	else if (c[0]=='W') {printf("4\n");}
	else if (c[0]=='T'&&c[1]=='H') {printf("3\n");}
	else if (c[0]=='F') {printf("2\n");}
	else if (c[0]=='S'&&c[1]=='A') {printf("1\n");}
	else {printf("7\n");}
	return 0;
}

Measured memory_bytes: 256