akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int n = Integer.parseInt(strs[0]);
		int  ref= Integer.parseInt(strs[1]);
		strs = br.readLine().split(" ");
		int[] px = new int[n];
		for(int i = 0 ; i < n ; i++){
			px[i] = Math.abs(Integer.parseInt(strs[i]) - ref);
		}
		int res = px[0];
		for(int i = 0 ; i < px.length ; i++){
			int a = (px[i] > res) ? px[i] : res;
			int b = (px[i] > res) ? res : px[i];
			while(a%b != 0){
				int buff = b;
				b = a%b;
				a = buff;
			}
			res = b;
		}
		
		System.out.println(res);
	}
}


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

int main() {
  int A, B, C, D, x, y;
  cin >> A >> B >> C >> D;
  x = A + B;
  y = C + D;
  if (x > y) {
    cout << "Left" << endl;
  }
  else if (x == y) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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


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

    int len = 0;
    std::vector<int> a(n), lis(n, -1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if (i == 0) {
            lis[len] = a[i];
            len++;
            continue;
        }
        if (lis[len - 1] < a[i]) {
            lis[len] = a[i];
            len++;
        } else {
            for (int j = 0; j < len; j++) {
                if (lis[j] >= a[i]) {
                    lis[j] = a[i];
                    break;
                }
            }
        }
    }
    std::cout << len << std::endl;
}



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

using namespace std;

typedef long long ll;
const ll N = 2e5+5;

ll a[N], d[N], s[N], n, i;

main(){
	cin >> n;
	for(; i < n; ++i)
	{
		cin >> a[i];
		s[i] = (i > 1 ? s[i - 2] : 0) + a[i];
	}
	for (i = 1; i < n; ++i)
	{
		if (i & 1)
			d[i] = max(s[i - 1], d[i - 2] + a[i]);
		else
			d[i] = max(d[i - 1], d[i - 2] + a[i]);
	}
	cout << d[n - 1];
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int>x(N);
  vector<int>y(N);
  int kaijou = 1;
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
    kaijou *= i+1;
  }
  int A = (kaijou * 2) / N;
  double sum = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      sum += sqrt((x.at(i) - x.at(j))*(x.at(i) - x.at(j))+(y.at(i) - y.at(j))*(y.at(i) - y.at(j))) * 1.0 * A;
    }
  }
  printf("%.8lf\n", sum / kaijou);
}
    



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

int main(){
   int n;
   cin >> n;
   int h[n];
   rep(i,n) cin >> h[i];
   int dp[n];
   rep(i,n) dp[i]=0;
   rep(i,n){
      if(!i) continue;   
      else if(i==1) dp[i] = abs(h[i]-h[i-1]);
      else{
         int one = dp[i-1]+abs(h[i]-h[i-1]);
         int twe = dp[i-2]+abs(h[i]-h[i-2]);
         //cout << one <<" "<< twe<<endl;
         dp[i] = min(one,twe);
      }
 
   }
   cout << dp[n-1] << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n";
typedef long long ll;
typedef unsigned long long ull;   
const int N = 2*1e5+10;

ll x;
ll n,k;
int arr[N];

int main()
{
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    cin>>n;
    int currNum=1;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        if(k==currNum)
            currNum++;
    }
    if(currNum==1)
        cout<<-1;
    else
        cout<<n-(currNum-1)<<endl;

    return 0;
}

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


/*
隣接行列を参照渡しするといい感じに計算します。Nodeは0始まり
*/
template<typename Cost>
void warshall_floyd(vector<vector<Cost>> &d){
    int V = d.size();
    const Cost INF = numeric_limits<Cost>::max();

    for (int k=0;k<V;k++){
        for (int i=0;i<V;i++){
            for (int j=0;j<V;j++){
                if (d[i][k] != INF && d[k][j] != INF && d[i][k]+d[k][j]<d[i][j]){
                    d[i][j] = d[i][k]+d[k][j];
                }
            }
        }
    }
}

void solve(long long N, long long M, long long R, std::vector<long long> r, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
        const ll INF = numeric_limits<ll>::max();
        vector<vector<ll>> graph(N,vector<ll>(N,INF));
        for (int i=0;i<M;i++){
            graph[A[i]-1][B[i]-1] = C[i];
            graph[B[i]-1][A[i]-1] = C[i];
        }
        for (int k=0;k<N;k++){
            graph[k][k]=0;
        }
        warshall_floyd<ll>(graph);
        ll minimum=INF;
        sort(r.begin(),r.end());
        do {
            ll sum = 0;
            for (int i=0;i<R-1;i++){
                if (graph[r[i]-1][r[i+1]-1]<INF) sum+= graph[r[i]-1][r[i+1]-1];
                else{
                    sum=INF;
                    break;
                }
            }
            minimum = min(sum,minimum);
        } while (std::next_permutation(r.begin(), r.end()));
        printf("%lld\n",minimum);

}   



// Generated by 1.1.6 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);
    long long M;
    scanf("%lld",&M);
    long long R;
    scanf("%lld",&R);
    std::vector<long long> r(R);
    for(int i = 0 ; i < R ; i++){
        scanf("%lld",&r[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, R, std::move(r), std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 1024
def main():
  import sys
  from scipy.sparse.csgraph import floyd_warshall as f
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d==float('inf')]=-1
  print('\n'.join(map(str,map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)]))))
main()

Measured memory_bytes: 36196
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n,ans = 0;
	bool c = true;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	while (c) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				a[i] = a[i] / 2;
			}
			else {
				c = false;
				break;
			}
			if (i == n - 1)ans++;
		}
	}


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

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	string s,t;
	cin>>s>>t;

	int ans=0;
	for (int i = 0; i < 3; ++i){
		if(s[i]==t[i])ans++;
	}

	cout<<ans<<endl;

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int a_i = a[n-1];
  int res = a[0];
  for(int i = 0; i < n-1; i++){
    double tmp1 = (double)a_i / 2 - res;
    double tmp2 = (double)a_i / 2 - a[i];
    if(abs(tmp2) < abs(tmp1)) res = a[i];
  }
  cout << a_i << " " << res << endl;
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  ll A,B,C,D;
  cin >> A >> B >> C >> D;

  ll t = lcm(C,D);
  auto count = [&](ll x) {
    return x - x/C - x/D + x/t;
  };

  ll ans = count(B) - count(A-1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

enum STATUS {NOTFIN, FIN};

int main(){
  int n, y;
  enum STATUS s = NOTFIN;
  int result[3], p0, p1, p2;
  scanf("%d %d", &n, &y);
  if(n < 1 || 2000 < n || y < 1000 || 20000000 < y || (y%1000))
    return 1;

  for(p0 = 0; p0 <= n + 1; p0++){
    if(s == NOTFIN){
      for(p1 = 0; p1 <= n - p0; p1++){
        if(s == NOTFIN){
          for(p2 = 0; p2 <= n - p0 - p1; p2++){
            if(s == NOTFIN){
              if((p0 + p1 + p2) == n){
                if((p0 * 10000 + p1 * 5000 + p2 * 1000) == y){
                  result[0] = p0;
                  result[1] = p1;
                  result[2] = p2;
                  s = FIN;
                }
              }
            }
          }
        }
      }
    }
  }
  if(s == FIN)
    printf("%d %d %d\n", result[0], result[1], result[2]);
  else
    printf("%d %d %d\n", -1, -1, -1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

int main()
{
	cin >> n >> s;
	REP(i,n)
	{
		if (s[i] == 'I') counter++;
		else if (s[i] == 'D') counter--;
		ans = max(ans, counter);
	}
	cout << ans << endl;
}

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

int main(void){
    int s;
    cin >> s;
    vector<int> a(1000000);
    int count=0;

    while(true){
        a[count] = s;   //配列に計算結果を入れていく
        //cout << a[count];
        if(count>0){    //今入れた値が過去にあるかどうかを確認する
            for(int i=0;i<count;i++){
                if(s==a[i]){
                    cout << count+1 << endl;
                    return 0;
                }
            }
        }
        count++;
        if(s%2==0){
            s = s/2;
        }else{
            s = 3*s+1;
        }
    }
	return 0;
}

Measured memory_bytes: 7212
n = int(input())
h = list(map(int, input().split()))
count = 0
count_max = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count = count + 1
    else:
        count_max = max(count_max, count)
        count = 0
            
print(max(count_max, count))

Measured memory_bytes: 14252
#include<cstdio>
int main()
{
    int a,b;
    scanf("%d",&a);
    for(int i=1;;i++)
    {
        b=a%10;
        if(b==9||a==9)
            break;
        else
        {
            if(b<10&&a<10&&a!=9)
            {
                printf("No");
                return 0;
            }
            else
                a=a/10;
        }
    }
    printf("Yes");
}

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

typedef long long ll;

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

    string s,t;
    cin >> s >> t;
    ll ans = 0;
    for(ll i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce
def sml_cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
def main():
    n, a, b = map(int, input().split())
    v = list(map(int, input().split()))
    v.sort()
    ave = 0
    for i in range(1, a+1):
        ave += v[n-i]
    ave /= a
    l, r = -1, -1
    target = v[n-a]
    for i in range(n):
        if v[i] == target:
            l = i
            break
    for i in reversed(range(n)):
        if v[i] == target:
            r = i
            break
    cnt = r-l+1
    high, low = min(cnt, r-(n-b)+1), r-(n-a)+1
    ans = sml_cmb(cnt, low)
    if v[n-a] == v[n-1]:
        for i in range(low+1, high+1):
            ans += sml_cmb(cnt, i)
    print(ave)
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    string x;
    cin >> x;
    int ans = 0;
    int tnokori = 0;
    for(int i = x.length()-1; i >= 0; i--){
        if(x[i] == 'S'){
            if(tnokori > 0){
                tnokori--;
            }else{
                ans++;
            }
        }else{
            tnokori++;
        }
    }
    cout << ans+tnokori << endl;
    return 0;
}

Measured memory_bytes: 640
def solve():
    n,k = map(int, input().split())
    A = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 10420
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, V: "List[int]"):
    ans = 0
    for n_all in range(min(N, K)+1):
        for n_l in range(n_all+1):
            n_r = n_all - n_l
            tmp_v = sorted(V[:n_l] + V[N-n_r:])
            n_neg = sum([e < 0 for e in tmp_v])
            ans = max(ans, sum(tmp_v[min(n_neg, K-n_all):]))
    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    V = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, V)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x;
    cin>>n>>x;
    ll ans=3*(n-__gcd(n,x));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;


int main()
{
	string S;
	cin >> S;
	int N[1000001];
	fill(N, N+1000001, 0);
	for(int i = 0; i < S.length(); i++){
		N[i] = S[S.length()-1-i] - '0';
	}
	
	ll ans = 0;
	for(int i = 0; i <= S.length(); i++){
		if(N[i] == 5 && N[i+1] >= 5){
			N[i+1]++;
			ans += 10-N[i];
		}
		else if(N[i] <= 5){
			ans += N[i];
		}
		else if(N[i] == 10){
			N[i+1]++;
		}
		else{
			N[i+1]++;
			ans += 10-N[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5252
#include<stdio.h>
int main(void){
	int f[16][17],d[16][17],i,j,c,x,y;
	for(;scanf("%d%d",&x,&y),x;){
		for(i=0;i<y;*d[i]=d[i][x+1]=0,*f[i]=f[i][x+1]=1,i++)
			for(j=1;j<=x;j++)
				scanf("%d",f[i]+j);
		for(j=1;j<=x;j++)
			d[y][j]=1,d[y-1][j]=f[y-1][j]!=1;
		for(i=y-1;i--;)
			for(j=1;j<=x;d[i][j++]=c)
				switch(f[i][j]){
					case 0:
						c=d[i+1][j];
						f[i+1][j-1]-2?c+=d[i+1][j-1]:0;
						f[i+1][j+1]-2?c+=d[i+1][j+1]:0;
					break;
					case 1:
						c=0;
					break;
					case 2:
						c=d[i+2][j];
					break;
				}
		c=0;
		for(j=1;j<=x;j++)c+=d[0][j];
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
N, Q = map(int, input().split())
S = list(str(input()))
LR = []
counter = [0]
for i in range(Q):
	l, r = map(int, input().split())
	#配列要素との調節
	LR.append([l - 1, r - 1])
	
for i in range(1, len(S)):
	if S[i - 1] == "A" and S[i] == "C":
		counter.append(counter[-1] + 1)
	else:
		counter.append(counter[-1])
		
for i in range(len(LR)):
	print(counter[LR[i][1]] - counter[LR[i][0]])

Measured memory_bytes: 23588
package main

import (
	"fmt"
	"strconv"
)
	

func main() {
	var h,w int
	fmt.Scan(&h,&w)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}

	for i := 0; i < h; i++ {
		var si = "" 
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				si += "#"
				continue
			}
			score :=  score(s,i-1,j-1) + score(s,i, j-1) + score(s,i+1, j-1) + score(s,i-1, j) + score(s,i+1, j) + score(s,i-1, j+1) + score(s,i, j+1) + score(s,i+1,j+1)
			
			si += strconv.Itoa(score)
		}
		fmt.Println(si)
	}
}

func score(s []string, i int, j int) int{
	if i < 0 {
		return 0
	}
	if j < 0 {
		return 0
	}
	if i >= len(s) {
		return 0
	}
	if j >= len(s[i]) {
		return 0
	}

	if s[i][j] == '#' {
		return 1
	}else{
		return 0
	}
}



Measured memory_bytes: 640
//06
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n;){
    for(int m=n-1;;m--){
      int i;
      for(i=2;i<m;i++){
	if(m%i==0)break;
      }
      if(!(i<m)){
	cout<<i<<' ';
	break;
      }
    }
    for(int m=n+1;;m++){
      int i;
      for(i=2;i<m;i++){
	if(m%i==0)break;
      }
      if(!(i<m)){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>

main(){
        int a, b, c, tmp;
        std::cin >> a >> b >> c;

        if( a > b ) { 
                tmp = a;
                a   = b;
                b   = tmp;
        }
        if( b > c ) { 
                tmp = b;
                b   = c;
                c   = tmp;
        }
        if( a > b ) { 
                tmp = a;
                a   = b;
                b   = tmp;
        }

        std::cout << a << " " << b << " " << c << std::endl;


}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    cout<<fixed<<setprecision(12);
    const double pi=3.14;
    cout<<2*pi*n;
}






Measured memory_bytes: 3800
s=int(input())
a=0
b=0
ue=s//100
sita=s%100
if 1<=sita<=12:
 a+=1
if 1<=ue<=12:
 b+=1
if a==1 and b==1:
 print("AMBIGUOUS")
elif a==1 and b==0:
 print("YYMM")
elif a==0 and b==1:
 print("MMYY")
else:
 print("NA")

Measured memory_bytes: 3064
N = int(input())
statements = [[] for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        statements[i].append(tuple(map(int, input().split())))

ans = 0
for bits in range(1 << N):
    for i in range(N):
        if not bits & (1 << i):
            continue
        ok = True
        for j, type in statements[i]:
            if bits & (1 << (j-1)) != (type << (j-1)):
                ok = False
                break
        if not ok:
            break
    else:
        ans = max(ans, bin(bits).count('1'))
print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    int nold;
    cin >> nold;
    for(int i = 1; i < N; i++){
        int n;
        cin >> n;
        P[i] = n - nold;
        nold = n;
    }
    int count = 0;
    for(int i = 2; i < N; i++){
        if(P[i] * P[i-1] > 0){
            count ++ ;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) {
        int ai;
        cin >> ai;
        a[ai-1] = i+1;
    }
    out_ary(a);
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < string > a(n);
    int i;
    set < string > b;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        b.insert(a[i]);
    }
    if (b.size()==n)
    {
        int tag=0;
        for (i=1;i<n;i++)
        {
            if (a[i][0]==a[i-1][a[i-1].length()-1]) ;
            else {tag=1;break;}
        }
        if (!tag) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, M;
    scan(A, B, M);
    auto a = aryread();
    auto b = aryread();
    long ans = a.reduce!(min)() + b.reduce!(min)();
    foreach (i; 0 .. M)
    {
        long x, y, c;
        scan(x, y, c);
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }
    writeln(ans);
}


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

int main() {
    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a[100], n, minj, tmp, num;

	num = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}

	for(int i = 0; i < n - 1; i++){
		minj = i;
		for (int j = i + 1; j < n; j++){
			if (a[j] < a[minj]){
				minj = j;
			}
		}if(minj != i){
			tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			num++;
		}
	}
	cout << a[0];
	for(int i = 1; i < n; i++){
		cout << " " << a[i];
	}
	
	cout << "\n" << num << endl;
}

Measured memory_bytes: 3100
N = int(input())
l = [[] for i in range(N)]
for i in range(N):
    A = int(input())
    l[i] = [0 for j in range(A)]
    for j in range(A):
        x, y = map(int, input().split())
        l[i][j] = [x, y]
ans = 0
for i in range(2**N):
    cnt = 0
    flag = True
    for j in range(N):
        if (i >> j) & 1:
            cnt += 1
            for k in range(len(l[j])):
                if (i >> (l[j][k][0] - 1)) & 1 == l[j][k][1]:
                    pass
                else:
                    flag = False
                    break
    if flag:
        ans = max(ans, cnt)
    cnt = 0
print(ans)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {



		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();

		int[] data = new int[N];
		int ans = 0;
		boolean flag = true;
		for(int i = 0;i < data.length;i++){		//入力
			data[i] = scanner.nextInt();

		}
		
		int[] count = new int[2000001];
		for(int i = 0;i < data.length;i++){			//頻度を記録
			count[data[i]]++;
		}
		Arrays.sort(count);						//少ない順にそーと
		for(int i = count.length-1-K;i >= 0;i --){							//多い順にK番目までを取り除き、それ以外のを全部加える
			ans += count[i];
		}
		
		System.out.println(ans);

	}


}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 64752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }

    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < (1 << h); i++) {
        for(int j = 0; j < (1 << w); j++) {
            cnt = 0;
            for(int k = 0; k < h; k++) {

                for(int l = 0; l < w; l++) {
                    if ( !((i >> k) & 1) && !((j >> l) & 1) &&
                    c[k][l] == '#')
                    {
                        cnt ++;
                    }
                }

            }

            if(cnt == k) {
                ans ++;
            }
        }
    }

    cout << ans << endl;


}

int main()
{
    solve1();
}


Measured memory_bytes: 3600
using System;

namespace AOJ
{
    public class _007
    {
        public static void Main (string[] args)
        {
            float a = 100000;
            var l = int.Parse (Console.ReadLine ());
            for (int i = 0; i < l; ++i) {
                a *= 1.05f;
                if (a % 1000 != 0)
                    a += 1000 - a % 1000;
            }
            Console.WriteLine ((int)a);
        }
    }
}

Measured memory_bytes: 5620
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct UnionFind {
    vector<int> parent;
    vector<int> rank;
    UnionFind() {}
    void init(int size) { parent.assign(size, -1); rank.assign(size, 0); }
    int operator[](int x) { return find(x); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteByRank(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) ++rank[x];
        return parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteBySize(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (size(x) < size(y)) swap(x, y);
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<pair<int, int>, int>> xy(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        xy[i] = mp(mp(x, y), i);
    }

    vector<pair<int, pair<int, int>>> edges;
    sort(all(xy));
    rep(i, N - 1) {
        edges.emplace_back(abs(xy[i].first.first - xy[i + 1].first.first), mp(xy[i].second, xy[i + 1].second));
    }
    sort(all(xy), [](auto& l, auto& r) { return l.first.second < r.first.second; });
    rep(i, N - 1) {
        edges.emplace_back(abs(xy[i].first.second - xy[i + 1].first.second), mp(xy[i].second, xy[i + 1].second));
    }
    sort(all(edges));

    UnionFind uf;
    uf.init(N);
    ll ans = 0;
    rep(i, edges.size()) {
        if (uf.uniteByRank(edges[i].second.first, edges[i].second.second)) {
            ans += edges[i].first;
        }
    }
    write(ans);
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
string s[3] = {"Sunny","Cloudy","Rainy"};
	string ss;
	cin >> ss;
	rep(i,3){
		if(ss == s[i]){
			cout << s[(i+1)%3] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lst = []
for i in range(m):
  s, c = map(int, input().split())
  lst.append([s, c])
ans = -1
for j in range(10 ** n):
  if len(str(j)) != n:
    continue
  for i in range(m):
    if int(str(j)[lst[i][0]-1]) != lst[i][1]:
      break
  else:
    ans = j
    break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
typedef long long ll;
int N, M;
int cnt = 0;
int count = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(void){
  string S;
  cin >> S;
  int pre = (S[0] - '0') * 10 + (S[1] - '0');
  int post = stoi(S.substr(2));
  if(0 < pre && pre <= 12 && 0 < post && post <= 12){
    cout << "AMBIGUOUS" << endl;
  }else if(pre >= 0 && post <= 12 && post > 0){
    cout << "YYMM" << endl;
  }else if(pre > 0 && pre <= 12 && post >= 0){
    cout << "MMYY" << endl;
  }else{
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, readline().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)

def check(s, t):
    u = [0]*N
    u[s] = u[t] = 1
    que = deque()
    for v in G[s]:
        if v == t:
            continue
        u[v] = 1
        que.append(v)
        ok = 0
        while que:
            x = que.popleft()
            for y in G[x]:
                if y == s and x != v:
                    return 1
                if not u[y]:
                    u[y] = 1
                    que.append(y)
    return 0
C = [0]*4
ok = 1
for i in range(N):
    if len(G[i]) % 2 == 1:
        ok = 0
    C[min(3, len(G[i])//2)] += 1
if C[1] == N or (C[1] == N-1 and C[2] == 1):
    ok = 0
elif C[1] == N-2 and C[2] == 2:
    VV = []
    for i in range(N):
        if len(G[i]) == 4:
            VV.append(i)
    if not check(*VV):
        ok = 0
print("Yes" if ok else "No")

Measured memory_bytes: 22296
import math
a, b, x = map(int, input().split())
y = x/a
if y <= a*b/2:
  theta = 90 - math.degrees(math.atan(2*y/(b**2)))
else:
  theta = math.degrees(math.atan(2*(a*b-y)/(a**2)))
print(theta)

Measured memory_bytes: 38384
#include <stdio.h>
#define INF 2147483647

int matrixChainOrder();
int n,p[101],m[100][100];

int main(){
  int i,r,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    p[i]=r;
  }
  p[i]=c;
  
  matrixChainOrder();
  printf("%d\n",m[1][n]);

  return 0;
}

int matrixChainOrder(){
  int i,j,k,l,q;

  for(i=1;i<=n;i++) m[i][i]=0;
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>q) m[i][j]=q;
      }
    }
  }
}

Measured memory_bytes: 636
# Stack

class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b)


def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop())

main()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int max(vector<int> arr){
    return *max_element(arr.begin(),arr.end());
}
int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;i++){
      cin>>arr[i];
  }
  int m1=max(arr);
  vector<int> brr;
  brr=arr;
  vector<int>::iterator it=std::find(arr.begin(),arr.end(),m1);
  arr.erase(it);
  
  int m2=max(arr);
  
  for(int i=0;i<n;i++){
      if(brr[i]==m1){
          cout<<m2<<endl;
      }
      else{
          cout<<m1<<endl;
      }
  }
  return 0;
}

Measured memory_bytes: 3952
S = list(input())
for i in range(2 ** 3):
    pm = ['-'] * 3
    for j in range(3):
        if i >> j & 1:
            pm[j] = '+'
    ans = [None] * 7
    ans[::2] = S
    ans[1::2] = pm
    ans = ''.join(ans)
    if eval(ans) == 7:
        print(ans + '=7')
        break

Measured memory_bytes: 38256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "a.cpp"

int main() {
  string s;
  cin >> s;

  if (s[1] == 'B') {
    cout << "ARC" << el;
  } else {
    cout << "ABC" << el;
  }
}


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

int main()
{
	int Dice[6];
	string direction;
	int tmp;
	int i;
	
	for(i=0;i<6;i++){
		cin >> Dice[i];
	}
	cin >> direction;
	
	for(i=0;direction[i]!='\0';i++){
		if(direction[i]=='E'){
			tmp=Dice[0];
			Dice[0]=Dice[3];
			Dice[3]=Dice[5];
			Dice[5]=Dice[2];
			Dice[2]=tmp;
		}
		else if(direction[i]=='W'){
			tmp=Dice[0];
			Dice[0]=Dice[2];
			Dice[2]=Dice[5];
			Dice[5]=Dice[3];
			Dice[3]=tmp;
		}
		else if(direction[i]=='N'){
			tmp=Dice[0];
			Dice[0]=Dice[1];
			Dice[1]=Dice[5];
			Dice[5]=Dice[4];
			Dice[4]=tmp;
		}
		else if(direction[i]=='S'){
			tmp=Dice[0];
			Dice[0]=Dice[4];
			Dice[4]=Dice[5];
			Dice[5]=Dice[1];
			Dice[1]=tmp;
		}
	}
	
	cout << Dice[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1208
program sum_of_large_numbers
  implicit none
  integer(8), parameter :: m = 1000000007_8, h = (m+1)/2, t = (m+1)/3, s = mod(h*t,m)
  integer(8) :: n, k, i
  read(*,*) n, k
  write(*,'(i0)') modulo(x(n+1)-x(k-1),m)
contains
  integer(8) function f(i)
    integer(8), intent(in) :: i
    f = mod(mod(h*i,m)*(i+1),m)
  end
  integer(8) function g(i)
    integer(8), intent(in) :: i
    g = mod(mod(s*i,m)*mod((i+1)*(i*2+1),m),m)
  end
  integer(8) function x(i)
    integer(8), intent(in) :: i
    x = mod((n+1)*f(i)-g(i)+i,m)
  end
end program sum_of_large_numbers

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

int main(){
  int n,k,s=0; char c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> c >> k;
    if(c=='(')s+=k;
    else s-=k;
    if(s<0){cout << "NO\n"; return 0;}
  }
  if(!s)cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 1128
program dm
    implicit none
    integer::N
    character(4000)::S
    
    integer(16)::ANS=0

    integer::i,j
    logical,allocatable,dimension(:)::R,G,B
    integer(16)::cntR=0,cntG=0,cntB=0
    read*,N
    read*,S
    allocate(R(N),G(N),B(N))

    R=.false.
    G=.false.
    B=.false.

    do i=1,N
        if(S(i:i)=="R")then
            R(i)=.true.;cntR=cntR+1
        endif
        if(S(i:i)=="G")then
            G(i)=.true.;cntG=cntG+1
        endif
        if(S(i:i)=="B")then
            B(i)=.true.;cntB=cntB+1
        endif
    end do
    !RGB
    do i=1,N
        if(R(i))then
            do j=i+1,N
                if(G(j))then
                    if(2*j-i<=N)then
                        if(B(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do
    !RBG
    do i=1,N
        if(R(i))then
            do j=i+1,N
                if(B(j))then
                    if(2*j-i<=N)then
                        if(G(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do
    !GRB
    do i=1,N
        if(G(i))then
            do j=i+1,N
                if(R(j))then
                    if(2*j-i<=N)then
                        if(B(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do
    !GBR
    do i=1,N
        if(G(i))then
            do j=i+1,N
                if(B(j))then
                    if(2*j-i<=N)then
                        if(R(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do

    do i=1,N
        if(B(i))then
            do j=i+1,N
                if(R(j))then
                    if(2*j-i<=N)then
                        if(G(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do
    do i=1,N
        if(B(i))then
            do j=i+1,N
                if(G(j))then
                    if(2*j-i<=N)then
                        if(R(2*j-i))then
                            ANS=ANS+1
                        endif
                    endif
                endif
            end do
        endif
    end do
    print"(i0)",cntR*cntG*cntB-ANS
contains
end program dm

Measured memory_bytes: 2932
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

ans = 0
for i in count:
    ans = (ans + count[i] * pow(2,i,MOD)) % MOD

print ans


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  cout << min(A*N, B) << endl;

  return 0;
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    SGET(S);
    if(S == "SUN")PRINT(7);
    if(S == "MON")PRINT(6);
    if(S == "TUE")PRINT(5);
    if(S == "WED")PRINT(4);
    if(S == "THU")PRINT(3);
    if(S == "FRI")PRINT(2);
    if(S == "SAT")PRINT(1);
}


Measured memory_bytes: 256
# import itertools
S = input()[::-1]
# l = len(S)
# nums = range(1, l+1)
count = [0]*2019
count[0] = 1
num = 0
d = 1
for i in S:
    num += int(i)*d
    count[num % 2019] += 1
    d *= 10
    d %= 2019

ans = 0
for i in count:
    ans += i*(i-1)//2
print(ans)


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

#define FOR(i,s,t) for(int i =s ; i <t ; i++)

void solve() {
	int N, M, P;
	while (cin>>N>>M>>P,N){
		vector<int>a(N);
		FOR(i, 0, N) {
			cin >> a[i];
		}
		long long sum = accumulate(a.begin(), a.end(), 0LL);
		M--;
		sum *= 100;
		if (a[M] == 0)cout << 0 << endl;
		else 		cout << max(0LL, sum *(100-P)/ a[M]/100) << endl;

	}

}

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

	solve();

	return 0;
}


Measured memory_bytes: 3184