akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

vector<int> sieve(int n){
  vector<int> ret;
  vector<bool> is_prime(n + 1, true);

  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i < n + 1; i++){
    if(is_prime[i]){
      ret.push_back(i);
      for(int j = i; j < n + 1; j += i){
	is_prime[j] = false;
      }
    }
  }
  
  return ret;
}

int main(){
  int n;
  vector<int> prime = sieve(1299710);

  while(cin >> n, n){
    int idx = lower_bound(all(prime), n) - prime.begin();
    if(prime[idx] == n) cout << 0 << endl;
    else cout << prime[idx] - prime[idx - 1] << endl;
  }

  return 0;
}



Measured memory_bytes: 3460
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,x;
    cin >> a >> b >> x;
    if(a == 0) cout << b / x + 1 << '\n';
    else{
        --a;
        cout << (b / x + 1) - (a / x + 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;

int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;

}













	


	 



































    





Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#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;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n,m,x;
    cin>>n>>m>>x;
    int a[n][m],d[n];
    f(i,0,n-1)
    {
        cin>>d[i];
        f(j,0,m-1)
            cin>>a[i][j];
    }
    int ans=1e18;
    int e=pow(2,n);
    f(i,0,e-1)
    {
        int b[m+1],c=1,s=0;
        f(j,0,m)
            b[j]=0;
        f(j,0,n-1)
        {
            if( (i)&(1<<j))
            {
                s+=d[j];
                f(k,0,m-1)
                    b[k]+=a[j][k];
            }
        }
        
        f(j,0,m-1)
            if(b[j]<x)
                c=0;
        if(c)
            ans=min(ans,s);
    }
    if(ans==1e18)
        cout<<"-1";
    else
        cout<<ans;
}


Measured memory_bytes: 4124
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,k;
string s;
vector<int> nule;
vector<int> jedinice;

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

    cin>>n>>k;
    cin>>s;

    int flag=(s[0]-'0');
    int cnt=1;
    if(flag==0) jedinice.push_back(0);
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
        {
            if(flag==0) nule.push_back(cnt);
            else jedinice.push_back(cnt);
            cnt=1;
            flag=(s[i]-'0');
        }
        else
            cnt++;
    }

    if(flag==0) nule.push_back(cnt), jedinice.push_back(0);
    else jedinice.push_back(cnt);


    int index0=0;
    int index1=0;
    int suma=0;
    int maxi=0;
    while(index0<k && index0<nule.size())
        suma+=nule[index0++];
    while(index1<k+1 && index1<jedinice.size())
        suma+=jedinice[index1++];

    maxi=suma;
    while(index1<jedinice.size())
    {
        suma-=jedinice[index1-k-1];
        suma+=jedinice[index1++];
        suma-=nule[index0-k];
        suma+=nule[index0++];
        maxi=max(maxi,suma);
    }

    cout<<maxi;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
using namespace std;

string reverse(string str)
{
	string rev = string((str).rbegin(), (str).rend());
	return rev;
}
	
	
int main()
{
	int m;
	
	cin >> m;
	
	for(int i = 0; i < m ; i++)
	{
		string str;
		set<string> s;
		
		cin >> str;
		
		int len = str.size();
		for( int i = 1; i < len; i++)
		{
			string left = str.substr( 0, i);
			string right = str.substr(i);
			string leftr = reverse(left);
			string rightr = reverse(right);
			
			s.insert(left + right);
			s.insert(leftr + right);
			s.insert(leftr + rightr);
			s.insert(left + rightr);
			s.insert(right + left);
			s.insert(rightr + left);
			s.insert(rightr + leftr);
			s.insert(right + leftr);
		}
		
		cout << s.size() <<endl;
		s.clear();
	}
	
	return 0;
}

Measured memory_bytes: 1000
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<int>> grid(h, vector<int>(w, 0));
    rep(i, h) rep(j, w)
    {
        int a;
        cin >> a;
        grid[i][j] += a;
    }

    rep(i, h) rep(j, w)
    {
        int b;
        cin >> b;
        grid[i][j] -= b;
        grid[i][j] = abs(grid[i][j]);
    }

    int DMAX = 80 * (h + w - 1);
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(DMAX + 1, false)));

    rep(i, h) rep(j, w) irep(k, DMAX)
    {
        if (i == 0 && j == 0)
        {
            dp[i][j][k] = (grid[i][j] == k);
        }
        else
        {
            if (i - 1 >= 0)
            {
                dp[i][j][k] = dp[i][j][k] || dp[i - 1][j][abs(k - grid[i][j])] || (k + grid[i][j] <= DMAX && dp[i - 1][j][k + grid[i][j]]);
            }
            if (j - 1 >= 0)
            {
                dp[i][j][k] = dp[i][j][k] || dp[i][j - 1][abs(k - grid[i][j])] || (k + grid[i][j] <= DMAX && dp[i][j - 1][k + grid[i][j]]);
            }
        }
    }
    int result = DMAX;
    rirep(i, DMAX)
    {
        if (dp[h - 1][w - 1][i])
        {
            result = i;
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>

int main(void)
{
	int a[3][3];
	int b, n;
	int i, j, k;

	/* ビンゴカードに数字を書く */
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 3; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	/* n個の数を選ぶ */
	scanf("%d", &n);

	for (k = 0; k < n; k++)
	{
		scanf("%d", &b);
		/* 選ばれた数に印を付ける */
		for (i = 0; i < 3; i++)
		{
			for (j = 0; j < 3; j++)
			{
				if (b == a[i][j]) {
					a[i][j] = -1;
				}
			}
		}
	}

	/* 横列のビンゴを確認する */
	for (i = 0; i < 3; i++)
	{
		if (a[i][0] == a[i][1] && a[i][1] == a[i][2])
		{
			printf("Yes\n");
			return 0;
		}
	}

	/* 縦列のビンゴを確認する */
	for (i = 0; i < 3; i++)
	{
		if (a[0][i] == a[1][i] && a[1][i] == a[2][i])
		{
			printf("Yes\n");
			return 0;
		}
	}

	/* 斜めのビンゴを2通り確認する */
	if (a[0][0] == a[1][1] && a[1][1] == a[2][2])
	{
		printf("Yes\n");
		return 0;
	}

	if (a[0][2] == a[1][1] && a[1][1] == a[2][0])
	{
		printf("Yes\n");
		return 0;
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
//#include<bits/stdc++.h>
//using namespace std;
//#define mem(a) memset(a,0,sizeof(a))
//#define dbg(x) cout<<#x<<" = "<<x<<endl
//#define ll long long
//int d[100010]={0};
//map<int,vector<int> >a;
//int n,m;
////int dbg=0;
////void dbve(vector<int>tt)
////{
////	for(vector<int>::iterator it=tt.begin();it!=tt.end();it++)
////	{
////		printf("%d ",*it);
////	}
////	cout<<endl;
////}
//void mins(int i)
//{
//	//printf("now dbg mins %d:*********\n",i);//****************
//	//if(a.find(i)==a.end())printf("不存在\n");//--------------
//	vector<int>temp=a[i];
//	vector<int>::iterator it;
//	//printf("Then a[%d]:   ",i);dbve(a[i]);//******************
//	for(it=temp.begin();it!=temp.end();it++)
//	{
//		//dbg((*it));//****************
//		int t,num;
//		num=*it,t=d[i]+1;
//		if(d[num]==0||d[num]>t)
//		{
//			if(num!=1)
//			{
//				d[num]=t;
//				//printf("t=%d,num=%d,d[%d]=%d\n",t,num,num,d[num]);//*********************
//				//printf("由%d到%d,fresh\n",i,num);//***********************
//				mins(num);
//			}
//			
//		}
//		
//	}
//}
//int main()
//{
//	int i;
//	scanf("%d%d",&n,&m);
//	if(n>m+1){cout<<"No"<<endl;return 0;}
//	for(i=0;i<m;i++)
//	{
//		int b,c;
//		scanf("%d%d",&b,&c);
//		a[b].push_back(c);
//		a[c].push_back(b);
//	}
//	
//	//for(i=1;i<=n;i++)printf("dbg vector[%d]:   ",i),dbve(a[i]);//*************
//	mins(1);
//	for(i=2;i<=n;i++)
//	{
//		if(!d[i]){cout<<"No"<<endl;return 0;}
//	}
//	printf("Yes\n");
//	for(i=2;i<=n;i++)
//		printf("%d\n",d[i]);
//	//for(i=1;i<=n;i++)printf("dbg vector[%d]:   ",i),dbve(a[i]);//
//	//printf("a[5]:   ");dbve(a[5]);//*******************
//	return 0;
//}

#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
int nage[200010]={0};
vector<int> h[200010];
int main()
{
	queue<int>q;
	int n,m;
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		h[x].push_back(y);
		h[y].push_back(x);
		
	}
	q.push(1);
	while(q.size())
	{
		int t=q.front();
		q.pop();
		vector<int>::iterator it=h[t].begin();
		for(;it!=h[t].end();it++)
		{
			if(!nage[*it])
			{
				nage[*it]=t;
				q.push(*it);
			}
		}
	}
	for(int i=2;i<=n;i++)
		if(!nage[i])
		{
			printf("No");
			return 0;
		}
	printf("Yes\n");
	for(int i=2;i<=n;i++)printf("%d\n",nage[i]);
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n;
	cin>>n;
	int flag = 0;

	for(int i=1;i<10;i++){
		if(n%i==0){
			if(n/i<10)
				flag++;
		}
	}

	if(flag)
		cout<<"Yes";
	else
		cout<<"No";


	return 0;
}





Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<vector<ll>> F(N, vector<ll>(10));
    rep(i, N) rep(j, 10) cin >> F[i][j];

    vector<vector<ll>> P(N, vector<ll>(11));
    rep(i, N) rep(j, 11) cin >> P[i][j];

    ll ans = -INF;
    ll days = 10;
    for (ll bit = 0; bit < (1 << days); bit++) {
        if (bit == 0) continue;
        ll sum = 0;

        for (ll k = 0; k < N; k++) {
            // cout << "k: " << k << endl;
            ll cnt = 0;
            for (ll i = 0; i < days; i++) {
                if ((bit & (1 << i))) {
                    if (F[k][i] == 1) {
                        cnt++;
                    }
                }
            }
            // cout << cnt << endl;
            sum += P[k][cnt];
        }

        chmax(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int n, k, w[105];
ll vr[105], dp[100005];
const ll inf = 1e15;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1 ; i <= n ; ++i){
	cin >> w[i] >> vr[i];
}
for(int i = 1 ; i <= k ; ++i){
	dp[i] = -inf;
}
for(int i = 1 ; i <= n ; ++i){
	for(int j = k ; j >= w[i] ; --j){
		dp[j] = max(dp[j], dp[j - w[i]] + vr[i]);
	}
}
cout << *max_element(dp, dp + k + 1) << endl;

return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    VI v(3);
    for(i=0;i<3;i++) cin>>v[i];
    ll ans = INF;
    for(i=0;i<70;i++){
        ll cnt = 0;
        VI w = v;
        for(j=0;j<3;j++){
            while(w[j] < i) {
                cnt ++ ;
                w[j] += 2;
            }
            while(w[j] > i) {
                cnt ++ ;
                w[j] -= 1;
            }
        }
        chmin(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

from decimal import *


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    A, B = [Decimal(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([A, B]))

    B = B * 100

    logger.debug('{}'.format([A, B]))

    c = int(A * B)

    if len(str(c)) <= 2:
        print(0)
    else:
        print(str(c)[:-2])


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """198 1.10"""
        output = """217"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 0.01"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000000000000000 9.99"""
        output = """9990000000000000"""
        self.assertIO(input, output)


Measured memory_bytes: 16820
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut t: [i64; 5],
    }

    t.sort_by_key(|&v| (v + 9) / 10 * 10 - v);

    let mut ans = 0;

    for i in 0..5 {
        if i != 4 {
            ans += (t[i] + 9) / 10 * 10;
        } else {
            ans += t[i];
        }
    }

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


Measured memory_bytes: 4352
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  let N = input[0];
  let Y = input[1];

  const h = 1e4;
  const m = 5e3;
  const l = 1e3;

  let rx = -1;
  let ry = -1;
  let rz = -1;
  for(let x=0; x<=N; ++x){
    for(let y=0; y<=N-x; ++y){
      let lz = (N-x-y)*l;
      let total = h*x + m*y + lz;
      if(total === Y) {
        rx = x;
        ry = y;
        rz = N-x-y;
      }
    }
  }


  console.log(rx,ry,rz);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

class Soroban_col
{
  public:
    Soroban_col();
    ~Soroban_col();

  public:
    void Show(int i);
    void Set(int n);

  private:
    char* m_soroban_col;
};

Soroban_col::Soroban_col()
{
  m_soroban_col = new char[8];
}

Soroban_col::~Soroban_col()
{
  delete[] m_soroban_col;
}

void Soroban_col::Show(int i)
{
  cout << m_soroban_col[i];
}

void Soroban_col::Set(int n)
{
  if (n < 5)
  {
    m_soroban_col[0] = '*';
    m_soroban_col[1] = ' ';
  }
  else
  {
    m_soroban_col[0] = ' ';
    m_soroban_col[1] = '*';
  }

  m_soroban_col[2] = '=';

  for (int i = 3; i < 3 + n % 5; ++i)
  {
    m_soroban_col[i] = '*';
  }
  m_soroban_col[3+n%5] = ' ';
  for (int i = 4 + n % 5; i < 8; ++i)
  {
    m_soroban_col[i] = '*';
  }
}

class Soroban
{
  public:
    Soroban(int n);
    ~Soroban();

  public:
    void Show();

  private:
    Soroban_col* m_soroban;
};

Soroban::Soroban(int n)
{
  m_soroban = new Soroban_col[5];
  for (int i = 5; i > 0; --i)
  {
    int buf = (n % (int)pow(10, i) ) / (int)pow(10, i-1);
    m_soroban[5-i].Set(buf);
  }
}

Soroban::~Soroban()
{
  delete[] m_soroban;
}

void Soroban::Show()
{
  for (int i = 0; i < 8; ++i)
  {
    for (int j = 0; j < 5; ++j)
    {
      m_soroban[j].Show(i);
    }
    cout << endl;
  }
}

int main(void)
{
  int n;
  cin >> n;
  while (true)
  {
    Soroban soroban(n);
    soroban.Show();
    cin >> n;
    if (cin.eof()) break;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

priority_queue<int> pq;
void solve(){  
	int n,m;
	cin>>n>>m;
	if(m>=3000000){
		cout<<0<<endl;
		return;
	}
	rep(i,0,n){
		int x;
		cin>>x;
		pq.push(x);
	}
	long long cost = 0;
	while(m--){
		int k=pq.top();
		k/=2;
		pq.pop();
		pq.push(k);
	}
	while(!pq.empty()){
		cost+=pq.top();
		pq.pop();
	}
	cout<<cost<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 892
from itertools import permutations, combinations,combinations_with_replacement,product
import sys
input = sys.stdin.readline

n = int(input())
p = list(map(int, input().replace("\n","").split()))
q = list(map(int, input().replace("\n","").split()))

dic = list(permutations(p))
dic.sort()

tp = tuple(p)
tq = tuple(q)

print(abs(dic.index(tp)-dic.index(tq)))

Measured memory_bytes: 44912
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
#define scout cout << fixed << setprecision(20)
ll INF = 9e17;
ll mod = 1e9 + 7;

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

Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

S=one_str()

half = len(S)//2

count=0
for h,t in zip(S[:half], S[half:][::-1]):
    if h!=t:
        count+=1
print(count)

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

using namespace std;

int main() {
    int X, Y, A, B, C, a;

    scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);

    vector<pair<int, char>> as;
    for (int i = 0; i < A; i++) {
        scanf("%d", &a);
        as.push_back({a, 'A'});
    }
    for (int i = 0; i < B; i++) {
        scanf("%d", &a);
        as.push_back({a, 'B'});
    }
    for (int i = 0; i < C; i++) {
        scanf("%d", &a);
        as.push_back({a, 'C'});
    }
    sort(as.rbegin(), as.rend());

    long long ans = 0;
    int ea = 0, eb = 0, ec = 0;
    for (auto p: as) {
        int d = p.first, a = p.second;
        if (a == 'A' && ea == X) continue;
        if (a == 'B' && eb == Y) continue;
        ans += d;
        if (a == 'A') ea++;
        else if (a == 'B') eb++;
        else ec++;
        if (ea + eb + ec == X + Y)
            break;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//約数のリストを返す

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

    ll res = INF;

    for(int i = 1; i <= sqrt(N); ++i)
    {
      if(N % i != 0)continue;

      res = min(res, i + N / i - 2);
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,k;
char c[N];
int main(){
	ios::sync_with_stdio(false);
	cin >> k;
	if(k%2==0 || k%5==0){
		return cout << "-1\n",0;
	}
	int cur=7%k;
	int ans=1;
	while(cur!=0){
		cur=cur*10+7;
		cur%=k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi numbers(4);
    FOR(i,n){
        string s; cin >> s;
        if(s == "AC") numbers[0]++;
        else if(s == "WA") numbers[1]++;
        else if(s == "TLE") numbers[2]++;
        else if(s == "RE") numbers[3]++;
    }
    cout << "AC x " << numbers[0] << "\n";
    cout << "WA x " << numbers[1] << "\n";
    cout << "TLE x " << numbers[2] << "\n";
    cout << "RE x " << numbers[3] << "\n";
    return 0;
}


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

int main(){
  int a,s,d,f,g;
  cin>>a>>s>>d>>f>>g;

  if(a<40) a=40;
  if(s<40) s=40;
  if(d<40) d=40;
  if(f<40) f=40;
  if(g<40) g=40;

  cout << (a+s+d+f+g)/5 << endl;

  
    
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

LL extgcd(LL a, LL b, LL &x, LL &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    LL g = extgcd(b, a % b, x, y);
    LL nextx = y, nexty = x-(a/b)*y;
    x = nextx; y = nexty;
    return g;
}

LL fact[200010];
LL invfact[200010];
const LL mod = 1e9 + 7;

LL nCr(int n, int r){
    LL ret = fact[n];
    (ret *= invfact[n-r]) %= mod;
    (ret *= invfact[r]) %= mod;
    return ret;
}

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    fact[0] = 1;
    for(LL i=1; i<=200000; i++){
        fact[i] = (fact[i-1] * i) % mod;
    }
    for(LL i=0; i<=200000; i++){
        LL x, y;
        LL g = extgcd(fact[i], mod, x, y);
        while(x < 0) x += mod;
        x %= mod;
        invfact[i] = x;
    }

    LL ans = 0;
    for(int i=B; i<W; i++){
        LL tmp = nCr((H-A-1)+i, H-A-1);
        (tmp *= nCr((A-1)+(W-i-1), A-1)) %= mod;
        (ans += tmp) %= mod;
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();

  vint ss(n+1), ts(m+1);
  rep(i, n) ss[i+1] = (ss[i] + 1 + (s[i] == 'B')) % 3;
  rep(i, m) ts[i+1] = (ts[i] + 1 + (t[i] == 'B')) % 3;

  int q;
  cin >> q;
  rep(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((ss[b]+3-ss[a-1])%3 == (ts[d]+3-ts[c-1])%3 ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 2512
# pragma GCC optimize("Ofast")
# pragma GCC target("avx,avx2,fma")
# pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
 
int n;
 
ll a[20][20],dp[1<<16+5],s[1<<16+5];
 
vector <int> g[1<<16+5];
 
int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            for(int t=0;t<j;t++){
                if((i&(1<<j)) && (i&(1<<t))){
                    s[i]+=a[j+1][t+1];
                }
            }
        }
    }
    for(int i=1;i<(1<<n);i++){
        for(int j=1;j<=i;j++){
            if((i&j)==j) dp[i]=max(dp[i],dp[i-j]+s[j]);
        }
    }
    cout << dp[(1<<n)-1];
}

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

int main(){
  int N,ans;
  int64_t num=1;
  int64_t K,T;
  cin >> N >> K;
  int A[N+1],B[N+1];
  for(int i=1; i<N+1; i++) cin >> A[i];
  for(int i=1; i<N+1; i++) B[i] = 0;
  int i=1;
  while(B[A[i]]==0 && num < K) {
    B[A[i]] = num;
    num++;
    i = A[i];
  }
  if(num==K){
    ans = A[i];
  } else {
    num = num - B[A[i]];
    T = (K-B[A[i]]+1)%num;
    while(T>0) {
      i = A[i];
      T--;
    }
    ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
pair< ll,pair<ll,ll> >edge[100010];
ll parent[10010];
ll root(ll x)
{
    if(parent[x]==x)
    {
        return x;
    }
    else
    {
        parent[x]=root(parent[x]);
        return parent[x];
    }
}
void un(ll a,ll b)
{
    a=root(a);
    b=root(b);
    parent[a]=parent[b];
}
ll kruskal(pair<ll,pair<ll,ll>>p[] , ll m )
{
    ll i,j,a,b,cost=0,c;
    for(i=0;i<m;i++)
    {
       a= p[i].second.first;
       b= p[i].second.second;
       c= p[i].first;
       if(root(a)!=root(b))
       {
           un(a,b);
           cost+=c;
       }
    }
    return cost;
}
void init()
{
    for(ll i=0;i<=10000;i++)
    {
        parent[i]=i;
    }
}
int main()
{
    ll n,m,i,j,a,b,c,ans=0; init();
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>b>>c;
        edge[i]=make_pair(c,make_pair(a,b));
        edge[i]=make_pair(c,make_pair(b,a));
    }
    sort(edge,edge+m);
    ans=kruskal(edge,m);
    cout<<ans<<endl;
}



Measured memory_bytes: 5556
import sys
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
if N == 1 and T[0] != A[0]:
    print(0)
    sys.exit()
INF = 10**13
minH = [1]*N
maxH = [INF]*N
pre_ti = 0
MOD = 10**9 + 7
for i, ti in enumerate(T):
    if ti > pre_ti:
        minH[i] = ti
        maxH[i] = ti
    else:
        maxH[i] = min(ti, maxH[i])
    pre_ti = ti
pre_ai = 0
for i, ai in enumerate(A[::-1], 1):
    if ai > pre_ai:
        minH[-i] = ai
        maxH[-i] = ai
    else:
        maxH[-i] = min(ai, maxH[-i])
    pre_ai = ai

ans = 1
for lh, uh in zip(minH, maxH):
    if lh > uh:
        ans = 0
        break
    ans = (ans * (uh-lh+1)) % MOD
print(ans)

Measured memory_bytes: 98120
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,x,sum=0;
  ll a[LIMIT2]={0};
  string s;
  ll dp[LIMIT1]={0},dp2[LIMIT1]={0};
  
  cin >> n >> x >> m;
  a[0] = x;
  rep(i,m) dp[i]=-1;
  dp[x] = 0;
  
  ll tmp = x;
  sum = x;
  dp2[0] = x;
  bool looped = false;
  for(i=1;i<n;i++){
    tmp = modpow(a[i-1],2,m);
    sum += tmp;
    a[i] = tmp;
    dp2[i] = sum;
    if(looped) continue;
    if(dp[tmp] != -1){//m回以内に必ずある
      k = i-dp[tmp];//循環発見
      //cout << i << " " << k << endl;
      tmp = (n-1-i)/k;//ループが何回あるか
      sum += tmp * (sum-dp2[i-k]);//循環部分の合計
      n -= tmp*k;
      looped = true;
    }else{
      dp[tmp] = i;
    }
  }
  result = sum;
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 10640
s = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
for i in range(len(s)):
    if i%2 == 0:
        if s[i] not in odd:
            print('No')
            exit()
    else:
        if s[i] not in even:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
  int a,b;
  cin >> a >> b;
  cout << max(0, a-2*b) << endl;
}

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


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

#define M 1100000
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + key % (M - 1);}

int find(char str[]){
  long long trip; 
  int i = 0;
  long long sum = getKey(str);

  while(1){
    trip = (h1(sum)+ i * h2(sum)) % M;
    if(strcmp(H[trip], str) == 0) return 1;
    if(H[trip][0] == '\0') return 0;
    i++;
  }
  return 0;
}

void insert(char str[]){
  int  i = 0;
  long long ago;
  long long sum = getKey(str);

  while(1){
    ago = (h1(sum)+ i * h2(sum)) % M;
    if(H[ago][0] == '\0' || strcmp(H[ago],str) == 0){
      strcpy(H[ago], str);
      break;
    }
    i++;
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 15644
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int n = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      n++;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let l: Vec<i64> = (0..n).map(|_| read()).collect();
    let max: i64 = *l.iter().max().unwrap();
    let sum: i64 = l.iter().sum::<i64>() - max;
    println!("{}", if sum > max {"Yes"} else {"No"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> vv, a(n);
  rep(i, n) cin >> a.at(i);

  vector<ll> v(100000, 0);
  rep(i, n) ++v.at(a.at(i) - 1);
  v.erase(remove(all(v), 0), v.end());
  v.erase(remove(all(v), 1), v.end());
  ll sousa = 0;
  ll isExist2 = false;
  for (const auto &i : v) {
    sousa += (i - 1) / 2;
    if (i % 2 == 0) {
      if (not isExist2) ++sousa;
      isExist2 = not isExist2;
    }
  }
  cout << (n - sousa * 2) << endl;

  return 0;
}

Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
n=s.size
ans=""

n.times do|i|
  ans+=s[i] if (i+1).odd?
end
puts ans

Measured memory_bytes: 71940
n,k = map(int,input().split())
r,s,p = map(int,input().split())
lst1 = list(input())

lstk = [0]*n
ans = 0
def f(index):
    if lstk[index%k] == lst1[index]:
        lstk[index%k] = "free"
        return False
    else:
        lstk[index%k] = lst1[index]
        return True

"""
def score(index):
    global lst1
    global ans
    if lst1(index) == "r":
        ans += p
    elif lst1(index) == "s":
        ans += r
    else:
        ans += s
"""
for i in range(n):
    if i < k:
        lstk[i] = lst1[i]
        if lst1[i] == "r":
            ans += p
        elif lst1[i] == "s":
            ans += r
        else:
            ans += s
    else:
        if f(i): #True=okとする
            if lst1[i] == "r":
                ans += p
            elif lst1[i] == "s":
                ans += r
            else:
                ans += s

print(ans)

Measured memory_bytes: 52976
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s,t;
    cin >> s >> t;
    std::vector<char> s1;
    std::vector<char> t1;
    rp(i,s.length()) s1.pb(s[i]);
    rp(i,t.length()) t1.pb(t[i]);
    sort(all(s1));
    sort(all(t1));
    string ss ="";
    string tt ="";
    for (auto it = s1.begin(); it != s1.end(); it++) {
      ss += string(1,*it);
    }
    for (auto it = t1.crbegin(); it != t1.crend(); it++) {
      tt += string(1,*it);
    }
    // cout << ss << " ss"<<endl;
    // cout << tt << " tt"<<endl;

    if(ss < tt) cout << "Yes"<<endl;
    else cout << "No" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
n, a, b = map(int, input().split())
xs = list(map(int, input().split()))
dx = [0] * (n-1)
for i in range(n-1):
    dx[i] = xs[i+1] - xs[i]

res = 0
for i in range(n-1):
    if dx[i] * a < b:
        res += dx[i] * a
    else:
        res += b

#print(xs)
#print(dx)
print(res)

Measured memory_bytes: 14224
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  int n;
  int max=0;
  int min=1000;
  cin >> n;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    if(tmp > max)
      max = tmp;
    if(tmp < min)
      min = tmp;
  }

  cout << max - min << endl;


  return 0;
}

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

int main(){
  int Np1,N0,Nn1,K;
  cin >> Np1 >> N0 >> Nn1 >> K;

  int ans= (K <= Np1    ) ? K
          :(K <= Np1+ N0) ? Np1
                          : Np1- (K- Np1- N0);

  cout << ans << endl;
}

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

int32_t main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  bool dp[k+1]={false};
  for(int i=0;i<k;i++){
    if(dp[i])continue;
    for(int j=0;j<n;j++){
        if(i+a[j]<=k)dp[i+a[j]]=true;
    }
  }
  if(dp[k])cout<<"First";else cout<<"Second";
}


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

char text[150];
char round_text[300];
char pattern[150];
char cmp[150];
int main(){
int count = 0;

scanf("%s",text);
scanf("%s",pattern);

int len_pattern = strlen(pattern);
int len_text = strlen(text);


int len_round = 2*len_text;

for(int i=0,j=0;j<len_round;i++,j++){
if(text[i] == '\0'){
	i = 0;
}
round_text[j] = text[i];

}

for(int i=0;i<len_round;i++){
	int p = 0;
	for(int j=i;j<(i+len_pattern);j++){
		if(pattern[p] == round_text[j]){
			p++;
		}
	
	}
	if(p==len_pattern){
		printf("Yes\n");
		count++;
		break;
	}

}
if(count==0){
	printf("No\n");
}


	return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<vector>
using namespace std;
#define HP(a,b) (a-b)*(a-b)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
typedef long int li;

int main(){
  int n; cin >>n;
  int ans=0;
  vector<int> vec(n);
  for(int& x:vec){
    cin >>x;
    ans+=x*x;
  } 
  rep(i,101){
    int temp=0;
    for(int x:vec){
      temp+=HP(x,i);
    }
    if(ans>temp) ans=temp;
  }
  cout << ans;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy


lun = [[str(i)] for i in range(10)] + [[]]
olun =[[str(i)] for i in range(10)] + [[]]

ans = [str(i) for i in range(1,10)]

while True:
    for i in range(0,10):
        lun[i] = list(map(lambda x: str(i) + x, (olun[i-1]+olun[i]+olun[i+1])))
        if i>= 1: ans += lun[i]

    if len(ans) >= 10**5 + 5: break
    olun = copy.deepcopy(lun)

k = int(input())
print(ans[k-1])



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

#define LL long long
int main()
{
    
    LL t = 1;
    //cin >> t;
    
    while(t--)
    {
        LL n , k , x , y;
        cin >> n >> k >> x >> y;
        
        if(n <= k)
            cout << x * n;
        else
            cout << x * k + y * (n - k);
    }

    return 0;
}

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

int dp[202];

#define INF 1000000

void chmin(int &a,int b){
  if(a>b) a=b;
}

int main(){
  int N;
  cin>>N;
  vector<int> p(4),t(4);
  for(int i=0;i<4;i++) cin>>p[i];
  for(int i=0;i<4;i++) cin>>t[i];

  for(int j=0;j<=N;j++) dp[j]=INF;
  dp[0]=0;
  for(int i=0;i<4;i++){
    for(int j=0;j<=N;j++){
      if(dp[j]==INF) continue;
      if(j+t[i]>=N){
        chmin(dp[N],dp[j]+p[i]);
      }else{
        chmin(dp[j+t[i]],dp[j]+p[i]);
      }
    }
  }

  cout<<dp[N]<<endl;


  return 0;
}



Measured memory_bytes: 3100