akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
    long long  a, b, gcd, lcm, t, x, y;
    while((scanf("%lld %lld", &a, &b))!=EOF){
            x=a;
            y=b;
        if(a==0) gcd=b;
        else if(b==0) gcd=b;
        else{
            while(b!=0){
                t=b;
                b=a%b;
                a=t;
            }
          gcd=a;
        }
        lcm=(x*y)/gcd;
        printf("%lld %lld\n",gcd,lcm);
    }
    return 0;
}

Measured memory_bytes: 596
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      int[] input=new int[N];
      for (int i=0;i<N;i++){
        input[i]=int.Parse(Console.ReadLine());
      }
        int dif=input[1]-input[0];

        int min=input[0];
      for(int i=1;i<=N-1;i++){
  if(dif<=input[i]-min){
dif=input[i]-min;
 }        
if(input[i]<min){
min=input[i];
}
      
        
      }
      Console.WriteLine(dif);
     
    }
    
  }

}



Measured memory_bytes: 20280
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

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

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int a; cin >> a;
  cout << (a + a * a + a * a * a) << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




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

using namespace std;
using llint = long long;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

int x, t;
double ans;

int main() {
    // Input
    cin >> t >> x;
    ans = (double)t/x;

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

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	int d = sc.nextInt();
	int n = sc.nextInt();
	int[] t = new int[d];
	for(int i=0; i<d; i++) t[i] = sc.nextInt();
	int[] a = new int[n];
	int[] b = new int[n];
	int[] c = new int[n];
	for(int i=0; i<n; i++){
	    a[i] = sc.nextInt();
	    b[i] = sc.nextInt();
	    c[i] = sc.nextInt();
	}

	int INF = -1;

	int[][] dp = new int[d][n];
	for(int i=0; i<d; i++) Arrays.fill(dp[i], INF);

	for(int i=0; i<n; i++){
	    if(a[i]<=t[0] && t[0]<=b[i]) dp[0][i] = 0;
	}

	for(int i=1; i<d; i++){
	    for(int j=0; j<n; j++){
		if(!(a[j]<=t[i] && t[i]<=b[j])) continue;
		for(int k=0; k<n; k++){
		    if(dp[i-1][k]==INF) continue;
		    dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + Math.abs(c[k]-c[j]));
		}
	    }
	}

	//for(int i=0; i<d; i++) System.out.println(Arrays.toString(dp[i]));

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

	System.out.println(ans);
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

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

int main()
{   
    int N; cin >> N;
    long A[100005];
    REP(i, N) cin >> A[i];
    long ans = 1l;
    long sai = 1000000000000000000;
    bool ok = true;
    sort(A, A+N);
    REP(i, N){
        if(A[i] == 0l){
            ans = 0l;
            break;
        }
        if(sai/ans < A[i]){
            ok = false;
            break;
        }
        ans *= A[i];
        //cout << ans << endl;
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}






Measured memory_bytes: 4336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            string[] l = Console.ReadLine().Split(' ');
            int[] ll = new int[n];
            int i;
            for (i = 0; i < n; i++) ll[i] = int.Parse(l[i]);
            Array.Sort(ll);
            Array.Reverse(ll);
            int total = 0;
            for (i = 0; i < k; i++) total = total + ll[i];
            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, M, Q;
int b[51], c[51], d[51];
int he[11], ne[51];
int are[11][21];
int kotae, goukei;
void keisan(int n, int mae) {
	if (n == N) {
		chmax(kotae, goukei);
		return;
	}
	for (int to = he[n]; to; to = ne[to]) {
		are[b[to]][mae + c[to]] += d[to];
	}
	goukei += are[n][mae];
	keisan(n + 1, mae);
	goukei -= are[n][mae];
	for (int to = he[n]; to; to = ne[to]) {
		are[b[to]][mae + c[to]] -= d[to];
	}

	for (int i = mae + 1; i <= M; i++) {
		if (are[n][i]) {
			for (int to = he[n]; to; to = ne[to]) {
				are[b[to]][i + c[to]] += d[to];
			}
			goukei += are[n][i];
			keisan(n + 1, i);
			goukei -= are[n][i];
			for (int to = he[n]; to; to = ne[to]) {
				are[b[to]][i + c[to]] -= d[to];
			}
		}
	}
}

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


	scanf("%d %d %d", &N, &M, &Q);
	rep1(i, Q) {
		int a;
		scanf("%d %d %d %d", &a, b + i, c + i, d + i);
		a--;
		b[i]--;
		ne[i] = he[a];
		he[a] = i;
	}

	keisan(0, 1);

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

	Would you please return 0;
}

Measured memory_bytes: 1704
#include<stdio.h>
int main(void)
{
    char s[21];
    char a[21];
    int i;
    scanf("%s",s);
    for(i=0;i<21;i++){
        if(s[i]=='\0'){
            i-=1;
            break;
        }
    }
    for(;i>=0;i--){
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);

    ll X;
    cin >> X;
    ll res = 2 * (X / 11);
    if (X % 11 > 6)
        res += 2;
    else if (X % 11)
        res++;
    cout << res << "\n";
}

Measured memory_bytes: 256
A, B, C = map(int,input().split())

empty = [0] * 3
count = 0
if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    print(-1) 
elif (A % 2 != 0) or (B % 2 != 0) or (C % 2 != 0):
    print(0)
else:
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0: 
        count += 1
        A_ = A//2
        B_ = B//2
        C_ = C//2
        A = B_ + C_
        B = A_ + C_
        C = A_ + B_

    print(count)

Measured memory_bytes: 9208
N = input()
a = int(len(N))
n = int(N)
ans = 0
if (a//2)*2 != a:
    for j in range(0,a-1,2):
        ans += 9 * (10**j)
    ans += n - 10**(a-1) + 1
else:
    for j in range(0,a,2):
        ans += 9 * (10**j)
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String[] judge = new String[n];
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    for (int i = 0;i < n;i++) {
      judge[i] = scan.next();
      if (judge[i].equals("AC")) {
        AC += 1;
      }
      else if (judge[i].equals("WA")) {
        WA += 1;
      }
      else if (judge[i].equals("TLE")) {
        TLE += 1;
      }
      else{
        RE += 1;
      }
    }
    System.out.println("AC x " + AC);
    System.out.println("WA x " + WA);
    System.out.println("TLE x " + TLE);
    System.out.println("RE x " + RE);
  }
}


Measured memory_bytes: 64600
#pragma GCC optimize("Ofast")

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
	cout<<"\n";
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	string s;
	cin>>s;
	int cnt = 0, ans = 0;
	rep(i, s.length()){
		if(s[i] == 'R')
			cnt++;
		else
			cnt = 0;
		ans = max(ans, cnt);
	}
	cout<<ans<<endl;
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
int main(){
  char s[100001];
  scanf("%s",s);
  int a=strlen(s),b[26]={0},c=-1;
  for(int i=0; i<a; i++){
    b[s[i]-'a']++;
  }
  for(int i=0; i<26; i++){
    if(b[i]==0){c=i;break;}
  }
  if(c==-1){
    printf("None");
  }else{
    printf("%c",'a'+c);
  }
  return 0;}


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

int main(void){
    char s[27];
    int i, j, flag=0, len;
    
    
    scanf("%s", &s);
    //printf("%s",s);
    
    len=strlen(s);
    
    for(i=0; i<len; i++){
        for(j=0; j<len; j++){
            if(i==j)continue;
            if(s[i]==s[j]){
                printf("no\n");
                flag=1;
                break;
            }
        }
        if(flag==1) break;
    }
    
    if(flag==0) printf("yes\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int i, j, n, a[100], min, swap, ans = 0;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);
    
  for(i = 0; i < n-1; i++){
    min = i;
    for(j = i; j < n; j++){
      if(a[min] > a[j])
        min = j;
    }
    
    if(i != min){
      swap = a[min];
      a[min] = a[i];
      a[i] = swap;
    
      ans++;
    }
  }
  
  for(i = 0; i < n-1; i++)
    printf("%d ", a[i]);
    
  printf("%d\n", a[n-1]);
  
  printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

enum STATE {
  TATE,
  YOKO,
};

int main() {
  mint ans = 1;

  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  STATE prev = TATE;

  int pos = 0;
  if (s1[0] == s2[0]) {
    ans = 3;
    pos += 1;
    prev = TATE;
  } else {
    ans = 6;
    pos += 2;
    prev = YOKO;
  }

  while (pos < n) {
    if (s1[pos] == s2[pos]) {
      if (prev == TATE) ans *= 2;
      pos += 1;
      prev = TATE;
    } else {
      if (prev == TATE) ans *= 2;
      else ans *= 3;
      pos += 2;
      prev = YOKO;
    }
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    int cnt = 0;
    ll ans = 1;
    for(int i=0; i<n; i++){

        // 1, 3, 5, ... と置けないとき
        if(x[i] < cnt * 2 + 1){
            ans *= (cnt + 1);
            ans %= MOD;
            cnt--;
        }
        cnt++;
    }

    while(cnt > 0){
        ans *= cnt--;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>>a(n);
    rep(i,n){
        a[i].resize(n-1);
        rep(j,n-1){
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(),a[i].end());
    }
    int cnt = 0;
    set<int>st;
    rep(i,n)st.insert(i);
    for(int ans = 1; ; ans++){
        bool f = false;
        set<int>st2;
        for(int i : st){
            if(a[i].size() == 0)continue;
            int s = a[i].back();
            if(s < 0 or a[s].size() == 0)continue;
            int t = a[s].back();
            if(t == i)a[i].back() = a[s].back() = -1, cnt++, f = true,st2.insert(i), st2.insert(s);
        }
        for(int i : st2)a[i].pop_back();
        st = st2;
        if(cnt == n * (n - 1) / 2){
            cout << ans << endl;
            return 0;
        }
        if(!f){
            cout << -1 << endl;
            return 0;
        }
    }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector <int>> graph(n);
    vector<vector <int>> cost(n);
    vector<int> color(n, -1);
    for(int i=0; i<n-1; i++){
        int u, v;
        long w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
        cost[u].push_back(w%2);
        cost[v].push_back(w%2);
    }

    queue<int> que;
    color[0] = 0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int i=0; i<graph[v].size(); i++){
            if(color[graph[v][i]] != -1) continue;
            color[graph[v][i]] = (color[v] + cost[v][i]) % 2;
            que.push(graph[v][i]);
        }
    }

    for(int i=0; i<n; i++){
        cout << color[i] << endl;
    }

    return 0;
}


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

int main(){
	int time[5],unk[5],min=1000,minmenu,ans=0;
	cin>>time[0];
	cin>>time[1];
	cin>>time[2];
	cin>>time[3];
	cin>>time[4];
	unk[0]=time[0]%10;
	unk[1]=time[1]%10;
	unk[2]=time[2]%10;
	unk[3]=time[3]%10;
	unk[4]=time[4]%10;
	for(int i=0;i<5;i++){
        	if(min>unk[i] && unk[i]!=0){
                	min=unk[i];
			minmenu=i;
		}
	}
	for(int i=0;i<5;i++){
        	if(i!=minmenu){
                	if(unk[i]==0){
				ans+=time[i];
			}else{
                        	ans+=time[i]+(10-unk[i]);
			}
		}
	}
	ans+=time[minmenu];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

template <typename U>
map<U, int> doPrimeFactorization(U n) {

  map<U, int> rs;
  U a = 1;

  while (!(n & 1)) {
    n >>= 1;
    rs[2]++;
  }

  for (U i = 3; i * i <= n; /*NOP*/) {
    auto q = n / i;
    auto r = n - i * q;
    if (r == 0) {
      rs[i]++;
      n = q;
    }
    else {
      i += 2;
    }
  }

  if (n > 1) {
    rs[n]++;
  }

  return move(rs);
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 N;
  cin >> N;

  auto pf = doPrimeFactorization(N);

  i64 result = 0;
  for (auto p : pf) {
    for (int n = 1; n <= p.second; n++) {
      p.second -= n;
      result++;
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>kaza(M);
  for(int i=0;i<M;i++){
    cin>>kaza.at(i);
  }
  int sum=0;
  for(int j=0;j<M;j++){
    sum+=kaza.at(j);
  }
  if(sum>N){
    cout<<"-1"<<endl;
  }
  else{
    cout<<N-sum<<endl;
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    int kai=1,ans=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==kai){
            ans++;
            kai++;
        }
    }
    if(ans==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n-ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i * 108 / 100 == n) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << ":(" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=10000010;
struct edge{
	int la,b;
}con[N<<1];
int tot,fir[N];
void add(int from,int to)
{
	con[++tot].la=fir[from];
	con[tot].b=to;
	fir[from]=tot;
}
int val[N],n;
bool vis[N],ans[N];
void dfs(int pos)
{
	vis[pos]=1;
	ans[pos]=0;
	for(int i=fir[pos];i;i=con[i].la)
	{
		dfs(con[i].b);
		if(ans[con[i].b]==0) ans[pos]=1;
	}
}
int main()
{
	int from,to;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&from,&to);
		if(val[from]<val[to]) add(to,from);
		if(val[to]<val[from]) add(from,to);
	}
	for(int i=1;i<=n;i++)if(!vis[i])
		dfs(i);
	for(int i=1;i<=n;i++)if(ans[i])
		printf("%d ",i);
	printf("\n");
	return 0;
}

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

int K;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2,
 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    cin>>K;

    cout<<a[K-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){ 
	int x,t;
	cin>>x>>t;
	if(x>t){
		cout<<x-t<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;cin>>n;
    int p[20];
    rep(i,n)cin>>p[i];

    int ans=0;
    rep(i,n-2){
        if((p[i]<p[i+1]) && p[i+1]<p[i+2])++ans;
        else if((p[i]>p[i+1]) && p[i+1]>p[i+2])++ans;
    }
    cout<<ans<<endl;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int q;
    cin>>q;
    int c[n]={};
    while(q--){
        int t,x,d;
        cin>>t>>x>>d;
        x--;
        if(t==1){
            c[x] += d;
        }
        else c[x] -= d;
        if(c[x] > a[x] || c[x]<0){
            cout << x+1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const ll INF=1e+15;
int n;
ll W;
ll w[110],v[110];
ll dp[110][100010];
int main(){
  scan(n);scan(W);
  int sumv=0;
  rep(i,n){
    scan(w[i]);scan(v[i]);
    sumv+=v[i];
  }
  rep(j,sumv+1){
    dp[0][j]=INF;
  }
  rep1(i,n){
    rep(j,sumv+1){
      if(j<=v[i-1]){
	dp[i][j]=min(w[i-1],dp[i-1][j]);
      }
      else{
	dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1],dp[i-1][j]);
      }
    }
  }
  bool f=true;
  for(int j=sumv;j>0;j--){
    if(dp[n][j]<=W){
      prin(j);
      f=false;
      break;
    }
  }
  if(f)prin(0);
  /* rep(i,n+1){
    rep(j,sumv+1){
      cout<<dp[i][j]<<" ";
    }
    prin('.');
    }*/

  

  
  return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void chmax(int &a, int b) {
  if (a < b) a = b;
}

void MAIN() {
  int n, w;
  cin >> n >> w;
  vector<ii> a(n);
  for (auto &i : a) {
    cin >> i.fi >> i.sc;
  }
  int minW = a[0].fi;
  for (auto &i : a) {
    i.fi -= minW;
  }
  sort(all(a), [](ii a, ii b) -> bool {
    return a.sc > b.sc;
  });
  vector<vi> f(301, vi(101, -2e9));
  f[0][0] = 0;
  int ans = 0;
  for (auto &i : a) {
    for (int k = n; k >= 1; k--) {
      if (w - minW * k < 0) continue;
      for (int j = i.fi; j <= min(w - minW * k, 300ll); j++) {
        chmax(f[j][k], f[j - i.fi][k - 1] + i.sc);
        chmax(ans, f[j][k]);
      }
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	int matrix[h][w];
	int n;
	cin >> n;

	int colors[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> colors[i];
	}
	int index = 0;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (colors[index] == 0) index++;
			if (i%2 == 0)
			{
				matrix[i][j] = index + 1;
				colors[index]--;
			}
			else
			{
				matrix[i][w - 1 - j] = index + 1;
				colors[index]--;
			}
		}
	}

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cout << matrix[i][j] << " ";
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 using namespace std;
  int n,k,i;
  int a[50]={0};
  long long s=0;
  int main()
  {
      cin>>n>>k;
      for(i=1;i<=n;i++)
      cin>>a[i];
      sort(a,a+n+1);
      for(i=1;i<=k;i++)
      s+=a[n-i+1];
      cout<<s<<endl;
      return 0;
  }

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

int main(){
    int N;
    cin >> N;
    if(N==1||N==2){
        cout << 0 << endl;
    }else if(N%2==1){
        cout << (N-1)/2 << endl;
    }else{
        cout << (N-2)/2 << endl;
    }
}


Measured memory_bytes: 256
import sys
 
input = sys.stdin.buffer.readline
 
n, m, limit = map(int, input().split())
infi = 10 ** 15
graph = [[infi] * (n + 1) for _ in range(n + 1)]
step = [[infi] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][a] = c

for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if graph[i][j] <= limit:
            graph[i][j] = 1
        elif graph[i][j] == 0:
            graph[i][j] = 0
        else:
            graph[i][j] = infi
for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])
 
 
q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    if graph[a][b] == infi:
        graph[a][b] = 0
    print(graph[a][b] - 1 if graph[a][b] != infi else -1)

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

int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;
  for (int i = 0; i < A; i++) {
	if (S[i] < '0' || '9' < S[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for (int i = A+1; i < A + B + 1; i++) {
    if (S[i] < '0' || '9' < S[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int MOD=2019;
int L,R;
int main(){
	//freopen("in","r",stdin);
	L=read(),R=read();
	if(R-L+1>=2019)
		printf("0\n");
	else{
		int ans=2020;
		for(int i=L;i<=R;i++)
			for(int j=i+1;j<=R;j++)
				if(1LL*i*j%MOD<ans)
					ans=1LL*i*j%MOD;
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w, a, b int
	fmt.Scan(&h, &w, &a, &b)

	for i := 0; i < h; i++ {
		if i < b {
			s1 := multi_string("0", a)
			s2 := multi_string("1", w-a)
			fmt.Println(s1 + s2)
		} else {
			s1 := multi_string("1", a)
			s2 := multi_string("0", w-a)
			fmt.Println(s1 + s2)
		}
	}
}

func multi_string(str string, n int) string {
	r := ""
	for i := 0; i < n; i++ {
		r = r + str
	}
	return r
}


Measured memory_bytes: 8832
N,M=map(int, input().split())
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]

AB_road=[[] for i in range(N)]
for r in AB:
    if H[r[0]-1] > H[r[1]-1]:
        AB_road[r[1]-1].append(r[0])
    elif H[r[0]-1] < H[r[1]-1]:
        AB_road[r[0]-1].append(r[1])
    else:
        AB_road[r[1]-1].append(r[0])
        AB_road[r[0]-1].append(r[1])

print(AB_road.count([]))

Measured memory_bytes: 103132
/*First observation is that little numbers should be summed up to go to above 3
 * any number above 3 is better multiplied
 * also given a set of numbers to add, the best pairs to pick are least with most since we will multiply them next
 * also if the number of numbers we are going to add is N
 * then the numbers we will add are the first N numbers given that the array is sorted
 * so we just bruteforce on N
 *
 */

#include <bits/stdc++.h>
#include <complex>

using namespace std;
typedef long long int ll;

const double PI = acos(-1);
const int N = 2e6, MOD = 1e6 + 3, LOG = 21;

ll k, mvup, toAdd;
bool chn = false;
vector<ll> v;

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%lld", &k);
	while (k % 50 != 0) {
		k++;
		mvup++;
	}
	ll N = 50;
	ll base = N - 1;
	ll needed = k / N;
	printf("%lld\n", N);
	for (int i = 0; i < N; i++) {
		v.push_back(base + needed);
	}
	toAdd = mvup;
	for (int i = 0; i < N; i++) {
		if (mvup) {
			v[i] -= N;
			mvup--;
			v[i] += (toAdd - 1);
		} else {
			v[i] += toAdd;
		}
	}
	for (int i = 0; i < N; i++) {
		printf("%lld ", v[i]);
	}
	return 0;
}


Measured memory_bytes: 256
N, A, B = (int(x) for x in input().split())
result = 0
if N <= A:
  result = N
elif N > A and N <= A+B:
  result = A
else:
  Q = N//(A+B)
  R = N%(A+B)
  P = N - Q*(A+B)
  if R<= A:
    result = Q*A + R
  else:
    result = Q*A + A
print(result)

Measured memory_bytes: 3064
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    string s;
    int n;
    cin>>n>>s;

    if(n<s.size()){
        loop(i, 0, n-1){
            cout<<s[i];
        }
        cout<<"...";
    }
    else
        cout<<s;




}



Measured memory_bytes: 3644
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)

odd=0
even=0

for i,m in c.items():
    if m%2==1:
        odd+=1
    else:
        even+=1

if even%2==0:
    print(odd+even)
else:
    print(odd+even-1)

Measured memory_bytes: 18648
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define DEBUG 1
#define ll         long long
#define REP(i, n) for (long long i = 0; i < (n); i++) 
static const ll INF = 1000000000000000000LL;
static const int MOD = 1000000007;

char tar[4] = {'A','C','G','T'};

int main(){
    string s;
    cin >> s;
    int res = 0;
    int ren = 0;
    for(int i = 0; i < s.size(); ++i)
    {
        bool flg = false;
        for(int j = 0; j < 4; ++j)
        {
            if(s[i] == tar[j])flg = true;
        }

        if(flg)++ren;
        else
        {
            res = max(res, ren);
            ren = 0;
        }
    }
    res = max(res, ren);


    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 int a,b;
 cin >> a >> b;
 if (a+b<10) cout << a+b << endl;
 else cout << "error" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
        int i,j,N,S,c=0,minj;
        int A[100];
        scanf("%d",&N);

        for (i=0; i<N; i++) {
                scanf("%d",&A[i]);
        }
        for(i=0; i<N; i++) {
                minj=i;
                for(j=i; j<N; j++) {
                        if(A[j]<A[minj]) {
                                minj=j;

                        }
                }
                S=A[i];
                A[i]=A[minj];
                A[minj]=S;
                if(A[minj]>A[i]) {
                        c++;
                }



        }

        for(i=0; i<N-1; i++) {
                printf("%d ",A[i]);
        }
        printf("%d\n",A[i]);
        printf("%d\n",c);
        return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>

int main (void)
{
	int i=1,input1,input2;
	
	do
	{
		scanf("%d %d",&input1,&input2);
		if(input1 == 0 && input2 == 0)
		{
			break;
		}
		if(input1 > input2)
		{
			printf("%d %d\n",input2,input1);
		}
		else
		{
			printf("%d %d\n",input1,input2);
		}
		i++;
	}while(i <= 10000);
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int ans=1000000000;
  vector <int> a(5);
  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
  sort(a.begin(),a.end());
  do {
    int tmp=0;
    for(int i=0;i<4;i++){
      tmp+=((a[i]+9)/10)*10;
    }
    tmp+=a[4];
    ans=min(ans,tmp);
  } while (std::next_permutation(a.begin(), a.end()));
  
  cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<ll> a(n);
	for(auto &x : a){
		cin>>x;
	}
	sort(a.begin(), a.end());
	if(a[0] == 0){
		cout<<0<<endl;
		exit(0);
	}
	ll ans = 1;
	ll tmp;
	for(auto x : a){
		if(__builtin_mul_overflow(ans, x, &tmp)){
			cout<<-1<<endl;
			exit(0);
		}
		ans = ans*x;
	}
	if(ans > 1000000000000000000LL){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}


	return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void)
{
  int cup[3] = {1, 0, 0};
  char a, b, dumy;

  while(cin >> a >> dumy >> b) {

    if(a == 'A' && b == 'B') swap(cup[0], cup[1]);
    if(a == 'A' && b == 'C') swap(cup[0], cup[2]);
    if(a == 'B' && b == 'A') swap(cup[1], cup[0]);
    if(a == 'B' && b == 'C') swap(cup[1], cup[2]);
    if(a == 'C' && b == 'A') swap(cup[2], cup[0]);
    if(a == 'C' && b == 'B') swap(cup[2], cup[1]);
    if(a == 'A' && b == 'A') swap(cup[0], cup[0]);
    if(a == 'B' && b == 'B') swap(cup[1], cup[1]);
    if(a == 'C' && b == 'C') swap(cup[2], cup[2]);
    
    //cout << cup[0] << ' ' << cup[1] << ' ' << cup[2] << endl;
  }
  if(cup[0] == 1) cout << 'A' << endl;
  else if(cup[1] == 1) cout << 'B' << endl;
  else if(cup[2] == 1) cout << 'C' << endl;
  //else cout << "error happened" << endl;
  return 0;
}

Measured memory_bytes: 0
use v5.18;
use warnings;

chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
my @s = split '', $s;
map {$s[$_] = pack("C", (unpack("C", $s[$_]) + $n) % unpack("C", "A") % 26 + unpack("C", "A"))} (0..@s-1);
say join('', @s);

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    // 500円玉の数
    int a = sc.nextInt();
    // 数
    int b = sc.nextInt();

    if (500 * a >= b) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    long long A[N];
    cin>>A[0];
    int X=0;
    long long ans=1;
    for(long long i=1;i<N;i++){
        cin>>A[i];
        if(X==0){
            if(A[i-1]>A[i]){
                X=-1;
            }
            else if(A[i-1]<A[i]){
                X=1;
            }
        }
        else if(X==1){
            if(A[i-1]>A[i]){
                X=-0;
                ans++;
            }
        }
        else if(X==-1){
            if(A[i-1]<A[i]){
                X=0;
                ans++;
            }
        }
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N;
	cin >> N;
	
	vector<vector<ll>> a(N + 1, vector<ll>(N + 1));

	repn(i, N) {
		for (ll j = i + 1; j <= N; j++) {
			a[i][j] = 1;
			for (ll k = j - i; k % 2 == 0; k /= 2) { a[i][j]++; }
		}
	}

	repn(i, N) {
		for (ll j = i+1; j <= N; j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}

	system("PAUSE");

}


Measured memory_bytes: 2680
#include<stdio.h>
#include<stdlib.h>

#define N 500000
#define M 1000000001

void merge(int[],int,int,int);
void mergesort(int[],int,int);

int S[N],cnt=0;

int main(){
  int n,i;

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

  mergesort(S,0,n);

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

  return 0;
}

void merge(int *A,int left,int mid,int right)
{
  int n1,n2,i=0,j=0,k;
  int *L,*R;

  n1=mid-left;
  n2=right-mid;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  i=0;

  L[n1]=M;
  R[n2]=M;

  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
  free(L);
  free(R);

  return;
}

void mergesort(int *A,int left,int right)
{
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
  return;
}

Measured memory_bytes: 4476
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n-1):
	if 	a[i+1] == a[i] + 1:
		ans += c[a[i]-1]
		
print(ans + sum(b))

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, Q = LI()
    sections = []
    D = []

    for _ in range(N):
        s, t, x = LI()
        s -= x
        t -= x
        sections.append((s, t, x))

    for _ in range(Q):
        D.append(I())
    sections = sorted(sections, key=lambda x: (x[-1], x[-2]))

    section_end_ix = collections.defaultdict(list)

    filled = [-1] * Q
    for sec in sections:
        l = bisect.bisect_left(D, sec[0])
        r = bisect.bisect_left(D, sec[1])
        x = sec[2]
        # 調整 [0, 2, 5, 8, 9]、区間[1, 5]のとき、l = 1, r = 3になる。r = 2にする。
        # 調整 [0, 2, 5, 8, 9]、区間[2, 4]のとき、l = 1, r = 2になる。r = 1にする。
        r -= 1
        if r < 0:
            continue
        section_end_ix[x].append(r)
        ix = l
        while ix <= r:
            val_X = filled[ix] # 進める距離
            # 既に埋まってたら終点までスキップ
            if val_X > -1:
                _i = bisect.bisect_left(section_end_ix[val_X], ix) # section_end_ix[val_X]: 進める距離の終点のindexがのった配列
                # ix = 4、section_end_ix[val_X] = [2, 4, 7]のとき、2がかえる。

                if _i >= len(section_end_ix[val_X]):
                    # かぶってないのでよい
                    pass
                else:
                    # 終点までスキップ
                    ix = section_end_ix[val_X][_i]
            # うまってなかったら埋める
            else:
                filled[ix] = x
            ix += 1

    for x in filled:
        print(x)
main()



Measured memory_bytes: 186568
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    REP(i, 0, N) cin >> A[i];

    ll cnt[60] = {};
    REP(i, 0, N) {
        ll tmp = A[i];
        REP(j, 0, 60) {
            cnt[j] += tmp & 1;
            tmp >>= 1;
        }
    }

    ll sum[61] = {};
    REP(i, 1, 61) {
        sum[i] = sum[i - 1] + (1LL << (i - 1)) * max(cnt[i - 1], N - cnt[i - 1]);
    }

    // REP(i, 0, 10) cout << sum[i] << " ";
    // cout << endl;

    ll ans = 0, cur = 0;
    for (int i = 59; i >= 0; i--) {
        if (K & (1LL << i)) {
            ans = max(ans, cur + cnt[i] * (1LL << i) + sum[i]);
            cur += (1LL << i) * (N - cnt[i]);
        } else {
            cur += (1LL << i) * cnt[i];
        }
    }
    ans = max(ans, cur);

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

Measured memory_bytes: 4044
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

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

    let max = 10usize.pow(18);
    let result = a.iter().fold(1usize, |acc, e| acc.saturating_mul(*e));

    if result > max {
        echo!(-1);
    } else {
        echo!(result);
    }
}


Measured memory_bytes: 4560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {

	int n,m;
	cin >> n >> m;
	vvi path(n, vi(0));

	rep(i, m) {
		int a, b;
		cin >> a >> b;a--;b--;
		
		path[a].push_back(b);
	}

	bool can = false;
	rep(i, path[0].size())rep(j,path[path[0][i]].size())if(path[path[0][i]][j] == n - 1)can++;
	
	cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}

Measured memory_bytes: 8576