akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M;
    cin>>N>>M;
    
    map<ll,ll,greater<ll>> m;
    REP(i,N){
        ll a;
        cin>>a;
        if(m.count(a)==0)m[a]=1;else m[a]++;
    }
    REP(i,M){
        ll b,c;
        cin>>b>>c;
        if(m.count(c)==0)m[c]=b;else m[c]+=b;
    }
    
    ll sum=0,nsum=0;
    for(const auto t:m){
        //sl(t.first,t.second);
        sum+=t.first*min(t.second,N-nsum);
        //sl(sum,t.second,N-nsum);
        nsum+=t.second;
        if(nsum>N)break;
    }
    cout<<sum;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
  
int main()
{
	int n,m,o;
	int p[21][21]={0}; //宝石の座標
	int x,y;
	int i,j,k;
	int ans;
	char a;

	while(1){
	scanf("%d",&n);
	if((n==0))
		break;
	//ここまでテンプレ

	ans=0;

	for(i=0;i<21;i++)
	{
		for(j=0;j<21;j++){
			p[i][j]=0;
		}
	}

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

	scanf("%d",&m);

	x=10;y=10;
	p[x][y]=0;

	for(i=0;i<m;i++)
	{
		scanf(" %c %d",&a,&o);
		for(j=0;j<o;j++)
		{
			if(a=='N'){
				y++;}
			else if(a=='S'){
				y--;}
			else if(a=='E'){
				x++;}
			else if(a=='W'){
				x--;}
			p[x][y]=0;
		}
	}

	for(i=0;i<21;i++)
	{
		for(j=0;j<21;j++){
			ans+=p[i][j];
		}
	}

	if(ans==0){
		printf("Yes\n");}
	else if(ans>0){
		printf("No\n");
	}

	//ここからテンプレ
	}
	return 0;
}

Measured memory_bytes: 1012
N,M = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    s = i
    b = [0]*N
    for j in range(N):
        if s >= (2**(N-j-1)):
            s -= 2**(N-j-1)
            b[j] = 1
    for j in range(M):
        on = 0
        for k in range(ks[j][0]):
            if b[ks[j][k+1]-1] == 1:
                on += 1
        if on%2 != p[j]:
            break
    else:
        ans += 1
print(ans)

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e+18;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    
    ll ans = INF;
    for ( int bit = 0; bit < (1<<N); ++bit){
        set<int> st;
        //vector<int> S;
        for ( int i = 0; i < N; ++i){
            if ( bit & (1<<i) ) {
                st.insert(i);
                //S.push_back(i);
            }
        }
        if ( st.size() != K ) continue;
        //if ( S.size() != K ) continue;
        ll cost = 0;
        int hight = 0;
        for ( int i = 0; i < N; ++i){
            if ( st.count(i) ){
                if ( a[i] > hight ) {
                    hight = a[i];
                } else {
                    ++hight;
                    cost += ( hight - a[i] );
                }
            } else {
                if ( a[i] > hight ) hight = a[i];
                else if ( a[i] == hight ) ++ hight;
            }
        }
        //cout << cost << endl;
        chmin(ans,cost);
        //int hight = a[S[0]];
        /*for ( int i = 1; i < K; ++i){
            if ( a[S[i]] > hight ){
                hight = a[S[i]];
            } else {
                ++hight;
                cost += ( hight - a[S[i]] );
            }
        }*/
        /*cout << "bit " << bit << endl;
        for ( auto a: S) cout << a << " ";
        cout << endl;
        cout << "cost " << cost << endl;
        chmin(ans,cost);*/
    }
    cout << ans << endl;
    return 0;
}

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

int64_t times10(int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; ++i) {
		output *= 10;
	}
	return output;
}

int main() {
	//input
	int64_t N, K;
	cin >> N >> K;

	//calculation
	int64_t output = 0;
	output += (N + 1) * (N + 1) * (N + 2) / 2;
	output -= (N + 1) * (N + 2) * (2 * N + 3) / 6;
	output += N + 1;
	output -= (N + 1) * (K - 1) * K / 2;
	output += (K - 1) * K * (2 * K - 1) / 6;
	output -= K - 1;

	output = output % (times10(9) + 7);

	//output
	cout << output << endl;


	return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i<=9;i++) {
    if (N <= 100*i+10*i+i) {
      cout << 100*i+10*i+i << endl;
      break;
    }
  }
}

 

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    int CountEven = 0;
    int CountOdd = 0;
    for(int i=0; i<A.size(); i++) {
        if (A[i] % 2 == 0)  CountEven++;
        else                CountOdd++;        
    }
    if ( CountOdd % 2 == 0) cout << YES << endl;
    else                    cout << NO << endl;
    return;    
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    rep(i,b)cout<<a;
    cout<<endl;
    return 0;
}

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

int main(){
    long a,b,x; cin>>a>>b>>x;

    double ans;
    if(x >= a*a*b/2){
        double c = (double)x/(a*a);
        ans = atan(((double)b-c)/(a/2.0));
        ans *= 180/M_PI;
    }else{
        double c = (2.0*x)/(a*b);
        ans = atan(c/b);
        ans *= 180/M_PI;
        ans = 90 - ans;
    }

    cout << fixed << setprecision(10) << ans << endl;
}


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

int main() {
	long long N;
	cin >> N;
	
	vector <int> primes;
	long long a = 2LL;
	
	while (a * a < N) {
		int num = 0;
		while (N % a == 0) {
			N /= a;
			num++;
		}
		primes.push_back(num);
		a++;
	}
	if (N != 0 && N != 1) primes.push_back(1);
	
	int ret = 0;
	for (int i = 0; i < primes.size(); ++i) {
		int j = 1;
		while (primes[i] >= j) {
			primes[i] -= j;
			j++;
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 7076
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    char s;
    bool ans[3] = {};
    for (int i = 0; i < 3; i++) {
        cin >> s;
        if (s == 'a')ans[0] = true;
        if (s == 'b')ans[1] = true;
        if (s == 'c')ans[2] = true;
    }
    for (int i = 0; i < 3; i++) {
        if (!ans[i]) {
            No;
            return 0;
        }
    }
    Yes;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> d(n);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	
	ll ans = 0LL;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			ans += d[i] * d[j];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int N;
set<string> S;
string s;

void dfs(string s){
  if(s.length() == N){
    S.insert(s);
    return;
  }
  char c;
  if(s.empty()) c = 'a';
  else{
    c = *max_element(s.begin(), s.end()) + 1;
  }
  for(char a = 'a'; a <= c; a++){
    s += a;
    dfs(s);
    s.pop_back();
  }
}

int main(){
  cin >> N;
  string s = "";
  dfs(s);
  for(auto in:S){
    cout << in << endl;
  }
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void fprint() { std::cout << '\n'; }
template <class H, class... T> void fprint(H &&head, T &&... args) {
    std::cout << std::fixed << std::setprecision(10) << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    fprint(std::forward<T>(args)...);
}

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

    int H, W, x, y;
    scan(W, H, x, y);

    double ans = (double)W * H / 2;
    int ok     = (2 * x == W && 2 * y == H) ? 1 : 0;
    fprint(ans, ok);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
int f(Int L, Int R) {
    // #{ (x, y) | L <= x <= y <= R, x is subset of y }
    //               e0        e1
    Int dp[61][2][2] = {};
    dp[60][1][1] = 1;
    for (int i = 59; i >= 0; i--) {
        int l = (L >> i) & 1;
        int r = (R >> i) & 1;
        REP(e0, 2) REP(e1, 2) REP(x, 2) REP(y, 2) {
            if (x == 1 && y == 0) continue;
            if (e0 && l > x) continue;
            if (e1 && y > r) continue;
            dp[i][e0 && l == x][e1 && y == r] += dp[i + 1][e0][e1];
        }
        REP(e0, 2) REP(e1, 2) dp[i][e0][e1] %= MOD;
    }
    Int ans = 0;
    REP(e0, 2) REP(e1, 2) ans += dp[0][e0][e1];
    return ans % MOD;
}
int solve(Int L, Int R) { // [L, R]
    R++; // [L, R)
    Int ans = 0;
    for (int i = 0; i < 60; i++) {
        Int S = max(L, 1LL << i);
        Int T = min(R, 1LL << (i + 1));
        if (S >= T) continue;
        ans += f(S, T - 1);
    }
    return ans % MOD;
}
int main() {
    Int L, R; cin >> L >> R;
    cout << solve(L, R) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
k = 0
for i in range(n-1):
    u,v = na()
    if u > v:
        u,v = v,u
    k += u*(n-v+1)

print((n+2)*n*(n+1)//6-k)

Measured memory_bytes: 68412
import java.util.Scanner;
import java.util.Stack;

public class Main {

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

        sc.nextLine();
        char[] S = sc.nextLine().toCharArray();

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            if (stack.isEmpty()) {
                stack.push(S[i]);
                continue;
            }
            if (stack.peek() == S[i]) {
                continue;
            }
            stack.push(S[i]);
        }

        System.out.println(stack.size());
    }

}


Measured memory_bytes: 26728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N;
  ll W;
  cin >> N >> W;
  ll MAX_VAL = 1000000000000;
  int val = N*1000+1;
  vector<vector<ll>> dp(N, vector<ll>(val, MAX_VAL)); // 価値vを達成するための最小重さW
  
  vector<int> v(N);
  vector<ll> w(N);
  for(int i = 0; i < N; i++){
    ll x;
    int y;
    cin >> x >> y;
    v.at(i) = y;
    w.at(i) = x;
  }
  dp[0][0] = 0;
  dp[0][v.at(0)] = w.at(0);
  
  for(int i = 1; i < N; i++){
    for(int j = 0; j < val; j++){
      if(j - v.at(i) >= 0){
        dp[i][j] = min(dp[i][j], dp[i-1][j-v.at(i)] + w.at(i));
      }
      dp[i][j] = min(dp[i-1][j], dp[i][j]);
    }
  }
  int ans = 0;
  for(int i = 0; i < val; i++){
    if(dp[N-1][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 79488
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


l = 1
for i in range(n):
    l = lcm(l, t[i])

print(l)


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;

    cin >> s;

    if(s[5]=='0'){
        if(s[6]=='1'||s[6]=='2'||s[6]=='3'||s[6]=='4'){
            cout << "Heisei" << endl;
        }else{
            cout << "TBD" << endl;
        }
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =200100;
int n , a[N] , q ;
double p[N] , sum[N];
int main ( ){
  for ( int i = 1; i <= 1000 ; i++ ) {
     for ( int pi = 1 ; pi <= i ; pi++ ){
        p[i] += (1.0*pi)/(1.0*i) ;
     }
  }
  scanf("%d %d",&n,&q);
  sum[0] = 0.0 ;
   for ( int i =1 ; i <= n ; i++) {
        int x;  scanf("%d",&x);
        sum[i] = sum[i-1] + (1.0*p[x]);
   }
   double mx = -100 ;
   for ( int i = 1; i+q-1 <= n; i++ ) {
      mx = max ( mx , sum[i+q-1]-sum[i-1]);
   }
   printf("%.6f",mx);
return 0 ;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
dp = [10**5 for i in range(n+1)]
for i in a:
        dp[i] = 0

a.sort()
for i in range(1,n+1):
        if dp[i] == 0:
                continue
        if i == 1:
                dp[i] = 1
                continue
        if i == 2:
                if dp[i-1] == 0:
                        dp[i] = 1
                else:
                        dp[i] = 2
                continue
        if dp[i-1] == 0:
                dp[i] = dp[i-2]
                continue
        if dp[i-2] == 0:
                dp[i] = dp[i-1]
                continue
        dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
        #print (dp[i])
print (dp[-1]%(10**9+7))

Measured memory_bytes: 7856
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n,a=0,b;
	cin>>n >>b;
	int arr[n];
	int j;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=0;i<n-1;i++)
	{
		int t=i;
		for(j=i+1;j<n;j++)
		{
			if(arr[t]<arr[j])
			{
				t=j;
			}
		}
		swap(arr[t],arr[i]);
	}
	for(int i=0;i<b;i++)
	{
		a=a+arr[i];
	}
	printf("%d",a);
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] a = Console.ReadLine().Split();
        string a1 = a[0].Substring(0,1);
        string a2 = a[1].Substring(0,1);
        string a3 = a[2].Substring(0, 1);
        Console.WriteLine(a1.ToUpper()+""+a2.ToUpper()+""+a3.ToUpper());
    }
}


Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := scanInt(sc)
	min := 100000
	find(n, 0, &min)
	fmt.Println(min)
}

func find(n, w int, min *int) {
	if n < 6 {
		if w+n < *min {
			*min = w + n
		}
		return
	}

	d := 6
	for d <= n {
		d *= 6
	}
	find(n-d/6, w+1, min)

	d = 9
	for d <= n {
		d *= 9
	}
	find(n-d/9, w+1, min)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 640
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    ll reg=0;
    ll res=0;
    rep(i,n){
        if(reg>vec[i]){
            res+=reg-vec[i];
        }
        chmax(reg,vec[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4784
import sys
import bisect

input = lambda: sys.stdin.readline().rstrip()

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


def solve():

    LIS = [A[0]]
    for i in range(1, N):

        if A[i] >= LIS[-1]:
            LIS.append(A[i])
        else:
            LIS[bisect.bisect_right(LIS, A[i])] = A[i]

    ans = len(LIS)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7840
n,t,aoki=map(int,input().split())

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

if tree[t-1]==[aoki-1]:
    print(0)
    exit()


from collections import deque
ans=[-1]*n
stack = deque([t-1])
ans[t-1]=0

while len(stack)>0:
    tmp=stack.popleft()
    for item in tree[tmp]:
        if ans[item]==-1:
            ans[item]=ans[tmp]+1
            stack.append(item)


ans2=[-1]*n
stack = deque([aoki-1])
ans2[aoki-1]=0

result=0
#print("hoge",ans2)

while len(stack)>0:
    tmp=stack.popleft()
    for item in tree[tmp]:
        if ans2[item]==-1:
            ans2[item]=ans2[tmp]+1
            stack.append(item)
            if ans[item]<ans2[item]:
                result=max(result,ans2[item])-1
            elif ans[item]==ans2[item]:
                result=max(result,ans2[item])-1

print(result)







Measured memory_bytes: 66352
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
 int A,B,ans;
 cin >> A >> B;
 ans =A+B;
 if (ans<A-B){
   ans = A-B;
 }
 if(ans<A*B){
   ans = A*B;
 }
 cout << ans;
 return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.out;
public class Main{
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args){
      int A = sc.nextInt();
      int B = sc.nextInt();
      String S = sc.next();
      if(S.indexOf("-") == A){
         try{
            Integer.parseInt(S.substring(0,A));
            Integer.parseInt(S.substring(A+1,S.length()));
            System.out.println("Yes");
         }catch(NumberFormatException e){
            System.out.println("No");
         }
      }else{
         out.println("No");
      }
   }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#define REP(i,a,b) for (int i = (a); i < (int)(b); i++)
#define rep(i,a) REP(i,0,a)

using namespace std;

char field[51][51];
map<char, vector<int>> corner;
vector<char> chars;
set<char> schars;
int H, W;

bool judge(char (*field)[51], char c) {
    REP(y, corner[c][2], corner[c][3]+1)
        REP(x, corner[c][0], corner[c][1]+1) {
            if (field[y][x] != c && field[y][x] != '*')  return false;
            field[y][x] = '*';
        }
    return true;
}

string solve(vector<char> chars) {
    do {
        char cp[51][51];
        rep(y, H) rep(x, W) cp[y][x] = field[y][x];
        
        bool flag = true;
        for(char c: chars) 
            if (!judge(cp, c)) {
                flag = false;
                break;
            }
        if (flag) return "SAFE";
    } while (next_permutation(chars.begin(), chars.end()));

    return "SUSPICIOUS";
}

int main(void){
    int N;
    cin >> N;
    while (N--) {
        cin >> H >> W;
        rep(y, H) rep(x, W) cin >> field[y][x];
        chars.clear(); schars.clear(); corner.clear();
        
        rep(y, H) rep(x, W) {
            char c = field[y][x];
            if (c == '.') continue;
            
            schars.insert(c);
            if (corner.find(c) == corner.end()) {
                vector<int> vec(4);
                vec = {x, x, y, y};
                corner[c] = vec;
            }
            else {
                corner[c][0] = min(corner[c][0], x);
                corner[c][1] = max(corner[c][1], x);
                corner[c][2] = min(corner[c][2], y);
                corner[c][3] = max(corner[c][3], y);
            }
        }
        
        for (char c: schars) chars.push_back(c);
        sort(chars.begin(), chars.end());
        cout << solve(chars) << endl;
    }
    return 0;
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N = 1e5 + 5;
int dp[N][3];

int32_t main()
{
    IOS;
    memset(dp,INT_MIN,sizeof(dp));
    int n;
    cin>>n;
    FOR(i,1,n+1)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(i==1)
        {
            dp[1][0] = a;
            dp[1][1] = b;
            dp[1][2] = c;
        }
        else
        {
            FOR(j,0,3)
            {
                FOR(k,0,3)
                {
                    if(j!=k)
                    {
                        if(k==0) dp[i][k] = max(a + dp[i-1][j],dp[i][k]);
                        if(k==1) dp[i][k] = max(b + dp[i-1][j],dp[i][k]);
                        if(k==2) dp[i][k] = max(c + dp[i-1][j],dp[i][k]);
                    }
                }
            }
        }
    }
    int ans = INT_MIN;
    FOR(i,0,3) ans = max(dp[n][i],ans);
    cout<<ans<<"\n";
    return 0;
}

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

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let mut cnt1 = 0;
    let mut cnt2 = 0;
    for i in 0..s.len() {
        if i % 2 == 0 {
            if s[i] == '0' {
                cnt1 += 1;
            } else {
                cnt2 += 1;
            }
        } else {
            if s[i] == '1' {
                cnt1 += 1;
            } else {
                cnt2 += 1;
            }
        }
    }
    println!("{}", std::cmp::min(cnt1, cnt2));
}

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


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

using namespace std;

int main(void) {
    int N;
    int M = 0;
    std::vector<int> A_pos, A_neg;

    std::cin >> N;
    for(int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        if(a > 0) {
            A_pos.push_back(a);
            M += a;
        }
        else {
            A_neg.push_back(a);
            M -= a;
        }
    }

    // 正も負も存在
    if(A_pos.size() > 0 && A_neg.size() > 0) {
        // 絶対値の和が最大値
        std::cout << M << std::endl;
        int smallest = A_neg[0], largest = A_pos[0];
        for(int i = 1; i < A_pos.size(); i++) {
            std::cout << smallest << " " << A_pos[i] << std::endl;
            smallest -= A_pos[i];
        }
        for(int i = 1; i < A_neg.size(); i++) {
            std::cout << largest << " " << A_neg[i] << std::endl;
            largest -= A_neg[i];
        }
        // largest - smallest
        std::cout << largest << " " << smallest << std::endl;
    }
    else if(A_pos.size() > 0) {
        std::sort(A_pos.begin(), A_pos.end());
        if(A_pos.size() == 2) {
            std::cout << A_pos[1] - A_pos[0] << std::endl;
            std::cout << A_pos[1] << " " << A_pos[0] << std::endl;
        }
        else {
            int smallest = A_pos[0] - A_pos[1];
            // 最初2つの数が負数を作り出すために犠牲となる
            M -= 2 * A_pos[0];
            std::cout << M << std::endl;
            std::cout << A_pos[0] << " " << A_pos[1] << std::endl;
            for(int i = 2; i < A_pos.size() - 1; i++) {
                std::cout << smallest << " " << A_pos[i] << std::endl;
                smallest -= A_pos[i];
            }
            std::cout << A_pos[A_pos.size() - 1] << " " << smallest << std::endl;
        }
    }
    else {
        std::sort(A_neg.begin(), A_neg.end());
        if(A_neg.size() == 2) {
            std::cout << A_neg[1] - A_neg[0] << std::endl;
            std::cout << A_neg[1] << " " << A_neg[0] << std::endl;
        }
        else {
            int largest = A_neg[N-1] - A_neg[N-2];
            // 最後2つの数が正数を作り出すために犠牲となる
            M += 2 * A_neg[N-1];
            std::cout << M << std::endl;
            std::cout << A_neg[N-1] << " " << A_neg[N-2] << std::endl;
            for(int i = 0; i < N - 2; i++) {
                std::cout << largest << " " << A_neg[i] << std::endl;
                largest -= A_neg[i];
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2424
import java.util.Scanner;

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

    int a = sc.nextInt();
    String s = sc.next();
    String ans;

    if(a >= 3200)	ans = s;
    else	ans = "red";

    System.out.print(ans);


  }
}

Measured memory_bytes: 23380
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;

int main()
{

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll  sum;
    sum=max(a*c,a*d);
    sum=max(sum,b*c);
    sum=max(sum,b*d);
    cout<<sum<<endl;
    return 0;

}


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

total = []
for i in range(1, n+1, 2):
  cnt = 0
  for j in range(1, i+1, 2):
    
    if i%j == 0:
      cnt += 1
    
    if cnt == 8:
      total.append(i)
      
    

print(len(total))

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   ll n;cin >>n;
   if(n%2==1){
       cout <<0<<endl;
   }
   if(n%2==0){
       ll ans=0;
       n/=2;
       while(n>=5){
           ans+=n/5;
           n/=5;
       }
       cout <<ans <<endl;
   }
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    a, b, c, d = list(input())
    ops = tuple(product(('+', '-'), repeat=3))
    for opse in ops:
        o = a + opse[0] + b + opse[1] + c + opse[2] + d
        s = eval(o)
        if s == 7:
            r = o + '=7'
            print(r)
            sys.exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
n,k=list(map(int,input().split()))

mod=10**9+7

def modinv(x):
    return pow(x,mod-2,mod)

ans=1
comb1=1
comb2=1

for i in range(1,min(n-1,k)+1):
    comb1*=(n-i+1)*modinv(i)
    comb2*=(n-i)*modinv(i)
    comb1%=mod
    comb2%=mod

    ans+=comb1*comb2
    ans%=mod

print(ans)

Measured memory_bytes: 73664
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<vector<int>> g(n);
    rep(i,m) {
        int a,b; cin>>a>>b;
        --a,--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> prev(n,INF);

    queue<int> q;
    vector<int> dp(n, INF);
    q.push(0);
    dp[0] = 0;
    while (!q.empty()) {
        int cur = q.front(); q.pop();
        for (auto &&e: g[cur]) {
            if (chmin(dp[e], dp[cur]+1)) {
                q.push(e);
                prev[e] = cur;
            }
        }
    }

    cout << "Yes" << '\n';
    for (int i = 1; i < n; ++i) {
        cout << prev[i]+1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 10528
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0]
for  i in range(N):
    sum_A.append(sum_A[i] + A[i])

sum_B = [0]
for  i in range(M):
    sum_B.append(sum_B[i] + B[i])

ans = 0
j = M

for i in range (N+1):
    if sum_A[i] > K:
        break
    while sum_B[j] > K - sum_A[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)


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

typedef long long ll;

int main()
{
	int n;
	ll ans = 0, cur = 0;
	scanf("%d", &n);
	vector<ll> a(n, 0);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &a[i]);
		if (i > 0 && a[i] < cur) {
			ans += cur-a[i];
		}
		else {
			cur = a[i];
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4852
#include <stdio.h>

int main(void)
{
  int n,m,a,h,p,q,i,j,hmax;

  for(;;){
    scanf("%d %d %d", &n, &m, &a);
    if(n==0&&m==0&&a==0) break;

    int line[100][1000]={0};
    hmax=0;
    for(i=0;i<m;i++){
      scanf("%d %d %d", &h, &p, &q);
      line[p-1][h-1]=1;
      if(h>hmax) hmax=h;
    }
    for(i=hmax-1;i>=0;i--){
      for(j=0;j<n;j++){
	if(line[j][i]==1&&a==j+1){
	  a++; break;
	} else if(line[j][i]==1&&a==j+2){
	  a--; break;
	}
      }
    }
    printf("%d\n", a);
  }

  return 0;
}


Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n;
vector<int> d;

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        cout << N << endl;
    } else {
        cout << N * 2 << endl;
    }
}

Measured memory_bytes: 256
s=input()
n=len(s)
if n==2:
  if s[0]==s[1]:
    print('1 2')
  else:
    print('-1 -1')
else:
  for i in range(n-1):
    if s[i]==s[i+1]:
      print('{} {}'.format(i+1,i+2))
      exit()
  for j in range(n-2):
    if s[j]==s[j+2]:
      print('{} {}'.format(j+1,j+3))
      exit()
  print('-1 -1')

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var s = ReadString();
            Console.WriteLine(s[0] == s[s.Length - 1] ^ s.Length % 2 == 0 ? "Second" : "First");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    string S;
    cin>>S;
    int N=S.length();
    reverse(S.begin(), S.end());
    
    string word[4] = {"dream", "dreamer", "erase", "eraser"};
    
    rep(i,4){
        reverse(word[i].begin(), word[i].end());
    }
    
    int s=0;
    while(s<N){
        if(S[s]=='m' && S.substr(s,5)==word[0]) s+=5;
        else if(S[s]=='r' && s+1<N && S[s+1]=='e' && S.substr(s,7)==word[1]) s+=7;
        else if(S[s]=='e' && S.substr(s,5)==word[2]) s+=5;
        else if(S[s]=='r' && s+1<N && S[s+1]=='e' && S.substr(s,6)==word[3]) s+=6;
        else{
            NO; return 0;
        }
    }
    YES;
    
    
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int n;
    int i;
    int x[10000];
    int min,max;
    long sum=0;
    cin >> n;
    for(i=0; i<n; i++)
    cin >> x[i];
    min = x[0];
    max = x[0];
    
    for(i=0; i<n; i++){
        if(min>x[i]){
            min = x[i];
        } else if(max<x[i]){
            max = x[i];
        } else{
            
        }
        sum+=x[i];
    }
    
    cout << min <<" "<< max <<" "<< sum << endl;
    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        if (a1 + a2 + a3 >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }

        sc.close();
    }

}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

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

int solve(int r,int c){
  rep(i,r+2)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r-1){
    rep(j,c){
      if (m[i][j] == 0 ){
	      rep(k,3){
	        int nex = j+dx[k];
	          if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2 && m[i+2][j] != 1){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  /*
  rep(i,r+1) {
    rep(j,c) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)m[r][j]=0;
    cout << solve(r,c) << endl;
  }
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n, m, l int
	fmt.Scan(&n, &m, &l)

	a := make([][]int, n)
	b := make([][]int, m)
	c := make([][]int, n)
	
	for i:=0; i<len(a); i++{
		a[i] = make([]int, m)
		for j:=0; j<m; j++{
			fmt.Scan(&a[i][j])
		}
	}
	for i:=0; i<len(b); i++{
		b[i] = make([]int, l)
		for j:=0; j<l; j++{
			fmt.Scan(&b[i][j])
		}
	}
	for i := 0; i < n; i++ {
		c[i] = make([]int, l)
		for k := 0; k < l; k++ {
			for j := 0; j < m; j++ {
				c[i][k] += a[i][j] * b[j][k]
			}
		}
	}
	for i := 0; i < n; i++ {
		for k:=0;k < l;k++ {
			fmt.Print(c[i][k])
			if k != l-1{
				fmt.Print(" ")
			}
		}
		fmt.Println("")
	}
}


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

int main(){
	int n,min=INT_MAX;
	cin>>n;
	vector<int> x(n);
	rep(i,n)cin>>x.at(i);
	rep(i,100){
		lint sum=0;
		rep(j,n){
			sum+=pow((i-x.at(j)),2);
		}
		if(sum<min)min=sum;
	}
	cout<<min<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> T(N);
  REP(i, N) cin >> T[i];

  vector<pair<int, int>> L(N, {T[0], T[0]});
  REP(i, N-1){
    if(T[i] < T[i+1]){
      L[i+1] = {T[i+1], T[i+1]};
    }else{
      L[i+1] = {1, T[i+1]};
    }
  }

  REP(i, N) cin >> T[i];
  vector<pair<int, int>> R(N, {T[N-1], T[N-1]});
  RREP(i, N-1){
    if(T[i] > T[i+1]){
      R[i] = {T[i], T[i]};
    }else{
      R[i] = {1, T[i]};
    }
  }

  int ans = 1;
  REP(i, N){
    int MIN = max(R[i].first, L[i].first);
    int MAX = min(R[i].second, L[i].second);
    if(MIN > MAX) ans = 0;
    (ans *= MAX-MIN+1) %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4096
// Aizu Vol-20 2000 Misterious Gems
// 2017.8.12 bal4u@uu

#include <stdio.h>
#include <string.h>

char a[22][22];

int main()
{
	int n, x, y, m, s;
	int i;
	char d[3];

	while (1) {
		scanf("%d", &n); if (!n) break;
		memset(a, 0, sizeof(a));
		for (i = 0; i < n; i++) scanf("%d%d", &x, &y), a[x][y] = 1;
		scanf("%d", &m);
		x = 10, y = 10;
		while (m-- > 0) {
			scanf("%s%d", d, &s);
			while (s-- > 0) {
				if      (d[0] == 'E') x++;
				else if (d[0] == 'S') y--;
				else if (d[0] == 'W') x--;
				else if (d[0] == 'N') y++;
				if (a[x][y]) n--, a[x][y] = 0;
			}
		}
		puts(!n ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[1000],n=10;
    for(int i=0; i<10; i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=9; i>=7; i--)
    {
        cout<<arr[i]<<endl;
    }
}

Measured memory_bytes: 1180
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();

		HashMap<String,Integer>m=new HashMap<>();

		for(int i=0;i<n;++i) {
			char[] c=s.next().toCharArray();
			Arrays.sort(c);
			m.merge(String.valueOf(c),1,Integer::sum);
		}

		System.out.println(m.values().stream().mapToLong(i->(long)(i-1)*i/2L).sum());
	}
}


Measured memory_bytes: 55172
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
vector<pair<pair<int,int>,int> >a;
int main(){
	int n,i;
	cin>>n>>i;
	cout<<n+1-i<<endl;
}


Measured memory_bytes: 256