akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int c[3][3];
	int a[3];
	int b[3];
	int aa[3];
	int ans=0;
	bool f;
	
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>c[i][j];
		}
	}

	for(int k=0;k<101;k++)
	{
		a[0]=k;
		b[0]=c[0][0]-k;
		b[1]=c[0][1]-k;
		b[2]=c[0][2]-k;
		if(b[0]<0||b[1]<0||b[2]<0)
		{
			continue;
		}
		f=true;
		for(int i=1;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				aa[j]=c[i][j]-b[j];
			}
			if(aa[0]==aa[1]&&aa[1]==aa[2])
			{
				a[i]=aa[0];
			}else{
				f=false;
				break;
			}
		}
		if(f==true)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int x,y;
        char a;
        cin>>x>>a>>y;
        if(a=='?') break;
        if(a=='+'){
            cout<<x+y<<endl;
        }
        else if(a=='-'){
            cout<<x-y<<endl;
        }
        else if(a=='*'){
            cout<<x*y<<endl;
        }
        else if(a=='/'){
            cout<<x/y<<endl;
        }
        
    }
    
}


Measured memory_bytes: 3088
use std::io;

fn read_lines() -> (i32, i32, i32) {
    let mut line = String::new();
    let mut res = Vec::new();
    io::stdin().read_line(&mut line).unwrap();
    for l in line.split_whitespace() {
        let num = l.parse::<i32>().ok().unwrap();
        res.push(num);
    }
    if res.len() != 3 {
        panic!("the input length is {} ", res.len());
    }
    (res[0], res[1], res[2])
}



fn main() {
    let input = read_lines();
    let (mut a, mut b, mut c) = input;

    for i in 1..(b+1) {
        if (a*i) % b == c {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


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

using namespace std;

#define MAXN 100005

long long p[MAXN],q[MAXN],r[MAXN];
priority_queue<int,vector<int>,greater<int> > Q;

bool cmp(long long x,long long y){
    return x>y;
}

int main(void)
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;++i) cin>>p[i];
    for(int i=0;i<b;++i) cin>>q[i];
    for(int i=0;i<c;++i) cin>>r[i];
    sort(p,p+a,cmp);
    sort(q,q+b,cmp);
    sort(r,r+c,cmp);
    for(int i=0;i<x;++i) Q.push(p[i]);
    for(int i=0;i<y;++i) Q.push(q[i]);
    for(int i=0;i<c;++i){
        if(r[i]>Q.top()){
            Q.pop();
            Q.push(r[i]);
        }
    }
    long long ans = 0;
    while(!Q.empty()){
        ans += Q.top();
        Q.pop();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  int c=0, d=0;
  if(s.size()<4) co("No");
  else if(s.at(0)=='Y' && s.at(1)=='A' && s.at(2)=='K' && s.at(3)=='I') co("Yes");
  else co("No");
  
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    k = I()
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            quit()
    print(1)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <vector>
//#include <string>
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> d(N);
    for(auto i=0; i < N; i++)
        cin >> d[i];
    
    if(N % 2) {
        cout << 0 << endl;
    } else {
        sort(d.begin(),d.end());
        cout << (d[N/2] - d[N/2-1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 640
def main():
    s = input()
    N = len(s)

    nox = []
    idxs = []
    ans = 0
    for i, c in enumerate(s):
        if c != "x":
            nox.append(c)
            idxs.append(i)
    
    if nox != nox[::-1]:
        print(-1)
        exit()
    
    if len(nox) == 0:
        print(0)
        exit()

    if len(nox)%2 == 0:
        left = len(nox)//2 - 1
        right = len(nox)//2
        
        left_idx = idxs[left]
        right_idx = idxs[right]

    else:
        center = len(nox)//2
        left_idx = idxs[center]
        right_idx = idxs[center]

    while not(left_idx == 0 and right_idx == N-1):
        if s[left_idx] == s[right_idx]:
            if left_idx > 0 and right_idx < N - 1:
                left_idx -= 1
                right_idx += 1
            else:
                if left_idx <= idxs[0] and right_idx >= idxs[-1] and (left_idx > 0 or right_idx < N - 1):
                    ans += 1
                if left_idx > 0:
                    left_idx -= 1
                if right_idx < N-1:
                    right_idx += 1

        elif s[left_idx] == "x":
            ans += 1
            if left_idx > 0:
                left_idx -= 1
        elif s[right_idx] == "x":
            ans += 1
            if right_idx < N-1:
                right_idx += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14736
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<stack>

using namespace std;

int main () {
	string st1;
	int ct=0;
	
	while(cin>>st1){
		if(cin.eof())
		break;
		string st2(st1);
		reverse(st2.begin(),st2.end());
		if(st1==st2)
		ct++;
	}
	printf("%d\n",ct);
}

Measured memory_bytes: 3212
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long ll;

const int maxn = 2e5 + 7;

int n, x;

struct node {
  int b, l, u;
  ll sorce;
  friend bool operator < (const node& x, const node& y) {
    //if (x.sorce == y.sorce) return 1;
    return x.sorce > y.sorce;
  }
} a[maxn];

ll check(ll t) {
  ll tim = t / x;
  ll res = t - tim * x;
  ll sum = 0;
  for (int i = 1; i <= tim; i++) {
    sum += a[i].sorce;
  }
  ll ans = 0;
  //ans = sum;
  for (int i = 1; i <= n; i++) {
    ll now = 0;
    if (res <= a[i].b) 
      now = res * a[i].l;
    else 
      now = (long long)a[i].b * a[i].l + (long long)(res - a[i].b) * a[i].u;
    if (i <= tim) ans = max(ans, sum - a[i].sorce + now + a[tim + 1].sorce);
    else ans = max(ans, sum + now);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  cin >> n >> x;
  ll goal = 0, maxx = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].b >> a[i].l >> a[i].u;
    goal += (long long)a[i].b * a[i].l;
    a[i].sorce =(long long )a[i].b * a[i].l + (long long) a[i].u * (x - a[i].b);
  }
  sort(a + 1, a + n + 1);
  ll l = 0, r = (long long)n * x;
  while (l < r) {
    ll mid = (l + r) / 2;
    if (check(mid) >= goal) r = mid;
    else l = mid + 1;
  }
  cout << r << endl;
}

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[N];
    bool visited[N]; fill(visited, visited + N, false); 

    int ans = 0;
    int a, b ,z;
    for(int i = 0;i < M; i++){
        cin >> a >> b >> z;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for(int i =0 ; i<N; i++){
        if(visited[i]) ;
        else{
            ans++;
            queue<int> que;
            que.push(i);
            while(!que.empty()){
                int v = que.front(); que.pop();
                for(int id : G[v]){
                    if(!visited[id]){
                        que.push(id);
                        visited[id] = true;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
        Integer[] data = makeint(br);
        Arrays.sort(data);
        show(data);
    }
    public static void show(Integer[] a){
        int n = a.length;
        for(int i = 0; i < n - 1; i++){ System.out.print(a[i] + " "); }
        System.out.println(a[n - 1]);
    }
    public static Integer[] makeint(BufferedReader br) throws IOException
    {
        String[] str = br.readLine().split(" ");
        int n = str.length;
        Integer[] a = new Integer[n];
        for(int i = 0; i < n; i++){ a[i] = Integer.parseInt(str[i]); }
        return a;
    }
}


Measured memory_bytes: 24376
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
int n;
ll a[101],sum,ans1,ans2,tt;
inline ll read(){
	char ch=getchar(); ll x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline ll poww(ll x){return x*x;}
int main()
{
	//freopen("Be Together.in","r",stdin);
	n=read();
	for(RG int i=1;i<=n;i++) a[i]=read(), sum+=a[i];
	tt=sum/n;
	for(RG int i=1;i<=n;i++) ans1+=poww(tt-a[i]);
	tt++;
	for(RG int i=1;i<=n;i++) ans2+=poww(tt-a[i]);
	printf("%lld",min(ans1,ans2));;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
const int N = 110;
int vis[N][N];
int t[100000];
ll a,b,c,d,n,w,sumv,sumw,maxx;
ll wa[1000],wb[1000],wc[1000],wd[1000];
ll va[1000],vb[1000],vc[1000],vd[1000];
struct node
{
    ll w,v;
}g[1000];

node aa[1000],bb[1000],cc[1000],dd[1000];
int cmp(node a,node b)
{
    return a.v>b.v;
}

void init()
{
    sort(aa+1,aa+a+1,cmp);
    sort(bb+1,bb+b+1,cmp);
    sort(cc+1,cc+c+1,cmp);
    sort(dd+1,dd+d+1,cmp);
}

void inv()
{

    wa[0]=0;
    va[0]=0;
    for(int i=1;i<=a;i++)
    {
        wa[i]=wa[i-1]+aa[i].w;
        va[i]=wa[i-1]+aa[i].v;
    }
    wb[0]=0;
    vb[0]=0;
    for(int i=1;i<=b;i++)
    {
        wb[i]=wb[i-1]+bb[i].w;
        vb[i]=vb[i-1]+bb[i].v;
    }
    wc[0]=0;
    vc[0]=0;
    for(int i=1;i<=c;i++)
    {
        wc[i]=wc[i-1]+cc[i].w;
        vc[i]=vc[i-1]+cc[i].v;
    }
    wd[0]=0;
    vd[0]=0;
    for(int i=1;i<=d;i++)
    {
        wd[i]=wd[i-1]+dd[i].w;
        vd[i]=vd[i-1]+dd[i].v;
    }
}
int main()
{
   a=0;
   b=0;
   c=0;
   d=0;
   for(int i=0;i<1000;i++)
   {
       wa[i]=wb[i]=wc[i]=wd[i]=0;
       va[i]=vb[i]=vc[i]=vd[i]=0;
   }
   for(int i=0;i<10000;i++)
   {
       t[i]=1;
   }
   for(int i=0;i<100;i++)
   {
       for(int j=0;j<100;j++)
       {
           vis[i][j]=-1;
       }
   }
   cin>>n>>w;
   for(int i=1;i<=n;i++)
   {
       scanf("%lld%lld",&g[i].w,&g[i].v);
       //printf("%lld %lld",g[i].w,g[i].v);
       if(g[i].w==g[1].w)
       {
           aa[++a]=g[i];
       }
       if(g[i].w==g[1].w+1)
       {
           bb[++b]=g[i];
       }
       if(g[i].w==g[1].w+2)
       {
           cc[++c]=g[i];
       }
       if(g[i].w==g[1].w+3)
       {
           dd[++d]=g[i];
       }
   }
    sort(aa+1,aa+a+1,cmp);
    sort(bb+1,bb+b+1,cmp);
    sort(cc+1,cc+c+1,cmp);
    sort(dd+1,dd+d+1,cmp);
    /*for(int i=1;i<=a;i++)
    {
        cout<<aa[i].w<<" "<<aa[i].v<<endl;
    }*/
    wa[0]=0;
    va[0]=0;
    for(int i=1;i<=a;i++)
    {
        wa[i]=wa[i-1]+aa[i].w;
        va[i]=va[i-1]+aa[i].v;
    }
    wb[0]=0;
    vb[0]=0;
    for(int i=1;i<=b;i++)
    {
        wb[i]=wb[i-1]+bb[i].w;
        vb[i]=vb[i-1]+bb[i].v;
    }
    wc[0]=0;
    vc[0]=0;
    for(int i=1;i<=c;i++)
    {
        wc[i]=wc[i-1]+cc[i].w;
        vc[i]=vc[i-1]+cc[i].v;
    }
    wd[0]=0;
    vd[0]=0;
    for(int i=1;i<=d;i++)
    {
        wd[i]=wd[i-1]+dd[i].w;
        vd[i]=vd[i-1]+dd[i].v;
    }
   sumv=0;
   sumw=0;
   maxx=0;
   //cout<<a<<b<<c<<d<<endl;
   for(int i=0;i<=a;i++)
   {
       //cout<<1<<endl;
       for(int j=0;j<=b;j++)
       {
           for(int k=0;k<=c;k++)
           {
               for(int q=0;q<=d;q++)
               {
                   sumw=wa[i]+wb[j]+wc[k]+wd[q];
                   sumv=va[i]+vb[j]+vc[k]+vd[q];
                   //cout<<sumw<<" "<<sumv<<endl;
                   //cout<<sumw<<sumv<<1<<endl;
                   if(sumw<=(ll)w)
                   {
                       maxx=max((ll)maxx,sumv);
                   }
               }
           }
       }
   }
   cout<<maxx<<endl;
   return 0;
}


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

int main() {
	int N, P;
	cin >> N >> P;
	int Odd = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		Odd += A % 2 == 1;
	}
	if (Odd == 0) cout << (P == 1 ? 0 : (1ll << N)) << endl;
	else cout << (1ll << (N - 1)) << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        edges[a].append(b)
        edges[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    def dfs(cur, par):
        for nex in edges[cur]:
            if nex == par:
                continue
            counter[nex] += counter[cur]
            dfs(nex, cur)

    dfs(0, -1)
    print(*counter, sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 268436
#include <stdio.h>
int main(){
  int a ,b ,x;
  while( scanf( "%d %d" ,&a ,&b ) != EOF ){
    x = b;
    while ( 1 ){
      if( a % b == 0 ){
	break;
      }
      x = a % b;
      a = b;
      b = x;
    }
    printf( "%d\n" ,x );
  }
  
  return 0;
}

Measured memory_bytes: 596
#include<iostream>	// 入出力
#include<stdio.h>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;

using ll = long long;





int main()
{
	int X, Y;

	cin >> X >> Y;

	if (X%Y != 0)
	{
		cout << X << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;

}

Measured memory_bytes: 256
def read():
    A, B = list(map(int, input().strip().split()))
    return A, B

def solve(A, B):
    if A <= 9 and B <= 9:
        return A * B
    else:
        return -1

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 38448
function Main (i) {
  if (
    i.charAt(0) !== 'A' ||
    i.slice(2, i.length - 2).indexOf('C') === -1 ||
    i.match(/C/g).length !== 1 ||
    !/^[a-z]+$/.test(i.replace('A', '').replace('C', '').replace(/\s/, ''))
  ) {
    console.log('%s','WA');
  } else {
    console.log('%s', 'AC');
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
W, H, N = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
M = [[0] * W for i in range(H)]
for x in X:
    if x[2] == 1:
        for i in range(0, x[0]):
            for j in range(H):
                M[j][i] = 1
    elif x[2] == 2:
        for i in range(x[0], W):
            for j in range(H):
                M[j][i] = 1
    elif x[2] == 3:
        for i in range(0, x[1]):
            for j in range(W):
                M[i][j] = 1
    elif x[2] == 4:
        for i in range(x[1], H):
            for j in range(W):
                M[i][j] = 1
c = 0
for i in range(W):
    for j in range(H):
        if M[j][i] == 0:
            c += 1
print(c)


Measured memory_bytes: 3188
import sys
input = lambda: sys.stdin.readline()


def solve():
    def init(init_val):
        for i in range(n):
            seg[i + num - 1] = init_val[i]
        for i in range(num - 2, -1, -1):
            seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

    def update(k, x):
        k += num - 1
        seg[k] = x
        while k:
            k = (k - 1) // 2
            seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])

    def query(p, q):
        if q <= p:
            return ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = segfunc(res, seg[p])
            if q & 1 == 1:
                res = segfunc(res, seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = segfunc(res, seg[p])
        else:
            res = segfunc(segfunc(res, seg[p]), seg[q])
        return res

    n, q = map(int, input().split())
    a = list(map(int, input().split()))

    segfunc = lambda x, y: max(x, y)
    ide_ele = 0
    num = 2 ** (n - 1).bit_length()
    seg = [ide_ele] * 2 * num

    init(a)
    res = []

    for _ in range(q):
        t, a, b = map(int, input().split())
        if t == 1:
            update(a - 1, b)
        elif t == 2:
            res.append(query(a - 1, b))
        elif t == 3:
            ng = a - 1
            ok = n + 1
            while ok > ng + 1:
                mid = (ok + ng) // 2
                if query(ng, mid) >= b:
                    ok = mid
                else:
                    ng = mid
            res.append(ok)
    print("\n".join(map(str, res)))


solve()


Measured memory_bytes: 116636
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
int n,m,p,l,r,a[202000],ans;
IN ck(int x){
	l=(x<<1)+1,r=(n<<1);
	while(l<r){
		if(a[l]+a[r]<m)return 0;
		l++;r--;
	}
	return 1;
}
IN divided(int x,int y){
	if(x==y)return x;
	re mid=(x+y)>>1;
	if(ck(mid))y=mid;
	else x=mid+1;
	return divided(x,y);
}
int main(){
	read(n);read(m);
	F(i,1,n<<1)read(a[i]);
	sort(a+1,a+1+(n<<1));
	p=divided(0,n)<<1;//cout<<p<<endl;
	ans=0;
	l=1;r=p;
	while(l<r)ans=max(ans,a[l++]+a[r--]);
	l=p+1;r=(n<<1);
	while(l<r)ans=max(ans,a[l++]+a[r--]-m);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	ll n;
	int k;
	cin >> n >> k;
	int count = 0;

	while (n / k > 0) {
		n /= k;
		count++;
	}
	cout << count + 1 << endl;

}

Measured memory_bytes: 3532
input_line = input()
buffer = ""
flag = False
for i, s in enumerate(input_line):
    if (i == 2 or i == 4):
        buffer = s
    elif (i == 3 or i == 5):
        if (buffer != s):
            break
        elif (i == 5 and buffer == s):
            flag = True

if (flag):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


bool f(int a, int b) {
    return abs(a) < abs(b);
}


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, l;
    cin >> n >> l;
    int a[n];
    for (int i = 1; i <= n; i++) {
        a[i] = i - 1 + l;
    }


    int ans = accumulate(a + 1, a + n + 1, 0);
    sort(a + 1, a + n + 1, f);
    cout << ans - a[1];







}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cout << fixed << setprecision(10);
  double a,b,c;
  cin >> a >> b >> c;
  double s = a*b*sin(c*PI/180)/2;
  cout << s << endl;
  cout << a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180)) << endl;
  cout << s*2/a << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> P2;
int main(){
    int H, W;
    cin >> H >> W;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vector<vector<char>> s(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> s[i][j];
    }
    deque<P2> dq;
    int INF = 1e9;
    vector<vector<int>> dis(H, vector<int> (W, INF));
    dq.push_back(P2(P(ch, cw), 0));
    dis[ch][cw] = 0;
    while(!dq.empty()){
        P2 v = dq.front();
        dq.pop_front();
        int x = v.first.first, y = v.first.second;
        s[x][y] = '#';
        if(v.second > dis[x][y]) continue;
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                int nx = x + i, ny = y + j;
                if(abs(i) + abs(j) == 1){
                    if(0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] == '.'){
                        dq.push_front(P2(P(nx, ny), v.second + 0));
                        dis[nx][ny] = min(dis[x][y] + 0, dis[nx][ny]);
                    }
                }
                else{
                    if(0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] == '.'){
                        dq.push_back(P2(P(nx, ny), v.second + 1));
                        dis[nx][ny] = min(dis[x][y] + 1, dis[nx][ny]);
                    }
                }
            }
        }
    }
    if(dis[dh][dw] == INF) cout << -1 << endl;
    else cout << dis[dh][dw] << endl;
}

Measured memory_bytes: 8992
#include <iostream>
#include<string>
#include <math.h>

using namespace std;

int main(){
        string s;
        int Black=0,White=0;

        cin>>s;

        for(int i=0; i<s.size(); i++){
                if((i%2==0)&&(s[i]=='1')) Black++;
                else if((i%2==1)&&(s[i]=='0')) Black++;
        }

        for(int i=0; i<s.size(); i++){
                if((i%2==0)&&(s[i]=='0')) White++;
                else if((i%2==1)&&(s[i]=='1')) White++;
        }

        cout<<min(Black,White)<<endl;
        return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    int64_t ten=10, nine=9, eight=8;
    int64_t tens=1, nines=1, eights=1;

    while(N > 0){
        if(N & 1){
            tens *= ten;
            tens %= MOD;
            nines *= nine;
            nines %= MOD;
            eights *= eight;
            eights %= MOD;
        }
        ten *= ten;
        ten %= MOD;
        nine *= nine;
        nine %= MOD;
        eight *= eight;
        eight %= MOD;

        N /= 2;
    }

    int64_t ans = tens;
    ans = (ans + MOD - nines) % MOD;
    ans = (ans + MOD - nines) % MOD;
    ans = (ans + eights) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    REP(i,k){
        cout << s << " ";
    }
    REP(i,n-k){
        if(s == 1)
            cout << s+1 << " ";
        else
            cout << s-1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(i, n) for(int i = n-1; i >= 0; i--)
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define rloop(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, val) memset(a, val, sizeof a);
#define all(v) v.begin(),v.end()
#define ll long long
#define ld long double
#define mp_ make_pair
#define sz(s) (int)s.size()
#define pb push_back
const int MAX = 1e5 + 5;
const int inf = 1e9+1;
const ll OO = 1e18;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


int main(){

    string s, t;
    cin>> s >> t;
    int mn = inf, idx, cnt;
    loop(i, 0, sz(s) - sz(t)){
        idx = cnt = 0;
        for(int j = i; j < i + sz(t); j ++){
            if(t[idx] != s[j])
                cnt ++;
            idx ++;
        }
        mn = min(mn, cnt);
    }
    cout<< mn;
    return 0;
}


Measured memory_bytes: 3628
// 
	#include<bits/stdc++.h> 
	#include <sstream> 
	using namespace std; 
	typedef long long ll;
	inline bool cmp(pair< ll , ll > &a , pair< ll , ll >  &b){
		if(a.first != b.first)
			return a.first > b.first;
		else
			return a.second < b.second;
	}

	int main() 
	{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin >> n;
	    int a[n];
	    int need = 1 , cnt = 0;
	    for(int i = 0 ; i < n ;i++){
	    	cin >> a[i];
	    	if(a[i] == need){
	    		cnt++;
	    		need++;
	    	}
	    }
	    //cout << cnt << endl;
	 	if(cnt == 0)
	 		cout << -1 << endl;
	 	else
	    	cout << n - cnt << endl;
	}


Measured memory_bytes: 1024
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int cnt(int x)
{
	int i=0;
	while(x>0)
	{
		i++;
		x=x/10;
	}
	if(i%2==1)
	{
		return 1;
	}
	return 0;
}
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d",&n);
	x=0;
	for(i=1;i<=n;i++)
	{
		if(cnt(i))
		{
			x++;
		}
	}
	printf("%d",x);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010],ans[100010];
int c[100010],b[100010],d[100010];
int main() {
    int n; scanf("%d",&n);
    int i; ll sum=0; for(i=1;i<=n;i++) { scanf("%lld",&a[i]); a[i]-=sum; sum+=a[i]; c[i]=i; }
    int m; ll k; scanf("%d%lld",&m,&k); int x; for(i=1;i<=m;i++) { scanf("%d",&x); swap(c[x],c[x+1]); }
    for(i=1;i<=n;i++) if(!b[i]) { int cnt=0; int j; for(j=i;!b[j];j=c[j]) { b[j]=1; d[++cnt]=j; } for(j=1;j<=cnt;j++) ans[d[j]]=a[d[(j+k-1)%cnt+1]]; }
    for(i=1;i<=n;i++) { ans[i]+=ans[i-1]; printf("%lld.0\n",ans[i]); }
    return 0;
}


Measured memory_bytes: 4224
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

H,W=rl()
h,w=rl()
print(H*W-(h*W+w*H-h*w))

Measured memory_bytes: 3316
import sys

if __name__ == '__main__':
    count = 0
    D = []
    for line in sys.stdin:
        if count == 0:
            line = line.rstrip("\n").split(" ")
            H = int(line[0])
            W = int(line[1])
            count+=1

        else:
            D.append(line.rstrip("\n"))

    print("".join(["#"]*(W+2)))
    for i in range(len(D)):
        print("#"+D[i]+"#")
    print("".join(["#"]*(W+2)))

Measured memory_bytes: 3064
/*
 
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;
 
char c;
 
int main () {
	cin >> c;
	cout << char(int(c) + 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
    int a;
    int h, m, s;
    std::string str;
    std::cin >> a;

    h = a / 3600;
    m = a % 3600 / 60;
    s = a % 60;

    str = std::to_string(h);
    str += ":";
    str += std::to_string(m);
    str += ":";
    str += std::to_string(s);

    std::cout << str << std::endl;
    return 0;
}



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();

                if (string.IsNullOrEmpty(input)) break;

                double[] nums = Array.ConvertAll(input.Split(' '), double.Parse);

                double a = nums[0], b = nums[1], c = nums[2];
                double d = nums[3], e = nums[4], f = nums[5];

                double x = (b * f - e * c) / (b * d - a * e);
                double y = (a * f - d * c) / (a * e - b * d);

                Console.WriteLine("{0:f3} {1:f3}",
                    Math.Round(x, 3, MidpointRounding.AwayFromZero),
                    Math.Round(y, 3, MidpointRounding.AwayFromZero));
            }
        }
    }
}

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



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

    vector<int> A(100010);
    vector<int> B(100010);
    for(int i=0; i<n; i++){
        if (i%2==0) A[V[i]]++;
        else B[V[i]]++;
    }

    int max_a=0, max_b=0;

    max_a = max_element(A.begin(), A.end()) - A.begin();
    max_b = max_element(B.begin(), B.end()) - B.begin();


    if (max_a != max_b){
        cout << (n/2-A[max_a]) + (n/2-B[max_b]) << endl;
    }else{
        sort(A.rbegin(), A.rend());
        sort(B.rbegin(), B.rend());
        cout << min((n/2-A[0]) + (n/2-B[1]), (n/2-A[1]) + (n/2-B[0])) << endl;
    }
    return 0;
}

Measured memory_bytes: 4532
m='+=+j[0]*Math.',n='(s*Math.PI/180)',x=y=s=0;require("fs").readFileSync("/dev/stdin","utf8").split('\n').some(function(i){j=i.split(','),eval('x'+m+'sin'+n+',y'+m+'cos'+n),s+=+j[1]});console.log(~~x+'\n'+~~y)

Measured memory_bytes: 7644
import heapq as hq

N = int(input())
H = []
for n in range(N):
    A, B = map(int, input().split())
    hq.heappush(H, (A + B, A, B))

res_a = 0
res_b = 0
for n in range(N):
    s, a, b = hq.heappop(H)
    if N % 2 == 0:
        if n % 2 == 0:
            res_b += b
        else:
            res_a += a
    else:
        if n % 2 == 0:
            res_a += a
        else:
            res_b += b

print(res_a - res_b)

Measured memory_bytes: 20592
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

// Sieve of Eratosthenes
fn get_primes(input: i64) -> Vec<i64> {
    let N: usize = max(input, 100) as usize;

    let mut Alive = vec![true; N];
    Alive[0] = false;
    Alive[1] = false;

    // i番目の素数が分かる (0-origin)
    let mut Ps: Vec<i64> = Vec::new();

    for smallest in 2..=((N as f64).sqrt()) as usize + 1 {
        if !Alive[smallest] {
            continue;
        }

        for i in (smallest * 2..N).step_by(smallest) {
            Alive[i] = false;
        }
    }

    for i in 2..N {
        if Alive[i] {
            Ps.push(i as i64);
        }
    }

    return Ps;
}

fn main() {
    input! {
        X: i64,
    }

    let primes = get_primes(100004);

    for &p in primes.iter() {
        if p >= X {
            println!("{}", p);
            return;
        }
    }
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
#define PI 3.141592653589793
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    FAST
    string s;cin>>s;
    f(i,0,s.length())
    {
        if(s[i]=='?') cout<<'D';
        else cout<<s[i];
    }
}


Measured memory_bytes: 3792
//
// Created by yuu on 2019-04-15.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>

using namespace std;


int main(void){
    string S,T;
    cin>>S;
    cin>>T;

    vector<string> temp;
    for (int i = 0; i < S.size(); ++i) {
        bool flag = true;
        string tep =S;
        for (int j = 0; j < T.size(); ++j) {
            if(S[i+j]==T[j] || S[i+j]=='?'){
                tep[i+j] = T[j];
                continue;
            }
            flag = false;
        }

        if(flag){
            for (int j = 0; j < tep.size(); ++j) {
                if(tep[j]=='?'){
                    tep[j] = 'a';
                }
            }
            temp.push_back(tep);
        }
    }

    if(temp.size() == 0){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    sort(temp.begin(),temp.end());

    cout<<temp[0]<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;
int main(){
	FIO;
	ll d,n,p,ans=0;cin>>d>>n;
	if(n==100) {
		if(d==0) cout<<"101\n";
		else if(d==1) cout<<"10100\n";
		else cout<<"1010000\n";
		return 0;
	}
	if(d==0) cout<<n<<"\n";
	else if(d==1) cout<<n*100<<"\n";
	else cout<<n*10000<<"\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
s=input()[::-1]
DP=[0]

num,point=0,1
for i in s:
    num +=int(i)*point
    num %=2019
    DP.append(num)
    point *=10
    point %=2019

ans=0
DP=Counter(DP)
for v,m in DP.items():
    if m>=2:
        ans +=m*(m-1)//2
print(ans)

Measured memory_bytes: 76748
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var p = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            Console.WriteLine("{0:f5}", Math.Sqrt(Math.Pow(p[0] - p[2], 2) + Math.Pow(p[1] - p[3], 2)));
        }
    }
}

Measured memory_bytes: 5796
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){ 

    ll a,b,x;cin>>a>>b>>x;
    ll ans = b/x;

    if(a%x==0){
        ans = ans - a/x + 1;
    }else ans = ans - a/x;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            final long mod = (long) (1e9 + 7);

            int N = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            long[] cumsum = new long[N + 1];
            for (int i = 0; i < N; i++) {
                cumsum[N - 1 - i] += cumsum[N - i] + A[N - 1 - i];
                cumsum[N - 1 - i] %= mod;
            }

            long sum = 0;
            for (int i = 0; i < N; i++) {
                sum += A[i] * cumsum[i + 1];
                sum %= mod;
            }

            System.out.println(sum);
        }
    }
}


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

int main()
{
	string str;
	const string ACGT = "ACGT";
	cin >> str;
	int ans = 0;
	for(int i = 0; i < str.size(); i++)
	{
		if(count(cbegin(ACGT), cend(ACGT), str[i]))
		{
			int s = i;
			for (; ++i < str.size() && count(cbegin(ACGT), cend(ACGT), str[i]););
			ans = max(ans, i - s);
		}
	}
	cout << ans << "\n";
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int p[N];
set<int> S;

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i ++ ) p[i] = i;
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		
		int pa = find(a), pb = find(b);
		p[pa] = pb;
	}
	
	for (int i = 1; i <= n; i ++ )
	{
		int pa = find(i);
		S.insert(pa);
	}
	
	printf("%d\n", S.size());
	return 0;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<ll> A;

int main(void) {
    ll K, N;
    cin >> K >> N;

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll longest = 0;
    for (int i = 1; i < N; i++) {
        chmax(longest, A[i] - A[i - 1]);
    }
    chmax(longest, K - A[N - 1] + A[0]);

    cout << K - longest << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

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

  cin >> n;
  double ans = 0.0;
  REP(i, n) {
    string s;
    double u;
    cin >> u >> s;
    if(s == "JPY") {
      ans += u;
    } else {
      ans += (u * 380000.0);
    }
  }

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


Measured memory_bytes: 256
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
S = rs()

ans = ''
for c in S:
	i = ord(c)-ord('A')
	n = (i + N) % 26 + ord('A')
	ans += chr(n)
print(ans)


Measured memory_bytes: 41580
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int m, k;
    scanf("%d%d", &m, &k);
    if(k >= (1<<m) || (m == 1 && k == 1)){
        printf("-1\n");
        return 0;
    }
    if(k == 0){
        rep(i, 1<<m) printf("%d ", i);
        rrep(i, 1<<m) printf("%d ", i);
        return 0;
    }
    printf("%d ", k);
    rep(i, 1<<m)if(i != k) printf("%d ", i);
    printf("%d %d ", 0, k);
    rFor(i, 1<<m, 1)if(i != k) printf("%d ", i);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

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

using namespace std;


int main(){
    int n;
    string s;
    string t;
    cin >> n;
    cin >> s;
    if(n % 2 == 1){
        cout << "No" << endl;
    return 0;}
    for(int i = 0;i < n / 2;i++){
        t =t + s[i];
    }
    if(s == t + t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll m[100001][101];
ll calc(ll ar[][2],ll n,ll w,ll p)
{
	if(m[w][p]!=0)return m[w][p];
	if(w==0 ||p<0)
	{
		m[w][p]=0;
		return m[w][p];
	}
	if(ar[p][0]>w)
	{
		m[w][p-1]=calc(ar,n,w,p-1);
		m[w][p]=m[w][p-1];
		return m[w][p];
	}
	m[w][p-1]=calc(ar,n,w,p-1);
	m[w-ar[p][0]][p-1]=calc(ar,n,w-ar[p][0],p-1);
	m[w][p]=max(ar[p][1]+m[w-ar[p][0]][p-1],m[w][p-1]);
	return m[w][p];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,w;
	cin>>n>>w;
	ll ar[n][2];
	for(ll i=0;i<n;i++)
	{
		cin>>ar[i][0]>>ar[i][1];
	}
	cout<<calc(ar,n,w,n-1);
	return 0;
}

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

int main(){
  int N, M; cin >> N >> M;
  vector< vector<int> > g(N+1, vector<int>());
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  for(int i = 1; i <= N; i++){
    cout << g[i].size() << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int m; cin >> m;
	cout << 24 - m + 24 << 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 a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int cap = a - b;
		if (cap > c) {
			System.out.println(0);
		} else {
			System.out.println(c - cap);
		}
		sc.close();
	}
}

Measured memory_bytes: 23636
N, M = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]
C = [[int(i) for i in input().split()] for _ in range(M)]

for a, b in A:
    mi = 1e10
    ans = 0
    for i, (c, d) in enumerate(C):
        t = abs(a - c) + abs(b - d)
        if t < mi:
            mi = t
            ans = i
    print(ans + 1)

Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto i = readln.chomp.to!long();
    if (i < 1200)
    {
        "ABC".writeln;
    }
    else if (i < 2800)
    {
        "ARC".writeln;
    }
    else
    {
        "AGC".writeln;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main()
{
	ll N, M, C;
	cin >> N >> M >> C;
	vector<ll> bv(M);
	for (auto& b : bv) {
		cin >> b;
	}
	ll ret = 0;
	vector<ll> av(M);
	for (ll i = 0; i < N; ++i) {
		ll sum = C;
		ll temp = 0;
		for (ll j = 0; j < M; ++j) {
			cin >> temp;
			sum += temp * bv[j];
		}
		if (0 < sum) {
			++ret;
		}
	}

	cout << ret << endl;

	return 0;
}

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

int main() {
  string s;
  cin>>s;
  if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256
while 1:
    try:
        h,m,s=map(int,input().split())
        if h+m+s==-3:break
        last=7200-h*3600-m*60-s
        print(f'{last//3600:0>2}:{(last%3600)//60:0>2}:{last%60:0>2}')
        last*=3
        print(f'{last//3600:0>2}:{(last%3600)//60:0>2}:{last%60:0>2}')     
    except:break


Measured memory_bytes: 5620
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = [[1]*n for i in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                exit()
            elif a[i][k] + a[k][j] == a[i][j] and i!=k!=j:
                b[i][j] = 0

ans = 0
for i in range(n):
    for j in range(n):
        if b[i][j]:
            ans += a[i][j]
print(ans//2)

Measured memory_bytes: 44764