akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, p;
  p=1;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  sort (vec.begin(), vec.end());
  
  for (int i=0; i<N-1; i++) {
    if (vec.at(i)==vec.at(i+1)) {
      cout << "NO" << endl;
      p=0;
      break;
    }
  }
  
  if (p==1) {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int dp[1000010][2];

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

	string s;
	cin >> s;
	reverse(all(s)); 
	int n = s.size();
	rep(i, n + 1) rep(j, 2) dp[i][j] = inf;
	dp[0][0] = 0;
	rep(i, n) {
		int c = s[i] - '0';
		chmin(dp[i + 1][0], dp[i][0] + c);
		chmin(dp[i + 1][0], dp[i][1] + c + 1);
		chmin(dp[i + 1][1], dp[i][0] + 10 - c);
		chmin(dp[i + 1][1], dp[i][1] + 9 - c);
	}
	cout << min(dp[n][0], dp[n][1] + 1) << '\n';
}

Measured memory_bytes: 9116
#include<stdio.h>
#include<math.h>
int main(void){
  int n,x[9],y[9],i,j,z;
  double s[9][9],f,ave;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&x[i],&y[i]);
  }
  z=1;
  f=0;
  /*n-1!*/
  for(i=1;i<=n-1;i++){
    z=z*i;
  }
  for(i=1;i<=n-1;i++){
    for(j=i+1;j<=n;j++){
      s[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      f=f+s[i][j]*z*2;
    }
  }
  ave=f/(z*n);
  printf("%5.10f\n",ave);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n;
	int a[1000];

	while(1){
		cin>>n;

		if(n==0)
			break;

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

		int diff=1000000;

		for(int i=0;i<(n-1);i++){
			for(int j=i+1;j<n;j++){
				if(diff>abs(a[i]-a[j]))
					diff=abs(a[i]-a[j]);
			}
		}

		cout<<diff<<endl;
	
	}

	return 0;
}

Measured memory_bytes: 3068
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	dd=[[] for i in range(n)]
	
	
	for i in range(n-1):
		na, nb , dist = IN()
		dd[na-1].append((nb-1, dist))
		dd[nb-1].append((na-1, dist))
	#parent, parent_color, current, dist
	
	stock=[(0,0,0)]
	ret=[0]*n
	
	while len(stock)>0:
		(pn, cn, cc) = stock.pop()
		#pa(len(stock))
		#print(pn,pc,cn,di)
		for next_n, dist in dd[cn]:
			if next_n==pn:
				continue
				
			paint_color = cc
			if dist % 2 == 1:
				paint_color = (cc + 1)%2
			ret[next_n] = paint_color
			stock.append((cn, next_n,paint_color))
			
	for color in ret:
		print(color)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38828
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int cnts[3];
int main()
{
    int n;
    cin >> n;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        int c = 0;
        while (a % 2 == 0)
        {
            a /= 2;
            ++c;
        }
        // cout << c << endl;
        if (c == 0)
            cnts[0]++;
        else if (c == 1)
            cnts[1]++;
        else
            cnts[2]++;
    }

    // cout << cnts[0] << ' ' << cnts[1] << ' ' << cnts[2] << endl;

    if (cnts[0] <= cnts[2])
        cout << "Yes" << endl;
    else if (cnts[1] == 0 and cnts[0] == cnts[2] + 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
ps = list(map(int, input().split()))

cnt = 0
for i in range(1, n, 1):
    pi = ps[i]
    if pi != max(ps[i-1:i+2]) and pi != min(ps[i-1:i+2]):
        cnt += 1

print(cnt)


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  int x = 0, y = 0, z = 0;
  rep(i, n) {
    int t;
    std::cin >> t;
    a[i] = t;
    if (t % 4 == 0)
      x++;
    else if (t % 2 == 0)
      y++;
    else
      z++;
  }
  if (y > 0)
    z++;

  std::cout << (x >= (z - 1) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
// H - Grid 1

#define MOD 1000000007

using namespace std;

int dp[1005][1005];

int main() {
    int H,W,i,j;
    char a;

    scanf("%d%d",&H,&W);

    dp[1][1] = 1;
    for (i = 1;i <= H;i++) {
        for (j = 1;j <= W;j++) {
            scanf(" %c",&a);
            if (a == '.') {
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                dp[i][j] %= MOD;
            }
        }
    }

    printf("%d\n",dp[H][W]);

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int f[12][12];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int h, w;
	cin >> h >> w;
	rep (i, 0, 9) {
		rep (j, 0, 9) {
			cin >> f[i][j];
		}
	}
	rep (k, 0, 9) {
		rep (i, 0, 9) {
			rep (j, 0, 9) {
				if (f[i][j] > f[i][k] + f[k][j]) {
					f[i][j] = f[i][k] + f[k][j];
				}
			}
		}
	}
	int ans = 0;
	rep (i, 1, h) {
		rep (j, 1, w) {
			int v;
			cin >> v;
			if (~v) ans += f[v][1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

	int n , k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0 ; i < n ; i++){
		cin>>v[i];
	}
	sort(v.begin(), v.end());
			
	int ans = 0;

	for(int i = 0; i < k; i++) ans += v[i];
	cout << ans ;     

  return 0;
}


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

int main(){
	
	string str, str1;
	int valid;
	
	while(getline(cin, str)){
		valid = 0;
		for(int i=0; i<26; i++){
			for(int j=0; j<str.length(); j++){
				if(str[j] == ' ' || str[j] == '.') continue;
				if(str[j] == 'z') str[j] = 'a';
				else{
					str[j]++;
				}
			}
			
			str1 = "";
			for(int j=0; j<str.length(); j++){
				if(str[j] != ' ' && str[j] != '.') str1 += str[j];
				else{
					if(str1 == "the" || str1 == "this" || str1 == "that"){
						cout << str << endl;
						valid = 1;
						break;
					}
					else str1 = "";
				}
			}
			if(valid == 1) break;
		}
	}

	return 0;
	
}

Measured memory_bytes: 1188
#include<stdio.h>
int main(void)
{
    int i,n;
    int number;
    long long int sum=0;
    int min=0;
    int max=0;
 
    scanf("%d",&n);
 
    for(i=0;i<n;i++)
    {
        scanf("%d",&number);
 
        if(i==0)
        {
            min = number;
            max = number;
        }
        if(number<min) min = number;
        if(number>max) max = number;
 
        sum += number;
 
    }
  
    printf("%d %d %lld\n",min,max,sum);
 
    return 0;
 
}
 

 

Measured memory_bytes: 600
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        mut s: Chars,
    }

    s.reverse();

    let mut now: u32 = 0;
    let mut ten: u32 = 1;

    let mut map: HashMap<u32, u32> = HashMap::new();
    map.insert(0, 1);

    for c in s {
        now = (c.to_digit(10).unwrap() * ten + now) % 2019;
        map.entry(now).and_modify(|v| *v += 1).or_insert(1);
        ten = (ten * 10) % 2019;
    }

    let ans: u32 = map
        .into_iter()
        .map(|(_, v)| if v >= 2 { v * (v - 1) / 2 } else { 0 })
        .sum();

    println!("{}", ans);
}


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

int main()
{
    string s;
    long long int count = 0;

    cin >> s;

    for (int i = 0; i < s.length(); i++)
    {
        count += (int(s[i]) - 48);
    }
    if (count % 9)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 3720
#include<iostream>

using namespace std;
int main()
{
	int H, N;
	cin >> H >> N;
	int* A = new int[N];
	if ((H >= 1 && H <= 1000000000) && (N >= 1 && N <= 100000))
	{
		for (int i = 0; i < N; i++)
		{
			cin >> A[i];
			if (A[i] < 1 || A[i]>10000)
			{
				cout << "Wrong inputs" << endl;
				break;
			}
			H -= A[i];
		}
		if (H <= 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "Wrong inputs" << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define swap(a,b,type)do{type temp; temp= a;a = b; b= temp;}while(0); 
int main(){
 int a,b,c;
 cin >> a>> b >> c;
 int d = min(a,b);
 for(int i= d;i>=1;--i){
   if(a%i==0&&b%i==0){
     --c;
     if(c==0){
       cout << i << endl;
       return 0;
     }
   }
 }
 assert(false);
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 200005


int main() {
    fastio;
    int n;
    cin>>n;
    lli a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    lli pro=1;
    sort(a,a+n);
    lli mn=1e18;
    int no=0;
    for(int i=0;i<n;i++)
    {
        if(pro==0)
            break;
        lli maxi;
        maxi=mn/pro;
        if(a[i]>maxi)
        {
            pro=-1;break;
        }
        else
            pro*=a[i];
    }
    cout<<pro<<"\n";
    return 0;
}


Measured memory_bytes: 4396
/*
 * ID:  ITP1_10_D
 * Problem: Distance 2
 */

#include <stdio.h>
#include <math.h>

int main(void)
{
    double x[100], y[100];
    double r1 = 0, r2 = 0, r3 = 0, rinf;
    int d, i;

    scanf("%d", &d);
    for (i = 0; i < d; i++)
        scanf("%lf", x + i);
    for (i = 0; i < d; i++)
        scanf("%lf", y + i);

    rinf = fabs(x[0] - y[0]);
    for (i = 0; i < d; i++) {
        int diff = fabs(x[i] - y[i]); 
        r1 += diff;
        r2 += diff * diff;
        r3 += diff * diff * diff;
        rinf = rinf > diff ? rinf : diff;
    }
    
    r2 = sqrt(r2);
    r3 = pow(r3, 1.0/3.0);
    printf("%f\n%f\n%f\n%f\n", r1, r2, r3, rinf);

    return 0;
}



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

int main(){
    int n, w, r[205], b[205], ans = 0;

    cin >> n;
    for(int i=0; i<201; ++i) r[i] = b[i] = 201;
    for(int i=0; i<n; ++i) {cin >> w; cin >> r[w];}
    for(int i=0; i<n; ++i) {cin >> w; cin >> b[w];}

    for(int i=1; i<200; ++i){
        if(b[i] != 201){
            int rmaxi = 201;
            for(int k=0; k<i; ++k){
                if(r[k] != 201 && r[k] < b[i]){
                    if(rmaxi == 201) rmaxi = k;
                    if(r[rmaxi] < r[k]){
                        rmaxi = k;
                    }
                }
            }
            if(rmaxi != 201){
                r[rmaxi] = 201;
                ++ans;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;
unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 


int main(void){
    string s;
    cin>>s;
    int ans=0;
    int l=0,r=s.length()-1;
    while(l<r){
        if(s[l]==s[r]){
            l++;
            r--;
        }
        else{
            if(s[l]=='x'){
                l++;
                ans++;
            }
            else{
                if(s[r]=='x'){
                    r--;
                    ans++;
                }
                else{
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int  y,m,n;
	scanf("%d/%d/%d",&y,&m,&n);
	if(y<2019)
		puts("Heisei");
	else if(y==2019)
	{
		if(m<4)
			puts("Heisei");
		else if(m==4){
			if(n<=30)
				puts("Heisei");
			else
				puts("TBD");
		}
		else
			puts("TBD");
		
		
	}
	else
		puts("TBD");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int r = 1000000000 + 7;

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = sc.nextInt();
		sc.close();
		Arrays.sort(a);
		long ans = 1;
		if(a[0] >= 0){
			for (int i = 0; i < k; ++i) {
				ans *= (long) a[n - i - 1];
				ans %= r;
			}	
		}
		else if(a[n - 1] <= 0){
			if(k % 2 == 1){
				for (int i = 0; i < k; ++i) {
					ans *= (long) a[n - i - 1];
					ans %= r;
				}	
			}else{
				for (int i = 0; i < k; ++i) {
					ans *= (long) a[i];
					ans %= r;
				}	
			}
		}
		else {
			long minus = 1, plus = 1;
			int curl = 0, curr = n - 1;
			if(k % 2 == 1){
				ans *= (long)a[n - 1];
				ans %= r;
				--k;
				--curr;
			}
			for (int i = 2; i <= k; i += 2) {
				minus = (long)a[curl] * (long)a[curl + 1];
				plus = (long)a[curr] * (long)a[curr - 1];
				if(minus >= plus){
					minus %= r;
					ans *= minus;
					ans %= r;
					curl += 2;
				}
				else{
					plus %= r;
					ans *= plus;
					ans %= r;
					curr -= 2;
				}
			}
		}
		if (ans < 0) {
			ans += r;
		}
		System.out.println(ans);
	}
}


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

int main(){
  while(1){
    unordered_map<int,int> mp;
    int x,y,c=0;
    scanf("%d %d",&x,&y);
    if(x==0&&y==0)break;
    
    while(x!=0&&mp.count(x)==0){
      mp[x]=c++;
      x*=10;
      x%=y;
    }
    if(x==0){
      cout<<c<<' '<<0<<endl;
    }else{
      cout<<mp[x]<<' '<<c-mp[x]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 42476
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	void set(int arg_from,int arg_to,int arg_cost){
		from = arg_from;
		to = arg_to;
		cost = arg_cost;
	}
	int from,to,cost;
};

int main(){

	int V,E,start;
	scanf("%d %d %d",&V,&E,&start);

	int* min_dist = new int[V];

	for(int i = 0; i < V; i++)min_dist[i] = BIG_NUM;
	min_dist[start] = 0;

	Info* Edges = (Info*)malloc(sizeof(Info)*E);

	int from,to,cost;

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&cost);
		Edges[i].set(from,to,cost);
	}

	bool FLG = true,updated;
	Info tmp;

	for(int i = 0; i < V; i++){
		updated = false;
		for(int k = 0; k < E; k++){
			tmp = Edges[k];
			if(min_dist[tmp.from] != BIG_NUM && min_dist[tmp.to] > min_dist[tmp.from] + tmp.cost){
				min_dist[tmp.to] = min_dist[tmp.from] + tmp.cost;

				updated = true;
				if(i == V-1){
					FLG = false;
					break;
				}
			}
		}
		if(!updated)break;
		if(!FLG)break;
	}

	if(!FLG){
		printf("NEGATIVE CYCLE\n");
		return 0;
	}

	for(int i = 0; i < V; i++){
		if(min_dist[i] == BIG_NUM){
			printf("INF\n");
		}else{
			printf("%d\n",min_dist[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 2760
#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; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<bool> buy(n),sell(n);
    for (int i = n-1; i > 0; --i) {
        if (a[i-1] < a[i]) {
            sell[i] = true;
            buy[i-1] = true;
        }
    }
    //print(buy);
    //print(sell);

    ll mon = 1000;
    ll kabu = 0;
    rep(i,n) {
        if (kabu > 0) {
            if (sell[i]) {
                ll tmp = kabu*a[i];
                mon += tmp;
                kabu=0;
                //cout << "mon = " << mon << '\n';
                //cout << "kabu = " << kabu << '\n';
            }
            if (buy[i]) {
                ll tmp = mon/a[i];
                kabu += tmp;
                mon = mon%a[i];
                //cout << "mon = " << mon << '\n';
                //cout << "kabu = " << kabu << '\n';
            }
        }
        else {
            if (buy[i]) {
                ll tmp = mon/a[i];
                kabu += tmp;
                mon = mon%a[i];
                //cout << "mon = " << mon << '\n';
                //cout << "kabu = " << kabu << '\n';
            }
            if (sell[i]) {
                ll tmp = kabu*a[i];
                kabu=0;
                mon += tmp;
                //cout << "mon = " << mon << '\n';
                //cout << "kabu = " << kabu << '\n';
            }
        }
    }

    cout << mon << '\n';
    return 0;
}

Measured memory_bytes: 3548
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        
        double pi = 3.14159;
        int r = in.nextInt();
        out.println(pi*2*r);
        
        
        in.close();out.flush();out.close();
    }
}

Measured memory_bytes: 36032
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
 return a / gcd(a, b)*b;
}
int main(){
  string a,b;
  cin >> a >> b;
  bool flag = true;
  for(int i=0;i<a.size();i++){
    if(a[i]!=b[SZ(b)-i-1]) {
      flag = false;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) {
		while(a[i] > 0) {
			int pos = i;
			while(a[pos] > 0) {
				a[pos]--;
				pos++;
			}
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int solve(int N, int P){
    vector<int> cans(N);
    int p = P;
    for (int i = 0;; i++){
        if (p){
            cans[i%N]++;
            p--;
        }else{
            p = cans[i%N];
            cans[i%N] = 0;
        }
        if (cans[i%N] == P) return i%N;
    }
    return -1;
}

int main(){
    cin.tie(0);

    int N, P; 
    vector<int> ans;
    while (1){
        cin >> N >> P;
        if (!N && !P) break;
        ans.push_back(solve(N, P));
    }
    for (auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << *itr << endl;
    }

}




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

int main(){
	int n; cin >> n;
	if(pcount(n) == 1) puts("No");
	else{
		puts("Yes");
		print2(1,2);
		print2(2,3);
		print2(3,n+1);
		print2(n+1,n+2);
		print2(n+2,n+3);
		for(int i=4; i<n; i+=2){
			print2(i,i+1);
			print2(i+1,i^(i+1));
			print2(i^(i+1),i+n);
			print2(i+n,i+n+1);
		}
		if(n & 1 ^ 1){
			int s = 0;
			rep(i,20){
				if(n>>i & 1){
					s = i;
					break;
				}
			}
			print2(n-(1<<s)+1, n);
			print2((1<<s)+n,2*n);
		}
	}
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


int main(){

    long long n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    string rs = string(s.rbegin(), s.rend());

    // p = 2, 5
    if (10%p == 0) {
        long long ans = 0;
        rep(i,n) {
            if ((rs[i]-'0') % p == 0) {
                ans += n-i;
            }
        }
        cout << ans << endl;
        return 0;
    }

    // それ以外
    // 各位に対応する累積和を計算する
    vector<long long> R(n);
    long long ten = 10 % p;
    R[0] = (rs[0]-'0') % p;
    rep1(i,n-1) {
        long long a = (rs[i]-'0') * ten % p;
        R[i] = (a + R[i-1]) % p;
        ten = (10 * ten) % p;
    }


    // 累積和をカウント
    vector<long long> c(p);
    rep(i,n) c[R[i]]++;
    c[0]++;

    long long ans = 0;
    rep(i,p) ans += c[i]*(c[i]-1)/2;

    cout << ans << endl;  



    return 0;
}


Measured memory_bytes: 2308
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=1000150;
///
ll mod=1e9+7;
ll arr[mx];

int main()
{
//    SPEED;
    int t,tc=1;
//    sf(t);
    t=1;
    while(t--)
    {
        string s;
        cin>>s;
        int c=0;
        int maxx=0;
        for(int i=0;i<3;i++)
        {
            if(s[i]=='R')
            {
                c++;
                maxx=max(maxx,c);
            }
            else
                c=0;
        }
        cout<<maxx<<endl;
    }


    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int k;
	
	scanf("%d",&k);
	
	string sum="";
	string acl="ACL";
	
	for(int i=0;i<k;i++)
	{
	   sum=sum+acl;
	}
	
    cout<<sum<<endl;
    
	
	
}
 

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  long int a,b,c;
  set<pair<pair<long int,long int>,long int> >s;
  cin>>a>>b>>c;
  if(a%2||b%2||c%2){cout<<0<<endl;goto L;}
  for(int i=1;i<100000;i++){
    long int aa=b/2+c/2,bb=a/2+c/2,cc=b/2+a/2;
    if(aa%2||bb%2||cc%2){
      cout<<i<<endl;
      goto L;
    }
    a=aa;b=bb;c=cc;
    if(s.count(mk(mk(a,b),c)))break;
    s.insert(mk(mk(a,b),c));
  }
  cout<<-1<<endl;
  L:;
}

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

int main(void){
int i,x,y,z;
char card[201],temp[201];
while(1){
 scanf("%s",card);
 if(strcmp(card,"-")==0) break;//同じ文字かどうか
 z=strlen(card);//zenbu
 scanf("%d",&x);
 for(i=0;i<x;i++){
  scanf("%d",&y);
  strcpy(temp,card);
  strcpy(card,&temp[y]);
  strncpy(&card[z-y],temp,y);
  card[z]='\0';
  }
 printf("%s\n",card);
 }
return 0;
}


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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	int X[3];
	int N[3];

	scanf("%d %d %d %d %d", X, X+1, N, N+1, N+2);

	priority_queue<ll> apples[3];

	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < N[i]; j++) {
			ll a;
			scanf("%lld", &a);
			apples[i].push(a);
		}
	}

	ll sum = 0;
	int C = X[0] + X[1];
	X[2] = min(C, N[2]);
	for (int i = 0; i < C; i++) {
		int s = 0;
		if (apples[s].top() < apples[1].top()) s = 1;
		if (apples[s].top() < apples[2].top()) s = 2;

		sum += apples[s].top();
		apples[s].pop();
		X[s]--;
		if(X[s] == 0) {
			while(!apples[s].empty()) apples[s].pop();
			apples[s].push(-1);
		}
	}

	printf("%lld\n", sum);

	return 0;
}


Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
ll power(ll a,ll b,ll c){
    ll ans = 1;
    ll base = a%c;
    while(b){
        if(b & 1) ans = (ans*base)%c;
        base = (base*base)%c;
        b >>= 1;
    }
    return ans;
}
ll n,m,p=1000000007,z;
long long pow(long long x,long long y)
{
    if (y==0)
        return 1;
    long long z=pow(x,y/2)%p;
    if (y%2==0)
        return z*z%p;
    return z*z%p*x%p;
}
long long ni(long long x,long long p)
{
    return pow(x,p-2);
}
long long c(ll n,ll m,ll p)
{
    long long x=1,y=1;
    for (ll i=n; i>=n-m+1; i--)
        x=x*i%p;
    for (ll i=1; i<=m; i++)
        y=y*i%p;
    return x*ni(y,p)%p;
}
int main()
{
    ll x,flag,i,t,ans=0,j,k=1,l,n,a,b,ans2;
    scanf("%lld %lld %lld",&n,&a,&b);
    ans=power(2,n,p);
    ans2=(c(n,a,p)%p+c(n,b,p)%p+1)%p;
    if(ans2>ans)ans=p+ans-ans2;
    else
        ans=ans-ans2;
    ans=ans%p;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

count = 0
(a+1).times do |i|
  (b+1).times do |j|
    (c+1).times do |k|
      count += 1 if i * 500 + j * 100 + k * 50 == x
    end
  end
end
puts count


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF (1e9)
#define N 100005
using namespace std;
int n,a,b,p1,p2,u,maxd,cnt,ans[N];
bool used[N],t[N];
vector<int> e[N];

void dfs(int x,int d){
  if(used[x])return;
  used[x]=true;
  if(maxd<d)maxd=d,u=x;
  for(int i=0;i<e[x].size();i++)
    dfs(e[x][i],d+1);
}

int dfs2(int x){
  int res=false;
  if(used[x])return res;
  if(x==p2)res=true;
  used[x]=true;
  for(int i=0;i<e[x].size();i++)
    res|=dfs2(e[x][i]);
  cnt+=res;
  return t[x]=res;
}

void dfs3(int x,int d){
  if(used[x])return;
  used[x]=true;
  if(t[x])ans[x]=min(ans[x],d);
  for(int i=0;i<e[x].size();i++)
    dfs3(e[x][i],d+1);
}

void dfs4(int x,int d){
  if(used[x])return;
  used[x]=true;
  ans[x]=d;
  for(int i=0;i<e[x].size();i++)
    dfs4(e[x][i],d-1);
}

int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a>>b; a--, b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  for(int i=0;i<n;i++)ans[i]=INF;
  maxd=0; dfs(0,0);  p1=u;
  memset(used,0,sizeof(used));
  maxd=0; dfs(p1,0); p2=u;
  memset(used,0,sizeof(used));
  dfs2(p1);
  memset(used,0,sizeof(used));
  dfs3(p1,2*n-cnt-1);
  memset(used,0,sizeof(used));
  dfs3(p2,2*n-cnt-1);
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++)
    if(t[i]){
      used[i]=true;
      for(int j=0;j<e[i].size();j++)
	if(!t[e[i][j]])dfs4(e[i][j],ans[i]-1);
    }
  for(int i=0;i<n;i++)
    cout<<ans[i]<<endl;
  return 0;
}

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

int main(void){
  int n,x,i,j,k;

  while(true){
      cin >> n >> x;
      if(n == 0 && x == 0){
          break;
      }
      int ans = 0;
      for(i = 1; i <= n; ++i) {
          for(j = i + 1; j <= n; ++j) {
              for(k = j + 1; k <= n; ++k) {
                  ans += i + j + k == x;
                }
            }
        }
        cout << ans << endl;
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
  
  return 0;
}


Measured memory_bytes: 3600
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]
hasi=[0]*N
for i in range(M):
    AB[i][0]-=1
    AB[i][1]-=1
    if H[AB[i][0]]>H[AB[i][1]]:
        hasi[AB[i][1]]+=1
    elif H[AB[i][0]]<H[AB[i][1]]:
        hasi[AB[i][0]]+=1
    else:
        hasi[AB[i][0]]+=1
        hasi[AB[i][1]]+=1
print(hasi.count(0))


Measured memory_bytes: 32024
#pragma GCC optimize(2)

#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstring>

#include <set>
#include <queue>
#include <complex>
#include <algorithm>

int read(void){
	int res = 0, sign = 1;
	char ch = std::getchar();
	while(!std::isdigit(ch)){
		if(ch == '-')
			sign = -1;
		ch = std::getchar();
	}
	while(std::isdigit(ch))
		res = res * 10 + ch - 48, ch = std::getchar();
	return sign * res;
}

template<class Tp>
	void write(const Tp &x){
		if(x > 9)
			write(x / 10);
		std::putchar(x % 10 + 48);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

int x;

int main(){
	x = read();
	if(x < 600)
		write(8);
	else if(x < 800)
		write(7);
	else if(x < 1000)
		write(6);
	else if(x < 1200)
		write(5);
	else if(x < 1400)
		write(4);
	else if(x < 1600)
		write(3);
	else if(x < 1800)
		write(2);
	else
		write(1);
	return 0;
}

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

int main() {
	int N;
	char S;
	bool f = 0;
	cin >> N;

	rep(i,N) {
		cin >> S;
		if(S == 'Y')
			f = 1;
	}

	cout << ((f) ? "Four" : "Three") << endl;
}

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

//1,000,000,007
//1000000007
int main(void)
{
	long int n, a, b;
	long int i, j;
	long int count, sum;
	
	scanf("%ld%ld%ld", &n, &a, &b);
	
	if(b > n * a) {
		printf("%ld\n", n * a);
	} else {
		printf("%ld\n", b);
	}
	
	return 0;
}

Measured memory_bytes: 128
//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}
 
const int N = 110;
 
char str[N]; 
 
int main()
{
	scanf("%s", str + 1);
	int n = strlen(str + 1);
	int ans = n;
	bool flag = 1;
	for (int i = 2; i <= n; ++i) flag &= (str[i] == str[i - 1]);
	if (flag) return puts("0"), 0;
	for (char ch = 'a'; ch <= 'z'; ++ch)
	{
		static char s[N], u[N];
		for (int i = 1; i <= n; ++i) s[i] = str[i];
		for (int i = 1; i <= ans; ++i)
		{
			for (int j = 1; j <= n - i; ++j)
				if (s[j + 1] == ch) u[j] = s[j + 1];
				else u[j] = s[j];
			for (int j = 1; j <= n - i; ++j)
				s[j] = u[j];
			s[n - i + 1] = '\0';
			bool flag = 1;
			for (int j = 1; j <= n - i; ++j)
				if (s[j] != ch) flag = 0;
			if (flag)
			{
				ans = i;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,l,i,j,t,count=0;
    scanf("%d%d",&n,&l);
    int a[n];

    for(i=0;i<n;i++)
        a[i]=fabs((int)l+i);

        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)
                if(a[i]>a[j])
            {
                t=a[i];
                a[i]=a[j];
                a[j]=t;
            }


            for(i=0;i<n;i++)
            {
               if(fabs((int)l+i)==a[0]) continue;

                count+=l+i;
            }
            printf("%d\t",count);
}


Measured memory_bytes: 128
#include <stdio.h>
 
int main()
{
    int i;
    int a[6];
    int tmp;
    int o;
    for(i=0; i<6; i++)scanf("%d ", &a[i]);
    while((o=getchar())!='\n'){
        switch(o){
            case 'E':
                tmp=a[0];a[0]=a[3];a[3]=a[5];a[5]=a[2];a[2]=tmp;
                break;
            case 'N':
                tmp=a[0];a[0]=a[1];a[1]=a[5];a[5]=a[4];a[4]=tmp;
                break;
            case 'S':
                tmp=a[0];a[0]=a[4];a[4]=a[5];a[5]=a[1];a[1]=tmp;
                break;
            case 'W':
                tmp=a[0];a[0]=a[2];a[2]=a[5];a[5]=a[3];a[3]=tmp;
                break;
            default:break;
        }
    }
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 2708
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int max = 0;
	int min = 1000;
	int i,temp;
	for(i=0;i<N;i++){
		scanf("%d",&temp);
		if(max<temp)max=temp;
		if(min>temp)min=temp;
	}
	printf("%d",max-min);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        //for input
        int[][] table = new int[8][3];

        for(int i = 0; i < 3; i++){
          String[] input = br.readLine().split(" ");
          table[i][0] = Integer.parseInt(input[0]);
          table[i][1] = Integer.parseInt(input[1]);
          table[i][2] = Integer.parseInt(input[2]);

          if(i == 0){
            table[3][0] = Integer.parseInt(input[0]);
            table[4][0] = Integer.parseInt(input[1]);
            table[5][0] = Integer.parseInt(input[2]); 
            table[6][0] = Integer.parseInt(input[0]);
            table[7][0] = Integer.parseInt(input[2]);
          }else if(i == 1){
            table[3][1] = Integer.parseInt(input[0]);
            table[4][1] = Integer.parseInt(input[1]);
            table[5][1] = Integer.parseInt(input[2]); 
            table[6][1] = Integer.parseInt(input[1]);
            table[7][1] = Integer.parseInt(input[1]);
          }else if(i == 2){
            table[3][2] = Integer.parseInt(input[0]);
            table[4][2] = Integer.parseInt(input[1]);
            table[5][2] = Integer.parseInt(input[2]); 
            table[6][2] = Integer.parseInt(input[2]);
            table[7][2] = Integer.parseInt(input[0]);
          }
        }

        int N = Integer.parseInt(br.readLine());

        for(int i = 0; i < N; i++){
          int num = Integer.parseInt(br.readLine());

          for(int j = 0; j < 8; j++){
             for(int t = 0; t < 3; t++){
               if(num == table[j][t]){
                 table[j][t] = -1;
               }
             }
          }
        }

        int result = 0;
        int count = 0;

        for(int i = 0; i < 8; i++){
          count = 0;
          for(int j = 0; j < 3; j++){
            if(table[i][j] == -1){
              count++;
              if(count == 3){
                result++;
              }
            }else{
              continue;
            }
          }
        }

        if(result == 0){
          System.out.println("No");
        }else{
          System.out.println("Yes");
        }

        //System.out.println(Arrays.deepToString(table));
        //System.out.println(result);
      }
    }
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[111][202020];
int main(){
    int n,w;
    cin>>n>>w;
    int a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,n+1)rep(j,101010)dp[i][j]=longinf;
    dp[0][0]=0;
    rep(i,n)rep(j,101010){
        dp[i+1][j+b[i]]=min(dp[i+1][j+b[i]],dp[i][j]+a[i]);
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
    ll ans=0;

    rep(i,101010){
        if(dp[n][i]<=w)ans=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 159232
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();

		System.out.println((X+Y)/(Y+Z) -1);

	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll ans = 0;
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  chmin(a, b);
  chmin(a, c);
  chmin(a, d);
  chmin(a, e);

  ans += (n - 1) / a + 5;
  print(ans);
}


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

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

const int N = 2e5+5;
int pw[N];

inline bool sgn(int a) {
    if(a < 0) return 0;
    return 1;
}

void solve() {
    int n; cin >> n;
    int ans = 1;
    map<pair<int,int>, int> pos, neg;
    int good = n; 
    int totzero = 0, zero = 0, revzero = 0;
    for(int i=0; i<n; i++) {
        int a, b; cin >> a >> b;
        if(a == 0 && b == 0) {
            totzero++; continue;
        }
        if(a == 0) zero++;
        else if(b == 0) revzero++;
        else {
            int g = __gcd(abs(a), abs(b));
            a /= g, b /= g;
            if(a<0) {
                a = -a, b = -b;
            }
            if(sgn(a) == sgn(b)) {
                pos[{abs(a), abs(b)}]++;
            } else {
                neg[{abs(a), abs(b)}]++;
            }
        }
    }
    good -= totzero + zero + revzero;
    vector<pair<int, int>> v;
    for(auto it : pos) {
        int a = it.first.first;
        int b = it.first.second;
        int cur = it.second;
        int oth = neg[{b, a}];
        if(oth) {
            good -= cur + oth;
            v.push_back({cur, oth});
        }
    }
    ans = mul(ans, pw[good]);
    ans = mul(ans, sub(add(pw[zero], pw[revzero]), 1));
    for(auto it : v) {
        ans = mul(ans, sub(add(pw[it.first], pw[it.second]), 1));
    }
    ans = add(ans, totzero);
    ans = sub(ans, 1);
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    pw[0] = 1;
    for(int i=1; i<N; i++) pw[i] = mul(2, pw[i-1]);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 23832
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include<cstring>
#include<tuple>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//code fes 2016 final B
int main(void) {
	vector<pair<ll, ll>> tri = vector<pair<ll, ll>>();
	rep(i, 0, 3) {
		ll x, y;
		cin >> x >> y;
		tri.push_back(make_pair(x, y));
	}
	long double a, b, c;
	a = sqrt(pow(tri[0].first - tri[1].first, 2) + pow(tri[0].second - tri[1].second, 2));
	b = sqrt(pow(tri[0].first - tri[2].first, 2) + pow(tri[0].second - tri[2].second, 2));
	c = sqrt(pow(tri[2].first - tri[1].first, 2) + pow(tri[2].second - tri[1].second, 2));
	long double mx = max(a, max(b, c));
	//ヘロン
	long double s = (a + b + c) / (long double)2;
	long double r = 2 * (sqrt(s * (s - a) * (s - b) * (s - c))) / (a + b + c);
	cout << setprecision(12) << r * mx / (2 * r + mx) << endl;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll count[5];
	FOR(i,0,5)count[i]=0;
	FOR(i,0,n){
		string s;
		cin >> s;
		if(s[0]=='M')count[0]++;
		if(s[0]=='A')count[1]++;
		if(s[0]=='R')count[2]++;
		if(s[0]=='C')count[3]++;
		if(s[0]=='H')count[4]++;
	}
	//FOR(i,0,5)cout << count[i] << " ";
	ll ans = 0;
	for(int i = 0; i < 3; i++){
		for(int j = i+1; j < 4; j++){
			for(int k = j+1; k < 5; k++){
				ans += count[i] * count[j] * count[k];
			}
		}
	}
	ANS(ans);
	return 0;
}


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

int main(){
  int K;
  string S,T;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S << endl;
  }
  else{
    T=S.substr(0,K)+"...";
    cout << T << endl;
  }
}

Measured memory_bytes: 3584