akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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


bool solution(vector<int>& num, vector<string>& s, vector<char>& ans){
    int N = s.size();
    REP(i, N){
        // 選ばれているものを数字に変換
        int i1 = s[i][0] - 'A';
        int i2 = s[i][1] - 'A';
        int large = i1, small = i2;  // 一般的にはどっちを選んでも良い

        if(num[i1]+num[i2] == 0) return false;
        else if(num[i1] == 1 and num[i2] == 1){
            if(i+1 < N and (s[i+1][0] == s[i][0] or s[i+1][1] == s[i][0])){
                small = i1;
                large = i2;
            }
        }else if(num[i1] < num[i2]){  // 基本的には大きい方から小さい方に持っていく
            small = i1;
            large = i2;
        }
        ans.push_back(small+'A');
        ++num[small];
        --num[large];
    }
    return true;
}

int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];

    vector<char> ans;
    if(solution(num, s, ans)){
        cout << "Yes" << endl;
        for(auto c: ans) cout << c << endl;
    }else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 5520
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] l = line.split(" ");
        int[] dice = new int[6];
        int tmp = 0;

        for(int i = 0; i < 6; i++) {
          dice[i] = Integer.parseInt(l[i]);
        }

        line = sc.nextLine();
        char[] com = line.toCharArray();
        for(int i = 0; i < com.length; i++) {
          if(com[i] == 'N') {
            //1 <= 2, 2 <= 6, 6 <= 5, 5 <= 1
            tmp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5]; dice[5] = dice[4]; dice[4] = tmp;
          } else if(com[i] == 'E') {
            //1 <= 4, 4 <= 6, 6 <= 3, 3 <= 1
            tmp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[2]; dice[2] = tmp;
          } else if(com[i] == 'W') {
            //1 <= 3, 3 <= 6, 6 <= 4, 4 <= 1
            tmp = dice[0]; dice[0] = dice[2]; dice[2] = dice[5]; dice[5] = dice[3]; dice[3] = tmp;
          } else if(com[i] == 'S') {
            //1 <= 5, 5 <= 6, 6 <= 2, 2 <= 1
            tmp = dice[0]; dice[0] = dice[4]; dice[4] = dice[5]; dice[5] = dice[1]; dice[1] = tmp;   
          }
        }

        System.out.println(dice[0]);
    }
}

Measured memory_bytes: 26068
mod = 2019
l, r = map(int, input().split())

if r//mod - l//mod > 0:
  print(0)
else:
  l %= mod
  r %= mod
  ans = mod
  for i in range(l, r):
    for j in range(i+1, r+1):
      ans = min(i*j%mod, ans)
      if ans == 0:
        break
    else:
      continue
    break
  print(ans)

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

int main() {
    long range = 120;
    long x;

    cin >> x;

    for (long i = -range; i <= range; ++i) {
        for (long j = -range; j <= range; ++j) {
            if (pow(i, 5) - pow(j, 5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4036
import java.util.Scanner;

class calc {

	int ans = 1;

	void func(int n) {
		for (int i = 0; i < 3; i++) {
			ans *= n;
		}
		System.out.println(ans);
	}

}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		calc cl = new calc();

		int n = sc.nextInt();

		cl.func(n);

	}

}

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

using namespace std;

#define MOD 998244353

long long mpow(long long x, long long y) {
	if (y == 0) return 1;
	if (y & 1) return mpow(x * x % MOD, y / 2) * x % MOD;
	return mpow(x * x % MOD, y / 2) % MOD;
}

int main() {
	int n; cin >> n;
	vector<int> d(n - 1);
	int d1; cin >> d1;
	for (auto& a : d) cin >> a;
	if (d1) {
		cout << 0 << endl;
		return 0;
	}
	sort(d.begin(), d.end());
	long long t = 1, bcnt = 1, ans = 1;
	for (int i = 0; i < n - 1; ++i) {
		if (d[i] != t) {
			ans = 0;
			break;
		}
		int cnt = 1;
		while (i < n - 2 && d[i] == d[i + 1]) i++, cnt++;
		(ans *= mpow(bcnt, cnt)) %= MOD;
		bcnt = cnt;
		t++;
	}
	cout << ans << endl;
	
	return 0;
}

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

lt = [0] + [int(x) for x in input().split()]
#print(lt)
h={1}
g=[1]
for _ in range(n):
    x = lt[g[-1]]
    g.append(x)
    if x in h:
        break
    h.add(x)
#print(g)
if k > len(g):
    i  = g.index(g[-1])
    b = len(g) - i - 1 
    k = (k-i)%b + i
print(g[k])


Measured memory_bytes: 32300
from collections import defaultdict, deque
import heapq
v, n = map(int, input().split())
es = [[int(x) for x in input().split()] for _ in range(v+n-1)]

outs = defaultdict(list)
ins = defaultdict(int)
edge_from = [[] for _ in range(v+1)]
edge_to = [[] for _ in range(v+1)]
ans = [-1]*(v+1)
for v1, v2 in es:
    edge_from[v1].append(v2)
    edge_to[v2].append(v1)
    outs[v1].append(v2)
    ins[v2] += 1

q = deque(v1 for v1 in range(v) if ins[v1] == 0)
res = []
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)
rev = [0]*(v+1)
for i in range(1,v+1):
    rev[res[i]] = i
redge_to = [[] for _ in range(v+1)]
for i in range(1,v+1):
    for j in edge_to[i]:
        ri = rev[i]
        rj = rev[j]
        heapq.heappush(redge_to[ri],-rj)
for ri in range(1,v+1):
    if redge_to[ri]:
        rj = redge_to[ri][0]
        i = res[ri]
        j = res[-rj]
        ans[i] = j
    else:
        i =res[ri]
        ans[i] = 0
for i in ans[1:]:
    print(i)

Measured memory_bytes: 90712
#include<stdio.h>

int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (A[j] < A[minj]) minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if (i != minj) sw++;
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    
    sw = selectionSort(A, N);
    
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    
    return 0;
}


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

int main()
{
    long int n;
    cin>>n;
    vector<double>p(n+1,0);
    double ans[3003][3003];
    ans[0][0]=1;
    for(long int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(long int i=1;i<=n;i++)
    {
        double head=p[i],tail=1-p[i];
        ans[0][i]=tail*ans[0][i-1];
        for(long int h=1;h<=i;h++)
        {
            ans[h][i]=head*ans[h-1][i-1]+tail*ans[h][i-1];
        }
    }
    double answer=0;
    for(long int i=n/2+1;i<=n;i++)
    {
        answer=answer+ans[i][n];
    }
    cout<<setprecision(9)<<answer;
    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(){

	int n, x, y;
	cin>>n>>x>>y;
	
	vector<int> dist(n+1, 0);
	
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			if(i == j) continue;
			dist[min( abs(i - j) ,min(abs(x - i) + 1 + abs(y - j), abs(x - j) + 1 + abs(y - i)) )]++;
		}	
	}	
	
	for(int i=1;i<n; i++){
		cout<<dist[i]<<endl;
	}
	
  return 0;
}

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

int main() {
    int n;
    ull k;
    cin >> n>>k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        a.at(i)--;
    }
    vector<int> flag(n);
    vector<int> anslst(n);
    int count=0;
    int now= 0;
//    while(1) {
//        if (cnt==k) {
//            cout << now+1 << endl;
//        }
//    }




    while (flag[now] == 0) {
        if(count>=k){
            cout << now+1 << endl;
            return 0;
        }
        flag[now] = 1;
        anslst[count] = now;
        now = a[now];
        count++;
    }
    int start=0;
    for(int i=0;i<count;i++){
        if(anslst[i]==now) {
            start = i;break;
        }else{continue;}
    }
    int loop = count-start;
    if (loop == 0) {
        cout << now <<endl;
    }else{
        int mod = (k-start)%loop;
        cout << anslst[mod+start]+1 << endl;
//        cout << anslst[k%loop+start]+1 << endl;
    }



    return 0;
}


/* うまくいかなかったコード
int main() {
    ll n,k;
    cin >> n>>k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
//        int tmp=0;
//        cin >> tmp; tmp--;
//        a[i] = tmp;
        cin >> a.at(i);
        a.at(i)--;
//        cin >> a[i];
//        a[i]--;
    }
    vector<int> flag(n);
    vector<int> anslst(n);
    ll count=0;
    ll now= 0;
    while (flag[now] == 0) {
        if(count>=k){
            cout << now << endl;
            return 0;
        }
        flag[now] = 1;
        anslst[count] = now;
        now = a[now];
        count++;
    }
    int start=0;
    for(int i=0;i<count;i++){
        if(anslst[i]==now) {
            start = i;break;
        }else{continue;}
    }
    int loop = count-start;
    if (loop == 0) {
        cout << now <<endl;
    }else{
        ll mod = (k-start)%loop;
        cout << anslst[mod+start]+1 << endl;
//        cout << anslst[k%loop+start]+1 << endl;
    }



    return 0;
}

*/


Measured memory_bytes: 5592
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void init(int *b){
  int n=b[0];
  int i;
  for(i=1;i<=n;i++) b[i]=0;
}

void add(int *b,int index,int v){
  int i;
  for(i=index;i<=b[0];i+=i&-i) b[i]+=v;
}

int sum(int *b,int index){
  int res=0;
  int i;
  for(i=index;i>0;i-=i&-i) res+=b[i];
  return res;
}

int *c=NULL;
int *bit=NULL;
int64 count(const int *a,const int n,const int v){
  c[0]=n+1;
  int i;
  for(i=1;i<=n;i++) c[i]=c[i-1]+(a[i-1]>=v?1:-1);
  init(bit);
  add(bit,c[0],1);
  int64 cnt=0;
  for(i=1;i<=n;i++){
    cnt+=sum(bit,c[i]);
    add(bit,c[i],1);
  }
  return cnt;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  c=(int *)malloc(sizeof(int)*(n+1));
  bit=(int *)malloc(sizeof(int)*(2*n+3));
  bit[0]=2*n+2;
  int64 t=(int64)n*(n+1)/2;
  int l=1;
  int r=1000000000+1;
  while(r-l>1){
    int m=(l+r)/2;
    int64 cnt=count(a,n,m);
    if(2*cnt>=t){
      l=m;
    } else {
      r=m;
    }
  }
  printf("%d\n",l);
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace ABC168C
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABHM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = ABHM[0];
            var B = ABHM[1];
            var H = ABHM[2];
            var M = ABHM[3];

            if (H == M)
            {
                Console.WriteLine(Math.Abs(B - A));
                return;
            }

            var mAngle = 6.0 * M;
            var hAngle = 30.0 * H + 0.5 * M;
            var angle = 0.0;

            if (mAngle > hAngle)
                angle = mAngle - hAngle;
            else
                angle = hAngle - mAngle;

            if (angle > 180)
                angle = 360 - angle;

            if (angle == 180.0)
            {
                Console.WriteLine(A + B);
                return;
            }

            var r = angle * (Math.PI / 180);
            var ans = Math.Sqrt((A * A) + (B * B) - (2 * A * B * Math.Cos(r)));

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28680
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	if(n == 1){
        		System.out.println("2");
        		continue;
        	}
        	int sum = 2;
        	for(int i = 2;i <= n;i++){
        		sum += i;
        	}
        	System.out.println(sum);
        }
    }
}

Measured memory_bytes: 18024
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
A = A*2

ans = []
for i in range(2):
    ans.append(str(s - sum(A[i+1:N+i-1:2])*2 ))
for i in range(2,N):
    ans.append(str(int(ans[i-2])+(A[i-1]-A[N+i-2])*2))

ans = ' '.join(ans)
print(ans)

Measured memory_bytes: 15896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a[100005],b[100005];
ll mans,pans;
ll d;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i+1]=b[i]+a[i];
        //cout<<b[i+1]<<endl;
    }
    for(int i=1;i<=n;i++){
        if(i%2==1){
            if(b[i]+d>=0){
                mans+=(b[i]+d+1);
                d-=(b[i]+d+1);
            }
        }else{
            if(b[i]+d<=0){
                mans+=(abs(b[i]+d)+1);
                d+=(abs(b[i]+d)+1);
            }
        }
        //cout<<i<<" "<<d<<" "<<mans<<endl;
    }
    d=0;
    for(int i=1;i<=n;i++){
        if(i%2==1){
            if(b[i]+d<=0){
                pans+=(abs(b[i]+d)+1);
                d+=(abs(b[i]+d)+1);
            }
        }else{
            if(b[i]+d>=0){
                pans+=(b[i]+d+1);
                d-=(b[i]+d+1);
            }
        }
    }
    //cout<<pans<<" "<<mans<<endl;
    cout<<min(pans,mans)<<endl;

}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, a; cin >> n >> a;
    cout << n*n-a << endl;
}

Measured memory_bytes: 256
input = raw_input
h, w = map(int, input().split(" "))
gh = h - 1
gw = w - 1

#dot_coords = []
#for hi in range(h):
#    wi = 0
#    for c in input():
#        if c == ".":
#            dot_coords.append((wi, hi))
#        wi += 1
        
maps = [list(input()) for _ in range(h)]
num_maps = [[None for _ in range(w)] for _ in range(h)]

count = 0
def find(sx, sy, cur_cost, color):
    next_cost_coord = []
    global count
    num_r = 1
    found = False
    routes = [(sx, sy)]
    num_maps[sy][sx] = cur_cost
    count += 1

    pre = False
    if sx == 1 and sy == 1:
        pre = True

    while num_r >= 1 and not found:
        x, y = routes[0]
        routes = routes[1:]
        num_r -= 1

        for nx, ny in [(x+1, y), (x, y+1)]:
            if pre:
                pass
                #print("lennummap", len(num_maps))
                #print(num_maps, ny, nx)
                #print(x, y, nx, ny, num_maps[ny][nx], gw, gh, "routes", routes)

            if nx <= gw and ny <= gh:
                if num_maps[ny][nx] is None:
                    if maps[ny][nx] == color:
                        num_maps[ny][nx] = cur_cost
                        if nx == gw and ny == gh:
                            found = True
                            return next_cost_coord, found
                        else:
                            routes.append((nx, ny))
                            num_r += 1
                    else:
                        next_cost_coord.append((nx, ny))
    return next_cost_coord, found

cur_coords = [(0, 0)]
if maps[0][0] == ".":
    cur_cost = 0
else:
    cur_cost = 1

while True:   
    color = "." if cur_cost % 2 == 0 else "#"
    #print("cur_cost", cur_cost, "cur_coords", cur_coords)
    next_coords = []

    in_cost = cur_cost // 2 if cur_cost % 2 == 0 else cur_cost // 2 + 1
    for sx, sy in cur_coords:
        cur_nc_coord, found = find(sx, sy, in_cost, color)
        next_coords += cur_nc_coord
        #print(cur_nc_coord, num_maps)
        found = num_maps[gh][gw] is not None
        if found:
            break
    #print("cur_cost", cur_cost,"num_maps", num_maps)
    if found:
        break
    else:
        #print("test")
        cur_coords = set(next_coords)
        assert len(cur_coords) >= 1
        cur_cost += 1
        #print("cur_cost", cur_cost)

out = num_maps[gh][gw]
print(out)
#print(count)

Measured memory_bytes: 34408
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  set<char> S;
  rep(i,si){
    S.insert(s[i]);
  }
  if(si==4){
    si=S.size();
    if(si==2){
      cout<<"Yes"<<'\n';
      
    }
    else{
      cout<<"No"<<'\n';
      
    }
  }
  else{
    cout<<"Yes"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)

prev = [None] * (N + 1)
seen = [False] * (N + 1)
node = deque([1])
seen[1] = True

while node:
    s = node.popleft()
    for t in edge[s]:
        if not seen[t]:
            seen[t] = True
            prev[t] = s
            node.append(t)

if any(x is None for x in prev[2:]):
    print("No")
else:
    print("Yes")
    print(*prev[2:], sep="\n")



Measured memory_bytes: 36956
def main():
    n=int(input())
    s=n*(n+1)//2
    s-=(n//3)*(n//3+1)//2 * 3
    s-=(n//5)*(n//5+1)//2 * 5
    s+=(n//15)*(n//15+1)//2 * 15
    print(s)
main()

Measured memory_bytes: 9172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int n;
    double x[30];
    string u[30];
    cin >> n;
    rep(i, n) {
        cin >> x[i];
        cin >> u[i];
    }
    double ret = 0;
    rep(i, n) {
        if (u[i] == "JPY") {
            ret += x[i];
        } else {
            ret += x[i] * 380000.0;
        }
    }
    cout << ret;

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
//use itertools::Itertools;

fn aux(memo: &mut [Option<i128>; 2001], s: i128) -> i128 {
    let filt : i128 = 1000000007;
    if s < 3 {
        0
    } else {
        match memo[s as usize] {
            Some(n) => n,
            None => {
                let mut res = 0;
                for n in 3..(s+1) {
                    res = (aux(memo, s-n) + res) % filt;
                }
                res += 1;
                memo[s as usize] = Some(res);
                res
            } 
        }
    }
}

fn main() {
    input!{s :i128};
    let mut memo: [Option<i128>; 2001] = [None; 2001];
    println!("{}", aux(&mut memo, s));
}

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


def solve(A: int, B: int):
    if A == B:
        print("EQUAL")
    elif A > B:
        print("GREATER")
    else:
        print("LESS")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61700
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());

        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";

        if(str1.charAt(0) == '1'){
            ans_int += 1;
        }
        if(str1.charAt(1) == '1'){
            ans_int += 1;
        }
        if(str1.charAt(2) == '1'){
            ans_int += 1;
        }


        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ull = unsigned long long;
using p = pair<int, int>;

const ull MOD = 1000000007;

int main(void)
{
    int N, M, B, C;
    cin >> N >> M;
    auto A = vc(int, N);
    ull ans = 0;
    fa(i, A)
    {
        cin >> i;
        ans += i;
    }
    sort(all(A));
    auto cb = vc(p, M);
    fa(i, cb) cin >> i.second >> i.first;
    sort(all(cb), greater<p>());
    auto D = vcd(int, N, -1);
    int c = 0;
    fa(i, cb) for (; c < N && i.second; i.second--) D[c++] = i.first;
    //D.resize(c);
    int i;
    for (i = 0; i < c && A[i] <= D[i]; i++) ans += D[i] - A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)

int main()
{
    int n;
    cin>>n;
    string str[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>str[i];

    }
    sort(str,str+n);
    int cnt[n+1];
    set_null(cnt,n);
    int ind=0,max=0;
    for(int i=1;i<n;i++)
    {
        if(str[i]==str[i-1])
        {
            cnt[ind]++;
            if(cnt[ind]>max)
            {
                max=cnt[ind];
            }
        }
        else{
            cnt[ind]++;
            if(cnt[ind]>max)
            {
                max=cnt[ind];
            }
            ind=i;
        }
    }
    cnt[ind]++;
    if(cnt[ind]>max)
    {
        max=cnt[ind];
    }
    for(int i=0;i<n;i++)
    {
        if(cnt[i]==max)
        {
            cout<<str[i]<<endl;
        }
    }
    return 0;
}


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

#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define rep(a, b, i) for(int i = a; i < b; i++)
#define repi(a, b, i) for(int i = a; i > b; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef double ld;

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 5;
const int mxn = 1e5 + 5;
const int mx = 1000;

class DSU {
  vector<int> parent;
  vector<int> size;
  int components = 0;
public:
  DSU(int n = -1) { if(n >= 0) init(n); }
  void init(int n) {
    parent.resize(n + 1);
    size.assign(n + 1, 1);
    components = n;
    for(int i = 0; i < n + 1; i++) parent[i] = i;
  }
  int find_set(int x) { return x == parent[x] ? x : parent[x] = find_set(parent[x]); }
  void union_set(int a, int b) {
    a = find_set(a); b = find_set(b);
    if(a != b) {
      if(size[a] < size[b]) swap(a, b);
      parent[b] = a;
      size[a] += size[b];
    }
  }
  int max_size() {
    int maxi = INT_MIN;
    for(int i = 1; i < components + 1; i++) { maxi = max(maxi, size[i]); }
    return maxi;
  }
};

int mp[(int)2e5 + 1];
int cnt[(int)2e5 + 1];

int main() {
  __;

  int n, m; cin >> n >> m;

  DSU *dsu = new DSU(n);

  int u, v;
  rep(0, m, i) {
    cin >> u >> v;
    dsu->union_set(u, v);
  }

  cout << dsu->max_size() << '\n';
 

  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

struct Acc2D {
  vector<vector<lli>> sum;
  Acc2D(vector<vector<lli>> v) {
    const int N = v.size() + 1;
    sum.resize(N);
    fill(sum.begin(), sum.end(), vector<lli>(N, 0));
    for (int i = 0; i < v.size(); ++i) {
      for (int j = 0; j < v.size(); ++j) {
        sum[i + 1][j + 1] = v[i][j];
      }
    }
    for (int i = 1; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        sum[i][j] += sum[i - 1][j];
      }
    }
    for (int i = 0; i < N; ++i) {
      for (int j = 1; j < N; ++j) {
        sum[i][j] += sum[i][j - 1];
      }
    }
  }
  lli query(int ai, int aj, int bi, int bj) {
    return sum[bi][bj] + sum[ai][aj] - sum[ai][bj] - sum[bi][aj];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

    int n, m, q;
  while (cin >> n >> m >> q) {
    vector<vector<lli>> g(n);
    fill(g.begin(), g.end(), vector<lli>(n, 0));

    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      ++g[a][b];
    }

    Acc2D acc(g);
    while (q--) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      cout << acc.query(a, a, b + 1, b + 1) << endl;
    }
  }
  
  return 0;
}


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

using namespace std;

const int MAXN = 1E5;
vector<int> adjList[MAXN + 1];
int s[MAXN + 1];
vector<int> path;

void dfs(int v, int parent, vector<int>& recurse, int n)
{
    recurse.push_back(v);
    if (v == n)
        path = recurse;
    s[v] = 1;
    for (int adj : adjList[v])
    {
        if (adj != parent)
        {
            dfs(adj, v, recurse, n);
            s[v] += s[adj];
        }
    }
    recurse.pop_back();
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    vector<int> temp;
    dfs(1, 0, temp, n);
    int meet = path[(int) (path.size() - 1) / 2 + 1];
    int s2 = s[meet];
    int s1 = n - s2;
    cout << (s1 > s2 ? "Fennec" : "Snuke") << endl;
    return 0;
}


Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  int c = 0;
  if(S.at(0)==T.at(0)){c = c + 1;}
  if(S.at(1)==T.at(1)){c = c + 1;}
  if(S.at(2)==T.at(2)){c = c + 1;}
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char *argv[])
{
	int l,r,d;
	scanf("%d %d %d",&l,&r,&d);
	int count=0;
	for(int i=l;i<=r;i++){
		if(i%d==0) count++;
	}
	printf("%d",count);
	return 0;
}

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

int main()
{
  int number;
  cin>>number;
  int list_a[number];
  int m,v;
  for(int i=0;i<number;i++)
  {
    cin>>list_a[i];
  }
  for(int i=1;i<number;i++)
  {
  for(int k=0;k<number;k++)
  {
    if(k>0)cout<<" ";
    cout<<list_a[k];
  }
  cout<<endl;
    for(int j=i-1;j>=0;j--)
    {
      if(list_a[j+1]<=list_a[j])
      {
        m=list_a[j];
        list_a[j]=list_a[j+1];
        list_a[j+1]=m;
      }
    }
  }
  for(int k=0;k<number;k++)
  {
    if(k>0)cout<<" ";
    cout<<list_a[k];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
 
using namespace std;
 
string in, t;
int n, h;
 
 
int main(){
    while (true){
        cin >> in;
        if (in == "-") break;
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> h;
            t = in.substr(0, h);
            in = in.substr(h, in.size());
            in += t;
        }
        cout << in << endl;
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
const double E = 1e-7;
const ll INF = 1e17;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first                                                 
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sort_(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define rsort_(a) sort(a.begin(), a.end()); reverse(a.begin(), a.end())
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false)
// ____________________________________________________________
#define cina(a) forn(i,0,sz(a)) cin >> a[i]
#define cinpr(a) cin >> a.ft >> a.sec 
//--------------------------------------------------------------

const int MAXN = 3 * 1e5;


int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    forn(i,0,n) cin >> a[i];
    int all = 0;
    forn(i,0,n) all+=a[i];

    int minn = all/(4*m) + ((all % (4*m) != 0) ? 1 : 0);

    int ans = 0;
    forn(i,0,n) {
        if (a[i]>=minn) {
            ans++;
        }
    }
    if (ans >= m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

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

using namespace std;
using ll =long long;
#define rep(i,n) for(ll i =0; i < n ; i ++)

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  ll n;
  cin>> n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  string ans ="APPROVED";
  rep(i,n){
    if(a[i]%2 ==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        ans ="DENIED";
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n):
    for j in range(i+1,n):
        ans=0
        for k in range(d):
            ans+=(x[i][k]-x[j][k])**2
        if math.sqrt(ans).is_integer()==True:
            count+=1
print(count)





Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b >> c;
	d = b - a; 

	if ( d < 2 * c)
	{
		for(int i = a; i <= b; i++)
		{
			std::cout << i << std::endl;
		}
	}else{
		for(int i = a; i <= a + c - 1; i++)
		{
			std::cout << i << std::endl;
		}
		for(int i = b - c + 1; i <= b; i++)
		{
			std::cout << i << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int main() { 
   long long n;
   cin>>n;
   vector<long> v(n);
   vector<long> c(n);
   vector<long> xy(n);
   for(int i=0;i<n;i++){
     cin>>v[i];
   }
   for(int i=0;i<n;i++){
     cin>>c[i];
   }
   for(int i=0;i<n;i++){
     xy[i]=v[i]-c[i];
   }
   sort(xy.begin(), xy.end());
   reverse(xy.begin() ,xy.end());
   long ans=0;
   for(int i=0;i<n;i++){
     if(xy[i]>0){
       ans+=xy[i];
     }
     else{
       break;
     }
   }
   cout<<ans<<endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
typedef long long ll;

using namespace std;

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

    int ans = a.size();
    int cnt = 0;

    for (int i=0; i<a.size(); i++) {
        if(i%2 == 0) {
            if (a[i] == 'h') {
                cnt++;
            }
        } else {
            if (a[i] == 'i') {
                cnt++;
            }
        }
    }

    if(cnt == ans && (cnt % 2 == 0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
       Optimized solution
*/
//C-H and V 
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
   int h,w,k,i,j;cin>>h>>w>>k;
   char M[h][w];
   fo(i,0,h)
   fo(j,0,w)cin>>M[i][j];
   
   ll ans=0;
   for(int rmask=0;rmask<(1<<h);rmask++)
   {
       for(int cmask=0;cmask<(1<<w);cmask++)
       {
           int cnt=0;
           fo(i,0,h)
           fo(j,0,w)
           if((((rmask>>i)&1)==0)&&(((cmask>>j)&1)==0)&&M[i][j]=='#')cnt++;
           if(cnt==k)ans++;
       }
   }
   cout<<ans<<'\n';
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int main()
{
    int n,allr=0;
    string c;
    cin>>n>>c;
    for(int i=0;i<n;i++)
        allr+=c[i]=='R';
    int r=0;
    for(int i=0;i<allr;i++)
        if(c[i]=='R') r++;
    cout<<allr-r;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    int ans = 1;
    deque<char> deq;
    deq.push_front(s[0]);
    int c = 0;
    if(s[0]=='0') c++;
    for (int i = 1; i < s.length(); i++) {
        if(deq.front()==s[i]){
        }
        else{
            if(s[i]=='0'&&c==k){
                while(deq.back()=='1') deq.pop_back();
                while(deq.back()=='0') deq.pop_back();
                c--;
            }
            if(s[i]=='0'){
                c++;
            }
        }
        deq.push_front(s[i]);
        ans = max(ans,(int)deq.size());
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
using namespace std;

const int MOD = 1e9 + 7;

long long ModPow(long long x, long long n, long long m) {
        long long res = 1;
        while (n > 0) {
                if (n & 1) res = res * x % m;
                x = x * x % m;
                n >>= 1;
        }
        return res;
}

long long Inv(long long a) {
        long long res = 1;
        long long n = MOD - 2;
        while (n > 0) {
                if (n & 1) res = res * a % MOD;
                a = a * a % MOD;
                n >>= 1;
        }
        return res;
}

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> g(n + 1);
        for (int i = 0; i < n; i ++) {
                int p;
                scanf("%d", &p);
                g[p].push_back(i + 1);
        }
        n ++;
        vector<vector<long long>> zeros(n), ones(n);
        map<int, int> cnt;
        function<void (int, int)> dfs = [&](int u, int d) {
                int mx = 0, idx = u;
                cnt[d] ++;
                for (int v : g[u]) {
                        dfs(v, d + 1);
                        if (mx < zeros[v].size()) {
                                mx = zeros[v].size();
                                idx = v;
                        }
                }
                swap(zeros[u], zeros[idx]);
                swap(ones[u], ones[idx]);
                int m = 0;
                for (auto v : g[u]) if (v != idx) m = max(m, (int)zeros[v].size());
                for (int i = 0; i < m; i ++) {
                        long long zero = zeros[u][mx - 1 - i];
                        long long sum = ones[u][mx - 1 - i] * Inv(zeros[u][mx - 1 - i]) % MOD;
                        long long all = (zeros[u][mx - 1 - i] + ones[u][mx - 1 - i]) % MOD;
                        for (auto v : g[u]) if (v != idx) {
                                long long z = 1, o = 0;
                                int sz = zeros[v].size();
                                if (sz > i) {
                                        z = zeros[v][sz - 1 - i];
                                        o = ones[v][sz - 1 - i];
                                }
                                (zero *= z) %= MOD;
                                (sum += o * Inv(z)) %= MOD;
                                (all *= o + z) %= MOD;
                        }
                        ones[u][mx - 1 - i] = zero * sum % MOD;
                        zeros[u][mx - 1 - i] = (all - ones[u][mx - 1 - i]) % MOD;
                }
                ones[u].push_back(1);
                zeros[u].push_back(1);
        };
        dfs(0, 0);
        long long ans = 0;
        for (int i = 0; i < ones[0].size(); i ++) {
                (ans += ones[0][i] * ModPow(2, n - cnt[ones[0].size() - 1 - i], MOD)) %= MOD;
        }
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 67684
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N =cin.nextInt();
		for(;N--!=0;){
			En A =new En(cin.nextDouble(),cin.nextDouble(),cin.nextDouble());
			En B =new En(cin.nextDouble(),cin.nextDouble(),cin.nextDouble());
			boolean f=false;
			if(A.r<B.r){
				En C = A.clone();
				A = B;
				B=C;
				f=true;
			}
			double distance=dist(A,B);
			
			if(distance>A.r){
				// 外
				if(A.r+B.r>=distance){
					System.out.println(1);
				}
				else{
					System.out.println(0);
				}
				
			}
			else{
				int x = 2;
				if(f){
					x*=-1;
				}
				if(distance+B.r<A.r){
					System.out.println(x);
				}
				else{
					System.out.println(1);
				}
			}
		}

	}
	static double dist(En A,En B){
		double x = (A.x-B.x)*(A.x-B.x);
		double y = (A.y-B.y)*(A.y-B.y);
		
		return Math.sqrt(x+y);
	}
}
class En{
	double x,y,r;
	En(double a,double b,double c){
		x=a;y=b;r=c;
	}
	protected En clone(){
		En c=new En(this.x,this.y,this.r);
		return c;
	}
}

Measured memory_bytes: 12000
def main():
    import math
    import sys
    from collections import defaultdict

    n = int(input())
    s = str(input())
    dic1 = defaultdict(list)

    for i in range(len(s)):
        dic1[s[i]] += [i]

    c = 0
    co = len(dic1["B"])

    for a in dic1["R"]:
        for b in dic1["G"]:
            f = 0
            t = abs(a-b)
            ma = max(a,b) + t
            mi = min(a,b) - t
            if abs(a + b) % 2 == 0:
                if s[abs(a + b) // 2] == "B":
                    f += 1
            if ma <= len(s) - 1:
                if s[ma] =="B":
                    f += 1
            if mi >= 0:
                if s[mi] == "B":
                    f += 1
            c += (co - f)

    print(c)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9520
public class Main {
  private static void solve() {
    int a = ni();
    int b = ni();
    int c = b - a;
    
    int x = c * (c + 1) / 2;
    System.out.println(x - b);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

int main()
{
    int n, sum = 0, ans = 0;
    cin >> n;

    while(1){
		sum += n;
		ans++;
		if(sum % 360 == 0){
			cout << ans;
			break;
		}
		//ans++;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <string.h>
#include <stdio.h>
#define REP(a) for(i = 0; i < a; i++)

int main(void)
{
    char a[100005];
    int i,m = 'a';
    scanf("%s",a);
    REP(26) {
        if (strchr(a, m) == NULL) {
            printf("%c",m);
            goto end;
        }
        m++;
    }
    printf("None");
end:
    printf("\n");
    return 0;
 }

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

int main()
{
  int n,m;
  for(;cin>>n>>m;)
    {
      int l[m];
      int r[m];
      for(int i=0;i<m;i++)
	cin>>l[i]>>r[i];

      int now=1;
      int cnt=0;
      while(now<=n)
	{
	  //	  cout<<"now:"<<now<<endl;
	  int tmp=now-1;
	  for(int i=0;i<m;i++)
	    {
	      if(l[i]<=now && tmp<r[i])
		tmp=r[i];
	    }
	  //	  cout<<"tmp:"<<tmp<<endl;
	  if(tmp==now-1)
	      break;
	  cnt++;
	  now=tmp+1;
	}
      if(now>n)
	cout<<cnt<<endl;
      else
	cout<<"Impossible"<<endl;
    }

}

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

typedef long long ll;

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

    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    vector<int> cnt(n+10,0);
    for(int i=0;i<m;i++){
        cin >> p[i] >> s[i];
        cnt[p[i]]++;
    }
    int ac=0,wa=0;
    vector<bool> ok(n+10,false);
    for(int i=0;i<m;i++){
        if(!ok[p[i]] && s[i]=="WA"){
            wa++;
        }
        if(!ok[p[i]] && s[i]=="AC"){
            ac++;
            ok[p[i]] = true;
        }
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>=1 && ok[i]==false){
            wa -= cnt[i];
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 6528