akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
ll ans[1000][1000];
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	ans[0][0]=1;
	int h,w;
	cin>>h>>w;
	char a[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>a[i][j];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			if(a[i][j]=='#')	continue;
			if(j>0)	ans[i][j]=ans[i][j-1];
			if(i>0)	ans[i][j]+=ans[i-1][j];
			ans[i][j]%=mod;
		}
	cout<<ans[h-1][w-1]<<"\n";
return 0;	
}

Measured memory_bytes: 12372
#include <stdio.h>
int main(void)
{
    int i,j,k,x[2][7];
    
    for(i=0;i<2;i++)
        for(j=1;j<7;j++)
            scanf("%d",&x[i][j]);
    
    for(i=0;i<6;i++){
        if(x[0][1]==x[1][1])
            for(j=0;j<4;j++){
                for(k=1;k<7;k++)
                    if(x[0][k]!=x[1][k]) break;
                    
                if(k==7){
                    printf("Yes\n");
                    return 0;
                }
        
                x[1][0]=x[1][2];
                x[1][2]=x[1][3];
                x[1][3]=x[1][5];
                x[1][5]=x[1][4];
                x[1][4]=x[1][0];
                    
            }
                
            x[1][0]=x[1][1];
                
            switch(i){
                
                case 2:
                    x[1][1]=x[1][3];
                    x[1][3]=x[1][6];
                    x[1][6]=x[1][4];
                    x[1][4]=x[1][0];
                    break;
            
                default:
                    x[1][1]=x[1][2];
                    x[1][2]=x[1][6];
                    x[1][6]=x[1][5];
                    x[1][5]=x[1][0];
                    break;
            }
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 2108
def d():
    N, K = map(int,input().split())
    S = list(input())
    happiness = 0

    for i in range(N-1):
        if S[i] == S[i+1]:
            happiness += 1

    print(min(happiness+2*K, N-1))


if __name__ == '__main__':
    d()


Measured memory_bytes: 49264
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n) != EOF){
		int sum = 1;
		for(int i = 1; i <= n; i++)
			sum += i;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define endl "\n"
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    FAST();
    ll x;
    long double y;
    cin >> x >> y;
    cout << (ll)(x*y);
    

}

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

int pos[2][2010], afd[2][2010][2010], afs[2][2010], f[2010][2010];

int main()  {
	int n;
	cin >> n;
	for (int i = 1; i <= 2*n; i++) {
		char c; int a;
		cin >> c >> a;
		//s[i] = {c,a};
		if (c == 'W') pos[0][a] = i; else pos[1][a] = i;
	}
	
	for (int ci = 0; ci < 2; ci++) for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			afd[ci][i][j] = afd[ci][i][j-1];
			if (pos[1-ci][j] > pos[ci][i]) afd[ci][i][j]++;
		}
	}
	
	for (int ci = 0; ci < 2; ci++) for (int i = 1; i < n; i++)  
		for (int j = i+1; j <= n; j++) 
			if (pos[ci][j] < pos[ci][i]) afs[ci][j]++;
	
	for (int w = 0; w <= n; w++)
		for (int b = 0; b <= n; b++) {
			if (w == 0 && b == 0) continue;
			else if (w == 0) 
				f[w][b] = f[w][b-1] + pos[1][b] - b + afs[1][b];
			else if (b == 0)
				f[w][b] = f[w-1][b] + pos[0][w] - w + afs[0][w];
			else 
				f[w][b] = min(f[w][b-1] + pos[1][b] + afs[1][b] + afd[1][b][w],
							f[w-1][b] + pos[0][w] + afd[0][w][b] + afs[0][w])
							-(w+b);
		}	
	cout << f[n][n] << "\n";
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
#define ll long long

using namespace std;
set < char > st;
int main()
{
    int a,b;  cin >> a >> b;
    for(int i = 1;i<=1e6;i++){
        if(i * 8/100 == a && i * 10/100 == b)  return cout << i , 0;
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

def max a,b
  (a>b)?a:b
end

x = Array.new(n+1,0)
y = Array.new(n+1,0)
n.times{|i|
  x[i+1] = a[i]+x[i]
  y[i+1] = max(a[i],0)+y[i]
}

ans = 0
(n-k+1).times{|i|
  bk = (x[i+k]-x[i])+(y[i]-y[0])+(y[n]-y[i+k])
  ans = bk if ans < bk
  wh = (y[i]-y[0])+(y[n]-y[i+k])
  ans = wh if ans < wh
}

p ans


Measured memory_bytes: 12044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll mod = (ll)1e9 + 7;
string str;
ll d, ans = 0;
vector<vvi> dp;

// Digit DP - Is actually NOT Easy even if thought about for enough time.

// Version 1
// inline void solve()
// {

//     for (int i = 1; i < 10; i++)
//     {
//         dp[str.size() - 1][i % d] = 1;
//     }

//     for (int i = str.size() - 1; i >= 0; i--)
//     {
//         for (int j = 0; j < d; j++)
//         {
//             for (int k = 0; k < 10; k++)
//             {
//                 int x = (int) (str[i] - '0') ;
//                 if ((i > 0 && x > 0) || ((i == 0 || x == 0) && j <= x))
//                     dp[i][j] = (dp[i][j] + dp[i + 1][(j - k + d) % d]) % mod;
//             }
//         }
//     }
// }
// Wrong because account extra for many cases


inline ll solve(int pos, int cnt, bool tight = false)
{
    if (pos == str.size())
    {
        if (!(cnt % d))
            return 1;
        return 0;
    }

    if (dp[pos][cnt][tight] != -1)
        return dp[pos][cnt][tight];
    
    ll res = 0;
    int x = (int) (str[pos] - '0');
    int lmt;
    if (tight)
        lmt = 9;
    else
        lmt = x;
    
    for (int i = 0; i <= lmt; i++)
    {
        int new_bool = tight;
        int new_cnt = cnt % d;
        if (!tight && i < lmt)
            new_bool = true;
        new_cnt = (i + new_cnt) % d;
        res = (res + solve(pos + 1, new_cnt, new_bool)) % mod;
    }

    return dp[pos][cnt][tight] = res;
}


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> str >> d;
    dp.resize(str.size() + 1, vvi(d + 2, vi(2, -1)));
    cout << (solve(0,0) - 1 + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 57088
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	int A[100001];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A, A + N);
	int ptr = 0;
	int res = 0;
	while (ptr < N) {
		int cc = A[ptr], f = 0;
		while (ptr < N && A[ptr] == cc) {
			f++, ptr++;//同じ数字が並んでいなかったらこのループを抜ける
		}//fは連続した数字の数ptrはイテレータ
		res += f % 2;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans=-(1<<30);
	scanf("%d%d",&a,&b);
	ans=max(ans,a+b);
	ans=max(ans,a-b);
	ans=max(ans,a*b);
	return !printf("%d\n",ans);
}

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

int kyori(int i, int j){
	int k;
	k = i - j;
	if (k < 0) k *= -1;
	return k;
}

int main(){

	int x, a, b,c,d;
	cin >> x >> a >> b;

	c = kyori(x, a);
	d = kyori(x, b);

	if (c > d) cout << "B" << endl;
	else       cout << "A" << endl;

	return 0;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    int c = stoi(a+b);
    for(int ii=1; ii<=400; ii++){
        if(c==ii*ii){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, m, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);
			m = 0;
			s = 0;

			m = a;
			if (m < b)
				m = b;
			if (m < c)
				m = c;

			s = a + b + c - m;

			Console.WriteLine(s);
		}
	}
}

Measured memory_bytes: 27408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    string N;
    cin >> N;
    int y,m,d;
    y = 0;
    for (int i = 0;i<4;i++){
        y= y + (N[i] - '0') * pow(10,3-i);
    }
    m = 10*(N[5] - '0') + (N[6] - '0');
    d = 10*(N[8] - '0') + (N[9] - '0');
    if(y >= 2020){
        cout << "TBD" << endl;
    }
    else if(y = 2019 && m >= 5){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
}


Measured memory_bytes: 888
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> ch;
		//ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}

		if (ch <= 'Z' && ch >= 'A')
			cout << 'A';
		else
			cout << 'a';




		ln
	}
	return 0;
}


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

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

  int y = 0;

  for (int i = 0; i < N; i++)
  {
    char S;
    cin >> S;
    if (S == 'Y')
    {
      y = 1;
      break;
    }
  }
  if (y)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}

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

int main(){
  int E,Y;

  cin >> E >> Y;

  if (E == 0) {
    if (Y <= 1911) {
      cout << "M" << Y - 1867 << endl;
    }
    else if (1912 <= Y && Y <= 1925) {
      cout << "T" << Y - 1911 << endl;
    }
    else if (1926 <= Y && Y <= 1988) {
      cout << "S" << Y - 1925 << endl;
    }
    else {
      cout << "H" << Y - 1988 << endl;
    }
  }

  else if (E == 1) {
    cout << Y + 1867 << endl;
  }

  else if (E == 2) {
    cout << Y + 1911 << endl;
  }

  else if (E == 3) {
    cout << Y + 1925 << endl;
  }

  else if (E == 4){
    cout << Y + 1988 << endl;
  }

  return 0;
}



Measured memory_bytes: 3120
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
#include<sstream>

  using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)


typedef pair<ll,ll> pii;

bool comp(const pii l,const pii r){
  return l.second==r.second ? l.first<r.first : l.second<r.second;
}

int main()
{
  
  while(true){
    ll n;cin>>n;
    if(n==0)break;

    vector<pii> input(n);
    rep(i,n){
      string s,e;cin>>s>>e;
      pii train;
      const char *s_char = s.c_str();
      const char *e_char = e.c_str();
      ll hour,minute,second;
      sscanf(s_char, "%lld:%lld:%lld",&hour,&minute,&second);
      train.second=hour*60*60+minute*60+second;
      sscanf(e_char, "%lld:%lld:%lld",&hour,&minute,&second);
      train.first=hour*60*60+minute*60+second;
      input[i]=train;
    }
    
    sort(all(input),comp);
    
    priority_queue<pii,vector<pii>,greater<pii> > que;
    ll ans=0;
    rep(i,n){
      pii train=input[i];

      while(que.size()>0 && train.second>=que.top().first){
        que.pop();
      }
      que.push(train);
      ans=max(ans,(ll)que.size());
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1540
#include<iostream>
#include<queue>

using namespace std;

static const int N = 100;
static const int INFTY=(1<<21);// <<左シフト

int n,M[N][N];
int d[N];//距離によって訪問状態(color)を管理

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++){
        d[i]=INFTY;
    }
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front();
        q.pop();
        for(int v=0; v<n; v++){
            if(M[u][v]==0){continue;}
            if(d[v]!=INFTY){continue;}
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i=0; i<n; i++){
        cout<<i+1<<" "<<((d[i]==INFTY)? (-1):d[i])<<endl;
    }
}

int main(){
    int u,k,v;
    cin>>n;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j]=0;
        }
    }

    for(int i=0; i<n; i++){
        cin>>u>>k;
        u--;
        for(int j=0; j<k; j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    bfs(0);
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#define N 100
using namespace std;

typedef struct{
	int parent;
	int right;
	int left;
} Node;
Node node[N];
int d[N],h[N],deg[N];

void in(int);
void pos(int);
void pre(int);
void swap(int *,int *);

int main(){
	int n,id,l,r;
	cin>>n;
	for(int i=0;i<n;i++){
		node[i].parent=-1; //???????´¢??¨
		d[i]=-1;
		deg[i]=0;
		h[i]=-1;
	}
	for(int i=0;i<n;i++){
		cin>>id>>l>>r;
		node[id].left=l;
		if(l!=-1) deg[id]++;
		node[id].right=r;
		if(r!=-1) deg[id]++;
		node[l].parent=id;
		node[r].parent=id;
	}
	int z;
	printf("Preorder\n");
	for(z=0;z<n;z++){
		if(node[z].parent==-1){
			pre(z);
			break;
		}
	}
	printf("\nInorder\n");
	in(z);
	printf("\nPostorder\n");
	pos(z);
	printf("\n");
	return 0;
}

void pre(int i){
	printf(" %d",i);
	int l=node[i].left;
	int r=node[i].right;
	if(l!=-1) pre(l);
	if(r!=-1) pre(r);
}
void in(int i){
	int l=node[i].left;
	int r=node[i].right;
	if(l!=-1) in(l);
	printf(" %d",i);
	if(r!=-1) in(r);
}
void pos(int i){
	int l=node[i].left;
	int r=node[i].right;
	if(l!=-1) pos(l);
	if(r!=-1) pos(r);
	printf(" %d",i);
}
void swap(int *a,int *b){
	int w=*a;
	*a=*b;
	*b=w;
}

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


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for ai in a:
        while ai % 2 == 0:
            ans += 1
            ai = ai // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
int n,A[10100],cnt[10010],ans[10100],C[3000][3000];
void init(){
	C[0][0]=1;
	for(int i=1;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%n;
		}
	}
}
int main(){
	scanf("%d",&n);
	init();
	for(int i=0;i<n;i++)scanf("%d",&A[i]);
	for(int i=0;i<n;i++){
		if(A[i]==1)cnt[i]++,ans[0]++;
	}
	for(int i=0;i<n;i++){
		if(cnt[i]==0)continue;
		for(int j=0,po=1;j<n;j++){
			int res=C[n-1][j]*po;
			res%=n;
			if(res<0){
				int tmp=abs(res);
				res=(n-tmp%n)%n;
			}
			else res=res%n;
			ans[n-1-j]=(ans[n-1-j]+n-res)%n;
			po=po*(-i);
			if(po<0){
				int tmp=abs(po);
				po=(n-tmp%n)%n;
			}
			else po=po%n;
		}
	}
	for(int i=0;i<n;i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 34304
"""
B-Buffet
"""

import sys
input = sys.stdin.readline
from itertools import *
from collections import *

INF = float('inf')


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    total = 0
    pre_a = - INF
    for a in A:
        a -= 1
        total += B[a]

        if pre_a + 1 == a:
            total += C[pre_a]
        pre_a = a

    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//xを素因数分解する
//例えば60 = 5*3*2*2 であれば[(5,1),(3,1),(2,2)]を返す
vector<pair<LL,LL>> factorial(LL x){
	vector<pair<LL,LL>> ret;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0){
			LL counter = 0;
			while(1){
				if(x%i!=0) break;
				x /= i;
				counter++;
			}
			ret.push_back(make_pair(i,counter));
		}
	}
	if(x!=1) ret.push_back(make_pair(x,1));
	return ret;
}
 
LL N;
 
LL ans = 0;
 
void solve(){
	//N!の約数をfacts[素数] = その素数がいくつ含まれているか　で表現する
	map<LL,LL> facts;
	for(int i=1;i<=N;i++){
		vector<pair<LL,LL>> f = factorial(i);
		for(auto iter=f.begin();iter!=f.end();iter++){
			facts[iter->first] += iter->second;
		}
	}

	//75 = 1*75,5*15,3*25,3*5*5のいずれかで表せる。
	//75 = 1*75の時
	for(auto iter=facts.begin();iter!=facts.end();iter++){
		if(iter->second>=75 - 1) ans++;
	}
	//75 = 5*15の時
	for(auto iter=facts.begin();iter!=facts.end();iter++){
		if(iter->second>=5 - 1){
			for(auto iter_sub=facts.begin();iter_sub!=facts.end();iter_sub++){
				if(iter_sub==iter) continue;
				if(iter_sub->second>=15 - 1) ans++;
			}
		}
	}
	//75 = 3*25の時
	for(auto iter=facts.begin();iter!=facts.end();iter++){
		if(iter->second>=3 - 1){
			for(auto iter_sub=facts.begin();iter_sub!=facts.end();iter_sub++){
				if(iter_sub==iter) continue;
				if(iter_sub->second>=25 - 1) ans++;
			}
		}
	}
	//75 = 3*5*5の時
	for(auto iter=facts.begin();iter!=facts.end();iter++){
		if(iter->second>=3 - 1){
			for(auto iter_sub=facts.begin();iter_sub!=facts.end();iter_sub++){
				if(iter_sub==iter) continue;
				if(iter_sub->second>=5 - 1){
					for(auto iter_sub2=iter_sub;iter_sub2!=facts.end();iter_sub2++){
						if(iter_sub==iter_sub2 || iter_sub2==iter) continue;
						if(iter_sub2->second>=5 - 1) ans++;
					}
				}
			}
		}
	}
}
 
int main(){
    cin >> N;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// 119 B - Digital Gifts 2019/2/24
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<pair<double,string>> x(n);
    rep(i ,n) cin >> x[i].first >> x[i].second;
    double __money=0.0;
    rep(i ,n){
        if(x[i].second=="JPY") __money+=x[i].first;
        else if(x[i].second=="BTC") __money+=x[i].first*380000.0;
    }
    cout << __money << 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 s = sc.nextLine();
		char[] a = s.toCharArray();
		char[] b = s.toCharArray();
		int count = 0;
		for (char a1 : a) {
			count = 0;
			for (char b1 : b) {
				if(a1 == b1)count++;
			}
			if(count == 2) break;
		}
		if(count == 2)System.out.println("no");
		else System.out.println("yes");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    char c[n]; zep(i, 0, n)cin >> c[i];
    
    ll cnt = 0;
    zep(i, 0, n){
    	if(c[i] == 'R')cnt++;
    }
    
    ll ans = 0;
    zep(i, 0, cnt){
    	if(c[i] == 'W')ans++;
    }
    print(ans)
    
    return 0;
}

Measured memory_bytes: 3832
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n;cin >> n;
  vector<double> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  double ans=0;
  sort(vec.begin(), vec.end());
  ans+=(vec.at(0)/pow(2,n-1));
  for(int i=1;i<n;i++){
    ans+=(vec.at(i)/pow(2,n-i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

bool is_prime[2000000];
bool is_able[2000000];

int main(){
	
	int N = 1000001;
	
	for(int i = 0; i < N; i++){
		is_prime[i] = true;
	}
	
	is_prime[0] = false;
	is_prime[1] = false;
	
	for(int i = 2; i < N; i++){
		if(is_prime[i]){
			for(int j = i * 2; j < N; j += i){
				is_prime[j] = false;
			}
		}
	}
	
	int n, x;
	
	while(true){
		
		cin >> n >> x;
		
		if(n == 0 && x == 0){
			break;
		}
		
		int v[200];
		
		for(int i = 0; i < n; i++){
			cin >> v[i];
		}
		
		for(int i = 0; i <= x; i++){
			is_able[i] = false;
		}
		
		is_able[0] = true;
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= x - v[i]; j++){
				if(is_able[j]){
					is_able[j + v[i]] = true;
				}
			}
		}
		
		int ans = 0;
		
		for(int i = x; i >= 0; i--){
			if(is_able[i] && is_prime[i]){
				ans = i;
				break;
			}
		}
		if(ans == 0){
			cout << "NA" << endl;
		}else{
			cout << ans << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 4940
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: u64 = sc.read();

    let mut ans = 0;
    for a in 1..(k + 1) {
        for b in 1..(k + 1) {
            for c in 1..(k + 1) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

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

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
  char X, Y;
  cin >> X >> Y;
  
  if (X == Y) {
    cout << '=' << endl;
  } else if (X > Y) {
    cout << '>' << endl;
  } else {
    cout << '<' << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b)
	printf("a > b\n");
	else if(a<b)
	printf("a < b\n");
	else if(a == b)
	printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：Red and Black
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/1130
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----
const ll dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

// グローバル変数（入力）
ll w, h, state[25][25], tiles[25][25];
pair<ll, ll> start;

// 入力
void input() {
  rep(y, h) {
    string s;
    cin >> s;
    rep(x, w) {
      if (s[x] == '.') {
        tiles[y][x] = 0;
      } else if (s[x] == '#') {
        tiles[y][x] = 1;
      } else {
        tiles[y][x] = 0;
        start = make_pair(x, y);
      }
      // cout << tiles[y][x];
      // if (x != w-1){cout << " ";}
    }
  }
}

// (x,y)にいけるかどうか
bool valid(ll x, ll y) {
  if ((0 <= x && x < w) && (0 <= y && y < h)) {
    if (tiles[y][x] == 0) { return true; }
  }
  return false;
}

// 深さ優先探索
void dfs(ll x, ll y) {
  state[y][x] = 1; // 訪問済み
  // cout << "x:" << x << " y:" << y << endl;
  rep(i, 4) {
    ll x2 = x + dx[i];
    ll y2 = y + dy[i];
    if (valid(x2, y2) && state[y2][x2]==0) { 
      dfs(x2, y2); 
    }
  }
}

void solve() {
  // state初期化
  rep(i, h) {
    rep(j, w) { state[i][j] = 0; }
  }

  // 始点から探索
  dfs(start.first, start.second);

  // 出力
  ll ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (state[i][j] == 1) { ans++; }
    }
  }
  cout << ans << endl;
}

int main() {
  while (cin >> w >> h && w > 0) {
    input();
    solve();
  }
  return 0;
}



Measured memory_bytes: 3240
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2,n):
    a1 = dp[i-1] + abs(h[i] - h[i-1])
    a2 = dp[i-2] + abs(h[i] - h[i-2])
    dp[i] = min(a1,a2)
    
print(dp[n-1])



Measured memory_bytes: 13980
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string str;
    cin >> str;
    int q,i;
    cin >> q;
    string s1,s2;
    int a,b;
    for(i=0;i<q;i++){
        //cout << str << endl;
        cin >> s1 >> a >> b;
        if(s1 == "print"){
            cout << str.substr(a,b-a+1) << endl;  //substr(a,b)でa番目から長さb文を文字列を取得
        }else if(s1 == "reverse"){
            string s3 = str.substr(a,b-a+1);
            reverse(s3.begin(),s3.end()); //reverse(始まり、終わり);で指定区間内を入れ替え
            str = str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
        }else{
            cin >> s2; //入れ替える文字列
            str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
        }
    }
}


Measured memory_bytes: 3216
a, b, c, x, y = map(int, input().split())
# ピザの枚数a,b,cについては
# 2c = a+b が成り立つ
# cを奇数個買ってもこの問題の場合意味がないので基本2cで考える

ans = float('inf')
# cをi枚買ったとする。
# x,y <= 10^5 なので100000+1回しとけば問題なし
for i in range(100001):
    ans = min(ans, (2*c)*i + a*max(x-i,0) + b*max(y-i,0))
print(ans)

Measured memory_bytes: 9136
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():
    x = in_n()

    if x == 0:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62064
while True :
    n = int(input())
    if n == 0 :
        break
    
    seki = 1
    for i in range(n) :
        seki *= (i+1)
    
    ans = 0
    while True :
        if seki % 10 != 0 :
            break
        else :
            seki = seki // 10
            ans += 1
    print(ans)



Measured memory_bytes: 5624
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << '\n';
  return 0;
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
const MOD: isize = 1_000_000_009;
fn main() {
    input! { n, k, a: [usize; n] };
    let a = a.into_iter().filter(|&aa| aa < k).collect::<Vec<_>>();
    let n = a.len();
    let mut ans = n;
    let mut dp1 = vec![0; 2 * k];
    let mut dp2 = vec![0; 2 * k];
    dp1[0] = 1;
    for i in 0..n {
        for j in (0..(k + a[i])).rev() {
            dp1[j] = (dp1[j] + if j >= a[i] { dp1[j - a[i]] } else { 0 }) % MOD;
        }
    }
    for i in 0..n {
        for j in 0..(k + a[i]) {
            dp2[j] =
                ((dp1[j] as isize - if j >= a[i] { dp2[j - a[i]] } else { 0 }) % MOD + MOD) % MOD;
        }
        for j in (k - a[i])..k {
            if dp2[j] != 0 {
                ans -= 1;
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
h,n=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
  a_num,b_num=map(int,input().split())
  a.append(a_num)
  b.append(b_num)

#dpテーブル　dp[i+1][j]=i番目までの魔法を用いて体力をj以上減らす時の消耗の最小値
dp=[[float("INF") for i in range(h+1)] for j in range(n+1)]
#初期条件
dp[0][0]=0
for i in range(n):
  for j in range(h+1):
    #i番目の魔法を使わない時
    if a[i]>j:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+b[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i])

print(dp[n][h])
  

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

int main() {

  int N;

  // nameに10を代入
  cin >> N;

  if (N<1001) {
    cout << 1000-N << endl;
  } 
    
  else if (N<2001) {
    cout << 2000-N << endl;
  }
  
  else if (N<3001) {
    cout << 3000-N << endl;
  }
  
  else if (N<4001) {
    cout << 4000-N << endl;
  }
  
  else if (N<5001) {
    cout << 5000-N << endl;
  }
  
  else if (N<6001) {
    cout << 6000-N << endl;
  }
  
  else if (N<7001) {
    cout << 7000-N << endl;
  }
  
  else if (N<8001) {
    cout << 8000-N << endl;
  }
  
  else if (N<9001) {
    cout << 9000-N << endl;
  }
  
  else {
    cout << 10000-N << endl;
  }
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
	
	int N;
	int M;
	scanf("%d %d",&N,&M);
	
	
	
	if(N>100 || N<=0 || M<0 || M>N){
		printf("eror\n");
	}
	else if(N==M){
		printf("Yes");
	}
	else if(N>=M || N<=M){
		printf("No");
	}

	
	
	
	
	return 0;
}

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

int main(void){
	int m, n, p, q;
	int k;
	cin >> k;
	while(k--){
		cin >>m>>n;
		int cnt = 0;
		for(int x = -200; x < 200; x++){
			for(int y = -200; y < 200; y++){
				int z = x*x + y*y;
				if(!z) continue;
				if((m*x+n*y) % z || (m*y-n*x) % z) continue;
				int p = (m*x+n*y) / z;
				int q = (m*y-n*x) / z;
				if((m*m + n*n) != z * (p*p + q*q)) continue;
				cnt++;
			}
		}
		if(cnt == 8) cout << "P" << endl;
		else cout << "C" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
//
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<algorithm>
#include<cmath>

#include<cstring>
#include<string>
#include<cctype>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<list>

typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::vector<int> vi;

const int OO=(int)2e9;
const ll INF=(ll)4e18;
const double EPS=(double)1e-12;

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

#define INL(i,a,b) ((a<=i)&&(i<=b))
#define EXL(i,a,b) ((a< i)&&(i< b))
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
using namespace std;

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

int n,m;
ll a,b;
ll rea,reb;

int main(){
	scanf("%d %d",&n,&m);
	rea=0;
	scanf("%lld",&a);
	REP(i,1,n-1){
		scanf("%lld",&b);
		rea=(rea+((((b-a)%MOD)*i)%MOD*((n-i)%MOD))%MOD)%MOD;
		a=b;
	}
	reb=0;
	scanf("%lld",&a);
	REP(i,1,m-1){
		scanf("%lld",&b);
		reb=(reb+((((b-a)%MOD)*i)%MOD*((m-i)%MOD))%MOD)%MOD;
		a=b;
	}
	printf("%lld\n",(rea*reb)%MOD);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string t,s;
    cin>>t>>s>>t;
    cout<<'A'<<s[0]<<'C'<<endl;
    return 0;
}

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

N = int(input())

e = [0] * (N+1)

for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(n):
    return len(list(filter(lambda x: x >= n-1, e)))

# num(3)-1はnum(25)で3以上のものを一個使っているので、一つ引いている。//2は、例えばa^4 * b^4 * c^2 と b^4 * a^4 * c^2がかぶって計上されるため。
print(num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2)

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    vector<int> count(110000, 0);
    for (int i = 0; i < N; ++i)
    {
        ++count[a[i]];
    }

    for (int i = 0; i < 110000; ++i)
    {
        if (i == 0)
        {
            ans = max(ans, count[i] + count[i + 1]);
        }
        else if (i == 1)
        {
            ans = max(ans, count[i] + count[i - 1]);
        }
        else
        {
            ans = max(ans, count[i] + count[i - 1] + count[i - 2]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3972
N, K = map(int, input().split())

lst = []
for i in range(N):
    lst += [list(map(int, input().split()))]

lst.sort()


for i in range(N):
    if K <= lst[i][1]:
        print (lst[i][0])
        exit()
    else:
        K -= lst[i][1]

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

int main(){
  int a,b;
  cin>>a>>b; 
  if(max(a,b)-1>=min(a,b)){
    cout<<max(a,b)+max(a,b)-1<<endl;
  }else{
    cout<<max(a,b)+min(a,b);
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<pair<ll, ll>> prime_factorize(ll N) {
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
template<typename T>
T factorial(T a){
  if(a == 2) return 2;
  return a * (factorial(a-1));
}

int main(){
    ll N;
    cin >> N;
    vector<pair<ll,ll>> re = prime_factorize(N);
    // for(auto p : re){
    //     cout << p.fi << ' ' << p.se << endl;
    // }
    ll count = 0;
    for(auto p : re){
        for(int i = 1; ;i++){
            if(p.se >= i){
                p.se -= i;
                count++;
            }else break;
        }
    }
    cout << count << endl;
}

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

//pair<double,double> s,t,u;

void koch(int d,pair<double,double> p1,pair<double,double> p2){
    pair<double,double> s,t,u;
    if(d == 0) return;
    s.first = (2*p1.first + p2.first)/3;
    s.second = (2*p1.second + p2.second)/3;
    t.first = (p1.first + 2*p2.first)/3;
    t.second = (p1.second + 2*p2.second)/3;
    u.first = (t.first - 1.7320508*t.second +s.first + 1.7320508*s.second)/2;
    u.second = (1.7320508*t.first + t.second - 1.7320508*s.first + s.second)/2;
    koch(d-1,p1,s);
    cout << s.first << " " << s.second << endl;
    koch(d-1,s,u);
    cout << u.first << " " << u.second << endl;
    koch(d-1,u,t);
    cout << t.first << " " << t.second << endl;
    koch(d-1,t,p2);
}

int main(){
    int n;
    pair<double,double> p1(0,0);
    pair<double,double> p2(100,0);
    cin >> n;
    cout << p1.first << " " << p1.second << endl;
    koch(n,p1,p2);
    cout << p2.first << " " << p2.second << endl;
    return 0;
}



Measured memory_bytes: 3272
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll K;
    cin >> K;

    if (K % 2 == 0) {
        cout << (K / 2) * (K / 2) << endl;
    } else {
        cout << (K / 2 + 1) * (K / 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
while True:
    a, op, b = map(str, input().split())
    if op == '?':
        break
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long X,K,D;cin>>X>>K>>D;
  X=abs(X);
  long ans=0;
  if(X/D>K){
    ans=X-K*D;
  }else{
    K=K-X/D;
    X=X-X/D*D;
    if(K%2==1)X-=D;
    ans=X;
  }
  cout<<abs(ans)<<endl;
}


Measured memory_bytes: 3632
fn main(){
  loop {
    let n: usize = read();
    
    if n == 0 { break; }
    
    let mut adj: Vec<Vec<usize>> = vec![Vec::new();100];
    let mut vt: Vec<bool> = vec![false;100];
    
    for _ in 0 .. n {
      let ab:Vec<usize> = read_vec();
      adj[ab[0]-1].push(ab[1]-1);
      adj[ab[1]-1].push(ab[0]-1);
    }

    let ans = (0..100).map(|i| dfs(&adj, &mut vt, i)).max().unwrap();
    
    println!("{}", ans);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn dfs(adj: &Vec<Vec<usize>>, vt: &mut Vec<bool>, i: usize) -> usize {
  if vt[i] {
    0
  } else {
    vt[i] = true;
    let mut mxl: usize = 0;
    for &j in &adj[i] {
      let k = dfs(adj, vt, j);
      if mxl < k { mxl = k; }
    }
    vt[i] = false;
    mxl + 1
  }
}



Measured memory_bytes: 5036
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String L = sc.get();
		int mod = 1000000007;
		int patterns = 1;
		for (int i = L.lastIndexOf('1'); i >= 0; i = L.lastIndexOf('1', i - 1)) {
			patterns = (((patterns * 2) % mod) + modpow(3, L.length() - 1 - i, mod)) % mod;
		}
		System.out.println(patterns);
	}

	int modpow(long a, long n, int mod) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) res = res * a % mod;
			a = a * a % mod;
			n /= 2;
		}
		return Math.toIntExact(res);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 23124
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize
    }

    solve(n, k);
}

fn solve(n: usize, k: usize) {
    let mut flags = vec![true; n];

    for _ in 0..k {
        input! {
            d: usize,
            a: [usize; d]
        }

        for i in 0..d {
            flags[a[i] - 1] = false;
        }
    }

    println!("{}", flags.iter().filter(|&&x| x).count());
}


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

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

int main(){
  int n;
  cin>>n;
  string S;
  cin>>S;
  int mx=0;
  vector<int> arr;
   rep(i,n){
     map<char,int> m;
     int count=0;
     for(int j=0;j<i;j++)
      m[S[j]]++;
    
     for(int k=i;k<n;k++){
       if(m[S[k]]>=1){
	 count++;
	 m[S[k]]=-1;
       }
     }
     mx=max(mx,count);
    }
   cout<<mx<<endl;
  
  



  return 0;
}


Measured memory_bytes: 256
import math
def comb(n, k):
    if n < 0 or k < 0 or n < k: return 0
    return math.factorial(n) // math.factorial(n-k) // math.factorial(k)

n,k = map(int, input().split())
MOD = 10 ** 9 + 7
print(comb(n + k - 1, k - 1) % MOD)



Measured memory_bytes: 5668
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
allpat=[]
todo=[[]]
while todo:
  pat=todo.pop()
  if len(pat)==n//2:
    allpat.append(pat)
    continue
  s=0
  if pat:s=max(pat)+1
  for i in range(s,n):
    todo.append(pat+[i])

def func(pat):
  # カードを最終的に偶奇どちらのidxになるかで分類
  # pat内のidxが最後に奇数のidxになるとする
  ablev=[]
  ablod=[]
  for i in range(n):
    if i in pat:
      if i%2==0:
        ablod.append([i,b[i]])
      else:
        ablod.append([i,a[i]])
    else:
      if i%2==0:
        ablev.append([i,a[i]])
      else:
        ablev.append([i,b[i]])
  ablev.sort(key=lambda x:x[1]*20+x[0])
  ablod.sort(key=lambda x:x[1]*20+x[0])
  now=0
  ary=[]
  for i in range(n//2):
    if ablev[i][1]>=now:
      now=ablev[i][1]
      ary.append(ablev[i][0])
    else:
      return -1
    if ablod[i][1]>=now:
      now=ablod[i][1]
      ary.append(ablod[i][0])
    else:
      return -1
  if n%2==1:
    if ablev[n//2][1]>=now:
      now=ablev[i][1]
      ary.append(ablev[n//2][0])
    else:
      return -1
  ret=0
  for i in range(n-1):
    for j in range(i+1,n):
      if ary[i]>ary[j]:ret+=1
  return ret

ans=float('inf')
for pat in allpat:
  t=func(pat)
  if t>=0:
    ans=min(ans,t)
print(ans if ans!=float('inf') else -1)


Measured memory_bytes: 85920
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
		int N,R;
		cin >> N>>R;
		if (N >= 10)
			cout << R;
		else
			cout << R + (10-N) * 100;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#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>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

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

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

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

    bool c = false;
    rep(i, S.size()) {
        if (S[i] == 'C') c = true;
        if (S[i] == 'F' && c) {
            debug("Yes");
            return 0;
        }
    }
    debug("No");
    return 0;
}


Measured memory_bytes: 760