akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,a;
    in>>n;
    set<int> st;
    fr(i,n){
        in>>a;
        st.insert(a);
    }
    puts(st.size()==n?"YES":"NO");
}

Measured memory_bytes: 9600
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  AB = sorted([tuple(map(int, input().strip().split())) for _ in range(n)], key=lambda x:x[1])
  time = 0
  for a, b in AB:
    time += a
    if time > b:
      print('No')
      return
  print('Yes')

if __name__=='__main__':
  main()



Measured memory_bytes: 33456
use proconio::input;

fn main() {
    input! {
        n: usize,
        aa: [usize; n],
    }

    if aa[0] != 0 {
        println!("-1");
        return;
    }
    for i in 1..n {
        if aa[i] > aa[i-1] + 1 {
            println!("-1");
            return;
        }
    }

    let mut ans = 0;
    for i in 1..n {
        if aa[i] == aa[i-1] + 1 {
            ans += 1;
        } else {
            ans += aa[i];
        }
    }

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


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

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		dels = []
		if a[i] < a[i+1]:
			last = a[i+1]
			continue

		j = a[i+1]
		for k in d.keys():
			if j < k:
				dels.append(k)

		while j > 0:
			if j in d and d[j] == x-1:
				del d[j]
				j -= 1
			else:
				break

		if j in d:
			d[j] += 1
		else:
			d[j] = 1

		for k in dels:
			del d[k]

		if 0 in d:
			valid = False
			break
		last = j

	if valid:
		ok = x
	else:
		ng = x
print(ok)

Measured memory_bytes: 91988
#include <iostream>
using namespace std;
int main(){
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  if (islower(s[b-1])){
    s[b-1]=toupper(s[b-1]);
    cout << s << endl;
  }
  else {
    s[b-1]=tolower(s[b-1]);
    cout << s << endl;
  }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s;
  cin >> s;
  int n=s.size();
  ll ans=0,a=n-1;
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      ans +=a-i;
      a--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	while(1)
	
	{
		int d;
		scanf("%d",&d); if(!d) return 0;
		int n,m,ret=0;
		scanf("%d %d",&n,&m);
		vector<int>vec;
		vec.pb(0); vec.pb(d);
		for(int i=2;i<=n;i++)
		{
			int g; scanf("%d",&g);
			vec.pb(g);
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<m;i++)
		{
			int g; scanf("%d",&g);
			int idx=upper_bound(vec.begin(),vec.end(),g)-vec.begin();
			ret+=min(vec[idx]-g,g-vec[idx-1]);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1708
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        boolean isGood = true;
        for (int i=1; i<=s.length(); i++) {
            if (i % 2 == 0) {
                if (!(s.charAt(i-1) == 'L' || s.charAt(i-1) == 'U' || s.charAt(i-1) == 'D')) {
                    isGood = false;
                    break;
                }
            } else {
                if (!(s.charAt(i-1) == 'R' || s.charAt(i-1) == 'U' || s.charAt(i-1) == 'D')) {
                    isGood = false;
                    break;
                }
            }
        }
        System.out.print(isGood ? "Yes" : "No");
    }
}

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

#define NONE -1

vector < vector <int> > C;
vector < vector <int> > T;
vector < vector <int> > E;

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n && m )
	{
		// ツ渉可甘コツ可サ
		C = vector < vector <int> > ( m, vector <int>(m,NONE) );
		T = vector < vector <int> > ( m, vector <int>(m,NONE) );
		E = vector < vector <int> > ( m );
		for ( int i = 0; i < n; i++ )
		{
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			a--;
			b--;
			C[a][b] = C[b][a] = cost;
			T[a][b] = T[b][a] = time;
			E[a].push_back(b);
			E[b].push_back(a);
		}

		// floyd for cost
		for ( int k = 0; k < m; k++ ) for ( int i = 0; i < m; i++ ) for ( int j = 0; j < m; j++ )
		{
			if ( C[i][k] != NONE && C[k][j] != NONE )
			{
				if ( C[i][j] == NONE || C[i][k] + C[k][j] < C[i][j] )
				{
					C[i][j] = C[i][k] + C[k][j];
				}
			}
		}

		// floyd for time
		for ( int k = 0; k < m; k++ ) for ( int i = 0; i < m; i++ ) for ( int j = 0; j < m; j++ )
		{
			if ( T[i][k] != NONE && T[k][j] != NONE )
			{
				if ( T[i][j] == NONE ||  T[i][k] + T[k][j] < T[i][j] )
				{
					T[i][j] = T[i][k] + T[k][j];
				}
			}
		}



		// ツ姪「ツつ「ツ債づュツつケ
		int k;
		cin >> k;
		for ( int i = 0; i < k; i++ )
		{
			int p, q, r;
			cin >> p >> q >> r;
			int s = p - 1;
			int g = q - 1;
			if ( r )
				cout << T[s][g] << endl;
			else
				cout << C[s][g] << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1108
#include <iostream>
#include <string>
#include <list>
using namespace std;         //  名前空間指定

int main()
{
  string s_in;
  string s_out;
  int index_out = 0;
  cin >> s_in;

  int s_size = s_in.size();
  for (int i=0; i<s_size; ++i){
    char c = s_in[i];
    if (c == '0'){
      s_out += '0';
    }
    else if (c == '1'){
      s_out += '1';
    }
    else if (c == 'B'){
      if (s_out != ""){
      	s_out.pop_back();
      }
    }
  }
  
  cout << s_out << endl;
}


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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  set<int> s;
  for (int i = 0; i < n; i++){
    int d;
    cin >> d;
    for (int j = 0; j < d; j++){
      int a;
      cin >> a;
      s.insert(a);
    }
  }
  cout << n - s.size() << endl;
  return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

r_list = []
total = 0

for i in range(1, N, 2):
    total += a_list[i]

r_list.append(sum(a_list) - total * 2)

for i in range(1, N):
    r = a_list[i - 1] * 2 - r_list[i - 1]
    r_list.append(r)

ans = " ".join([str(w) for w in r_list])
print(ans)


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    ll n; cin>>n;
    ll ans = 1e18;


    auto get = [](ll x) {
	ll res=0;
	while (x) {
	    res++;
	    x=x/10;
	}
	return res;
    };

    for (ll i=1; i*i<=n; i++) {
	if (n%i) continue;
	ans = min(ans,max(get(i),get(n/i)));
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e2+10;
const int M = 1e6+10;
/*=================================================================================*/
ll n, k;
struct node {
   ll mp[N][N];
   node() { ms(mp, 0);}
};


node matmul(node a, node b) {
   node ans;
   for1(i, n) for1(j, n) for1(k, n) {
      ans.mp[i][j] = (ans.mp[i][j] + (a.mp[i][k] * b.mp[k][j]) % mod) % mod;
   }
   return ans;
}

node matpow(node a, ll b) {
   node ans;
   for1(i, n) ans.mp[i][i] = 1;
   while(b) {
      if(b & 1) ans = matmul(ans, a);
      a = matmul(a, a);
      b >>= 1;
   }
   return ans;
}

int main() {
   node a;
   cin >> n >> k;
   for1(i, n) for1(j, n) {
      scanf("%lld", &a.mp[i][j]);
   }
   node res = matpow(a, k);
   ll ans = 0;
   for1(i, n) for1(j, n) {
      ans = (ans + res.mp[i][j]) % mod;
   }
   printf("%lld\n", ans);
   return 0;
}

Measured memory_bytes: 4536
s = input()
a = 0
z = 0
num = len(s)

for i in range(len(s)):
    if s[i] == "A":
        a = i
        break
for i in range(len(s)):
    if s[len(s)-i-1] == "Z":
        z = len(s)-i
        break
        
print(z-a)

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

int main() {
  int a,b,h,m;
  double th;
  double ans;

  cin >> a>>b>>h>>m;

  th=abs(h*30+m*0.5-m*6);
  if(th>180) th=360-th;

  ans=sqrt(a*a+b*b-2*a*b*cos(M_PI*th/180));

  cout <<fixed<<setprecision(15);
  cout <<ans<< endl;

  return 0;
}


Measured memory_bytes: 4156
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007

ll RepeatSquaring(ll n,ll p, ll mod){
    if(p==0) return 1;
    if(p%2==0){
        ll t=RepeatSquaring(n,p/2,mod);
        t%=mod;
        return t*t%mod;
    }
    return n*RepeatSquaring(n,p-1,mod);
}

int main(){
    ll m,n;cin>>m>>n;
    ll ans=RepeatSquaring(m,n,MOD);
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
const int maxn = 1e5 + 4;
const int inf = (int)1e9;

ll a[maxn], par[maxn];

int main() {
	ios::sync_with_stdio(false);
	ll ans = 0;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		par[i] = par[i - 1] + (a[i] > 0) * a[i];
	}
	
	ll sum = 0;
	for (int i = 1; i <= k; i++) {
		sum += a[i];
	}

	for (int i = k; i <= n; i++) {
		ans = max (ans, (sum > 0) * sum + par[n] - par[i] + par[i - k]);
		sum += a[i + 1] - a[i - k + 1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int a,b,n;

  scanf("%d%d",&a,&b);
  if(a<b){
    n=a;
    a=b;
    b=n;
  }

  n=a%b;
  while(n!=0){
    a=b;
    b=n;
    n=a%b;
  }

  printf("%d\n",b);

  return 0;
}



Measured memory_bytes: 2072
/*
*/

#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-11
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 337

using namespace std;

const int INF = 1e9;
const int N = 200031;

string st;
int dp[N];

bool match(int ps, string temp)
{
	if (ps + temp.size() > st.size())
		return false;
	for (int i = 0; i < temp.size(); i++)
	{
		if (temp[i] != st[ps + i])
			return false;
	}
	return true;
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//	freopen("F:/input.txt", "r", stdin);
	//	freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> st;
	dp[0] = 1;
	for (int i = 0; i < st.size(); i++)
	{
		if (dp[i] == 0)
			continue;
		if (match(i, "dream"))
			dp[i + 5] = 1;
		if (match(i, "dreamer"))
			dp[i + 7] = 1;
		if (match(i, "erase"))
			dp[i + 5] = 1;
		if (match(i, "eraser"))
			dp[i + 6] = 1;
	}

	if (dp[st.size()])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	cin.get(); cin.get();
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        printf("%d\n", a + b);
    }
    else
    {
        printf("%d\n", b - a);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    string s;
    cin >> s;
    ll n = s.size();

    vvl dp(n+1, vl(5));  // dp[i][j] : i文字目までで"ABC"のj文字目までに丸をつける方法の数
    dp[0][0] = 1;
    rep(i, n) {
        exrep(j, 0, 3) {
            if(s[i] == '?') {
                dp[i+1][j] += 3*dp[i][j];
                dp[i+1][j+1] += dp[i][j];
            }
            else {
                dp[i+1][j] += dp[i][j];
                if(j < 3 && s[i] == "ABC"[j]) {
                    dp[i+1][j+1] += dp[i][j];
                }
            }
            dp[i+1][j] %= mod;
            dp[i+1][j+1] %= mod;
        }
    }

    out(dp[n][3]);
    re0;
}

Measured memory_bytes: 10396
a,b,h,m=map(int,input().split())
# Pythonで三角関数は単位をradiansにしてから
from math import cos,radians
# 時針Aの角度は1時間で30°、分数を加味してh*30°+30°*m/60
# 分針Bの角度は1分で6°、m*6°
theta = abs(m*6 - (h*30 + m / 2))
# 余弦定理 c**2 = a**2 + b**2 - 2abcosθ
print((a**2 + b**2 - 2*a*b*cos(radians(theta)))**0.5)

Measured memory_bytes: 9496
//abc070_b Two Switches


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

int main()
{
int i;
char S[ 110 ];
char T[ 110 ];

	cin >> S;

	i = strlen( S );
	sprintf( T, "%c%d%c", S[ 0 ], i - 2, S[ i - 1 ] );
	cout << T << endl;

	return 0;
}






Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,x,ans;
    cin >> n >> x;
    ll a[n];
    ll s;
    cin >> s;
    a[0]=s-x;
    ans=a[0];
    for (ll i=1;i<n;i++){
        ll s;
        cin >> s;
        a[i]=s-x;
        ans=gcd(ans,a[i]);
    }
    cout << abs(ans) << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 120031;

int n,m,d;

double solve(int n,int d){
	if (d==0)
		return 1.0/n;
	double res=2*(n-d)*1.0*1.0/n/n;
//	cout<<res<<endl;
	return res;
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>m>>d;

	double res=solve(n,d)*(m-1);
	cout.precision(12);
	cout<<fixed<<res<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int k;
cin>>k;
long long int t1,t2,t3,t,c;
int i,j,n;
int a[10]={0};
if(k<10){cout<<k;return 0;}
vector<long long int>v[10],ans;
for(i=1;i<=9;i++){
    v[i].push_back(i);
    ans.push_back(i);
}
//vector<long long int>ans;
while(1){
    for(i=1;i<=9;i++){n=v[i].size();
       for(j=a[i];j<n;j++){
           t=v[i][j];
           t=t%10;
           t1=t-1;t2=t;t3=t+1;
           if(t1>-1){c=v[i][j]*10+t1;v[i].push_back(c);ans.push_back(c);}
           c=v[i][j]*10+t2;
           ans.push_back(c);
           v[i].push_back(c);
           if(t3<10){c=v[i][j]*10+t3;
               v[i].push_back(c);
               ans.push_back(c);
           }
       }
       a[i]=n;
       if(ans.size()>=k)break;
    }
    if(ans.size()>=k)break;
}sort(ans.begin(),ans.end());
cout<<ans[k-1];
    return 0;}

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

int main(){
    int s;
    int a,b;
    cin >> s;
    a=s/100;
    b=s%100;
    if(a>=1 and a<=12 and b>=1 and b<=12){
        cout << "AMBIGUOUS" << endl;
    }
    else if(a>=1 and a<=12){
        cout << "MMYY" << endl;
    }
    else if(b>=1 and b<=12){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int len, ans = 1;
int main() {
	scanf("%d%s", &len, &s);
	for (int i = 1; i < len; i++)
		if (s[i] != s[i - 1]) ans++;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i<N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());
  for (int i=0; i<N-1; i++) L.at(N-1) -= L.at(i);
  if (L.at(N-1)<0) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.awt.*;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        double coins[]=new double[n+1];
        for (int i=1;i<=n;i++)coins[i]=sc.nextDouble();
        double dp[][]=new double[n+1][n+1];
        dp[0][0]=1.0;
        for (int i=1;i<=n;i++){
            for (int j=0;j<=i;j++){
                if (j==0)dp[i][j]=dp[i-1][j]*(1.0-coins[i]);
                else {
                    dp[i][j]=dp[i-1][j]*(1.0-coins[i])+dp[i-1][j-1]*coins[i];
                }
            }
        }
        double ans=0.0;
        for (int i=(n+1)/2;i<=n;i++){
            ans+=dp[n][i];
        }
        System.out.println(ans);
    }
}

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

using namespace std;

int main()
{
    string a;
    cin>>a;
    int k=a.size();
    int ne=0;
    int nee=0;
    if(k==2 && a!="hi")
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(k%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }else
    {
        for(int i=0;i<(k-2);i=i+2)
        {
            if(a[i]!='h')
            {
               ne=1;
            }
        }
        for(int i=1;i<=(k-3);i=i+2)
        {
            if(a[i]!='i')
            {
                nee=1;
                //cout<<"tu"<<endl;
            }
        }
    }
    if(ne==0 && nee==0)
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
}


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

int main(){
  int N, M; cin >> N >> M;
  int WAnum = 0, ACnum = 0;
  int WA[105000]; bool AC[105000];
  for(int i = 1; i <= N; i++){
    WA[i] = 0;
    AC[i] = false;
  }
  for(int i = 1; i <= M; i++){
    string s; int p;
    cin >> p >> s;
    if(AC[p]) continue;
    if(!AC[p]){
      if(s == "AC"){
        AC[p] = true;
        ACnum++;
        WAnum += WA[p];
      }
      else if(s == "WA"){
        WA[p]++;
      }
    }
  }
  cout << ACnum << " "  << WAnum << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  cin >> n;
  if(n % 2)print(n*2);
  else print(n);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    
    map<ll, ll> mp;
    ll sum = 0;
    mp[0]++;
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include <cstdio>
#include <iostream>
#include <unordered_map>
using namespace std;

int N;
#define MAXN 200000
int A[MAXN+10];
unordered_map<int,long long int> h;
long long int S[MAXN+10];
long long int SUM;

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

void init(){
    SUM = 0;
    for( int i = 0; i < N; i++ ){
        h[A[i]]++;
    }
    for( auto iter = h.begin(); iter != h.end(); iter++ ){
        long long int t = iter->second;
        S[iter->first] = t * (t-1) / 2;
        SUM += S[iter->first];
    }
    //printf("sum = %lld\n", SUM);
}

void solve(){
    for( int i = 0; i < N; i++ ){
        int num = A[i];
        long long t = S[num];
        long long a;
        if( h[num] > 2 )
            a = (h[num]-2) * (h[num]-1) / 2;
        else
            a = 0;
        cout << SUM - t + a << endl;
    }
}

int main(void){
    read();
    init();
    solve();
    return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  
  int n = s.size();
  ll ans = 0;

  for(int i = 0; i < 1<<(n-1); i++){
    int st = 0;
    for(int j = 0; j < n-1; j++){
      if(i>>j & 1){
        ans += stol(s.substr(st, j-st+1));
        st = j+1;
      }
    }
    ans += stol(s.substr(st, n-st));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())

count=0
xlist=[x,-x,x,-x]
ylist=[y,y,-y,-y]
numlist=[0,1,1,2]
ans=10**9+7

for i in range(4):
    if xlist[i] <= ylist[i]:
        ans=min(ans,numlist[i]+ylist[i]-xlist[i])

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	public class QuestionA
	{
		public static void Main(string[] args)
		{
			// 整数の入力
			int n = int.Parse(Console.ReadLine());

			List<int> mochiList = new List<int>();
			for (int i = 0; i < n; ++i) {
				mochiList.Add(int.Parse(Console.ReadLine()));
			}

			var sort = mochiList.OrderByDescending(x => x).ToList();

			int now = 101;
			int count = 0;
			foreach(var mochi in sort) {
				if(now > mochi) {
					now = mochi;
					++count;
				}
			}

			Console.WriteLine(count);

		}
	}
}


Measured memory_bytes: 28372
// ref: https://drken1215.hatenablog.com/entry/2019/03/03/150200

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    uint N; cin >> N;
    vector<int> vH(N);
    for(uint i=0; i<N; ++i){ cin>>vH[i]; }
    
    int64 cnt=0ll;
    for(uint i=0;;){
        bool isUpdate=false;
        while( i<vH.size() && vH[i]==0 ){ ++i; } // skip empty
        while( i<vH.size() && vH[i]!=0 ){ --vH[i]; ++i; isUpdate=true; }
        if(isUpdate){ ++cnt; }
        
        if(i==vH.size()){
            if(!isUpdate && *max_element(vH.begin(), vH.end())==0){ break; }
            i=0;
        }
    }
    cout << cnt << endl;
    
    return 0;
}
/*
AC

int main(){
    uint N; cin >> N;
    vector<int> vH(N);
    for(uint i=0; i<N; ++i){ cin>>vH[i]; }
    
    int64 cnt=0ll;
    for(;;){
        if(*max_element(vH.begin(), vH.end())==0){ break; }
        
        for(uint i=0;;){
            bool isUpdate=false;
            while( i<vH.size() && vH[i]==0 ){ ++i; } // skip empty
            while( i<vH.size() && vH[i]!=0 ){ --vH[i]; ++i; isUpdate=true; }
            if(isUpdate){ ++cnt; }
            
            if(i==vH.size()){ break; }
        }
    }
    cout << cnt << endl;
    
    return 0;
}
//*/
/*
TLE

int main(){
    uint N; cin >> N;
    vector<int> vH(N);
    for(uint i=0; i<N; ++i){ cin>>vH[i]; }
    
    int64 cnt=0ll;
    for(uint i=0;;){
        while( i<vH.size() && vH[i]==0 ){ ++i; } // pass empty
        if(i==vH.size()){ i=0; continue; }
        
        while( i<vH.size() && vH[i]!=0 ){ --vH[i]; ++i; }
        ++cnt;
//        printn(vH);
        
        bool isAllZero=true;
        for(uint i2=0; i2<vH.size(); ++i2){ if(vH[i2]!=0){isAllZero=false;} }
        if(isAllZero){ break; }
    }
    cout << cnt << endl;
    
    return 0;
}
//*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k=1;
    cin >> n;
    long long sum = 0;
    while (k <= n) {
        if (k % 3 != 0 && k % 5 != 0) {
            sum += k;
        }
        k++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#define ll long long
using namespace std;
	int main(){
	int m,b;
	string str;
	cin >> str;
	while(str[0]!='-') {
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> b;
			str=str.substr(b, str.size()-b)+str.substr(0,b);
		}
		cout << str << endl;
		cin >> str;
	}
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{

    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    string ans;
    if (x - r >= 0 && y - r >= 0 && w >= x + r && h >= y + r)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define read(v, a, b) for(int i=(a); i<(b); i++) cin>>v[i]
#define printv(v, a, b) for(int i=(a); i < (b); i++) cout << v[i] << ' '
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<

const int maxn = 2e5 + 100;
int c[maxn], used[maxn], sz[maxn], n;
vi g[maxn];
ll ans[maxn];

void dfs(int v = 0, int p=-1){
	sz[v] = 1;
	for(auto u : g[v]){
		if(u == p) continue;
		dfs(u, v);
		sz[v] += sz[u];
	}
}

void solve(int v=0, int p=-1){
	
	int last = used[c[v]];
	
	ll sum = sz[v]-1; //sum of all subtrees (-1 to remove itself)
	
	ans[c[v]] += 1ll*(n - last - sz[v] + 1)*(sz[v]);
	
	for(auto u : g[v]){
        if(u == p) continue;
        sum -= sz[u];
        ans[c[v]] += sz[u] * sum;
    }
	
	for(auto u : g[v]){
		if(u == p) continue;
		used[c[v]] = n-sz[u];
		solve(u, v);
	}
	
	used[c[v]] = last + sz[v];
}

int main(){
	FAST;
	
	cin >> n;
	
	for(int i = 0, val; i < n; i++){
		cin >> val;
		c[i] = --val;
	}
	
	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
		
	dfs();
	solve();
	
	for(int i = 0; i < n; i++)
		cout << ans[i] << '\n';
}


Measured memory_bytes: 34016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int x,n;
int main(){
	x=read();n=read();
	FOR(i,1,n) x-=read();
	puts(x<=0?"Yes":"No");
}

Measured memory_bytes: 256
N,M= list(map(int,input().split()))
import sys
A=set()
B=set()
l=[i.rstrip().split() for i in sys.stdin.readlines()]
for i,j in l:
   if i == "1":
      A.add(j)
   if j == str(N):
      B.add(i)
if len(A&B) > 0:
   print("POSSIBLE")
else:
   print("IMPOSSIBLE")

Measured memory_bytes: 75564
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]+' ';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int a = s.length(),b = t.length();
    if (a > b) PRINT("GREATER");
    else if (a < b) PRINT("LESS");
    else if (s > t) PRINT("GREATER");
    else if (s < t) PRINT("LESS");
    else PRINT("EQUAL");
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int dp[64][4096];
int N,M,S;

int main(){
  while(scanf("%d%d%d",&N,&M,&S) && N||M||S){
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i=1;i<=M;i++){
      for(int j=N*N;j>=0;j--){
	for(int s=1;s<=S;s++){
	  if(s-i>=0) dp[j+1][s] = (dp[j+1][s]+dp[j][s-i])%100000;
	}
      }
    }
    printf("%d\n", dp[N*N][S]);
  }
  return 0;
}

Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n, m;
    cin >> n >> m;

    map<int, int> A;

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

        int k;
        cin >> k;
        
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            if (A.find(a) == A.end()) {
                A[a] = 1;
            } else {
                A[a] ++;
            }
        }
    }

    int cnt = 0;

    for (int i = 1; i <= m; i++) {
        if (A[i] == n) {
            cnt ++;
        }
    }

    cout << cnt << endl;

    return 0;    

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(b < a) System.out.println(a-1);
        else System.out.println(a);
    }    
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//最大公約数 複数個
int gcd(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = gcd(ret, v[i]);
	return ret;
}
//最小公倍数 複数個
int lcm(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = lcm(ret, v[i]);
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> T(N); rep(i, 0, N) {
		cin >> T[i];
	}
	cout << lcm(T) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int i, n;
    short a[101];
 
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    if (n >= 1) printf("%d", a[n - 1]);
    for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,K;cin>>N>>K;
    ll info[N];
    rep(i,N)cin>>info[i];
    sort(info,info+N);
    ll ans=0;
    rep(i,N-K)ans+=info[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
s = [input() for _ in range(n)]

apl = list("abcdefghijklmnopqrstuvwxyz")
dic = [[0 for _ in range(26)] for _ in range(n)]

for i in range(n):
    for j in range(len(s[i])):
        dic[i][apl.index(s[i][j])] += 1
result = [min([dic[i][j] for i in range(n)]) for j in range(26)]
r = ""
for i in range(26):
    r = r+apl[i]*result[i]
print(r)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int mood(int a, int b){
    if (a % b == 0) return b;
    else return a % b;
}

int main() {
    int x; cin >> x;
    reppl(i,min(x+1,10000),max(-x,-10000)){
        ll k = i*i*i*i*i - x;
        double b;
        ll c;
        ll ans ;
        if (k < 0) {
            b = pow(-k,0.2);
            c = b;
            ans = -c;
        }
        else {
            b = pow(k,0.2);
            c = b;
            ans = c;
        }
        if (b - c < 0.0000000001){
            cout << i << " " << ans << endl;
            break;
        }
    }
}

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define fori(i,a,b) for(int i=a,b_=b;i<=b_;++i)
#define ford(i,a,b) for(int i=a,b_=b;i>=b_;--i)
#define forv(i,a) for(auto &i:a)
#define ll long long
#define pb push_back
#define pp pop_back()
#define pii pair<ll,ll>
#define fi first
#define se second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ___ << "\n"
#define __ << " " <<
#define _ << " "
using namespace std;

ll ScanInt()
{
    //ll w; cin >> w; return w;
  ll x=0; char ch=getchar(); bool nega=0;
  while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if(ch=='-') nega=1; else x=x*10+ch-'0'; ch=getchar();
  while('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
  if(nega) return -x; return x;
}

const int N=200005;
int n;
ll h[N],C,f[N];
pii cht[N];
int top;
double b[N];

double CutP(pii x, pii y){ return 1.0*(y.se-x.se)/(x.fi-y.fi); }
int Find(int x)
{
    int l=1, r=top, mid, pos;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(b[mid]<=x) pos=mid, l=mid+1;
        else r=mid-1;
    }
    return pos;
}
int main()
{
    //freopen("frog3.inp","r",stdin); /// nho sua scanint
    n=ScanInt(); C=ScanInt();
    fori(i,1,n) h[i]=ScanInt();

    top=0; f[1]=0; cht[++top]={-2*h[1], h[1]*h[1]+f[1]}; b[1]=0;
    pii li; int j;
    fori(i,2,n)
    {
        j=Find(h[i]);
        f[i]=cht[j].fi*h[i] + cht[j].se + h[i]*h[i] + C;
        li={-h[i]*2, h[i]*h[i] + f[i]};
        while(top>=2 && CutP(cht[top-1], cht[top]) >= CutP(cht[top], li)) top--;
        cht[++top]=li;
        b[top]=CutP(cht[top-1], cht[top]);
    }
    //fori(i,1,n) cout << f[i] _; cout ___;
    cout << f[n];
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{

    int a[100],n=5;
    int temp =0;

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



    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {

              swap(a[i],a[j]);

            }
        }
    }

    for(int i=0;i<n;i++)
    {
        printf("%d",a[i]);
        if(i<4)
        printf(" ");
        else printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define ll unsigned long long int
#define pb push_back
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x,a,b,c;
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	ll a[4][4];
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3 ; j++){
			cin>>a[i][j];
		}
	}
	ll b[10];
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>b[i];
	}
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			for(int r=1; r<=n; r++){
				if(a[i][j]==b[r]){
					a[i][j]=0;
				}
			}
		}
	}
	if(a[1][1]==0 && a[1][2]==0 && a[1][3]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[2][1]==0 && a[2][2]==0 && a[2][3]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[3][1]==0 && a[3][2]==0 && a[3][3]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[1][1]==0 && a[2][1]==0 && a[3][1]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[3][2]==0 && a[2][2]==0 && a[1][2]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[1][3]==0 && a[2][3]==0 && a[3][3]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[1][3]==0 && a[2][2]==0 && a[3][1]==0){
		cout<<"Yes";
	return 0;
	}
	if(a[1][1]==0 && a[2][2]==0 && a[3][3]==0){
		cout<<"Yes";
	return 0;
	}
	cout<<"No";
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****
 
//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

def solve():
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    
    if N == 1 and M == 0:
        return 1
    elif N == 1 and M == 1 and A[0] == 0:
        return 0

    l = [1 for _ in range(N+1)]
    for a in A:
        l[a] = 0
        
    dp = [0 for i in range(N+1)]
    dp[1] = 0 if 1 in A else 1
    dp[2] = 0 if 2 in A else dp[1] + 1

    for i in range(3, N+1):
        if l[i] == 0:
            dp[i] = 0
        else:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= MOD

    return dp[N] % MOD

print(solve())

Measured memory_bytes: 57048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){

    int n;
    cin >> n;
    if(n == -1) break;

    int ans = 1150;
    //if(n <= 10) cout << 4280 - 1150 << endl;
    if(n > 10) ans += min(10, n - 10) * 125; 
    if(n > 20) ans += min(10, n - 20) * 140;
    if(n > 30) ans += (n - 30) * 160;
    cout << 4280 - ans << endl;
  }
  return 0;
}




Measured memory_bytes: 3000