akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define MAX 1000001

using namespace std;

bool dp[MAX];
int n,est;
int value[31] = {0};


int isPrime(int N){

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

}

void solve(void){

  dp[0] = 1;
  for( int i = 0 ; i < n ; i++ ){
    for( int j = value[i] ; j <= est ; j++ ){
      if( dp[j - value[i]] ) dp[j] = true;
    }
  }
  
}

int main(void){


  while( cin >> n >> est , n + est ){

    fill( dp , dp + MAX , false );

    for( int i = 0 ; i < n ; i++ )
      cin >> value[i];

    solve();

    int ans = 0;
    for( int i = est ; i >= 2 ; i-- ){
      if( dp[i] ){
	ans = isPrime(i);
	if( ans ) break;
      }
    }
    if( ans ) cout << ans << endl;
    else cout << "NA" << endl;

  }

  return 0;
}

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

using namespace std;

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

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N;
   string A,B,C;
   cin>>N>>A>>B>>C;
   ll ans = 0;
   for(int i=0;i<N;i++){
     if(A[i]!=B[i]&&B[i]!=C[i]&&C[i]!=A[i]){
       ans+=2;
     }
     else if(A[i]==B[i] && B[i]==C[i]){
      
     }
     else if(A[i]==B[i] || B[i]==C[i] || C[i]==A[i]){
       ans++;
     }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
using System;
class abc163_d{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    long n = long.Parse(str[0]);
    long k = long.Parse(str[1]);
    long ans=0;
    long min,max;
    long minn = 0, maxn = n;
    long minsum=0, maxsum=0;
    for(long i=k; i<=n+1; i++){
      if(i==k){
        long temp = i;
        while(temp>0){
          minsum+=minn;
          temp--;
          minn++;
        }
        min = minsum;
        temp = i;
        while(temp>0){
          maxsum+=maxn;
          maxn--;
          temp--;
        }
        max = maxsum;
      }
      else{
        minsum += minn;
        maxsum += maxn;
        minn++;
        maxn--;
        max = maxsum;
        min = minsum;
      }
      //Console.WriteLine("{0}: {1}~{2}",i,min,max);
      ans = (ans + max-min+1)%(long)(Math.Pow(10,9)+7);
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 18360
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  vi A(3);
  cin >> A;
  i64 ans = 0;
  if(A[0] % 2 == A[1] % 2 and A[0] % 2 != A[2] % 2){
    A[0]++;
    A[1]++;
    ans++;
  }
  if(A[0] % 2 == A[2] % 2 and A[0] % 2 != A[1] % 2) {
    A[0]++;
    A[2]++;
    ans++;
  }
  if(A[1] % 2 == A[2] % 2 and A[0] % 2 != A[1] % 2) {
    A[1]++;
    A[2]++;
    ans++;
  }
  sort(rng(A));
  ans += (A[2] - A[0]) / 2;
  ans += (A[2] - A[1]) / 2;

  cout << ans << "\n";


}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Q=1<<10;
int ans[Q],owo[Q],rem[Q];
int a[Q],kk,now;
int b[Q],had[Q];
vector<int> nw,as;
bool New(int len)
{
    fill(had+1,had+kk+1,0);
    for(int i=1;i<=kk;i++)
        b[i]=a[i];
    for(int i=0;i<(kk-len);i++)
        had[ans[now-i]]=1;
    int mn=1e9,mx=0;
    for(int i=1;i<=kk;i++){
        if(!had[i])--b[i];
        mx=max(mx,b[i]),mn=min(mn,b[i]);
    }
    if((mn<<1)+1<mx)return 0;
    if((mn<<1)>=mx){
        int tp=0;
        for(int i=1;i<=kk;i++)
            if(!had[i])owo[++tp]=i;
        return 1;
    }
    nw.clear(),as.clear();
    for(int i=1;i<=kk;i++)
        if(!had[i]){
            if(b[i]==mx)nw.push_back(i);
            else if(b[i]!=mn)as.push_back(i);
        }
    for(int i=1;i<=kk;i++)
        if((!had[i])&&b[i]==mn)nw.push_back(i);
    merge(nw.begin(),nw.end(),as.begin(),as.end(),owo+1);
    return 1;
}
int main()
{
    scanf("%d",&kk);
    int mn=1e9,mx=0,sm=0;
    for(int i=1;i<=kk;i++)
        scanf("%d",&a[i]),sm+=a[i],mx=max(mx,a[i]),mn=min(mn,a[i]);
    if((mn<<1)<mx)return 0&puts("-1");
    New(kk),now=kk;
    for(int i=1;i<=kk;i++)
        ans[i]=owo[i],--a[i];
    while(now<sm){
        rem[1]=1e9;
        int len=0;
        for(int p=1;p<=kk&&p<=sm-now;p++){
            if(!New(p))continue;
            for(int i=1;;i++)
                if(owo[i]!=rem[i]){
                    if(owo[i]<rem[i]){
                        len=p;
                        for(int i=1;i<=p;i++)
                            rem[i]=owo[i];
                        rem[p+1]=0;
                    }
                    break;
                }
        }
        for(int i=1;i<=len;i++)
            ans[++now]=rem[i],--a[rem[i]];
    }
    for(int i=1;i<=sm;i++)
        printf("%d ",ans[i]);
    return 0;
}

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

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

   cout << ceil(n / 2) << endl;
}

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

using namespace std;

constexpr int MAXN = 200000, MAXP = 10000;

typedef long long ll;

int cnt[MAXP + 2];
char S[MAXN + 2];

int main() {
	int N, P;
	cin >> N >> P >> S;
	ll ans = 0;
	if(P == 2 || P == 5) {
		for(int i = 0; i < N; i++)
			if((S[i] - '0') % P == 0)
				ans += i + 1;
	} else {
		cnt[0]++;
		for(int i = N - 1, cum = 1, sum = 0; i >= 0; i--) {
			int x = (cum * (S[i] - '0') + sum) % P;
			ans += cnt[x]++;
			cum = 10 * cum % P;
			sum = x;
		}
	}
	cout << ans << '\n';
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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


    ll X, K, D;
    cin >> X >> K >> D;

    if (X < 0) X *= -1;

    ll ans = X - D * min((ll)(X / D), K);
    K = max(K - (ll)(X / D), (ll)0);

    if (K % 2 == 0) {
        cout << ans << endl;
    }
    else {
        cout << abs(ans - D) << endl;
    }

    return 0;
}


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

int main(){
  string S;ll K;
  cin >> S >> K;
  int i=0;
  while(S[i]=='1'){
    ++i;
  }
  if(K-1<i) cout << 1 << endl;
  else{
    cout << S[i] << endl;
  }
}

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



int main() {
	scanf("%d",&n);
	int ans=0;
	for(int c=1;c<n;c++) {
		int x=sqrt(n-c);
		for(int a=1;a<=x;a++) {
			if((n-c)%a==0) {
				ans++;
				if((n-c)/a!=a) {
					ans++;
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int tani[21];
int needs[21];


// iÌóÔ©çUÈãÌPÊÉ½Çè­Å¬C
int dp[1<<20];
// s«æ
int U;
int n;

int dfs(int s,int sum){
	if(dp[s]!=-1)
		return dp[s];
	else if(sum>=U){
		dp[s]=0;
		return dp[s];
	}
	else{
		int minCost=1000000;
		//bool used[21];
		//for(int i = 0; i < n; i++){
		//	if((s>>i)&1)
		//		used[i]=true;
		//}
		// Â¬ÉÇ±ÖJÚ·é©
		//for(int i = 0; i < tos[s].size(); i++){
		//	minCost=min(minCost,dfs(s|(1<<(tos[s][i])),sum+tani[tos[s][i]])+1);
		//	if(minCost==1)
		//		break;
		//}
		for(int i = 0; i < n; i++){
			// Ü¾JÚµÄÈ©Á½ç
			if(!((s>>i)&1)){
				if(((needs[i])&s)==needs[i]){
					minCost=min(minCost,dfs(s|(1<<i),sum+tani[i])+1);
					if(minCost==1)
						break;
				}
				//for(int j = 0; j < vpii[i].second.size(); j++){
				//	if(!used[vpii[i].second[j]]){
				//		f=true;
				//		break;
				//	}
				//}
				//if(!f)
				//	minCost=min(minCost,dfs(s|(1<<i),sum+vpii[i].first)+1);
			}
		}
		dp[s]=minCost;
		return dp[s];
	}
}

int main(){

	int c,k;
	int t;
	int tn;
	while(cin>>n>>U&&!(n==0&&U==0)){
		fill(dp,dp+(1<<20),-1);
		for(int i = 0; i < n; i++){
			cin>>tani[i]>>k;
			needs[i]=0;
			for(int j = 0; j < k; j++){
				cin>>t;
				needs[i]|=(1<<t);
			}
		}
		//for(int s = 0; s < (1<<n); s++){
		//	for(int i = 0; i < n; i++){
		//		if(!((s>>i)&1)){
		//			if(((needs[i])&s)==needs[i]){
		//				tos[s].push_back(i);
		//			}
		//		}
		//	}
		//}
		cout<<dfs(0,0)<<endl;
		//for(int i = 0; i < (1<<n); i++)
		//	tos[i].clear();
	}
	return 0;
}

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

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

Measured memory_bytes: 512
// RMQ (Range Minimum Query)
#include<cstdio>
#include<algorithm>
#include<climits>
using namespace std;
#define MAX ( 1 << 17 )
const int INF = INT_MAX;
int n, seg[MAX * 2 - 1];
void update( int i, int x){
  i += n - 1;
  seg[i] = x;
  while(i > 0){
    i = ( i - 1 ) / 2;
    seg[i] = min( seg[i * 2 + 1], seg[i * 2 + 2]);
  }
}
inline int query( int a, int b, int k, int l, int r){
  if( r <= a || b <= l ) return INF;
  if( a <= l && r <= b ) return seg[k];
  int vl = query( a, b, k * 2 + 1, l, (l + r) / 2);
  int vr = query( a, b, k * 2 + 2, (l + r) / 2, r);
  return min( vl, vr);
}
void init( int& size){
  n = 1;
  while( n < size ) n *= 2;
  fill_n( seg, n * 2 - 1, INF);
}
int main(){
  int size, q;
  scanf("%d %d", &size, &q);
  init(size);
  while(q--){
    int com, a, b;
    scanf("%d %d %d", &com, &a, &b);
    if( com == 0 ) update( a, b);
    else printf("%d\n", query( a, b + 1, 0, 0, n));
  }
}

Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        String op = scan.next();
        int B = scan.nextInt();
        int answer = A + B;
        if ("-".equals(op)) {
            answer = A - B;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = INT_MAX;

int main(){
    string s;
    int ans=0;
    bool flag;
    cin >> s;
    if(s[0]=='B') flag = true;
    else flag = false;
    for(int i=1; i<s.length(); i++){
        if(s[i]=='B' && !flag){
            ans++;
            flag = true;
        }
        else if(s[i]=='W' && flag){
            ans++;
            flag = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#define QMOD 1000000007
const long long Slmax=100001;
using namespace std;

//dp[][r]:13で割った余りがrである総数
long long  dp[Slmax][13]={0};

int main(){
  
  string str;
  cin>>str;
  
  //逆順にして1桁目から
  int RSlen=str.length();
  char RS[Slmax];
  for(int i=0;i<RSlen;i++)RS[i]=str[RSlen-i-1];
  
  //1桁目から
  if(RS[0]=='?'){
    //?=kの時のdp処理
    for(int k=0;k<10;k++){
       dp[0][k]++;
    }
  }else dp[0][RS[0]-'0']++;
  
  int mod[6]={1,10,9,12,3,4};
  //2桁目以降
for(int i=1;i<RSlen;i++){
    if(RS[i]=='?'){
      //?=kの時のdp処理
      for(int k=0;k<10;k++){
        for(int j=0;j<13;j++){
          dp[i][(j+k*mod[i%6])%13]+=dp[i-1][j];
          dp[i][(j+k*mod[i%6])%13]%=QMOD;
        }
      }
    }else{
      int d=RS[i]-'0';
        for(int j=0;j<13;j++){
          dp[i][(j+d*mod[i%6])%13]+=dp[i-1][j];
          dp[i][(j+d*mod[i%6])%13]%=QMOD;
        }      
    }
  }
  
  //debug
  /*
  for(int i=0;i<RSlen;i++){
    cout << i+1 <<"桁目:";
    for(int k=0;k<13;k++)
      cout << dp[i][k] << " ";
    cout << endl;
  }*/
  
  cout << dp[RSlen-1][5] << endl;
  return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int main(void) 
{
    int i, j, k;
    long n, m, l;
    long a[100][100], b[100][100], c[100][100] = { 0 };
    

    scanf("%ld %ld %ld\n", &n, &m, &l);

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

    for (k = 0; k < m; k++) 
    {
        for (j = 0; j < l; j++) 
        {
            scanf("%ld", &b[k][j]);
        }
    }

    for (i = 0; i < n; i++) 
    {
        for (j = 0; j < l; j++) 
        {
            for (k = 0; k < m; k++) 
            {
                c[i][j] = c[i][j] + a[i][k] * b[k][j];
            }
        }
    }

    for (i = 0; i < n; i++) 
    {
        for (j = 0; j < l; j++) 
        {
            printf("%ld", c[i][j]);
            if (j < l - 1) 
            {
                printf(" ");
            }
        }

        printf("\n");
    }


    return 0;
}


Measured memory_bytes: 2136
n = int(input())

S = []
for i in range(n):
    S.append(input())
    
cnt = [50] * 26

for i in range(n):
    tmp = [0] * 26
    for j in range(len(S[i])):
        tmp[ord(S[i][j])-97] += 1
    for j in range(26):
        cnt[j] = min(cnt[j],tmp[j])

res = '' 
for i in range(26):
    for j in range(cnt[i]):
        res = res + chr(97 + i)

print(res)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int l=0;
  if(a==b)++l;
  if(b==c)++l;
  if(c==a)++l;
  if(l==1)return cout<<"Yes"<<endl,0;
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A, B; scanf("%d%d", &A, &B);
  printf("%d %d ", A/B, A%B);
  double C = A, D = B;
  printf("%.10lf\n", C / D);

  return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<P> red(n),blu(n);
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        red[i]=P(a,b);
    }
    for(int i=0;i<n;i++){
        ll c,d;cin>>c>>d;
        blu[i]=P(c,d);
    }
    sort(red.begin(),red.end());
    sort(blu.begin(),blu.end());
    int res=0;
    for(int i=0;i<n;i++){
        ll xb=blu[i].first,yb=blu[i].second;
        int ma=-1,idx;
        for(int j=0;j<n;j++){
            ll xr=red[j].first,yr=red[j].second;
            if(xr>=xb || yr>=yb) continue;
            if(yr>ma){
                ma=yr;idx=j;
            }
        }
        if(ma==-1) continue;
        //cout<<idx<<endl;
        res++;
        red[idx].second=INF;
    }
    cout<<res<<endl;
}


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

using namespace std;

int main(void)
{
    int M1,M2,D1,D2;
    cin>>M1>>D1>>M2>>D2;

    int result=0;
    if(M1 != M2){
        result = 1;
    }

    cout<<result<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())

#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N; cin >> N;
  vector<pair<ll, ll>> A(N + 1);
  rep(i, 1, N + 1) {
  	ll a; cin >> a;
    A[i] = make_pair(a, i);
  }
  vsort(A);
  rep(i, 1, N + 1) {
  	cout << A[i].second << " ";
  }
}

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

ll H,W,N,K;
int t[100][100];

ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res= mpow( a*a%K , b/2 );
  if(b&1)res=(res*a)%K;
  return res;
}

int main(){
  cin>>H>>W>>N>>K;
  for(int a=0;a<H;a++){
    for(int b=0;b<W;b++){
      cout<<"? "<<a<<' '<<b<<' '<<a<<' '<<b<<endl;
      cin>>t[a][b];
    }
  }

  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans+=(t[i][j] * mpow(2, i*W+j) );
      ans%=K;
    }
  }
  cout<<"! "<<ans<<endl;
  return 0;
}


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

int main() {
  int n,x,t;
  cin>>n>>x>>t;
  for(int i=0;i<1005;i++){
    if(n<=i*x){
      cout<<i*t;
      break;
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int total = 0;
  for(int i=0; i < n; i++) {
    int t; cin >> t;
    total += min(t, abs(k-t))*2;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a[1000], b[1000], ans[1000] = {0}, i, cnt = 0;
  char op[1000];


  for(i = 0; i < 1000; i++) {
    scanf("%d %c %d", &a[i], &op[i], &b[i]);
    if(op[i] == '?') {
      break;
    }
    switch(op[i]){
    case '+':
      ans[i] = a[i] + b[i];
      break;
    case '-':
      ans[i] = a[i] - b[i];
      break;
    case '*':
      ans[i] = a[i] * b[i];
      break;
    case '/':
      ans[i] = a[i] / b[i];
      break;
    }
    cnt++;
  }

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

  return 0;
}

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

const int MaxN = 200000 + 5;

int N;
int A[MaxN];
int Pow[31];
map <int, int> mp;

void init() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), mp[A[i]]++;
    Pow[0] = 1;
    for (int i = 1; i < 31; ++i) Pow[i] = Pow[i - 1] << 1;
}

void solve() {
    sort(A + 1, A + 1 + N, greater<int>());

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int u = A[i];
        if (mp[u] == 0) continue;

        for (int j = 30; j >= 1; --j) {
            if (Pow[j] > u) {
                int v = Pow[j] - u;
                if (mp[v] != 0) {
                    if (u == v && mp[u] == 1) continue;
                    mp[u]--; mp[v]--; ans++; break;
                }
            }
        }
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 29824
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int n, m, q;
struct node{
    int a, b, c, d;
    bool operator < (const node &rhs) const{
        return d > rhs.d;
    }
}Q[55];
int v[12], ans = 0;

void dfs(int i, int k){
    if (k > n){
        int res = 0;
        for (int i = 0; i < q; i++){
            if (v[Q[i].b]-v[Q[i].a]==Q[i].c) res += Q[i].d;
        }
        ans = max(ans, res);
        return ;
    }
    for (; i <= m; i++){
        v[k] = i;
        dfs(i, k+1);
    }
}

int main(){
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < q; i++){
        scanf("%d%d%d%d", &Q[i].a, &Q[i].b, &Q[i].c, &Q[i].d);
    }
    dfs(1, 1);
    printf("%d\n", ans);
}


Measured memory_bytes: 3832
def solve(n):
    if n % 2 == 1:
        return 0 
    div_2 = 0
    cur = 2
    while cur <= n:
        div_2 += (n // cur)
        cur = cur * 2
    div_5 = 0
    cur = 5
    while cur <= n:
        div_5 += (n // cur) // 2
        cur = cur * 5
    return min(div_2, div_5)

n = int(input())
print(solve(n))


Measured memory_bytes: 9100
//Let's play once again :)
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tarzan;
	int test = 1;
	//cin >> test;
	while(test--) {
		int x;
		cin >> x;

		int lcm = 360 * x / __gcd(360LL, x);
		cout << lcm / x << '\n';
	}
	return 0;
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i < N; i++)
#define CK(N, A, B) (A <= N && N < B)
#define p(s) cout << (s) << endl
#define p2(a, b) cout << (a) << ' ' << (b) << endl
using namespace std;
typedef long long ll;

const int NODE_SIZE=10101;
int H;
int W;
int start_y, start_x;

string field_s[NODE_SIZE];

int d[NODE_SIZE][NODE_SIZE];

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

void bfs(){
    queue<pair<int,int>> q;
    bool visited[H][W];
    REP(i,0,H) REP(j,0,W) visited[i][j]=false;
    REP(i,0,H) REP(j,0,W) d[i][j]=-1;
    q.push({start_y, start_x});
    d[start_y][start_x]=0;
    while(!q.empty()){
        int cur_y = q.front().first;
        int cur_x = q.front().second;
        int curStep = d[cur_y][cur_x];
        q.pop();
        if(visited[cur_y][cur_x]) continue;
        visited[cur_y][cur_x] = true;

        REP(k,0,4){
            int next_y = cur_y + dy[k];
            int next_x = cur_x + dx[k];

            if(!CK(next_y,0,H) || !CK(next_x,0,W))continue;
            if(field_s[next_y][next_x]=='#')continue;
            if(field_s[next_y][next_x]=='.')field_s[next_y][next_x]='@';
            if(!visited[next_y][next_x]){
                q.push({next_y, next_x});
                d[next_y][next_x] = d[cur_y][cur_x] + 1;
            }
        }
    }
}

int main() {

    while(cin >> W >> H && W) {

        string s;
        REP(i,0,H){
            cin >> field_s[i];
        }
        REP(i,0,H) REP(j,0,W) if(field_s[i][j]=='@'){
            start_x = j;
            start_y = i;
        }
        bfs();
        int cnt=0;

        REP(i,0,H) REP(j,0,W) if(field_s[i][j]=='@')cnt++;
        p(cnt);
    }
    return 0;
}


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

int main(){
  long long n;
  cin >> n;
  long long a[n],i,j;
  for(i=0;i<n;i++)cin >> a[i];
  sort(a,a+n);
  long long sum = 0,ret=0;
  for(i=0;i<n;i++){
    if(2*sum<a[i])ret=i;
    sum+=a[i];
  }
  cout << n-ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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;
}

template <class T>
T gcd(T a, T b) {
    if (a < b) {
        swap(a, b);
    }

    T r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

template <class T>
T lcm(const T& a, const T& b) {
    return (a * b) / gcd<T>(a, b);
}

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    long long X, Y;
    cin >> X >> Y;

    long long ans = 0;
    long long n1 = 1;
    long long n2 = X;
    while (n2 <= Y) {
        n2 = n2 * 2;
        ans++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, K;
	cin >> N >> K;
	vector<int>h(N);
	rep(i, N)cin >> h[i];
	sort(h.begin(), h.end());
	int num = 1e10;
	rep(i, N - K + 1)
	{
		int a = h[i + K - 1] - h[i];
		num = min(num, a);
	}
	cout << num;
}

Measured memory_bytes: 1024
from bisect import bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]

# 解は最長非増加部分列の長さ
dp = [-1 for _ in range(N)]
for a in A:
    dp[bisect_left(dp, a) - 1] = a
ans = sum(x >= 0 for x in dp)

print(ans)


Measured memory_bytes: 7848
//
// Created on 2020/09/12.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

vector<pair<ll,ll>>prime_factorize(ll n){
    vector<pair<ll,ll>>ret;
    for (ll i = 2; i * i < n ; ++i) {
        if(n % i == 0){
            ll ex = 0;//指数
            while(n % i == 0){
                ex++;
                n /= i;
            }
            ret.push_back({i, ex});
        }
    }
    if(n != 1){
        ret.push_back({n,1});
    }
    return ret;
    //example n = 12, ret = [[2,2],[3,1]と返す
}

ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }
    return gcd(b,a %b);
}

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

    set<int>s;

    ll init;
    cin>>init;
    auto ret = prime_factorize(init);
    for (int i = 0; i < ret.size(); ++i) {
        s.insert(ret[i].first);
    }
    int sum = init;
    bool pairwise = true;
    for (int i = 1; i < n; ++i) {
        int a;
        cin>>a;
        sum = gcd(sum,a);
        if(pairwise){
            ret = prime_factorize(a);
            for (int i = 0; i < ret.size(); ++i) {
                if(s.count(ret[i].first) != 0){
                    pairwise = false;
                }else{
                    s.insert(ret[i].first);
                }
            }
        }
    }

    if(sum == 1 && pairwise){
        cout<<"pairwise coprime"<<endl;
    }else if(sum == 1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }

    return 0;
}


Measured memory_bytes: 7252
A,B,K = map(int,input().split())
ans = []
for i in range(K):
    if A + i <= B:
        ans.append(A+i)
for i in range(K):
    if B - i >= A:
        ans.append(B-i)
ans = list(set(ans))
ans.sort()

for i in ans:
    print(i)


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

int main(){
	int a,b,c,d;
	int e=0;
	  cin>>a>>b>>c;
	for(d=a;d<=b;d++){
		if(c%d==0){
			e+=1;
		}
	}
	cout<<e<<endl;
	return 0;
}

Measured memory_bytes: 1160
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>

using namespace std;


int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)puts("Yes");
	else puts("No");
	return 0;
}



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

//#define debug(...)   printf( __VA_ARGS__ )
#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)
int n,i,j,cnt,ar[100007],flag=0;
vector<int> conseq;

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    while(cin>>n)
    {
        fr(i,0,n-1)
        scanf("%d",ar+i);

        fr(i,1,n)
        if(ar[i]!=ar[i-1])
            conseq.pb(ar[i-1]);

        for(auto von:conseq)
            debug("%d ",von);

        debug("\n");

        cnt=0;
        n=conseq.size();

        for(i=1; i<n;)
            if(conseq[i-1]<conseq[i])
            {
                while(i<n)
                {
                    if(conseq[i-1]<conseq[i])
                        flag=1;
                    else
                    {
                        flag=0;
                        break;
                    }
                    i++;
                }


                cnt++;
                i++;
            }
            else if(conseq[i-1]>conseq[i])
            {
                while(i<n)
                {
                    if(conseq[i-1]>conseq[i])
                        flag=1;
                    else
                    {
                        flag=0;
                        break;
                    }
                    i++;
                }

                cnt++;
                i++;
            }

        if(flag==0)
            cnt++;

        cout<<cnt<<'\n';
        conseq.clear();
    }



    return 0;
}

/*
10
1 1 1 3 2 2 1 1 2 3
1 3 2 1 2 3
3

3
1 1 2
1 3 2 1 2 3 3

8
1 2 3 3 4 1 2 3
*/




Measured memory_bytes: 1276
N = int(input())
a = [0] * N
b = [0] * N

for i in range(N):
    a[i], b[i] = map(int, input().split())

count = 'No'

for i in range(N-2):
    if a[i] == b[i] and a[i+1] == b[i+1] and a[i+2] == b[i+2]:
        count = 'Yes'

print(count)

Measured memory_bytes: 62344
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
    string s;cin>>s;
    ll k;cin>>k;
    rep(i,0,k)if(s[i]!='1'){cout<<s[i]<<ednl;return 0;}
  	cout << 1 << ednl;
}


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

namespace ABC112
{
    class B
    {
        static void Main(string[] args)
        {
            var NT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ct = Enumerable.Repeat(0, NT[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

            int res = int.MaxValue;
            for (int i = 0; i < NT[0]; i++)
            {
                if (ct[i][1] <= NT[1]) { res = Math.Min(res, ct[i][0]); }
            }

            if (res == int.MaxValue) Console.WriteLine("TLE");
            else Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13524
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
def find(a):
    return (a*(a+1))//2
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*find(n//i)
print(ans)





Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    vector<int>v(m);
    for(int i=0; i<m; i++)
    {
        cin >> v[i];
    }
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        int ans=0;
        for(int j=0; j<m; j++)
        {
            int a;
            cin >> a;
            ans+=(a*v[j]);

        }
        if(ans + c >0)
            cnt++;
    }
    cout << cnt <<'\n';
}


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

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

    vector<bool> A(1000000010);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        long long a = 0;
        cin >> a;
        if (A[a] == false) {A[a] = true; ans++;}
        else {A[a] = false; ans--;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 122368
#!/usr/bin/env python

import sys

n= int(sys.stdin.readline())
p= [ int(x) for x in sys.stdin.readline().split() ]
#
count = 0
for i in range(n-2):
    m= p[i+1]
    t= p[i:i+3]
    if m!=min(t) and m!=max(t): count+=1
print( count )


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

int main() {
  int n, T;
  cin >> n >> T;
  int c[n], t[n];
  int result = 10000;
  int i;
  for (i = 0; i < n; i++) {
    cin >> c[i] >> t[i];
    if (t[i] <= T) {
      result = min(result, c[i]);
    }
  }
  if (result <= 1100) {
    cout << result << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])

for r in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 7012
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}





int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>k;
    vii v;
    set<ll> st;

    lp(1,k)cin>>x,st.ins(x);
    x=n;
    while(1){
    	int flg=1;
    	y=x;
    	while(y){
    		if(st.count(y%10))flg=0;
    		if(!flg)break;
    		y/=10;
    	}
    	if(flg){
    		cout<<x<<"\n";die();
    	}
    	++x;

    	

    }
    



    	






    

}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n,l[200],ans=0;
  scanf("%d",&n);
  for(int i=0;i<2*n;i++)
    scanf("%d",&l[i]);
  sort(l,l+2*n);
  for(int i=0;i<2*n;i+=2)
    ans+=l[i];
  printf("%d\n",ans);
}

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

int main(){
  int n;
  cin>>n;
  vector<int> t(n);
  int ans=0;
  for(int i=0; i<n; i++){
    cin>>t.at(i);
    ans+=t.at(i);
  }
  
  int m;
  cin>>m;
  vector<int> p(m), x(m);
  for(int i=0; i<m; i++)cin>>p.at(i)>>x.at(i);

  for(int i=0; i<m; i++)cout<<ans-t.at(p.at(i)-1)+x.at(i)<<endl;
  
}

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

using namespace std;

void d()
{
	int N;
	cin >> N;
	vector<pair<int, int> > ab(N-1);
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		ab[i] = pair<int, int>(a-1, b-1);
	}
	vector<int> c(N);
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}

	// 全nodeのrankを求める
	vector<int> rank(N);
	for (int i = 0; i < N; i++) {
		rank[i] = 0;
	}
	for (int i = 0; i < N-1; i++) {
		rank[ab[i].first]++;
		rank[ab[i].second]++;
	}

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

	// rankの最も大きいものをrootとしてcの最大入れる
	int maxNode = 0;
	for (int i = 1; i < N - 1; i++) {
		if (rank[maxNode] < rank[i])
			maxNode = i;
	}

	int count = 0;
	vector<int> res(N);
	priority_queue<pair<int, int> > queue;
	queue.push(pair<int, int>(rank[maxNode], maxNode));
	vector<bool> reach(N); // そのノードを処理したかどうかを覚える
	for (int i = 0; i < N; i++) {
		reach[i] = false;
	}
	reach[maxNode] = true;
	while (queue.size() > 0) {
		int current = queue.top().second;
		queue.pop();

		res[current] = c[count++];
		
		// 現在のnodeとの間にedgeがあるnodeを抽出
		for (int i = 0; i < N - 1; i++) {
			pair<int, int> t = ab[i];
			if (t.first == current && ! reach[t.second]) {
				queue.push(pair<int, int>(rank[t.second], t.second));
				reach[t.second] = true;
			}
			if (t.second == current && ! reach[t.first]) {
				queue.push(pair<int, int>(rank[t.first], t.first));
				reach[t.first] = true;
			}
		}
	}

	long long int sum = 0;
	for (int i = 1; i < N; i++) {
		sum += c[i];
	}

	cout << sum << endl;
	cout << res[0];
	for (int i = 1; i < N; i++) {
		cout << " " << res[i];
	}
	cout << endl;
}

int main()
{
	d();
}



Measured memory_bytes: 768
i = [int(i) for i in input().split()]
N = i[0]
Y = i[1]

# 10000*N - Y = 5000*y + 9000*z
# 10*N - Y/1000 = 5*y + 9*z
sum = 10*N - Y/1000
for y in range(N+1):
    for z in range(N-y+1):
        if sum == 5*y + 9*z:
            print(str(N-y-z) + " " + str(y) + " " + str(z))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 9184
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{

    int n,m,ans=0;
    scanf("%d %d",&n,&m);
    int h[n],q[n];
    for(int i=0;i<n;i++)
    {
        q[i]=1;
        scanf("%d",&h[i]);
    }

    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);

        if(h[a-1]==h[b-1])
        {
            q[a-1]=0;
            q[b-1]=0;
        }
        else if(h[a-1]>h[b-1])
        {
            q[b-1]=0;
        }
        else
        {
            q[a-1]=0;
        }
    }

    for(int i=0;i<n;i++)
    {
        ans=ans+q[i];
    }

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

    return 0;
}

Measured memory_bytes: 2504
inpl = lambda: list(map(int,input().split()))
def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums

N = int(input())
S = input()
ele, num = get_sequence(S)
Estart = 1-int(ele[0]=='E')
NE = sum(num[Estart::2])
ans = cur = NE
for i in range(len(num)):
    if (i - Estart) % 2:
        cur += num[i]
    else:
        cur -= num[i]
        if cur < ans:
            ans = cur
print(ans)

Measured memory_bytes: 60248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N,L;
    cin >> N>>L;
    vector<string> S(N);
    rep(i,N){
        cin >> S.at(i);
    }
    sort(all(S));
    string ans;
    rep(i,N){
        ans+=S.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/
/*GRAPH_TEMPLATE=============================================*/
template<typename T_n>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T_n cost; //辺の重み
    Edge(int t, T_n w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T_n w) : srch(src), to(t), cost(w) {}
};
template<typename T_n>
using Edges = vector<Edge<T_n>>;  //重み付き辺集合
template<typename T_n>
using W_Graph = vector<Edges<T_n>>; //重み付きグラフ
using Graph = vector<vector<int>>;  //通常グラフ

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, m; cin >> n >> m;
    Graph G(n+1);
    rep1(i,m) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool can = false;
    for(int i : G[1]) {
        for(int j : G[i]){
            if(j == n) can = true;
        }
    }
    cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Measured memory_bytes: 12016
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        d: usize,
        g: i64,
        p: [(i64, i64); d],
    }
    let mut ans = std::i64::MAX;
    for bit in 0..1 << d {
        let mut sum = 0;
        let mut count = 0;

        let mut rest_max = 0;
        for i in 0..d as i64 {
            if bit & (1 << i) != 0 {
                sum += (i + 1) * 100 * p[i as usize].0 + p[i as usize].1;
                count += p[i as usize].0;
            } else {
                rest_max = i;
            }
        }
        if sum < g {
            let s = 100 * (rest_max + 1);
            let need = (g - sum + s - 1) / (s);
            if need >= p[rest_max as usize].0 {
                continue;
            }
            count += need;
        }
        ans = std::cmp::min(ans, count);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352