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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = n % 500;

        if(a >= b){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 22612
N = int(input())
matrix = [[0] * N for _ in range(N)]

for i in range(N):
    tmp = list(map(int, input().split()))
    for j in range(tmp[1]):
        matrix[tmp[0]-1][tmp[j+2]-1] = 1

for i in range(N):
    print(*matrix[i])



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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int X;
  cin >> X;
  if(X == 3 || X == 5 || X == 7) cout << "YES";
  else cout << "NO";
  return 0;
}

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

template<class T>
void chmax (T &a, const T &b) {
    if (a < b) a = b;
}

int main() {
    int n;
    cin >> n;
    vector<pair<long long, int>> a;
    for (int i = 0; i < n; i++) {
        long long e;
        cin >> e;
        a.emplace_back(e, i);
    }
    
    sort(a.rbegin(), a.rend());
    
    long long dp[2020][2020] = {};
    for (int i = 0; i < n; i++) {
        const long long val = a[i].first;
        const int &id = a[i].second;
        for (int x = 0; x <= i; x++) {
            const int y = i - x;
            chmax(dp[x + 1][y], dp[x][y] + val * abs(x - id));
            chmax(dp[x][y + 1], dp[x][y] + val * abs(n - y - 1 - id));
        }
    }
    
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        chmax(ans, dp[i][n - i]);
    }
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 35572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m)
      cin >> a[i][j];
  }
  int ans = INF;
  rep(i, 1<<n) {
    int cost = 0;
    vector<int> res(m);
    rep(j, n) {
      if (i>>j & 1) {
        cost += c[j];
        rep(k, m)
          res[k] += a[j][k];
      }
    }
    rep(j, m) {
      if (res[j] < x)
        cost = INF;
    }
    chmin(ans, cost);
  }
  if (ans == INF)
    cout << -1 << endl;
  else 
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
std::pair<int64_t, int64_t> value[200000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> value[i].first >> value[i].second;
		if (value[i].first > value[i].second) { std::swap(value[i].first, value[i].second); }
	}
	std::sort(value, value + N);

	int64_t min_value;
	int64_t max_diff;
	//最小と最大が違う
	{
		int64_t A_MAX = -1, A_MIN = 100000000000000000;
		int64_t I_MAX = -1, I_MIN = 100000000000000000;
		for (int32_t i = 0; i < N; ++i)
		{
			A_MAX = std::max(A_MAX, value[i].second); A_MIN = std::min(A_MIN, value[i].second);
			I_MAX = std::max(I_MAX, value[i].first ); I_MIN = std::min(I_MIN, value[i].first );
		}
		min_value = (A_MAX - A_MIN)*(I_MAX - I_MIN);
		max_diff = A_MAX - I_MIN;
	}
	//最大と最小が同じ
	int64_t diff2_sec_min = value[0].second;
	int64_t diff2_max = value[N-1].first;
	for (int32_t i = 1; i < N; ++i)
	{
		//最小値が決まる=>最大値を最小化すればよい=>貪欲
		//最小値を段々と上げていく=>更新するのは、旧最小値のみ
		//ソートにより、value[i].firstが最小
		diff2_sec_min = std::min(diff2_sec_min, value[i - 1].second);
		diff2_max = std::max(diff2_max, value[i - 1].second);
		min_value = std::min(min_value, max_diff*(diff2_max- std::min(diff2_sec_min,value[i].first)));
	}
	std::cout << min_value << std::endl;


	return 0;
}
#endif


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	int n,l[100];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i];
	sort(l,l+n);
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++)
				if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]+l[j]>l[k])
					ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
a=[0]*(10**5+1)
now=0
for i in input().split():
    a[int(i)]+=1
    now+=int(i)
for _ in range(int(input().rstrip())):
    b,c=map(int,input().split())
    now-=b*a[b]
    now+=c*a[b]
    print(now)
    a[b],a[c]=0,a[c]+a[b]


Measured memory_bytes: 17836
while a=gets.chomp
 break if a=='0 0'
 n,m=a.chomp.split
 n,m=n.to_i,m.to_i
 num=[]
 nu=[]
 sum=1
 n.times do |i|
  b=gets.chomp.to_i
  num[i]=b
 end
 m.times do |j|
  c=gets.chomp.to_i
  nu[j]=c
 end
 l=0
 m.times do
 sum+=nu[l]
 l+=1
  break if sum>=n  
  sum+=num[sum-1]
  break if sum>=n
 end
 puts l.to_s
end

Measured memory_bytes: 6116
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;

int num[10005];

void debugout ( long long value ){
    cout << value  << endl;
}


int main(){

    long double hourLength, minuteLength, hour, minute;
    cin >> hourLength >> minuteLength >> hour >> minute;

    long double PI = 3.141592653589793238462;

    long double theta = 2*PI*( hour/12.0 + minute/720.0 - minute/60.0);

    double length = ( hourLength*hourLength + minuteLength*minuteLength )
            - (long double)2.0 * hourLength * minuteLength * cos(theta);

    printf("%.20lf", sqrt(length));
    return 0;
}





Measured memory_bytes: 4124
s = input()
check = True
if 'a' in s:
	t = 1
else:
	check = False
if 'b' in s:
	t = 1
else:
	check = False
if 'c' in s:
	t = 1
else:
	check = False
if check:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
s=input()
i=0
if s[i]==s[i+1]==s[i+2]=="R":
  print(3)
elif s[i]==s[i+1]=="R":
  print(2)
elif s[i+1]==s[i+2]=="R":
  print(2)
elif "R" not in s:
  print(0)
else:
  print(1)
    

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N+1);
    vector<long long> B(N);
    for(int i = 0; i < N+1; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        cin >> B.at(i);
    }
    
    long long int count = 0;

    for(int i = 0; i < N; i++){
        if(A.at(i) - B.at(i) >= 0){ //一つも殺せない
            count += B.at(i);
        }
        else if(B.at(i) - A.at(i) - A.at(i+1) >= 0){ //二つとも殺せる
            count += A.at(i) + A.at(i+1);
            A.at(i+1) = 0;
        }
        else { //一つ目は殺せるが二つ目が殺せない
            count += B.at(i);
            A.at(i+1) -= B.at(i) - A.at(i);
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

ll n;
ll ar[301];

long double dp[301][301][301];

long double func(ll c1,ll c2,ll c3)
{
    //cout<<c1<<" "<<c2<<" "<<c3<<endl;
    if(c1==0&&c2==0&&c3==0){return 0.0;}
    if(dp[c1][c2][c3]==-1){
    long double ans=0;
    if(c1>0&&c2>0&&c3>0)
    {
        ans=(n*1.0/(c1+c2+c3)) + (c1*1.0/(c1+c2+c3))*func(c1-1,c2,c3) + (c2*1.0/(c1+c2+c3))*func(c1+1,c2-1,c3) + (c3*1.0/(c1+c2+c3))*func(c1,c2+1,c3-1);
    }
    else if(c1>0&&c2>0)
    {
        ans=(n*1.0/(c1+c2)) + (c1*1.0/(c1+c2))*func(c1-1,c2,c3) + (c2*1.0/(c1+c2))*func(c1+1,c2-1,c3);
    }
    else if(c1>0&&c3>0)
    {
        ans=(n*1.0/(c1+c3)) + (c1*1.0/(c1+c3))*func(c1-1,c2,c3) + (c3*1.0/(c1+c3))*func(c1,c2+1,c3-1);
    }
    else if(c2>0&&c3>0)
    {
         ans=(n*1.0/(c2+c3)) + (c2*1.0/(c2+c3))*func(c1+1,c2-1,c3) + (c3*1.0/(c2+c3))*func(c1,c2+1,c3-1);
    }
    else if(c1>0)
    {
        ans=(n*1.0/(c1)) + func(c1-1,c2,c3);
    }
    else if(c2>0)
    {
        ans=(n*1.0/(c2)) + func(c1+1,c2-1,c3);
    }
    else if(c3>0)
    {
        ans=(n*1.0/(c3)) + func(c1,c2+1,c3-1);
    }
    dp[c1][c2][c3]=ans;
    }
    return dp[c1][c2][c3];
}

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

    //freopen("output.txt","w",stdout);

    cin>>n;
    ll c1=0,c2=0,c3=0;
    for(ll i=0;i<n;++i){
        cin>>ar[i];
        if(ar[i]==1){++c1;}
        if(ar[i]==2){++c2;}
        if(ar[i]==3){++c3;}
    }

    for(ll i=0;i<=n;++i){
        for(ll j=0;j<=n;++j){
            for(ll k=0;k<=n;++k)
            {
                dp[i][j][k]=-1;
            }
        }
    }

    long double ans=func(c1,c2,c3);
    cout<<std::fixed;
    cout<<setprecision(9);
    cout<<ans<<endl;


    return (0);
}


Measured memory_bytes: 426496
using System;
using System.Numerics;

namespace Atcoder.ABC103
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int max = 0;

            int x, y, z;
            x = Math.Abs(a - b);
            y = Math.Abs(b - c);
            z = Math.Abs(a - c);
//        
//            Console.WriteLine(x);
//            Console.WriteLine(y);
//            Console.WriteLine(z);
            max = Math.Max(x, y);
            max = Math.Max(max, z);
            Console.WriteLine(max);
        }    
    }
}

namespace Atcoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC103.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, m, a, b;
    vector<pair<int, int>> ab;
    map<ll, ll> cnt;
    cin >> n >> m;
    rep(i, m){
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }

    for(auto const& e : ab){
        cnt[e.first]++;
        cnt[e.second]++;
    }

    bool res = true;
    for(auto const& e : cnt){
        if(e.second%2 != 0){
            res = false;
            break;
        }
    }

    ans2(res);

    return 0;
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define BIG 1000000007
#define ll long long int

int nb[6];

int rtoa(){
  int a=0;
  a+=nb[0]*100000;
  a+=nb[1]*10000;
  a+=nb[2]*1000;
  a+=nb[3]*100;
  a+=nb[4]*10;
  a+=nb[5];
  return a;
}

void ator(int a){
  for(int i=0;i<6;i++){
    nb[i]=0;
  }
  nb[5]=a%10;
  nb[4]=((a%100)/10);
  nb[3]=((a%1000)/100);
  nb[2]=((a%10000)/1000);
  nb[1]=((a%100000)/10000);
  nb[0]=(a/100000);
}

int main(){
  int n,m,i=0;
  int a[30];
  bool b;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    i=0;
    for(int i=0;i<30;i++){
      a[i]=0;
    }
    b=true;
    while(b){
      int high,low;
      a[i]=n;
      i++;
      ator(n);
      sort(nb+6-m,nb+6,greater<int>());
      high=rtoa();
      sort(nb+6-m,nb+6);
      low=rtoa();
      n=high-low;
      for(int j=0;j<i;j++){
	if(n==a[j]){
	  cout<<j<<" "<<n<<" "<<i-j<<endl;;
	  b=false;
	  break;
	}
      }
    }
  }
  return 0;
}
	  
	



Measured memory_bytes: 3036
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a, a + 4);
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
}

Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

struct Mod {
	static ll BASE;
	ll value = 0;
	static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
	Mod()
	: value(0) {}
	Mod(ll value)
	: value(residue(value)) {}
	Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
	void operator+=(const Mod& rhs) { *this = *this + rhs; }
	Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
	void operator-=(const Mod& rhs) { *this = *this - rhs; }
	Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
	void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;

int main() {
	ll N;
	cin >> N;
	vector<ll> cols;
	rep(i,0,N) {
		ll c;
		cin >> c;
		c--;
		if (cols.size() == 0 || cols.back() != c) {
			cols.push_back(c);
		}
	}
	N = cols.size();
	unordered_map<ll, Mod> memo;
	Mod ans = 1;
	rep(i,0,N) {
		Mod bak = memo[cols[i]];
		memo[cols[i]] += ans;
		ans += bak;
	}
	cout << ans.value << endl;
}


Measured memory_bytes: 12784
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 520;
//const int md = 1e9 + 7;

int c[maxn];
int s[maxn];
int f[maxn];

int n;

int go(int z, int t) {
    if (z == n) return t;
    
    //cout<<z<<" : "<<t<<endl;
    
    if (t <= s[z]) return go(z + 1, s[z] + c[z]);
    else { if (t % f[z] == 0) return go(z + 1, c[z] + t);
             else return go(z + 1, c[z] + t + f[z] - (t % f[z])); }
}
    

int main() {
	IOS;
	cin>>n;
	for (int i = 1; i < n; i++) {
	    cin>>c[i] >> s[i] >> f[i];
	}
	
	for (int i = 1; i <= n; i++) cout<<go(i, 0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define Mid ((L+R)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define deb(x) cout<<#x<<"="<<x<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int N = 1e6 + 7;
int cnt[N];
void s(int n)
{
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j+=i)
        cnt[j]++;
    return;
}
int main()
{
    go;
    int n;
    cin>>n;
    s(n);
    ll ans=0;
    for(int i=1;i<n;i++)
        ans+=cnt[n-i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7480
#include <stdio.h>

int main() {

char str[100];
int n,i,j,x,y;

if(scanf("%d", &n)== 1);
scanf("%s",str);

j=0;
for(i=0;str[i];i++) {
if(str[i]=='A') {
	x = i + 1;
if(str[x]=='B'){
	y = x + 1;
if(str[y]=='C'){
j++;
}
}
}
}

printf("%d",j);

return 0;
}

Measured memory_bytes: 128
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score(t):
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(len(t)):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution1():
    return [i % 26 for i in range(D)]

def solution2():
    t = None
    score = -1
    for i in range(26):
        nt = [(i + j) % 26 for j in range(D)]
        if calc_score(nt) > score:
            t = nt
    return t

def solution3():
    t = []
    for _ in range(D):
        score = -1
        best = -1
        t.append(0)
        for i in range(26):
            t[-1] = i
            new_score = calc_score(t)
            if new_score > score:
                best = i
                score = new_score
        t[-1] = best
    return t

def optimize0(t):
    return t

def optimize1(t):
    score = calc_score(t)
    while time() - start_time + 0.15 < limit_secs:
        d = int(random() * D)
        old = t[d]
        t[d] = int(random() * 26)
        new_score = calc_score(t)
        if new_score < score:
            t[d] = old
        else:
            score = new_score
    return t

def optimize2(t):
    score = calc_score(t)
    while time() - start_time + 0.15 < limit_secs:
        d1 = int(random() * D)
        q1 = int(random() * 26)
        d2 = int(random() * D)
        q2 = int(random() * 26)
        old1 = t[d1]
        old2 = t[d2]
        t[d1] = q1
        t[d2] = q2
        new_score = calc_score(t)
        if new_score < score:
            t[d2] = old2
            t[d1] = old1
        else:
            score = new_score
    return t


t = solution3()
t = optimize2(t)
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 84812
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){

    ll n;
    cin >> n;

    vector<ll> d(n);

    for(int i = 0; i<n; i++){
        cin >> d.at(i);
    }

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

    ll halfn = n/2;
    ll co1,co2;
    co1 = d.at(halfn-1);
    co2 = d.at(halfn);

    cout << co2-co1 << endl;
    

}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
   int a,b,c;

   scanf("%d %d %d\n", &a,&b,&c);

  if (a<=b && b<=c)
     printf("%d %d %d\n",a,b,c);
  else if (a<=c && c<=b)
     printf("%d %d %d\n",a,c,b);
  else if(b<=a && a<=c)
     printf("%d %d %d\n",b,a,c);
  else if(b<=c && c<=a)
     printf("%d %d %d\n",b,c,a);
  else if(c<=a && a<=b)
     printf("%d %d %d\n",c,a,b);
  else
     printf("%d %d %d\n",c,b,a);

    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=1e5+5;
const ll MOD=998244353;
const ll INF=1e18;
ll n,a[MAXN];

void solve()
{
    sort(a+1,a+1+n);
    printf("%lld\n",a[n/2+1]-a[n/2]);
}
int main()
{
//    freopen("c://duipai//data.txt","r",stdin);
//    freopen("c://duipai//wa.txt","w",stdout);
    while(~scanf("%lld",&n))
    {
//        string ss;
//        cin>>ss;
//        cout<<ss<<endl;
       // solve();
        for(ll i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
        }
        solve();
    }
}
/*
5
76578820211343624  293297008968192 189152283861189120 324294649604739072 20266198324215808
*/


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <utility>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, forall_a, forall_b) for (int i = (forall_a); i < (forall_b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P &forall_a, const P &forall_b)
{ //first昇順
	return forall_a.first < forall_b.first;
}
bool ps2(const P &forall_a, const P &forall_b)
{ //first降順
	return forall_a.first > forall_b.first;
}
bool ps3(const P &forall_a, const P &forall_b)
{ //second昇順
	return forall_a.second < forall_b.second;
}
bool ps4(const P &forall_a, const P &forall_b)
{ //second降順
	return forall_a.second > forall_b.second;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}

int main()
{
	int n;
	cin >> n;
	int c,k;
	cin>>c>>k;
	vector<int>pass(n);
	rep(i,n){
		cin>>pass[i];
	}
	sort(all(pass));
	bool next=true;
	int tl=0;
	int bus=0;
	int cnt=0;
	rep(i,n){
		if(next){
			cnt++;
			tl=pass[i]+k;
			next=false;
			bus++;
		}else{
			if(pass[i]<=tl&&bus<c){
				bus++;
			}else{
				bus=0;
				next=true;
				i--;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

p = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
def count(n):
    if n <= 0:
        return 1
    return p[n]

MOD = 1000000007

def main():
    H, W, K = rli()
    dp = [[0 for _ in range(W+2)] for _ in range(H+1)]
    dp[0][1] = 1
    for h in range(0, H):
        for w in range(1, W+1):
            dp[h+1][w] = dp[h][w-1]*count(w-3)*count(W-w-1)
            dp[h+1][w] += dp[h][w]*count(w-2)*count(W-w-1)
            dp[h+1][w] += dp[h][w+1]*count(w-2)*count(W-w-2)
            dp[h+1][w] %= MOD
    print(dp[H][K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> ac(n);
  int cnt = 0;
  ac.at(0) = 0;
  for (int i = 1; i < n; i++) {
    if (s.at(i - 1) == 'A' && s.at(i) == 'C') cnt++;
    ac.at(i) = cnt;
  }
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l.at(i) >> r.at(i);
    cout << ac.at(r.at(i) - 1) - ac.at(l.at(i) - 1) << endl;
  }
}

Measured memory_bytes: 2176
N, M, K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]
b = [0]
for i in range(N):
    a.append(a[-1] + A[i])
for i in range(M):
    b.append(b[-1] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:  break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 134352
def insertionSort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt += 1
            
        a[j+g] = v
    return cnt

if __name__ == '__main__':
    N = (int)(input())
    A = []
    cnt = 0
    for x in range(N):
        A.append((int)(input()))

    if N == 1:
        g = [1]
    else:
        g = [x for x in [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1] if x < N]

    count = 0

    for x in g:
        count += insertionSort(A,N,x)

    print(len(g))
    print(*g)
    print(count)
    print(*A,sep = '\n')
    

Measured memory_bytes: 63176
import math
def combinations_count(n, r):
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r))) % inf

inf = (10 ** 9) + 7
n, k = map(int, input().split())
if n == k:
    for i in range(1, k+1):
        if i == 1:
            print(1)
        else:
            print(0)
else:
    for i in range(1, k+1):
        if (n - k + 1 >= i):
            print((combinations_count((n - k + 1), i)*combinations_count((k-1), i-1))%inf)
        else:
            print(0)

Measured memory_bytes: 3316
#include <stdio.h>

#define SIZE 2000000

int main() {
  setvbuf(stdout, NULL, _IOFBF, 8000);
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\n';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5496
from copy import deepcopy
from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n)]
V = []
for i in range(m):
    a, b = list(map(lambda x: x-1, map(int, input().split())))
    G[a].append(b)
    G[b].append(a)
    V.append([a,b])

ans = 0
# 各辺について、除いた場合グラフが非連結になるか確かめる.
# 非連結ならば、適当な頂点から探索した時に到達できない頂点が存在する.
for i in range(m):
    _G = deepcopy(G)
    _G[V[i][0]].remove(V[i][1])
    _G[V[i][1]].remove(V[i][0])
    # BFS
    ## キューの初期化
    que = deque([0])
    ## 距離の初期化
    D = [-1]*n
    D[0] = 0
    ##キューが尽きるまで探索を行う
    while que:
        ### 現在地を取得.
        nw = que.popleft()
        ### 現在地から行けるところについて探索.
        for nx in _G[nw]:
            if D[nx]!=-1: continue
            D[nx] = D[nw]+1
            que.append(nx)
    if min(D) == -1:
        ans += 1
print(ans)

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

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  int count = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[i]) continue;
    count++;
  }
  cout<<count<<endl;
    
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int cnt=0;

  for(int i=l;i<=r;++i){
    if(i%d==0) ++cnt;
  }
  cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int main()
{
	int n,k;
	cin>>n>>k;
	int st[55];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>st[i];
		sum+=st[i];
	}
	sort(st,st+n);
	int b=n-k;
	for(int i=0;i<b;i++){
		sum-=st[i];
	}
	cout<<sum;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		Set<String> used = new HashSet<>();
		String prevW;

		String ans = "Yes";
		prevW = sc.next();
		used.add(prevW);
		for (int i = 1; i < N; i++) {
			String w = sc.next();
			if (used.contains(w) || w.charAt(0) != prevW.charAt(prevW.length() - 1)) {
				ans = "No";
				break;
			}

			prevW = w;
			used.add(w);
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int nums[3][3];
bool check(){
    for(int i = 0; i < 3; ++i){
        if(nums[i][0] == -1 && nums[i][1] == -1 && nums[i][2] == -1) return true;
    }
    for(int i = 0; i < 3; ++i){
        if(nums[0][i] == -1 && nums[1][i] == -1 && nums[2][i] == -1) return true;
    }
    if(nums[0][0] == -1 && nums[1][1] == -1 && nums[2][2] == -1) return true;
    if(nums[2][0] == -1 && nums[1][1] == -1 && nums[0][2] == -1) return true;
    return false;
}
int main() {

    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            cin >> nums[i][j];
    int n;
    cin >> n;
    for(int k = 0; k < n; ++k){
        int target;
        cin >> target;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                if(nums[i][j] == target) nums[i][j] = -1;
            }
        }
    }
    bool flag = check();
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


vector<P>cnt(100010),cnt2(100010);


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n) {
		if (i % 2 == 0) {
			cnt[a[i]].first++; cnt[a[i]].second = a[i];
		}
		else {
			cnt2[a[i]].first++; cnt2[a[i]].second = a[i];
		}
	}
	sort(ALLR(cnt)), sort(ALLR(cnt2));
	int ans = 0;
	if (cnt[0].second == cnt2[0].second) {
		// より種類数が多い方を選びたい
		if (cnt[1].first < cnt2[1].first) {
			ans += n / 2 - cnt[0].first;
			ans += n / 2 - cnt2[1].first;
		}
		else {
			ans += n / 2 - cnt[1].first;
			ans += n / 2 - cnt2[0].first;
		}
	}
	else {
		ans += n / 2 - cnt[0].first; ans += n / 2 - cnt2[0].first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); 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 repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double n; cin >> n;
	for (double i = 1; i <= 3500; i++) {
		for (double j = 1; j <= 3500; j++) {
			double k = n * i*j / (4 * i*j - n * i - n * j);
			if (1<= k&&floor(k) == k&&k<=3500) {
				cout << i << " " << j << " " << k << endl; return 0;
			}
		}
	}

	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int t=s.size();
    if(s[t-1]=='s')cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;



}


Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <assert.h>
#include <set>
#include <cstring>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n,q;
int A[200005];
int P[200005], S[200005];

int main(){
  
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  cin >> n;
  for ( int i = 1; i <= n; i++ ){
    cin >> A[i];
    P[i] = P[i-1] ^ A[i];
  }
  for ( int i = n; i >= 1; i-- ){
    S[i] = S[i+1] ^ A[i];
  }
  
  for ( int i = 1; i <= n; i++ ){
    int x = P[i-1] ^ S[i+1];
    cout << x ;
    if ( i < n ) cout << " ";
    else cout << endl;
  }
  return 0;
}








    

Measured memory_bytes: 5932
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)

    val (N, M, X) = scanner.nextLine().split(" ").map { it.toInt() }
    val gates = scanner.nextLine().split(" ").map { it.toInt() }

    var upCost = 0
    for (i in X .. N) if (gates.contains(i)) upCost += 1

    var downCost = 0
    for (i in X downTo 0) if (gates.contains(i)) downCost += 1

    println(Math.min(upCost, downCost))
}

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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int n, a[N], ans;
char s[N];
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	n = read();
	rep(i, 1, n) cin >> s[i];
	ans = n;
	rep(i, 1, n) {
		if(s[i] == s[i-1]) ans--; 
	}
	printf("%d\n", ans);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	return 0;
}


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

int main()
{ 
  int n;
  string u;
  double x, ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += x * 380000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 41432
#include<stdio.h>
int main()
{
    int a[3],i,max=-1,min=101;
    for(i=0; i<3; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    printf("%d",max-min);
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

N, D = map(int, input().split())
X = []

for i in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(N):
    x_i = X[i]
    for j in range(i+1, N):
        x_j = X[j]
        dist = 0
        for d in range(D):
            dist += (x_i[d] - x_j[d])*(x_i[d] - x_j[d])

        dist = dist**0.5
        if dist - int(dist) == 0:
            count += 1

print(count)

Measured memory_bytes: 3188
#include<iostream>
 
int main(){
    int a,b;
    std::cin>>a>>b;
    if(a>b){
        std::cout<<"a > b"<<std::endl;
        }else if(a<b){
        std::cout<<"a < b"<<std::endl;
        }else{
        std::cout<<"a == b"<<std::endl;
        }
    return 0;
    }

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	string s;
	cin >> s;	
	reverse(s.begin(),s.end());
	long long keta=s.size();
	vector<long long> ten(keta,0);
	
	ten[0]=1;
	for(long long i=1;i<keta;i++){
		ten[i]=(ten[i-1]*10)%2019;	
	}
	
	long long ans=0;
	vector<long long> n(keta,0),m(2019,0);
	for(long long i=0;i<keta;i++){
		long long now=(long long)(s[i]-'0');
		
		if(i==0)n[i]=(ten[i]*now)%2019;	
		else n[i]=(n[i-1]+(ten[i]*now)%2019)%2019;	
		
		//cout << n[i] << endl;
		
		if(n[i]==0)ans++;
		m[n[i]]++;
	}
	
	
	for(long long i=0;i<2019;i++){
		if(m[i]>0){
			ans+=(m[i]*(m[i]-1))/2;
		}
	}
	
	cout << ans << endl;
			
	return 0;
}


Measured memory_bytes: 6744
#include<iostream>
using namespace std;
long long solve(int n){
	long long ret=0;
	for(int i=1; i<=n; i++){
		if(i%3 && i%5) ret+=i;
	}
	return ret;
}
int main(){
	int n;
	cin>>n;
	cout<<solve(n);
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[111111];
int dp[111111];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i = 1; i < n; i++){
		if(i>=2)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
		if(i>=1)dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<dp[n-1];
	
	
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>

#define DIV 1000000007

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];

    int m = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        m = max(m ,A[i]);
    }

    int G[m+1]; fill(G, G + m + 1, 0);

    long ans = 1;
    int cnt = 0;

    for(long i =0; i<N; i++){

        if(A[i] != 0){
            ans *= G[A[i]-1];
            if(ans == 0){
                cout << 0 << endl;
                return 0;
            }
            ans %= DIV;
            G[A[i]-1]--;
            G[A[i]]++;
        }
        else{
            cnt++;
            G[0]++;
        }
    }
    if(cnt >= 4){
        cout << 0 << endl;
        return 0;
    }
    if(cnt == 1){
        ans *= 3;
        ans %= DIV;
    }
    else{
        ans *= 6;
        ans %= DIV;
    }

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

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

typedef long long       ll;
typedef vector<int>     vi;
typedef pair<int,int>   pi;
typedef map<int,int>    mi;

#define F               first
#define S               second
#define pb              push_back
#define mp              make_pair
#define M               1000000007
#define SQ(a)           (a)*(a)
#define rep(i,a,b)      for(int i=a; i<b; i++)

void solve(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(auto &x:v) cin >> x;
  int mn = *min_element(v.begin(), v.end());
  int mx = *max_element(v.begin(), v.end());

  cout << mx - mn << endl;
}
int main(){
    //int t; cin >> t; while(t--)
    solve();

    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main() {
	int a,b;
	char op;
	while (op != '?') {
	scanf("%d %c %d", &a, &op, &b);
		switch (op) {
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", a / b);
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i; i < N; i++) cin >> d.at(i);
  
  int sum;
  for(int i=0; i < N-1; i++){
    for(int j=i+1; j < N; j++) sum += d.at(i)*d.at(j);
  }
  
  cout << sum << endl;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N+1);
    for (int i=0;i<=N;i++) cin >> A[i];
    vector<ll> sum(N+2);
    for (int i=N+1;i>=1;i--) sum[i-1] = sum[i] + A[i-1];
    ll Lmax = 1;
    ll ans = 0;
    for (int i=0;i<=N;i++){
        if (A[i] > Lmax) {
            cout << -1 << "\n";
            return 0;
        } else {
            ans += Lmax;
            Lmax = (Lmax-A[i])*2;
            Lmax = min(Lmax,sum[i+1]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4772
m, n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asum = [0]
bsum = [0]
for i in range(m):
  asum.append(asum[i]+a[i])
for i in range(n):
  bsum.append(bsum[i]+b[i])
j = n
max = 0
for i in range(m+1):
    if asum[i] > k:
        break
    while asum[i] + bsum[j] > k:
        j-=1
    if i+j > max:
        max = i+j
print(max)

Measured memory_bytes: 134188
#! /usr/bin/env python3

def main():
    N = int(input())
    L = sorted(map(int, input().split()))
    a = b = 0
    c = len(L) - 1
    while c > -1:
        t = L[c]
        c -= 1
        if a == t:
            break
        else:
            a = t
    while c > -1:
        t = L[c]
        c -= 1
        if b == t:
            break
        else:
            b = t
    print(a*b)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 15020