akhauriyash/Code-Regression huggingface dataset:
s = input()

ans = [-1, -1]
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        ans = [i, i+1]
        break
    elif i >= 2 and s[i-2] == s[i]:
        ans = [i-1, i+1]

print(*ans)


Measured memory_bytes: 3188
#include<iostream>
#include <cstdio>
#include<cctype>

using namespace std;

int main(){
	
	char ch;
	
	while((ch = getchar()) != EOF){
		if(islower(ch))
			ch = toupper(ch);
		else
			ch = tolower(ch);
		cout << ch;
	}
	
	return 0;
}

Measured memory_bytes: 1084
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    double x[N];
    string u[N];
    double sum = 0;

    for(int i = 0; i < N; i++){
        cin >> x[i] >> u[i];
        if(u[i] == "JPY") sum += x[i];
        else sum += x[i]*380000;
    }
    cout << setprecision(int(log(sum)/log(10))+5) << sum << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

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

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s, t;
int ans;

signed main() {
	cin >> s >> t;
	for (int i = 0; i < 3; i++)if (s[i] == t[i])ans++;
	cout << ans << endl;
}


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

#define KI_MAX (1 << 14) /* 16384 */

int64_t ki[KI_MAX * 2 - 1];

void ki_init(void) {
	int i;
	for (i = KI_MAX - 1 - 1; i >= 0; i--) {
		int64_t a = ki[i * 2 + 1], b = ki[i * 2 + 2];
		ki[i] = a >= b ? a : b;
	}
}

int64_t ki_get_i(int idx, int qs, int qe, int ss, int se) {
	if (qe <= ss || se <= qs) { /* 完全にはずれ */
		return INT64_MIN;
	} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
		return ki[idx];
	} else {
		int sm = ss + (se - ss) / 2;
		int64_t left = ki_get_i(idx * 2 + 1, qs, qe, ss, sm);
		int64_t right = ki_get_i(idx * 2 + 2, qs, qe, sm, se);
		return left >= right ? left : right;
	}
}

int64_t ki_get(int qs, int qe) {
	return qs < qe ? ki_get_i(0, qs, qe, 0, KI_MAX) : INT64_MIN;
}

int N, K;
int P[5555];
int C[5555];

char visited[5555];

int mc;
int64_t mamegu[5555]; /* 得点 */
int64_t* yukati = ki + (KI_MAX - 1); /* 累積和 */

int64_t solve(void) {
	int i;
	int64_t answer = INT64_MIN;

	for (i = 1; i <= mc * 2; i++) {
		yukati[i] = yukati[i - 1] + mamegu[(i - 1) % mc];
	}
	ki_init();

	/* フルで回す + 余り */
	if (K >= mc) {
		int amari = K % mc;
		int64_t furu = yukati[mc] * (K / mc);
		int64_t makkusu = 0;
		int64_t candidate;
		if (amari > 0) {
			for (i = 1; i <= mc; i++) {
				/* iから1個～amari回したmax */
				int64_t mofu = ki_get(i, i + amari) - yukati[i - 1];
				if (mofu > makkusu) makkusu = mofu;
			}
		}
		candidate = furu + makkusu;
		if (candidate > answer) answer = candidate;
	}
	/* フル-1回す + 全部候補 */
	if (K >= mc * 2) {
		int64_t furu = yukati[mc] * (K / mc - 1);
		int64_t makkusu = 0;
		int64_t candidate;
		for (i = 1; i <= mc; i++) {
			/* iから1個～mc回したmax */
			int64_t mofu = ki_get(i, i + mc) - yukati[i - 1];
			if (mofu > makkusu) makkusu = mofu;
		}
		candidate = furu + makkusu;
		if (candidate > answer) answer = candidate;
	}
	/* 回さない + 全部候補 */
	{
		int avail = K < mc ? K : mc;
		int64_t makkusu = INT64_MIN;
		for (i = 1; i <= mc; i++) {
			/* iから1個～min(mc, K)回したmax */
			int64_t mofu = ki_get(i, i + avail) - yukati[i - 1];
			if (mofu > makkusu) makkusu = mofu;
		}
		if (makkusu > answer) answer = makkusu;
	}

	return answer;
}

int main(void) {
	int i;
	int cur;
	int64_t answer = INT64_MIN;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &P[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &C[i]) != 1) return 1;
	}

	for (i = 1; i <= N; i++) {
		if (!visited[i]) {
			int64_t cand;
			cur = i;
			mc = 0;
			while (!visited[cur]) {
				visited[cur] = 1;
				cur = P[cur];
				mamegu[mc++] = C[cur];
			}
			cand = solve();
			if (cand > answer) answer = cand;
		}
	}

	printf("%" PRId64 "\n", answer);
	return 0;
}


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

int fixNumberOne( int cnt, int a )
{
    if( cnt == 0 )
        return a;
    if( a + 11 <= 22 - cnt )
        return a + 10 + cnt;
    else
        return a + cnt;
}

int main()
{
    int a[128], b[100];
    for( int i = '1'; i < '1' + 9; i++ )
        a[i] = i - '0';
    a['1'+'0'] = 10;
    a['1'+'1'] = 10;
    a['1'+'2'] = 10;
    a['1'+'3'] = 10;

    string str;

    while( getline( cin, str ) )
    {
        if( str == "0" )
            break;

        str += " ";

        for( int i = 0; i < 100; i++ )
            b[i] = 0;
    
        int j = 0, sum = 0, cnt = 0;
        for( int i = 0; i < str.size(); i++ )
        {
            if( str[i] == ' ' )
            {
                if( a[sum] == 1 )
                    cnt++;
                else
                    b[j] = a[sum];
                sum = 0;
                j++;
            }
            else
                sum += str[i];
        }
        sum = 0;
        for( int i = 0; i < 100; i++ )
            if( b[i] != 1 )
                sum += b[i];
        sum = fixNumberOne( cnt, sum );

        if( sum > 21 )
            cout << 0 << endl;
        else
            cout << sum << endl;
    }

    return 0;
}


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

int main(){
  long N1, N2, N3, N4;
  char ans;
  cin >> N1 >>N2 >>N3 >>N4;
  int c;
  c=0;
  if(N1 == 1 || N2 == 1 || N3 == 1 || N4 == 1){
      c++;

  }
  if(N1 == 9|| N2 == 9 || N3 == 9 || N4 == 9){
      c++;

  }
  if(N1 == 7 || N2 == 7 || N3 == 7 || N4 == 7){
      c++;

  }
  if(N1 == 4 || N2 == 4 || N3 == 4 || N4 == 4){
      c++;

  }
  if(c==4){
    cout <<"YES";
  }
  else
  {
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, M; cin >> N >> M;
	vvi Graph(N, vector<int>(N, 0));
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		Graph[a][b] = 1;
		Graph[b][a] = 1;
	}
	vector<int> vec(N);
	REP(i, N) vec[i] = i;
	int ans = 0;
	do {
		if (vec[0] != 0) continue;
		bool fail = false;
		REP(i, N - 1) {
			if (Graph[vec[i]][vec[i + 1]] != 1) {
				fail = true;
				break;
			}
		}
		if (!fail) ++ans;
    } while (next_permutation(vec.begin(), vec.end()));
	cout << ans << endl;
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int [][] d = new int[8][];
            int [][] d2 = new int[8][];
            
            while(true)
            {
                string pattern = null;
                for(int i = 0, index = 0; i < 8; i++)
                {
                    d[index] = Console.ReadLine().Select(x => x - '0').ToArray();
                    var sum = d[index].Sum();
                    if (sum == 0) continue;
                    if (sum == 4) pattern = "C";
                    index++;
                }
                for (int i = 0, index = 0; i < 8; i++)
                {
                    d2[index] = Enumerable.Range(0, 8).Where(x => d[x] != null).Select(x => d[x][i]).ToArray();
                    var sum = d2[index].Sum();
                    if (sum == 0) continue;
                    if (sum == 4) pattern = "B";
                    index++;
                }

                if (pattern == null)
                {
                    if (d2[0][0] == 1)
                    {
                        if (d2[0][1] == 1 && d2[1][0] == 1) pattern = "A";
                        else if (d2[1][0] == 1) pattern = "E";
                        else if (d2[0][1] == 1) pattern = "F";
                    }
                    else
                    {
                        pattern = d2[0].Sum() == 2 ? "D" : "G";
                    }
                }
                Console.WriteLine(pattern);
                if (Console.ReadLine() == null) break;
            }
        }
    }
}

Measured memory_bytes: 5824
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){

  for(int n;cin>>n,n;){
    int r=0;
    for(int i=1;i*i<=n;i++) if(!(n%i)){
        int x=n/i;
        if(i!=x) r+=i;
        if(i!=1) r+=x;
      }
    if(n==r) cout<<"perfect number"<<endl;
    else if(n>r) cout<<"deficient number"<<endl;
    else cout<<"abundant number"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
   ll x,k,d; cin >>x >>k >>d;
   if(x<0) x*=-1;
   ll m=min(x/d,k);
   k-=m; x-=m*d;
   if(!k){cout <<x; return;}
   k%=2;
   if(k) x=d-x;
   cout <<x;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   solve();
return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <stack>
 
int main(){
    std::stack<int> s;
    int n;
    while(std::cin >> n){
        if(n)
            s.push(n);
        else{
            std::cout << s.top() << std::endl;
            s.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main(void) {

	char s[200000];
	int i, j, sl, a_num=0, z_num=0;

	scanf("%s", s);

	sl = strlen(s);

	for (i = 0; i < sl; i++) {
		if (s[i] == 'A'){
			a_num = i;
		break;}
	}

	for (j = sl-1; j >0; j--) {

		if (s[j] == 'Z') {
			z_num = j;
			break;
		}
	}
	printf("%d\n", z_num - a_num+1);

	return 0;

}

Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, LL> Vec2;
typedef tuple<LL, LL, LL> Tll;
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
struct Edge { LL to, cost; };
LL h, w, n, m, s, t, k, ans = 0, a[1000000], pos[10000][10000], sum, dp[10000][10000];
int main() {
	cin >> n >> m;
	cout << (n % 2 == 0 || m % 2 == 0 ? "Even" : "Odd") << endl;
	return 0;
}


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

int main(){
	char a[11];
	scanf("%s",a);
	for(int i=0;i<strlen(a);i++){
		int db=0;
		if(a[i]=='B'&&i!=0){
			int j=i;
			int k=1;
			while(a[j]=='B'){
				a[i-k]='B';
				k++;
				j++;
			}
			db++;
		}
	}
	for(int i=0;i<strlen(a);i++){
		if(a[i]!='B'){
			printf("%c",a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1640
X,Y = map(int,input().split())
if X == 1 and Y == 1:
    print(1000000)
    exit()
bumon = [X,Y]
man = 0
for i in bumon:
    if i == 1:
        man += 300000
    if i == 2:
        man += 200000
    if i == 3:
        man += 100000

print(man)


Measured memory_bytes: 2940
S = input()
T = input()
ans = 'UNRESTORABLE'
for i in range(len(S)-len(T), -1, -1):
    for j in range(len(T)):
        if S[i+j] != '?' and S[i+j] != T[j]:
            break
    else:
        ans = S[:i].replace('?', 'a')+T+S[i+len(T):].replace('?', 'a')
        break
print(ans)


Measured memory_bytes: 38256
N = int(input())
l = list(map(int,input().split(' ')))
dp = {}
k = True
for i in range(N):
    tmp = l[i]
    if tmp in dp:
        dp[tmp] +=1
    else:
        if len(dp)==3:
            k = False
            break
        else:
            dp[tmp] = 1

flag = False
num_l = []
ans_l = []
if k:
    if 0 in dp:
        if len(dp)==1:
            flag = True
        elif len(dp)==2:
            num_l = [None]*2
            ans_l = [None]*2
            for key,val in dp.items():
                if key==0:
                    num_l[0] = key
                    ans_l[0] = val
                else:
                    num_l[1] = key
                    ans_l[1] = val
            if ans_l[0]*2==ans_l[1]:
                flag = True
    else:
        if len(dp)==3:
            for key,val in dp.items():
                num_l.append(key)
                ans_l.append(val)
            if ans_l[0]==ans_l[1] and ans_l[0]==ans_l[2]:
                if num_l[0]^num_l[1]==num_l[2]:
                    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

long GCD(long a,long b);

int main(void){
    long a,b;
    long gcd,lcm;
    while(cin>>a>>b){
        gcd=GCD(a,b);
        lcm=a*b/gcd;
        cout<<gcd<<" "<<lcm<<endl;
    }
    return 0;
}


long GCD(long a,long b){
    if(min(a,b)==0){return max(a,b);}
    return GCD(min(a,b),max(a,b)%min(a,b));
}



Measured memory_bytes: 3076
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, h, w, a, b, sum = 0, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    sum += a;
    if(ans < a) ans = a;
  }
  printf("%s", ans < sum - ans ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a,b,c,k = NextInts()

ans = 0
ans += min(a,k)
k-=a
k-=b
ans -= min(max(0,k), c)
print(ans)


Measured memory_bytes: 9232
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,d; cin >> n >> d;
	d *= d;
	ll ans = 0;
	rep(i,n){
		ll x,y; cin >> x >> y;
		if(x*x + y*y <= d) ans++;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int ans = n;
    vvint a(n,vint(m));
    REP(i,n) {
        REP(j,m) {
            cin >> a[i][j]; 
            a[i][j]--;
        }
    }
    vint sp(m,1);
    int rem = m;
    while(rem>=1){
        vint cnt2(m,0);
        REP(i,n){
            REP(j,m){
                if(sp[a[i][j]]==1){
                    cnt2[a[i][j]]++;
                    break;
                }
            }
        }
        int tmp = 0;
        REP(i,m){
            tmp = max(tmp,cnt2[i]);
        }
        ans = min(ans,tmp);
        vint cnt(m,0);
        REP(i,n){
            REP(j,m){
                if(sp[a[i][j]]==1){
                    cnt[a[i][j]]++;
                    break;
                }
            }
        }
        int t = -1;
        int c = -1;
        REP(i,m){
            if(cnt[i]>c){
                c=cnt[i];
                t=i;
            }
        }
        sp[t]=0;
        //cout << rem << " " << t << endl;
        rem--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int s[101];

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

	sort(s,s+n);
	ll sum = 0;
	int flag = 0;

	rep(i,n) sum += s[i];
	int j = 0;
	if(sum%10 != 0){
		cout << sum << endl;
		return 0;
	}
	else if(sum%10 == 0){
			for(int i = 0; i<n; i++){
				if(s[i] %10 != 0){
					sum -=s[i];
					break;
				}
				if(i==n-1){
					sum = 0;
					break;
				}
			}
	}
	cout << sum << endl;


	return 0;
}

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

int main(void){
    int n;
    string s ="";
    cin>>n;
    if(n!=0){
        while(n!=0){
            if(n%2==0){
                s="0"+s;
                n = -n/2;
            }else{
                s="1"+s;
                n= -(n-1)/2;
            }
        }
    }else{
        s="0";
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
from collections import Counter as C

_ = input()

b = []
for k, v in C([int(x) for x in input().split()]).items():
    b.extend([k] * (v // 2))
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)

Measured memory_bytes: 22204
MAX_N_LENGTH = 100
 
x, nums_length = gets.chomp.split(' ').map{|i| i.to_i}
 
if nums_length == 0
  puts x
  exit
end
 
nums = gets.chomp.split(' ').map{|i| i.to_i}
 
answer = 0
x_abs = MAX_N_LENGTH + 1
(0...x).reverse_each do |i|
  unless nums.include?(i)
    if (x - i).abs < x_abs
      x_abs = (x - i).abs
      answer = i
    end
  end
end
 
(x..(MAX_N_LENGTH+1)).each do |i|
  unless nums.include?(i)
    if (x - i).abs < x_abs
      x_abs = (x - i).abs
      answer = i
    end
  end
end
 
if MAX_N_LENGTH + 1 == x_abs
  puts x
else
  puts answer
end

Measured memory_bytes: 14316
import sys

for i in sys.stdin:
    scores = list(map(int, i.split()))
    m = scores[0]
    f = scores[1]
    r = scores[2]
    if m == f == r == -1:
        break
    elif (m == -1) or (f == -1):
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= (m + f) < 80:
        print("B")
    elif 50 <= (m + f) < 65:
        print("C")
    elif 30 <= (m + f) < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
ll f(ll a, ll c, ll d) {
	ll p = a / c, q = a / d, r = a / (c / __gcd(c, d) * d);
	return a - (p + q - r);
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	ll now = max(1LL, a[0]), ans = (now == a[0] ? 0 : 1 - a[0]);
	ll b[n];
	b[0] = now;
	rep(i, n - 1) {
		now += a[i + 1];
		if (now * b[i] < 0)
			b[i + 1] = now;
		else if (b[i] > 0) {
			now = -1, b[i + 1] = now;
			ans += abs(b[i] + 1 + a[i + 1]);
		} else {
			now = 1, b[i + 1] = now;
			ans += abs(1 - b[i] - a[i + 1]);
		}
	}
	now = min(-1LL, a[0]);
	ll ans1 = (now == a[0] ? 0 : 1 + a[0]);
	b[0] = now;
	rep(i, n - 1) {
		now += a[i + 1];
		if (now * b[i] < 0)
			b[i + 1] = now;
		else if (b[i] > 0) {
			now = -1, b[i + 1] = now;
			ans1 += abs(b[i] + 1 + a[i + 1]);
		} else {
			now = 1, b[i + 1] = now;
			ans1 += abs(1 - b[i] - a[i + 1]);
		}
	}
	cout << min(ans, ans1) << endl;
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#define LL long long
std::string X;
int main() {
	std::cin >> X;
	std::stack<char> S;
	for (int i = 0; i < X.size(); i++) {
		if (X[i] == 'S') {
			S.push(X[i]);
		}
		else if(S.size()){
			if (S.top() == 'S') {
				S.pop();
			}else{
				S.push(X[i]);
			}
		}
		else {
			S.push(X[i]);
		}
	}
	std::cout << S.size() << std::endl;
	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    char c;cin>>c;
    cout<<(char)((int)c+1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int ,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
ll mod =1e9+7;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}


ll modpow(ll a,ll n, ll mod)
{
    ll res = 1;
    while(n>0)
    {
        if (n%2==1)
        {
            res = res * a % mod;
        }
        a = a * a % mod;
        n/=2;
    }
    return res;
}

int bin_ser(int *a,int n,int x)
{
    int l=0;
    int h=n-1;
    while(l<=h)
    {
        int mid=l+((h-l)/2);
        if(a[mid]==x)
        {
          return mid;
        }
        else if(a[mid]<x)
        {
            l=mid+1;
        }
        else
        {
            h=mid-1;
        }
    }
}

int main()
{
    __FastIO;

        string s;
        cin>>s;
        ll p=0;
        f(i,s.length())
        {
            p+=(s[i]-'0');
        }
        if(p%9==0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

    return 0;
}




Measured memory_bytes: 3744
#define _USE_MATH_DEFINES
//#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <list>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1000000007
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef priority_queue<P, vector<P>, greater<P> > minPQ;
struct edge {int to,cost;};
//const int SIZE = 1<<18;

vector<P> G[110];
int d[110][110];
//int list[110][110];
bool is[110][110];
bool ok[110];

void dijk(int s,int t) {
	if(!ok[s]) {
	REP(i,110) d[s][i] = INF;
	d[s][s] = 0;
	minPQ que;
	que.push(P(0,s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		if(d[s][p.second] < p.first) continue;
		int u = p.second;
		REP(i,G[u].size()) {
			int v = G[u][i].first;
			int cost = G[u][i].second;
			if(d[s][v] > cost+d[s][u]) {
				d[s][v] = cost+d[s][u];
				que.push(P(d[s][v],v));
			}
		}
	}
	ok[s] = true;
}
	queue<int> Q;
	Q.push(t);
	while(!Q.empty()) {
		int u = Q.front();
		Q.pop();
		REP(i,G[u].size()) {
			int v = G[u][i].first;
			int cost = G[u][i].second;
			if((d[s][u]-d[s][v])==cost) {
				is[u][v] = true;
				is[v][u] = true;
				Q.push(v);
			}
		}
	}
}

int main() {
	int N,M;
	cin >> N >> M;
	REP(i,M) {
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
	}
	for(int i = 1;i <= N;i++) {
		for(int j = i+1;j <= N;j++) {
			dijk(i,j);
		}
	}
	int cnt = 0;
	REP(i,N) {
		REP(j,N) {
			if(is[i+1][j+1]) cnt++;
		}
	}
	cnt /= 2;
	cout << M-cnt << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using System.Runtime.CompilerServices;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(1.0 / a.Sum(x => 1 / (double)x));
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


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

#define LL long long
#define hell 1000000007
#define PI acos(-1.0)



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

LL n;cin>>n;

LL sv = 26, ct = 1, sm=26, tmp=0;
while(sm<n)
{
    sv = sv*26;
    tmp = sm;
    sm+=sv;

    ct+=1;
}
n--;
n-=tmp;
string ans;
sv = 1;
for(int i=0;i<ct-1;i++)
{
   sv*=26;
}
for(int i=0;i<ct;i++)
{
    for(int j=26;j>=1;j--)
    {
        if((j-1)*sv<=n)
        {
            char c = 'a'+j-1;
            ans.push_back(c);
            n-=(j-1)*sv;
            break;
        }
    }
    sv/=26;
}

cout<<ans;



return 0;
} 

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

const int N=1e5+5;

struct Edge { int v; Edge *nxt; } edge[N<<1],*head[N];
int n,fa[N],Size[N],per[N],f1[N],f2[N],cnt_edge,cnt_per,max_dist;

inline void addedge(int u,int v){
    edge[++cnt_edge].v=v; Size[u]++;
    edge[cnt_edge].nxt=head[u],head[u]=&edge[cnt_edge];
}

inline void Diam_DFS(int now,int from,int dist,int &max_dist,int &t){
    fa[now]=from;
    if (dist>max_dist) max_dist=dist,t=now;
    for (register Edge *u=head[now];u;u=u->nxt)
        if (u->v!=from) Diam_DFS(u->v,now,dist+1,max_dist,t);
}

inline pair <int,int> Diameter(){
    int s=1,t=1;
    Diam_DFS(s,0,0,max_dist=0,t);
    s=t;
    Diam_DFS(s,0,0,max_dist=0,t);
    return make_pair(s,t);
}

int main(){
    scanf("%d",&n);
    for (register int i=1,u,v;i<n;i++)
        scanf("%d%d",&u,&v),addedge(u,v),addedge(v,u);
    pair <int,int> p=Diameter();
    int s=p.second,t=p.first,past=0;
    while (1){
        cnt_per++;
        for (register Edge *u=head[s];u;u=u->nxt)
            if (Size[u->v]>1&&u->v!=fa[s]&&u->v!=past){ printf("-1\n"); return 0; }
            else if (u->v!=fa[s]&&u->v!=past) per[cnt_per]++;
        if (s==t) break;
        past=s,s=fa[s];
    }
    for (register int i=1,sum1=1,sum2=1;i<=cnt_per;i++,sum1++,sum2++){
        for (register int j=1;j<=per[i];j++,sum1++)
            f1[sum1]=sum1+1; f1[sum1]=sum1-per[i];
        for (register int j=1;j<=per[cnt_per-i+1];j++,sum2++)
            f2[sum2]=sum2+1; f2[sum2]=sum2-per[cnt_per-i+1];
    }
    for (register int i=1;i<=n;i++)
        if (f1[i]<f2[i]){ for (register int j=1;j<=n;j++) printf("%d ",f1[j]); putchar('\n'); return 0; }
        else if (f2[i]<f1[i]){ for (register int j=1;j<=n;j++) printf("%d ",f2[j]); putchar('\n'); return 0; }
    for (register int j=1;j<=n;j++) printf("%d ",f1[j]); putchar('\n');
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    ll ans = 0;
    REP(i,N){
        int x = i+1;
        if(!(x%3 == 0 || x%5 == 0)) ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int ans = n;
    for(int i = 0; i <= n; i++){
        int tmp = 0;
        int m = i;
        while(m > 0){
            tmp += m % 6;
            m /= 6;
        }
        m = n - i;
        while(m > 0){
            tmp += m % 9;
            m /= 9;
        }
        if(ans > tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  int a, b; cin >> a >> b;
  int cur = 1;
  int cnt = 0;
  while(true) {
    if(cur * a >= b) {
      break;
    }
    cur *= a;
  }
  int has = (cur - 1) / (a - 1);
  for(int i = 0; i <= 10; i++) {
    if(i * (a - 1) >= b - cur) {
      cout << has + i << '\n';
      return 0;
    }
  }
}

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


def trial_division(n):
    #２で割った因数を格納するリスト
    factor = []
    #2で割れなくなった時点でストップ
    while n % 2 == 0:
        n //= 2    # ２で割った商を切り捨てて代入
        factor.append(2)
    #nが一度も２で割れなかったらそのまま返す
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


count = 0
for i in a:
    temp = trial_division(i)
    count += temp.count(2)

print(count)

Measured memory_bytes: 42220
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        int x, y, s, ans = 0;
        cin >> x >> y >> s;
        if (!x) break;
        loop (1010, ia) loop (1010, ib) {
            int a = ia+1, b = ib+1;
            if (a * (100 + x) / 100 + b * (100 + x) / 100 != s) continue;
            ans = max(a * (100 + y) / 100 + b * (100 + y) / 100, ans);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
# 初期入力
import sys
#input = sys.stdin.readline
K = int(input())
A,B = (int(x) for x in input().split())

distance =0
kekka ="NG"
for i in range(10):
    distance =K *(i + A//K)
    if A<=distance and distance <=B:
        kekka ="OK"
        #print(distance)
        break
print(kekka)

Measured memory_bytes: 9180
def Binary_Search_Small_Count(A,x,equal=False,sort=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()

    if A[0]>x or ((not equal) and A[0]==x):
        return 0

    L,R=0,len(A)
    while R-L>1:
        C=L+(R-L)//2
        if A[C]<x or (equal and A[C]==x):
            L=C
        else:
            R=C

    return L+1

def Binary_Search_Equal_Count(A,x,sort=False):
    """2分探索によって,xの個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"を超える"がx"以上"になる
    """

    if sort:
        A.sort()

    if x<A[0] or A[-1]<x:
        return 0

    X=Binary_Search_Small_Count(A,x,equal=True)
    Y=Binary_Search_Small_Count(A,x,equal=False)
    return X-Y
#================================================
N=int(input())
A=["*"]+list(map(int,input().split()))

B=[0]*N
for j in range(1,N+1):
    B[j-1]=j-A[j]
B.sort()

K=0
del A[0]
for i in range(1,N+1):
    K+=Binary_Search_Equal_Count(B,i+A[i-1],False)
print(K)


Measured memory_bytes: 104004
#include<cstdio>

#define MOD 1000000007

int arr[2005];

int main()

{

	int n,k;	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;++i)

	{

		scanf("%d",&arr[i]);

	}

	long long ans=0;

	for(int i=1;i<=n;++i)

	{

		long long cnt1=0,cnt2=0;

		for(int j=i+1;j<=n;++j)

		{

			if(arr[i]>arr[j])

			{

				++cnt1;

			}

		}

		for(int j=1;j<i;++j)

		{

			if(arr[i]>arr[j])

			{

				++cnt2;

			}

		}

		if(k%2==0)

		{

			ans=(ans+cnt1*(k+1)%MOD*(k/2))%MOD;

			ans=(ans+cnt2*(k-1)%MOD*(k/2))%MOD;

		}

		else

		{

			ans=(ans+cnt1*k%MOD*((k+1)/2))%MOD;

			ans=(ans+cnt2*k%MOD*((k-1)/2))%MOD;

		}

		

	}

	printf("%lld",ans);

	return 0;

}

Measured memory_bytes: 128
using System;

class Program {
    static void Main(string[] args) {

        string[] str1 = Console.ReadLine().Split(' ');
        string[] str2 = Console.ReadLine().Split(' ');

        int H = int.Parse(str1[0]);
        int W = int.Parse(str1[1]);
        int h = int.Parse(str2[0]);
        int w = int.Parse(str2[1]);

        int blackNum = 0;

        blackNum = ((h * W) + (w * H) - (h * w));

        Console.WriteLine((H * W) - blackNum);



    }
}

Measured memory_bytes: 11092
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
   
    if op=='?':
        break

    else:
        if op=='+':
            print(a+b)
        elif op=='-':
            print(a-b)
        elif op=='*':
            print(a*b)
        else:
            print(a//b)


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

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

int main(){
  int h,w;
  string g[10];
  int dx[] = {0,1,1,1,0,-1,-1,-1},dy[] ={-1,-1,0,1,1,1,0,-1};
  int lm;

  while(cin>> h >> w &&(h||w)){
    for(int i=0;i<h;i++)cin >> g[i];

    map<string,int> m;
    vector<string> v;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<8;k++){
	  string tmp;
	  tmp += g[i][j];
	  int sx = j,sy = i;
	  if(k&1)lm = lcm(h,w);
	  else if(!(k%4))lm = h;
	  else lm = w;
	  for(int t=1;t<lm;t++){
	    sx = (sx+w+dx[k])%w;
	    sy = (sy+h+dy[k])%h;
	    tmp += g[sy][sx];
	    m[tmp]++;
	    v.push_back(tmp);
	  }
	}
    string ans = v[0];
    for(int i=1;i<(int)v.size();i++)
      if(m[v[i]]>1)
	if(ans.size()<v[i].size() || (ans.size()==v[i].size()&&ans>v[i]))ans = v[i];
    if(m[ans]>1)cout << ans << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int i=0;
  for(;i<3;i++){
    
    if(s[i]=='7'){
      cout<<"Yes"<<endl;;
      break;
    }
  }
  if(i==3){
cout<<"No"<<endl;;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n,k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;
	char key = s[k-1];
	for (int i=0; i < n; i++) {
		if ( s[i] != key ) {
			s.replace(i,1,"*");
		}
	}
	cout << s;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if (a < b)
	{
		if (b < c)
			printf("%d %d %d\n", a, b, c);
		else if (a < c)
			printf("%d %d %d\n", a, c, b);
		else
			printf("%d %d %d\n", c, a, b);
	}
	else
	{
		if (a < c)	
		printf("%d, %d %d\n", b, a, c);
	else if (b < c)
		printf("%d %d %d\n", b, c, a);
	else
		printf("%d %d %d\n", c, b, a);
	}
	return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int resA = N * A;
    cout << (resA > B ? B : resA) << endl;
}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            sum += A[i];
        }
        long[] s = new long[N+1];
        for (int i = 0; i < N; i++) {
            s[i+1] = s[i] + A[i];
        }
        long ans = Long.MAX_VALUE;
        for (int i = 1; i < N; i++) {
            ans = Math.min(ans, Math.abs(sum-s[i]-s[i]));
        }
        System.out.println(ans);
    }
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int t=0;
  while(a>0 && c>0){
    if(t%2==0) c-=b;
    else a-=d;
    t++;
  }
  if(a>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int a = 0;
  for (int i = 9; i >= 1; i--){
    if(n % i == 0){
      a = i;
      break;
    }
  }
  if(a > 0 && n / a < 10){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
long long int mod = 1e9+7;

int main(){
  vector<int> a(5);
  for(int i=0; i<5; i++) cin >> a[i];
  int k; cin >> k;
  for(int i=0; i<5; i++) {
    for(int j=0; j<5; j++) {
      if(abs(a[i]-a[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


// EOF


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	if (a != b && b != c && c != a)ans = 3;
	else if (a == b && b == c && c == a)ans = 1;
	else ans = 2;
	cout << ans << endl;
	return 0;
}

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

int main() {
    long long N, max=0, i, count=0;
    vector<long long> A(200000);
    
    cin >> N;
    
    for (i=0; i<N; i++) {
        cin >> A.at(i);
    }
    max = A.at(0);
    
    
    for (i=1; i<N; i++) {
        if (A.at(i)>max){
            max = A.at(i);
        } else {
            count += max-A.at(i);
        }
    }
    
    cout << count;
}

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

using namespace std;

int n,k;

int sssp(int s, int g,vector<vector<int> > ship){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
  vector<bool> used(n+1,false);

  q.push(make_pair(0,s));
  while(!q.empty()){
    int cost=q.top().first,now=q.top().second; q.pop();
    used[now]=true;
    if(now==g) return cost;

    for(int i=1;i<=n;++i){
      if(ship[now][i]==1000005) continue;
      int ncost=cost+ship[now][i],nexto=i;
      if(used[nexto]==false) q.push(make_pair(ncost,nexto));
    }
  }
  return -1;
}

int main(){
  while(cin >> n >>k && (n || k)){
    vector<vector<int> > ship(n+1,vector<int>(n+1,1000005));
    while(k--){
      int info; cin >> info;
      if(info==0){
	int a,b; cin >> a >> b;
	cout << sssp(a,b,ship) << endl;
      }else{
	int c,d,e; cin >> c >> d >> e;
	ship[c][d]=ship[d][c]=min(ship[c][d],e);
      }
    }
  }
  
  return 0;
}



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

void solve(long long a, long long b)
{
    long long larger, smaller;
    if (a >= b)
    {
        larger = a;
        smaller = b;
    }
    else
    {
        larger = b;
        smaller = a;
    }

    for (int i = 0; i < larger; i++)
    {
        cout << smaller;
    }
    cout << endl;
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 3756
import collections as coll

n = int(input())
v = list(map(int,input().split()))
even = []
odd = []

for i in range(n):
	if i % 2 == 0:
		even.append(v[i])
	else:
		odd.append(v[i])

oddc = coll.Counter(odd).most_common()[:2]
evenc = coll.Counter(even).most_common()[:2]

if(len(oddc) == 1):
	oddc.append((0,0))
if(len(evenc) == 1):
	evenc.append((0,0))


if(oddc[0][0] != evenc[0][0]):
	print(n - oddc[0][1] - evenc[0][1])
else:
	print(min(n-oddc[0][1]-evenc[1][1],n-oddc[1][1]-evenc[0][1]))

Measured memory_bytes: 17500
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,r,n;
	cin>>n>>k;
	char ar[n+1];
	cin>>ar;

	vector<ll> vc;
	vc.ps(0);
	l=0; char c=ar[0];
	for(i=0;i<n;i++){
		if(ar[i]==c){
			l++;
		}
		else{
			vc.ps(l);
			l=1; c=ar[i];
		}
	}
	vc.ps(l);
	vc.ps(0);

	ll psum[vc.size()+10]={0},ex[vc.size()+10]={0};
	for(i=1;i<=vc.size()-1;i++){
		ex[i]=max((ll)0,vc[i]-1);
		ex[i]+=ex[i-1];
	}
	j=1;
	for(i=1;i<vc.size()-1;i++){
		psum[j++]=vc[i];
	}
	for(i=1;i<j;i++){
		psum[i]+=psum[i-1];
		//cout<<psum[i]<<" ";
	}//cout<<endl;

	k=2*k+1; ll mx=0;
	//cout<<j<<" # "<<k<<endl;
	if(k>=j){
		cout<<(psum[j-1]-1)<<endl;
	}
	else{
		for(i=0;i+k<j;i++){
		//	cout<<i+k<<" "<<i<<" "<<psum[i+k]-psum[i]<<endl;
			mx=max(mx,psum[i+k]-psum[i]-1+ex[i]+ex[vc.size()-1]-ex[i+k]);
		}
		cout<<mx;
	}
	return 0;
}

Measured memory_bytes: 2804