akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String data = sc.nextLine();
        
        String[] array = data.split(" ");
        int a = Integer.parseInt(array[0]);
        int b = Integer.parseInt(array[1]);
        
        int zeinuki = 1;
        
        while(zeinuki <= 1009)
        {
            int zei08 = (int)(zeinuki * 0.08);
            int zei10 = (int)(zeinuki * 0.1);
            if(zei08 == a && zei10 == b)
            {
                break;
            }
            zeinuki++;
        }
        
        if(zeinuki == 1010)
        {
            zeinuki = -1;
        }
        
        System.out.println(zeinuki);
    }
}


Measured memory_bytes: 23764
def main():
    N = int(input())
    X = tuple(map(int, input().split()))

    x2 = sorted(X)
    mid1 = x2[N//2 - 1]
    mid2 = x2[N//2]
    for i in X:
        if i < mid2:
            print(mid2)
        else:
            print(mid1)

main()


Measured memory_bytes: 26900
N = int(input())
wList = list(map(int, input().split()))

sum = 0
for i in range(N):
    sum += wList[i]

ans = 999999999
temp = 0
for i in range(N):
    temp += wList[i]
#    print(sum, sum - temp,  temp)
    ans = min(ans, abs((sum - temp)- temp))

print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].first.first >> A[i].first.second;
        A[i].second = i + 1; A[i].first.second *= (-1);
    }
    
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        cout << A[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int d, t, s; cin >> d >> t >> s;
	if ((d + s - 1) / s <= t)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3620
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    n=int(input())
    mp=[list(map(int,input().split())) for _ in range(n)]
    table=[[0]*a for _ in range(b)]
    #上下がa横がb
    #色々めんどくさいので、まずは端っこを求める。
    for m in range(a):
        if [m+1,1] in mp:
            break
        table[0][m]=1
    for l in range(b):
        if [1,l+1] in mp:
            break
        table[l][0]=1
    #上のおかげで0を考慮せずに済む
    for i in range(1,b):
        for j in range(1,a):
            if not [j+1,i+1] in mp: 
                table[i][j]=table[i][j-1]+table[i-1][j]
    print(table[b-1][a-1])


Measured memory_bytes: 5600
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    println(
        Array(N) { it + 1 }.filter {
            var cnt = 0
            for (i in 1 .. it) {
                if (it % i == 0) {
                    cnt++
                }
            }

            cnt == 8 && it % 2 == 1
        }.size
    )
}


Measured memory_bytes: 33812
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n, a;
    cin >> n >> a;

    vector<int> x(n), y(n);
    rep(i, n) {
        cin >> x[i];
        y[i] = x[i] - a;
    }
    sort(x.begin(), x.end());

    int X = max(x[n-1], a);

    vector<vector<ll>> dp(n+1, vector<ll>(2*n*X+1));  // dp[i+1][j] : i番目(iは0-index)までで合計j-n*Xになる場合の数

    dp[0][n*X] = 1;
    rep(i, n) {
        rep(j, 2*n*X+1) {

            dp[i+1][j] = dp[i][j];

            if(0 <= j-y[i] && j-y[i] <= 2*n*X) {
                dp[i+1][j] += dp[i][j-y[i]];
            }
        }
    }

    cout << dp[n][n*X] - 1 << endl;
    return 0;
}

Measured memory_bytes: 2304
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	int score=k-q;
	vector<int> an(n+1,score);
	for(int i=0;i<q;i++)
	{
		int t;
		cin>>t;
		an[t]++;
	}
	for(int i=1;i<=n;i++){
		if(an[i]<=0)
			puts("No");
		else
			puts("Yes");
	
	}
	return 0;
}

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

const int INF = 0x7fffffff;
const int MAXN = 110;
int M,N;
int X1[MAXN],Y1[MAXN];
int X2[MAXN],Z2[MAXN];

double width(int* X, int* Y, int n, double x)
{
    double lb = INF,ub = -INF;
    for(int i = 0; i < n; ++i)
    {
        double x1 = X[i], y1 = Y[i], x2 = X[(i+1)%n], y2 = Y[(i+1)%n];
        if((x1-x)*(x2-x) <= 0 && x1 != x2)
        {
            double y = y1 + (y2-y1)*(x-x1)/(x2-x1);
            lb = min(lb,y);
            ub = max(ub,y);
        }
    }
    return max(0.0,ub-lb);
}

void solve()
{
    int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
    int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
    vector<int> xs;
    for (int i = 0; i < M; i++)
        xs.push_back(X1[i]);
    for (int i = 0; i < N; i++)
        xs.push_back(X2[i]);
    sort(xs.begin(), xs.end());

    double res = 0;
    for (int i = 0; i + 1 < xs.size(); i++)
    {
        double a = xs[i], b = xs[i + 1], c = (a + b) / 2;
        if (min1 <= c && c <= max1 && min2 <= c && c <= max2)
        {
            double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
            double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
            double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
            res += (b - a) / 6 * (fa + 4 * fc + fb);
        }
    }
    printf("%.10f\n", res);
}

int main()
{
    while(scanf("%d %d",&M,&N) && M+N)
    {
        for(int i = 0; i < M; ++i)
            scanf("%d %d",&X1[i],&Y1[i]);
        for(int i = 0; i < N; ++i)
            scanf("%d %d",&X2[i],&Z2[i]);
        solve();
    }
    return 0;
}


Measured memory_bytes: 3268
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        vs: [i64; n],
        cs: [i64; n]
    }
    let ans = vs.iter().zip(cs.iter()).map(|x| x.0 - x.1).filter(|&x| x > 0).sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

class Main{
	public static void main(String[] $){
		//System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),r=0;
		int[]a=new int[n],c=new int[n];
		for(int i=0;i<n;++i)
			a[i]=s.nextInt();
		for(int i=0;i<n;++i)
			r+=s.nextInt();
		for(int i=1;i<n;++i)
			c[i]=s.nextInt();

		for(int i=0;i<n-1;++i) 
			if(a[i]+1==a[i+1])
				r+=c[a[i]];

		System.out.println(r);
	}
}


Measured memory_bytes: 23508
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

bool isMM(char s1, char s2)
{
    return (s1 == '0' && s2 > '0') || (s1 == '1' && s2 <= '2');
}

void check(const char (&s)[4])
{
    if (isMM(s[0], s[1]))
    {
        if (!isMM(s[2], s[3])) {
            cout << "MMYY" << endl;
        }
        else
        {
            cout << "AMBIGUOUS" << endl;
        }
        return;
    }
    else
    {
        if (isMM(s[2], s[3]))
        {
            cout << "YYMM" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
        return;
    }
}

int main()
{
    char s[4];
    cin >> s;

    check(s);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll abc[105][100005];
ll def[105][100005];
ll arr[100005];
int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	ll i,j;
	for(i=1; i<=n; i++)
		cin>>arr[i];
	for(i=1; i<=n; i++)
	{
		abc[i][0]=1;
		def[i][0]=1;
	}
	for(j=1; j<=k; j++)
	{
		if(j<=arr[1])
			abc[1][j]=1;
		def[1][j]=((def[1][j-1]%mod)+(abc[1][j]%mod))%mod;
	}
	for(i=2; i<=n; i++)
	{
		for(j=1; j<=k; j++)
		{
			ll xx=j-arr[i]-1;
			if(xx>=0)
				abc[i][j]=((def[i-1][j]%mod)-(def[i-1][xx]%mod)+mod)%mod;
			else
				abc[i][j]=def[i-1][j]%mod;
			def[i][j]=((def[i][j-1]%mod)+(abc[i][j]%mod))%mod;
		}
	}
	cout<<(abc[n][k]%mod)<<endl;
	return 0;
}

Measured memory_bytes: 158464
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

map<char, int> mp;

int getArab(string rm) {
    int total = 0;
    int prev = 0;
    REP(i,rm.size()) {
        int crt = mp[rm[i]];
        if (crt <= prev) {
            total += crt;
        }else {
            total += -2 * prev + crt;        }
        prev = crt;
    }
    return total;
}

int main() {
    mp['I'] = 1;
    mp['V'] = 5;
    mp['X'] = 10;
    mp['L'] = 50;
    mp['C'] = 100;
    mp['D'] = 500;
    mp['M'] = 1000;
    string s;
    while(cin >> s) {
        cout << getArab(s) << endl;
    }
    return 0;
}

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

int main()
{
    int H;
    int W;
    int A;
    int B;
    
    cin >> H;
    cin >> W;
    cin >> A;
    cin >> B;
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if((j<A & i<B) | (j>=A & i>=B)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

//BIT
struct BIT{
	int N;
	int data[300010];
	void init(int n){
		N = n;
		fill(data,data+N+1,0);
	}
    void add(int a,int w){
        for(int x = a;x < N; x |= x + 1) data[x] += w;
	}
    int sum(int a){
        int ret = 0;
        for(int x = a-1;x >= 0; x = (x & (x+1)) - 1)ret += data[x];
        return ret;
	}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n+1);
  BIT bit;
  bit.init(n + 2);
  ll ans = 0;
  a[0] = 0;
  FOR(i,1,n+1){
      cin>>a[i];
      a[i] -= k;
      a[i] += a[i-1];
  }
  //zip
  vector<pair<ll,ll> > b(n+1);
  REP(i,n+1)b[i] = make_pair(a[i],i);
  sort(b.begin(),b.end());
  ll tmp = b[0].first, ct = 0;
  for(int i = 0;i < n+1;i++){
      if(tmp != b[i].first){
          tmp = b[i].first;
          ct++;
      }
      a[b[i].second] = ct;
  }
  //  for(auto db:a)cout << db << endl;
  REP(i,n+1){
      ans += bit.sum(a[i]+1);
      bit.add(a[i],1);
  }
  
  cout << ans << endl;
  return 0;
}


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

d =[]
for i in range(n):
    if i == 0:
        d.append(a[0] + k-a[n-1])
    else:
        d.append(a[i]-a[i-1])

print(k-max(d)) 


Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,i,j,cnt,r,g,b;
		cin>>n;
		string str;

		cin>>str;
			r=g=b=0;
		for(i=0;i<str.size();i++)
		{
			if(str[i]=='R')	r++;
			else if(str[i]=='G')	g++;
			else	b++;
		}

		cnt=0;
			
		for(i=0;i<n;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(str[i]!=str[j])
				{
					if(2*j-i >= n)	break;

					if(str[2*j-i]!=str[i] and str[2*j-i]!=str[j])	cnt++; 
				}
			}
		}

		cout<<r*g*b - cnt;

 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3832
#include <iostream>
using namespace std;
int main(){
  int n;
  int dp[31];
  int ans;
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  while(cin >> n,n){
    
    for(int i = 2 ; i < n ; i++){
      dp[i + 1] = dp[i] + dp[ i - 1] + dp[i - 2];
    }
    ans = dp[n]/3650 + 1;
    
    cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
S = input()
Q = int(input())
K = list(map(int, input().split()))
 
for k in K:
    res = 0
    d = 0
    m = 0
    dm = 0
    for i in range(N):
        if S[i] == 'D':
            d += 1
        elif S[i] == 'M':
            dm += d
            m += 1
        elif S[i] == 'C':
            res += dm
        if i + 1 - k >= 0:
            if S[i + 1 - k] == 'D':
                d -= 1
                dm -= m
            elif S[i + 1 - k] == 'M':
                m -= 1
 
    print(res)

Measured memory_bytes: 57616
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<Vec<usize>> = (0..n)
        .map(|_| (0..m).map(|_| sc.read::<usize>() - 1).collect())
        .collect();

    let mut ans = n;
    let mut pos: Vec<usize> = vec![0; n];
    let mut dead = vec![false; m];
    for _ in 0..m {
        let mut count = vec![0; m];
        for i in 0..n {
            count[a[i][pos[i]]] += 1;
        }
        let (max, max_i) = count
            .iter()
            .enumerate()
            .map(|(i, &c)| (c, i))
            .max()
            .unwrap();
        ans = cmp::min(ans, max);
        dead[max_i] = true;
        for i in 0..n {
            while pos[i] < m && dead[a[i][pos[i]]] {
                pos[i] += 1;
            }
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
N, M = [int(i) for i in input().split()]
votes = [int(i) for i in input().split()]

votes = sorted(votes, reverse=True)

votes_sum = sum(votes)

flag = True
border_line = votes_sum / (4 * M)
for i in range(M):
    if votes[i] < border_line:
        flag = False
        
if flag :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    int x, y;
    cin >> x >> y;
    bool ans = false;
    for (int i = 1; i <= x; i++) {
        ans = ans || (i * 4 + (x - i) * 2) == y;
        ans = ans || (i * 2 + (x - i) * 4) == y;
    }
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <list>
#include <math.h>

using namespace std;

int main()
{
    string n, answer;
    answer = "";
    cin >> n;
    for (int i=0; i<3; ++i){
        if(n[i] == '1'){
            answer += "9";
        }
        else if(n[i] == '9'){
            answer += "1";
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long gcd(long long a,long long b){
    if(b==0) 
		return a;
    return gcd(b,a%b);
}
long long lcm(long long a,long long b){
    long long g=gcd(a, b);
    return (a/g)*b;
}
 
int main(void){
    int N;  cin >> N;
    long long T, ans = 1LL;
    for(int i=0; i<N;i++){
        cin >> T;
        ans = lcm(ans,T);
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MOD = (int)1e9 + 7;

class modint {
  int v;
public:
  modint (): v(0) { }
  modint (ll v): v((v + MOD) % MOD) { }

  bool operator== (modint x) { return v == x.v; }
  bool operator!= (modint x) { return v != x.v; }

  modint operator+ (modint x) { return v + x.v; }
  modint operator- (modint x) { return v - x.v; }
  modint operator* (modint x) { return (ll)v * x.v; }

  modint& operator+= (const modint x) { return *this = (*this + x); }
  modint& operator-= (const modint x) { return *this = (*this - x); }
  modint& operator*= (const modint x) { return *this = (*this * x); }

  int operator* () { return v; }
};

#define debug(format, ...) printf(format, __VA_ARGS__);

const int N_ = 105000;

int N;
vector<int> gph[N_];
int deg[N_];
bool chk[N_];

int main() {
  scanf("%d", &N);
  for(int i = 1; i < N; i++) {
    int a, b; scanf("%d%d", &a, &b);
    gph[a].push_back(b);
    gph[b].push_back(a);
    deg[a] += 1;
    deg[b] += 1;
  }

  try {
    if(N <= 2) throw "Second";

    priority_queue< pii, vector<pii>, greater<pii> > pq;
    for(int i = 1; i <= N; i++) {
      pq.push(pii(deg[i], i));
    }

    auto go = [&pq](int u) {
      chk[u] = true;
      for(int v : gph[u]) if(!chk[v]) pq.push(pii(--deg[v], v));
    };

    while(!pq.empty()) {
      int d, u; tie(d, u) = pq.top(); pq.pop();
      if(deg[u] != d || chk[u]) continue;

      if(deg[u] == 0) throw "First";

      go(u);

      for(int v : gph[u]) if(!chk[v]) {
        go(v);
        break;
      }
    }
    throw "Second";
  }catch(const char* s) {
    cout << s << endl;
  }
  return 0;
}


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

#define F first
#define S second
#define pii pair<int, int>
#define mod 1000000007

int N, A[2099], Z, W, ans = 0;
int dp[2100][10];

int main() {
    //freopen("input.in","r",stdin);
 	//freopen("output.out","w",stdout);
    cin >> N >> Z >> W;
    for(int i = 0;i < N;i++) {
        cin >> A[i];
    }
    ans = abs(A[N-1]-W);
    if(N > 1) ans = max(ans, abs(A[N-1]-A[N-2]));
    cout << ans << endl;

    return 0;
}


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

const int MAXV = 1E5 + 5;
long long value[MAXV];

int main () {
	int n, W;
	cin >> n >> W;
	int w, v;
	for (int i = 1; i <= n * 1000; i ++) {
		value[i] = (1ll) * 1E11 + 2;
	}
	for (int i = 0; i < n; i ++) {
		cin >> w >> v;
		for (int j = n * 1000 - v; j >= 0; j --)
			value[v + j] = min(value[v + j], value[j] + w);
	}
	int ans = -1;
	for (int i = 0; i <= 1000 * n; i ++) {
		if (value[i] <= W)
			ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  int N, K;
  cin >> N >> K;
  int Kmax = (N - 1) * (N - 2) / 2;
  if (K > Kmax) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int,int>> G;
  FOR(i,2,N+1) {
    G.pb({1,i});
  }

  int acc = 0;
  FOR(i,2,N+1) {
    FOR(j,i+1,N+1) {
      if(acc == Kmax - K) {
        cout << (N - 1) + acc << endl;
        for(auto e: G) {
          cout << e.first << " " << e.second << endl;
        }
        return 0;
      }
      G.pb({i,j});
      ++acc;
    }
  }
  cout << (N - 1) + acc << endl;
  for(auto e: G) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int i, ans = 0;
    int N, x, y, z;
    int num;
    x = y = z = 1;

    scanf("%d", &N);

    for(i=1; i <= N; i++) {
        ans = 0;

        for(x=1; x*x + x < N; x++) {
            for(y=1; y*y + y < N; y++) {
                for(z=1; z*z + z < 2*N; z++) {
                    num = x*x + y*y + z*z + x*y + y*z + z*x;
                    if(num == i) {
                        ans++;
                    } else if(num > i) {
                        break;
                    }
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#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 vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

bool f(int a) {
    return 1 <= a && a <= 12;
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    string S;
    cin >> S;
    string x{S[0], S[1]}, y{S[2], S[3]};
    int a = stoi(x), b = stoi(y);
    if (f(a) && f(b)) {
        puts("AMBIGUOUS");
    } else if (f(a)) {
        puts("MMYY");
    } else if (f(b)) {
        puts("YYMM");
    } else {
        puts("NA");
    }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = (0 until 3).map { (0 until 3).map { sc.next().toInt() } }
    val n = sc.nextInt()
    val b = (0 until n).map { sc.next().toInt() }
    println(problem157b(a, n, b))
}

fun problem157b(
    a: List<List<Int>>,
    n: Int,
    b: List<Int>
): String {
    val b = b.toHashSet()
    val list = Array(3) { IntArray(3) { 0 } }
    for (i in 0 until 3) {
        for (j in 0 until 3) {
            val ij = a[i][j]
            if (b.contains(ij)) {
                list[i][j] = 1
            }
        }
    }
    return when {
        list[0][0] == 1 && list[0][1] == 1 && list[0][2] == 1 -> "Yes"
        list[1][0] == 1 && list[1][1] == 1 && list[1][2] == 1 -> "Yes"
        list[2][0] == 1 && list[2][1] == 1 && list[2][2] == 1 -> "Yes"

        list[0][0] == 1 && list[1][0] == 1 && list[2][0] == 1 -> "Yes"
        list[0][1] == 1 && list[1][1] == 1 && list[2][1] == 1 -> "Yes"
        list[0][2] == 1 && list[1][2] == 1 && list[2][2] == 1 -> "Yes"

        list[0][0] == 1 && list[1][1] == 1 && list[2][2] == 1 -> "Yes"
        list[0][2] == 1 && list[1][1] == 1 && list[2][0] == 1 -> "Yes"
        else -> "No"
    }
}

Measured memory_bytes: 31524
// B - Count ABC
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; string S; cin>>N>>S;
	int ans = 0;
	rp(i, 0, N-2) if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
	cout<< ans <<endl;
}

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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int n;
  cin >> n;
  if((n&1) == 0)
    cout<<n<<"\n";
  else
    cout<<2*n<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = (int)1e9 + 7;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 100100


int dp[N], a[N];






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

	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i - a[j] >= 0 && dp[i - a[j]] == 0)
					dp[i] = 1;
		}
	}

	if (dp[k] == 1)
		cout << "First";
	else
		cout << "Second";


}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int ans = 0;
		for (int i = 0; i < len; i++) {
			if ((i + 1) % 2 == 1 && line[i] % 2 == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36000
#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
inline ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
inline ll read(){
  ll ans=0,c=getchar();
  while(c<'0'||c>'9'){c=getchar();}
  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
  return ans;
}
int main(){
    int n;
    ll ans=1,x;
    scanf("%d",&n);
    rep(i,n){
      x=read();
      ans=ans/gcd(ans,x)*x;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;
long long x[1005], y[1005], z[1005], a[1005];

int main(){
    
    int N, M;
    cin >> N >> M;
    long long ans = 0;
    long long temp;
    rep(i, N){
        cin >> x[i] >> y[i] >> z[i];
    }

    rep(i, N) a[i] = x[i] + y[i] + z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    rep(i, N) a[i] = x[i] + y[i] - z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    rep(i, N) a[i] = x[i] - y[i] + z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    rep(i, N) a[i] = -1 * x[i] + y[i] + z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);
    
    rep(i, N) a[i] = -1 * x[i] - y[i] + z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);
    
    rep(i, N) a[i] = -1 * x[i] + y[i] - z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    rep(i, N) a[i] =  x[i] - y[i] - z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    rep(i, N) a[i] = -1 * x[i] - y[i] - z[i];
    sort(a, a+N);
    temp =0;
    rep(i, M) temp +=a[N-1-i];
    ans = max(temp, ans);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 8000000000000000000
int main() {
	long long n;
	cin >> n;
	long long ans = n / (long long) 11;
	n %= 11;
	ans *= 2;
	if (n != 0) {
		ans++;
		if (n > 6) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int [] count = new int[26];
        
        while(sc.hasNext()){
            String line  = sc.next();
            
            for(int i = 0; i < line.length(); i++){
                if(Character.isLowerCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'a'];
                }
                
                else if(Character.isUpperCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'A'];
                }
            }
        }
        
        for(int i = 0; i < count.length; i++){
            System.out.println((char)('a' + i) + " : " + count[i]);
        }
    }
}


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

using namespace std;

using P = pair<int, int>;

const int INF = INT_MAX;

template <typename T>
struct SegmentTree {
    int n;
    vector<T> data;

    //使うときは、この3つを適宜変更する
    static T INITIAL_VALUE;
    static T merge(T x, T y); 
    void updateNode(int k, T x);

    SegmentTree(int size) {
        n = 1;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);
    }

    T getLeaf(int k) {
        return data[k + n - 1];
    }
    
    void update(int k, T x) {
        k += n - 1; //葉の節点
        updateNode(k, x);
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }
    
    //区間[a, b)に対するクエリに答える
    //k:節点番号, [l, r):節点に対応する区間
    T query(int a, int b, int k, int l, int r) {
        //[a, b)と[l, r)が交差しない場合
        if (r <= a || b <= l) return INITIAL_VALUE;
        //[a, b)が[l, r)を含む場合、節点の値
        if (a <= l && r <= b) return data[k];
        else {
            //二つの子をマージ
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }
    
    //外から呼ぶ用
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

//使うときは以下3つを変更
template <typename T>
T SegmentTree<T>::INITIAL_VALUE = T(INF, INF);

template <typename T>
T SegmentTree<T>::merge(T x, T y) {
    return min(x, y);
}

template <typename T>
void SegmentTree<T>::updateNode(int k, T x) {
    data[k] = x;
}

struct State {
	int x;
	int y;
	int idx1;
	int idx2;
	int L;
	int R;
	State(int x, int y, int idx1, int idx2, int L, int R) : x(x), y(y), idx1(idx1), idx2(idx2), L(L), R(R) {}
	bool operator>(const State& s) const {
		if (x != s.x) return x > s.x;
		return y > s.y;
	}
};

vector<SegmentTree<P>> st;

State solve(int L, int R, vector<int>& a) {
	int x, idx1;
	tie(x, idx1) = st[L % 2].query(L, R);
	int y, idx2;
	tie(y, idx2) = st[1 - L % 2].query(idx1 + 1, R);
	State res(x, y, idx1, idx2, L, R);
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < 2; i++) st.push_back(SegmentTree<P>(n));
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st[i % 2].update(i, P(a[i], i));	
	}
	vector<int> ans;
	priority_queue<State, vector<State>, greater<State> > pq;
	pq.push(solve(0, n, a));
	while (!pq.empty()) {
		State s = pq.top();
		pq.pop();
		ans.push_back(s.x);
		ans.push_back(s.y);
		if (s.L < s.idx1) pq.push(solve(s.L, s.idx1, a));
		if (s.idx1 + 1 < s.idx2) pq.push(solve(s.idx1 + 1, s.idx2, a));
		if (s.idx2 + 1 < s.R) pq.push(solve(s.idx2 + 1, s.R, a));
	}

	cout << ans[0];
	for (int i = 1; i < n; i++) {
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 13236
import cmath
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*(1+3**.5*1j)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5992
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //n??¨ai?????????????????????
            string s = Console.ReadLine();
            string[] ai = Console.ReadLine().Split(' ');
            int n = int.Parse(s);
            int first = int.Parse(ai[0]);


            //?????§?????¨????°??????¨????¨????????´????????????°(?????????ai???????´?????????????)
            int max = first, min = first;


            //????¨????????´????????????°
            long sum = first;


            //????´??????°???????????????
            for (int i = 1; i < n; i++)
            {
                int a = int.Parse(ai[i]);

                //?????§????????????
                if (max < a)
                    max = a;

                //????°?????????????
                if (min > a)
                    min = a;

                //????¨??????????????????????
                sum = sum + a;

            }

            //????????¨???
            Console.WriteLine(string.Format("{0} {1} {2}", min, max, sum));
        }
    }
}

Measured memory_bytes: 6380
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>

using namespace std;

void print(int a[], int n) {
  for (int i = 0; i < n; i++) {
    cout << a[i] << ", ";
  }
  cout << endl;
}

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  int l[n], r[n];
  for (int i = 0; i < n; i++) {
    l[i] = 0;
    r[i] = 0;
  }

  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'W') {
      l[i] = l[i - 1] + 1;
    }
    else {
      l[i] = l[i - 1];
    }
  }

  for (int i = n - 2; i >= 0; i--) {
    if (s[i + 1] == 'E') {
      r[i] = r[i + 1] + 1;
    }
    else {
      r[i] = r[i + 1];
    }
  }

  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    ans = min(ans, l[i] + r[i]);
  }

  cout << ans << endl;
}


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

int main(){
  int K,A,B;

  cin >> K >> A >> B;

  // if(B - A + 1 >= K || B % K == 0){
  //   cout << "OK" << endl;
  // }else{
  //   cout << "NG" << endl;
  // }


  if(B / K > A / K || B % K == 0 || A % K == 0){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }

}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vl cnt(4);
    rep(i,3){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        cnt[a]++;
        cnt[b]++;
    }
    rep(i,4){
        if(cnt[i]==3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main() {
  int n; cin >> n;
  const double rate = 380000.0;
  double sum = 0;
  
  vector<double> cash(n);
  vector<string> currency(n);
  for (int i = 0; i < n; i++) cin >> cash[i] >> currency[i];
  
  for (int i = 0; i < n; i++) {
    if (currency[i] == "JPY") sum += cash[i];
    else if (currency[i] == "BTC") sum += (rate * cash[i]);
  }
  
  cout << sum << endl;
}

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

using namespace std;

const int mod = 1e9 + 7;

int main() {
	int n, res = 1;
	cin >> n;
	for (int i = 2; i <= n; ++i)
		res = (1LL * res * i) % mod;
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node Tree[MAX];
int Depth[MAX], Height[MAX];

void setDepth(int, int);
int setHeight(int);
int Sibling(int);
void Print(int);

int main(){
  int n,i,num,le,ri;
  int root = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) Tree[i].p = NIL;

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d",&num,&le,&ri);
    Tree[num].l = le;
    Tree[num].r = ri;
    if(le != NIL) Tree[le].p = num;
    if(ri != NIL) Tree[ri].p = num;
  }

  for(i = 0 ; i < n ; i++) if(Tree[i].p == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i = 0 ; i < n ; i++) Print(i);

  return 0;
}

void setDepth(int x, int y){
  if(x == NIL) return;
  Depth[x] = y;
  setDepth(Tree[x].l, y+1);
  setDepth(Tree[x].r, y+1);
}

int setHeight(int x){
  int h1 = 0, h2 = 0;
  if(Tree[x].l != NIL) h1 = setHeight(Tree[x].l) + 1;
  if(Tree[x].r != NIL) h2 = setHeight(Tree[x].r) + 1;

  if(h1 > h2) return Height[x] = h1;
  else return Height[x] = h2;
}

int Sibling(int x){
  if(Tree[x].p == NIL) return NIL;
  if(Tree[Tree[x].p].l != x && Tree[Tree[x].p].l != NIL){
    return Tree[Tree[x].p].l;
  }
  if(Tree[Tree[x].p].r != x && Tree[Tree[x].p].r != NIL){
    return Tree[Tree[x].p].r;
  }

  return NIL;
}

void Print(int x){
  int degree = 0;
  printf("node %d: ",x);
  printf("parent = %d, ",Tree[x].p);
  printf("sibling = %d, ",Sibling(x));
  if(Tree[x].l != NIL) degree++;
  if(Tree[x].r != NIL) degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",Depth[x]);
  printf("height = %d, ",Height[x]);

  if(Tree[x].p == NIL){
    printf("root\n");
  }
  else if(Tree[x].l == NIL && Tree[x].r == NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}



Measured memory_bytes: 2088
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)
#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)
#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const int output_precision = 15;
const bool debug = true;
// const ll MOD = ;

stringstream ss;
int main()
{
	ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
	ss.precision(output_precision); ss << fixed;
	int a, b;
	while (cin >> a >> b) {
		cout << a + b << endl;
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

double cross (double x1, double y1, double x2, double y2 )
{
	return (x1*y2 - x2*y1 );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.APT", "r", stdin );
	string str = "";
	while (getline (cin, str ) && !str.empty() ){
		stringstream ss (str );
		double x1, y1, x2, y2, x3, y3, xp, yp;
		ss >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
		double c1 = cross (xp - x1, yp - y1 , x2 - x1, y2 - y1 );
		double c2 = cross (xp - x2, yp - y2 , x3 - x2, y3 - y2 );
		double c3 = cross (xp - x3, yp - y3 , x1 - x3, y1 - y3 );
		if ((c1 > 0. && c2 > 0. && c3 > 0. ) || (c1 < 0. && c2 < 0. && c3 < 0. ) ){
			printf ("YES\n" );
		}else{
			printf ("NO\n" );
		} // end if
	} // end while

	return 0;
}

Measured memory_bytes: 1232
x = list(map(int,input().split(" ")))
n = x[0]
a = x[1]
b = x[2]

proc = a + b
mul_syo = n // proc
mul_ama = n % proc

ans = 0

if mul_ama <= a:
    ans = (mul_syo * a) + mul_ama
else:
    ans = (mul_syo * a) + a

print(ans)

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

using namespace std;

long long x[3];

int main() {
	for (int i = 0; i < 3; i++)
		scanf("%lld", x + i);
	printf("%lld\n", x[1] + min(x[0] + x[1] + 1, x[2]));
	return 0;
}

Measured memory_bytes: 768