akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
vll adj[100005];
bool done[100005];
ll d[100005],mx = 1;;

void dfs(ll u){
    done[u] = 1;
    ll num = 0;
    for(auto v : adj[u]){
        if(!done[v]) dfs(v);
        num = max(num,d[v]);
    }
    d[u] = num + 1;
    mx = max(mx,d[u]);
}


int32_t main(){
    IOS;
    ll i,j,k,n,m,p,q;
    cin >> n >> m;
    fori(m){
        cin >> p >> q;
        adj[p].pb(q);
    }
    fori2(n){
        if(!done[i]) dfs(i);
        // cout << d[i] <<" ";
    }
    // cout <<"\n";
    cout << mx-1 <<"\n";
} 

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


int main() {
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
}



Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    ll A;
    string B;
    cin >> A >> B;
    ll ans = 0;
    int b0 = 0;
    int b1, b2;
    FOR(i, 0, B.length()) {
        if (B[i] != '.') {
            b0 = b0 * 10 + B[i]-'0';
        } else {
            break;
        }
    }
    b1 = B[B.length()-2]-'0';
    b2 = B[B.length()-1]-'0';
    //cerr << b0 << b1 << b2;
    ans += (A*b0*100 + A*b1*10 + A*b2)/100;
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    int n,k,x,y,ans;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    if(k>n){
        ans=n*x;
    }
    else{
        ans=k*x+(n-k)*y;
    };
    printf("%d",ans);
    return 0;
};


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

using namespace std;

int main()
{
    long long n,k;cin>>n>>k;
    if(n>k){
        n%=k;
    }
    while(abs(n-k)<n){
        n = abs(n-k);
    }
    cout<<n;
    return 0;
}


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

using namespace std;
using ll = long long int;

ll h, w, k;
vector<string> mat;

int color(int mask_r, int mask_c){
    int ans = 0;

    for(int i=0; i<h; i++){
        if (!((mask_r >> i) & 1)) continue;
        for(int j=0; j<w; j++){
            if (!((mask_c >> j) & 1)) continue;
            ans += (mat[i][j] == '#');
        }
    }

    return ans == k;
}

int main(){

    cin >> h >> w >> k;

    for(int i=0; i<h; i++){
        string s;
        cin >> s;
        mat.push_back(s);
    }

    ll ans = 0;
    ll limith = (1 << h);
    ll limitw = (1 << w);

    for(int i=0; i<limith; i++){
        for(int j=0; j<limitw; j++){
            ans += color(i, j);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
//Problem Link:  https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A


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

const long long int MOD = 1000000007;
const long long int INF = 100000000;
long long int N,M;
long long int Coins[30];
long long int dp[21][100000];


int FewestCoin(int n,int v)
{
	if(v == 0) return 0;
	if(n<0||v<0) return INF;

	if(dp[n][v]!=-1) return dp[n][v];
	return dp[n][v] = min(FewestCoin(n-1,v),FewestCoin(n,v-Coins[n])+1);
}

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

		for(int i = 0; i < M; i++){
			cin >> Coins[i];
		}

    memset(dp,-1,sizeof(dp));
    cout << FewestCoin(M-1, N) << endl;

		return 0;
}


// 55 4
// 1 5 10 50



Measured memory_bytes: 19620
/*input
Rainy

*/
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <iterator>
#include <limits>
#include <deque>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <climits>
#define ff first
#define ss second
#define MAX 10005
#define endl "\n"
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

signed main(){
 	ios_base::sync_with_stdio(false);	
 	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy";
	}
	if(s=="Cloudy")cout<<"Rainy";
	if(s=="Rainy")cout<<"Sunny";
 	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

#define MAXN 100111

struct Node
{
	int id;
	int a;
	vector<Node*> child;
};
Node nodes[MAXN];

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> e[MAXN];
	for(int i=0; i<n-1; ++i)
	{
		int u,v;
		cin >> u >> v;
		--u,--v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	
	vector<Node*> o;
	queue<int> q;
	int used[MAXN] = {0};
	q.push(0);
	used[0] = 1;
	
	for(int i=0; i<n; ++i)
		nodes[i].id = i+1;
	
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		o.push_back(&nodes[u]);
		
		for(int i=0; i<e[u].size(); ++i) if(!used[e[u][i]])
		{
			int v = e[u][i];
			used[v] = 1;
			nodes[u].child.push_back(&nodes[v]);
			q.push(v);
		}
	}
	
	for(int i=o.size(); i--;)
	{
		Node &u = *o[i];
		u.a = 0;
		
		for(int j=0; j<u.child.size(); ++j)
		{
			u.a ^= (u.child[j]->a+1);
		}
	}
	
	if(!nodes[0].a)
		cout << "Bob\n";
	else
		cout << "Alice\n";

	return 0;
}


Measured memory_bytes: 13172
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  for (int i=0;i<n-2;i++)
  {
    if(s[i]==65&&s[i+1]==66&&s[i+2]==67)
    {
      cnt++;
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 2000001

int H;

void insert(int A[], int key) {
    H++;
    A[H] = -1;
    heapIncreaseKey(A, H, key);
}

int parent(int i) { return i / 2;}

int heapIncreaseKey(int A[], int i, int key) {
    int tmp;
    if (key < A[i]) return -1;
    
    A[i] = key;
    while (i > 1 && A[parent(i)] < A[i]) {
	tmp = A[i]; A[i] = A[parent(i)]; A[parent(i)] = tmp;
	i = parent(i);
    }
}

void maxHeapify(int A[], int i) {
    int l, r, largest, tmp;
    l = 2*i;
    r = 2*i + 1;
    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    
    if (r <= H && A[r] > A[largest]) largest = r;
    
    if (largest != i) {
	tmp = A[i]; A[i] = A[largest]; A[largest] = tmp;
	maxHeapify(A, largest);
    }
}

int heapExtractMax(int A[]) {
    if (H < 1) return -1;
    
    int max = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(A, 1);

    return max;
}


int main() {
    int flag,key,max, len;
    char str[10];

    int *A;
    A = malloc(sizeof(int) * MAX);
    flag=1; 
    H=0;
    while(1){
	scanf("%s", str);
	len = strlen(str);
	if(len == 3) {
	    break;
	}
	else if (len == 6) {
	    scanf("%d", &key);
	    insert(A, key);
	}
	else if(len == 7) {
	    max = heapExtractMax(A);
	    printf("%d\n", max);
	}
      
    }

    return 0;
}

Measured memory_bytes: 5932
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int N, M, K[100], tmp, MM[100] = {};
    cin >> N >> M;
    for(int i=1; i<=N;++i){
        cin >> K[i];
        for(int j=1; j<=K[i]; ++j){
            cin >> tmp;
            ++MM[tmp];
        }
    }
    int ans = 0;
    for(int i=1; i<=M; ++i){
        if(MM[i] == N) ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc177/tasks/abc177_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s,t;
    cin >> s >> t;
    ll lens = s.length();
    ll lent = t.length();
    ll ans = lent+1;
    for(int i = 0;i<lens-lent+1;i++){
        ll temp = 0;
        for(int j = 0;j<lent;j++){
            if(s[i+j] != t[j]) temp++;
        }
        ans = min(ans, temp);
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

ll a[1000000];
bool used[1000000];

bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}



int main() {
	
	int n, pos = 0;
	cin >> n;
	for (int i = 2; i <= 55555; i++) {
		if (pos == 55)break;
		if (is_prime(i)&&i%5==1) {
			a[pos] = i;
			pos++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def check_small(string):
    if string in 'abcdefghijklmnopqrstuvwxyz':
        return True
    else:
        return False

s = input()
if s[0] != 'A':
    print('WA')
    sys.exit()
if check_small(s[-1]) == False or check_small(s[1]) == False:
    print('WA')
    sys.exit()
count = 0
for si in s[2:]:
        if si == 'C':
            count += 1
        elif check_small(si) == False:
            print('WA')
            sys.exit()
print('AC' if count == 1 else 'WA')

Measured memory_bytes: 3188
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans=0
if n<=2:
    print(0)
else:
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if l[i]+l[j]>l[k] and l[i]!=l[j] and l[j]!=l[k]:
                    ans+=1

    print(ans)

Measured memory_bytes: 9120
#include <cstdio>
using namespace std;

int main() {
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        int l = a + b, r = c + d;
        puts(l > r ? "Left" : l == r ? "Balanced" : "Right");
        return 0;
}

Measured memory_bytes: 128
/*
A:认为自己的思路ok
但似乎并不是这样的
*/

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    int n,i,temp,min;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    min=b[n-1];
    temp=n-1;
    for(i=0; i<n; i++)
    {
        if(b[n-1]%2==1)
        {

            if(fabs((b[n-1]+1)/2-b[i])<min)
            {
                min=(b[n-1]+1)/2-b[i];
                temp=i;
            }
        }
        else
        {
            if(b[i]<=b[n-1]/2)
            {
                if(fabs(b[n-1]/2-b[i])<min)
                {
                    min=fabs(b[n-1]/2-b[i]);
                    temp=i;
                }
            }
            if(b[i]>b[n-1]/2)
            {
                if(fabs(b[i]-b[n-1]/2)<min)
                {
                    min=fabs(b[i]-b[n-1]/2);
                    temp=i;
                }
            }
        }
    }
printf("%d %d\n",b[n-1],b[temp]);
    /*
    int n,x,i,s,cnt,temp;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        int a[x],b[x];
        for(i=0;i<x;i++)
            scanf("%d",&a[i]);
        for(i=0;i<x;i++)
        {
            scanf("%d",&b[i]);
            b[i]=b[i]-a[i];
        }
        s=0;cnt=1;
        for(i=0;i<x;i++)
        {
            if(cnt==1)
            {
                temp=i;
            }
            if(b[i]!=0)
                cnt++;
              if(b[i]!=0&&cnt!=2&&cnt!=1)
              {
                  b[i]=b[i]+b[temp];
                  s=s+fabs(b[temp]*(i-temp));
                  temp=i;
              }
        }
        printf("%d   %d\n",b[temp],s);
    }

    */
    /*
    int n,k,i,x,cnt,y=0,asd=1;
    scanf("%d%d",&n,&k);
    int sz[100000]={0},s;
    s=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        sz[x%k]++;
        s=s+x%k;
    }
    s=s%k;
    if(s==0)
        printf("%d\n",n);
    else
    {
        if(sz[s]!=0)
            printf("%d\n",n-1);
        else
        {
            cnt=0;
            while(sz[s]==0)
            {
                for(i=s-1;i>=0;i--)
                {
                    if(i==0&&sz[i]==0&&y==0)
                    {
                        i=k-1;
                        y=1;
                    }
                    if(sz[i]==0)
                    {
                        cnt++;
                    }
                    else
                    {
                        printf("%d\n",n-cnt-1);
                        asd=0;
                        break;
                    }
                }
                if(!asd)
                    break;
            }
        }
    }
    */
    return 0;
}


Measured memory_bytes: 896
N = int(raw_input())
P = []
p_hash = {}
for i in range(N):
    num = int(raw_input())
    P.append(num)
    p_hash[num] = i

now_pos = p_hash[1]
count_1 = 1
max_1 = 1
for i in range(1,N):
    pos_new = p_hash[i+1]
    if pos_new > now_pos:
        count_1 += 1
        max_1 = max(max_1,count_1)
        now_pos = pos_new
    else:
        max_1 = max(max_1,count_1)
        count_1 = 1
        now_pos = pos_new

print(N - max_1)

Measured memory_bytes: 34456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	int a[n]={};
	for(int i=0; i<n; i++){
		int b;
		cin>>b;
		a[b-1]=i+1;
	}
	for(int i=0; i<n; i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 4004
#!/usr/bin/ruby
n,m=gets.split.map(&:to_i)
a=$<.map(&:to_i)
1.upto(m){|f|
	(n-1).times{|i|a[i],a[i+1]=a[i+1],a[i] if a[i]%f>a[i+1]%f}
}
puts a

Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(100001);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
    }
    priority_queue<int> q;
    long long sum = 0;
    for (int i = 1; i <= m; i++) {
        for (auto it : a[i]) q.emplace(it);
        if (!q.empty()) {
            sum += q.top();
            q.pop();
        }
    }
    cout << sum;
    return 0;
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


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

Measured memory_bytes: 256
#include<stdio.h>

int solve(int ,int );

int n,A[2000];

int main(){
  int q,m[2000];
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    if(solve(0,m[i])==1){
      printf("yes\n");
  }
    else printf("no\n");  
  }
  return 0;
}

int solve(int i, int m){
  int res1,res2;
  if(m==0) return 1;
  if(i>=n) return -1;
  res1=solve(i+1,m);
  res2=solve(i+1,m-A[i]);
  if(res1==1||res2==1) return 1;
  return -1;
}



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

int main() {
  int N, x, K;
  double k, y;
  cin >> N;
  string S;
  x = 0;
  y = 0;
   
  	for (int i = 0; i < N; i++) {
      cin >> k >> S;
      if (S == "JPY") {
        x += k;
      }
      else if (S == "BTC") {
        y += k;
        cout << fixed << setprecision(8);
      }
    }
  	double ysum;
  	ysum = 380000 * y;
  	
  	cout << x + ysum << endl;
}

Measured memory_bytes: 256
import math
X = int(input())
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
for i in range(X,100010):
	if(isPrime(i)):
		print(i)
		exit()

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>

#define FOR(i,k,n) for(long(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)

using namespace std;

int main()
{

  long n;
  cin >> n;
  long nr = sqrt(n);
  long a;
  FOR(i,1,nr+1)
  {
    if(n%i==0)
    {
      a = i;
    }

  }
  
   long b= n/a;
   cout << b-1+a-1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll N=62;
    //N=3;
    ll dp[N][3];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,1,N-1){
        ll p=1ll<<(N-1-i);
        if(n&p){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=mod(dp[i-1][0]+dp[i-1][1]);
            dp[i][2]=mod(dp[i-1][1]*2+dp[i-1][2]*3);
        }else{
            dp[i][0]=mod(dp[i-1][0]+dp[i-1][1]);
            dp[i][1]=dp[i-1][1];
            dp[i][2]=mod(dp[i-1][1]+dp[i-1][2]*3);
        }
    }
    ll ans=0;rep(j,0,2)Add(ans,dp[N-1][j]);
    cout<<mod(ans)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
//传说中的序列自动机 get √ 
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
int n,K,dp[1<<21][21],nxt[1<<21][2],Log[1<<21];
bool inq[1<<21][21];
struct node
{
	int S,pos;
};
queue<node>q;
void init()
{
	for(int S=1;S<(1<<n);S++)
	{
		Log[S]=log2(S);
		nxt[S][0]=nxt[S][1]=-1;
		for(int i=0,f0=0,f1=0;i<Log[S]&&(!f0||!f1);i++)
			if(S&(1<<i))
			{
				if(!f1)nxt[S][1]=S>>i;
				f1=1;
			}
			else
			{
				if(!f0)nxt[S][0]=S>>i;
				f0=1;
			}
	}
}
void bfs()
{
	while(!q.empty())
	{
		int S=q.front().S,pos=q.front().pos;
		q.pop();
		if(pos==Log[S])continue;
		int L=S&((1<<pos)-1),R=S>>pos;
		int T=L+(1<<pos),pos2=pos;
		dp[T][pos2]+=dp[S][pos];
		if(!inq[T][pos2])
			inq[T][pos2]=1,q.push((node){T,pos2});
		if(nxt[R][0]!=-1)
		{
			T=L+(nxt[R][0]<<pos);
			pos2=pos+1;
			dp[T][pos2]+=dp[S][pos];
			if(!inq[T][pos2])
				inq[T][pos2]=1,q.push((node){T,pos2});
		}
		if(nxt[R][1]!=-1)
		{
			T=L+(nxt[R][1]<<pos);
			pos2=pos+1;
			dp[T][pos2]+=dp[S][pos];
			if(!inq[T][pos2])
				inq[T][pos2]=1,q.push((node){T,pos2});
		}
	}
	int maxn=-1,ans=0;
	for(int S=1;S<(1<<n);S++)
		if(dp[S][Log[S]]>=K&&Log[S]>maxn)
			maxn=Log[S],ans=S;
	for(int i=Log[ans]-1;i>=0;i--)
		printf("%d",(ans>>i)&1);
	puts("");
}
int main()
{
	scanf("%d %d",&n,&K),n++;
	init();
	for(int i=1;i<=n;i++)
		for(int j=1,x;j<=(1<<(i-1));j++)
		{
			scanf("%1d",&x);
			if(x==1)
			{
				int S=j-1+(1<<(i-1));
				dp[S][0]++;
				if(!inq[S][0])
					inq[S][0]=1,q.push((node){S,0});
			}
		}
	bfs();
	return 0;
}
/*
3 4
1
01
1011
01001110

10
*/

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

vector<int> F(45, -1);
int fib(int n) {
  if (F[n] != -1)
    return F[n];
  else if (n == 1 || n == 0) {
    F[n] = 1;
  } else {
    F[n] = fib(n - 1) + fib(n - 2);
  }
  return F[n];
}
int main() {
  int n;
  cin >> n;
  cout << fib(n) << endl;
}



Measured memory_bytes: 3088
if __name__ == "__main__":
    h, w = map(int, input().split())
    a = list()
    for i in range(h):
        a.append(input())

    count = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                count += 1

    if count == h + w - 1:
        print('Possible')
    else:
        print('Impossible')


Measured memory_bytes: 3060
process.stdin.on("data",function(c){
	(c+"").trim().split("\n").slice(1).some(function(n){
		n=n.split(" ");
		var x1=+n[0],y1=+n[1],x2=+n[2],y2=+n[3],x3=+n[4],y3=+n[5],
		a=2*(x1-x2),b=2*(y1-y2),c=x1*x1+y1*y1-(x2*x2+y2*y2),
		d=2*(x1-x3),e=2*(y1-y3),f=x1*x1+y1*y1-(x3*x3+y3*y3),
		z=a*e-b*d,x=(c*e-f*b)/z,y=(f*a-c*d)/z;
		console.log(x.toFixed(3),y.toFixed(3),Math.sqrt(Math.pow(x-x1,2)+Math.pow(y-y1,2)).toFixed(3));
	});
}).resume();

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

public class Main {
  private static int solve(int n, int d, int x, int[] as) {
    int answer = x;
    for (int a : as) {
      answer += d / a + (d % a > 0 ? 1 : 0);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int d = reader.nextInt();
    int x = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, d, x, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

vector<P> count(vector<int> vec){
    vector<P> num;
    vec.push_back(0);
    int count=0;
    rep(vec.size()-1){
        count++;
        if(vec.at(i)!=vec.at(i+1)){
            num.push_back(P(vec.at(i),count));
            count=0;
        }
    }
    return num;
}

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(n)cin>>a.at(i);
    sort(a.begin(),a.end());
    vector<P> num=count(a);
    int ans=0;
    rep(num.size()){
        if(num.at(i).first>num.at(i).second){
            ans+=num.at(i).second;
        }else if(num.at(i).first<num.at(i).second){
            ans+=num.at(i).second-num.at(i).first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2564
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<ll>> DP(N+1, vector<ll>(2,0));
    DP[0][0] = 0;
    DP[0][1] = -9999999999;
    int cnt = 0;
    rep(i,N) {
        DP[i+1][0] = max(DP[i][0]+A[i], DP[i][1]-A[i]);
        DP[i+1][1] = max(DP[i][0]-A[i], DP[i][1]+A[i]);
//        printf("%18ld %18ld\n", DP[i+1][0], DP[i+1][1]);
    }
    cout << DP[N][0] << endl;
}


Measured memory_bytes: 9516
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);
			int a = int.Parse(input[1]);
			int b = int.Parse(input[2]);

			if (a * n > b)
			{
				Console.WriteLine(b);
			}
			else
			{
				Console.WriteLine(a * n);
			}
		}
	}
}


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

int n;
vector<ll> a;
ll dp[3005][3005];
// ll solve(int i,int j) {
//     if(dp[i][j] !=  0)
//     if(i == j) {
//         return a[i];
//     }
//     if(j == i+1) return max(a[i],a[j]);
//     return max(min(solve(i+2,j),solve(i+1,j-1))+ a[i], min(solve(i+1,j-1),solve(i,j-2)) + a[j]);  

    
// }
int main() {
    cin>>n;
    a.resize(n);
    ll sum = 0;
    for(int i = 0;i<n;i++) {
        cin>>a[i];
        sum += a[i];
    }
    for(int i = n-1;i>= 0 ;i--) {
        for(int j = i;j<n;j++) {
            if(i==j) dp[i][j] = a[i];
            else if(i == j-1) dp[i][j] = max(a[i],a[j]);
            else {
                dp[i][j] = max(min(dp[i+2][j],dp[i+1][j-1])+a[i],min(dp[i+1][j-1],dp[i][j-2])+a[j]);
            }
            //printf("dp[%d][%d] = %lld\n",i,j,dp[i][j]);
        }
    }  
    ll ans =  sum - dp[0][n-1];
    ll other = sum - ans;
    cout<<other - ans<<"\n";
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
    a[i]--;
  }
  int x = 0;
  int ans = 0;
  while (x != 1 and x != N) {

    int y = x;
    x = a[x];
    ans++;
    a[y] = N;
  }
  dump(x);
  if (x == N)
    cout << -1;
  else
    cout << ans;
  cout << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>
#include <bitset>
#include <numeric>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll ai[100010], ti[100010];
int main()
{
    int n;
    cin >> n;
    ll t[n], a[n];
    for (int i = 0; i < n; i++)
        cin >> t[i];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    if (t[n - 1] != a[0])
    {
        cout << 0 << endl;
        return 0;
    }

    ti[0] = t[0];
    for (int i = 0; i < n - 1; i++)
    {
        if (t[i] == t[i + 1])
        {
            ti[i + 1] = 0;
        }
        else
        {
            ti[i + 1] = t[i + 1];
        }
    }

    ai[n - 1] = a[n - 1];
    for (int i = n - 1; i > 0; i--)
    {
        if (a[i] == a[i - 1])
        {
            ai[i - 1] = 0;
        }
        else
        {
            ai[i - 1] = a[i - 1];
        }
    }

    // for (int i = 0; i < n; i++)
    //     cout << ti[i];
    // cout << endl;
    // for (int i = 0; i < n; i++)
    //     cout << ai[i];
    // cout << endl;

    ll ans = 1;
    for (int i = 0; i < n; i++)
    {
        //cout << ti[i] << " " << ai[i] << endl;
        if (ti[i] == 0 || ai[i] == 0)
        {
            if ((ti[i] == 0 && ai[i] == 0))
            {
                ans = (ans * min(t[i], a[i])) % MOD;
                // ti[i] = min(t[i], a[i]);
                // ai[i] = min(t[i], a[i]);
            }
            else
            {
                if (ti[i] == 0)
                    ti[i] = ai[i];
                else
                    ai[i] = ti[i];
            }
        }
        else if (ti[i] != ai[i])
        {
            cout << 0 << endl;
            return 0;
        }
    }

    // for (int i = 0; i < n; i++)
    //     cout << ti[i] << " ";
    // cout << endl;
    // for (int i = 0; i < n; i++)
    //     cout << ai[i] << " ";
    // cout << endl;

    // cout << ans << endl;

    //ll tmax = max(ai[0], ti[0]);
    for (int i = 1; i < n; i++)
    {
        if (ti[i] == 0 && ai[i] == 0)
        {
            continue;
        }
        if (ti[i] > t[i] || ai[i] > a[i])
        {
            cout << 0 << endl;
            return 0;
        }

        // if (ti[i] == 0 || ai[i] == 0)
        // {
        //     continue;
        // }
        // if (max(ai[i], ti[i]) <= tmax)
        // {
        //     cout << 0 << endl;
        //     return 0;
        // }
        // tmax = max(ai[i], ti[i]);
    }

    cout << ans % MOD << endl;

}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;
    for(int i = 0; i < n; i++){

        int x, y, a, b; cin >> x >> y >> a >> b;
        int ans = x * a + y * b;
        if(a >= 5 && b >= 2){
            ans -= ans / 5;
            cout << ans << endl;
        }else{
            if(a < 5) a = 5;
            if(b < 2) b = 2;

            int tmp = x * a + y * b;
            tmp -= tmp / 5;
            ans = min(ans, tmp);
            cout << ans << endl;
        }

    }
    return 0;
}



Measured memory_bytes: 3108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
struct Node{
    int key;
    Node *next,*prev;
};

Node *nil;

Node *listSearch(int key)
{
    Node *cur = nil->next;
    while(cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil)
            break;
        if(isf++ > 0)
            printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    cout << endl;
}
void deleteNode(Node *t){
    if(t == nil)
        return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
void deleteFirst(){
    deleteNode(nil->next);
}
void deleteLast()
{
    deleteNode(nil->prev);
}
void deletekey(int key)
{
    deleteNode(listSearch(key));
}
void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
int main()
{
    int n,key;
    char s[20];
    int np = 0, nd = 0;
    int size = 0;
    scanf("%d",&n);
    init();
    for(int i=0; i<n; i++)
    {
        scanf("%s%d",s,&key);
        if(s[0] == 'i')
        {
           insert(key);
           np++;
           size++;
        }
        else if(s[0] == 'd')
        {
            if(strlen(s) > 6)
            {
                if(s[6] == 'F')
                    deleteFirst();
                else if(s[6] == 'L')
                    deleteLast();
            }
            else{
                nd++;
                deletekey(key);
            }
            size--;
        }
    }
    printList();
    return 0;
}



Measured memory_bytes: 34552
use std::io::stdin;

fn main() {
    let mut nd = String::new();
    stdin().read_line(&mut nd).unwrap();
    let nd: Vec<usize> = nd.trim().split_whitespace().flat_map(str::parse).collect();
    let (n, d) = (nd[0], nd[1]);

    println!("{}", (n / (2 * d + 1)) + if n % (2 * d + 1) > 0 { 1 } else { 0 });
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){

int w, h, x, y, r;
scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h){
printf("Yes\n");
}
else{
printf("No\n");
}
	
return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;

typedef pair<int,int> pii;

bool memo[100][100][4][11][11];
struct p {
	int y, x, d, r, l;
};

int main() {
	int N, M, A;
	cin >> N >> M >> A;
	vector<string> b(N);
	for(int i = 0; i < N; i++) {
		cin >> b[i];
	}
	queue<p> q;
	pii goal, start;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			if(b[i][j]=='S') {
				memo[i][j][0][0][0] = true;
				q.push((p){i,j,0,0,0});
				start=pii(i,j);
			}
			if(b[i][j]=='G') {
				goal=pii(i,j);
			}
		}
	}
	while(q.size()) {
		int dxy[] = {1,0,-1,0,1};
		p t = q.front(); q.pop();
		//cout << t.y << " " << t.x << " " << t.d << endl;
		for(int i = 0; i < 4; i++) {
			int nx, ny;
			ny = t.y + dxy[i];
			nx = t.x + dxy[i+1];
			if(ny < 0 || N <= ny || nx < 0 || M <= nx) continue;
			if(b[ny][nx] == '#') continue;

			if(ny==start.first && nx==start.second && i==2) continue;

			if(i==(t.d+2)%4) {
				continue; // turn
			}
			else if(i==t.d) {
				// go straight
				if(memo[ny][nx][i][t.r][t.l]) continue;
				memo[ny][nx][i][t.r][t.l] = true;
				q.push((p){ny,nx,i,t.r,t.l});
			}
			else if(b[t.y][t.x] == '.') {
				if(i+t.d==3){
					// type P
					if(t.r+1 > A) continue;
					if(memo[ny][nx][i][t.r+1][t.l]) continue;
					memo[ny][nx][i][t.r+1][t.l] = true;
					q.push((p){ny,nx,i,t.r+1,t.l});
				}
				else {
					// type Q
					if(t.l+1 > A) continue;
					if(memo[ny][nx][i][t.r][t.l+1]) continue;
					memo[ny][nx][i][t.r][t.l+1] = true;
					q.push((p){ny,nx,i,t.r,t.l+1});
				}
			}
		}
	}
	int res = -1;
	for(int i = 0; i <= A; i++) {
		for(int j = 0; j <= A; j++) {
			for(int k = 0; k < 4; k++) {
				if(memo[goal.first][goal.second][k][i][j]) {
					if(res+1) res = min(res, i+j);
					else res = i+j;
				}
			}
		}
	}
	cout << res << endl;
}

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

static const long long MOD=1e9+7;
long long C[2005][2005];

void COMB(){
    for(int i=0;i<2005;++i){
        C[i][0]=1;
        C[i][i]=1;
    }

    for(int i=2;i<2005;++i){
        for(int j=1;j<i;++j){
            C[i][j]=C[i-1][j-1]%MOD+C[i-1][j]%MOD;
            C[i][j]=C[i][j]%MOD;
        }
    }
}

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

    COMB();

    for(int i=1;i<=k;++i){
        long long ans=C[n-k+1][i]*C[k-1][i-1]%MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=1000000+5,mod=1e9+7;
int a[N],L[N];
int S[N];
bool vis[N];
vector<int> v[N];
void seive(int num){
  for(int i=1;i<=num;i++) L[i]=i;
   vis[0]=vis[1]=1;
   for(int i=2;1ll*i*i<=num;i++){
    if(vis[i]) continue;
    L[i]=i;
    for(int j=i*2;j<=num;j+=i){
        vis[j]=1;
        L[j]=min(L[j],i);
    }
   }

}
void get_fact(int num){
   int onum=num;
   bool fl=0;
   if(sz(v[onum])!=0) fl=1;
   while(num>1){

      S[L[num]]++;
      if(fl==0)
      v[onum].pb(L[num]);

      num/=L[num];
   }

}
int main(){
    GO();

   int T;
   // cin>>T;
   T=1;
    while(T--){
       int n;
       cin>>n;
       seive(1000000);

       ll gg=0;
       for(int i=0;i<n;i++){
         cin>>a[i];
         get_fact(a[i]);
         gg=__gcd(gg,a[i]*1ll);
       }
       bool ok=1;
       for(int i=0;i<n&&ok;i++){

           for(int j=0;j<sz(v[a[i]]);j++){
            int val= v[a[i]][j];
            S[val]--;
           }
           for(int j=0;j<sz(v[a[i]])&&ok;j++){
            int val= v[a[i]][j];
            if(S[val]>0){
                ok=0;
            }
           }

       }
       if(ok){
        cout<<"pairwise coprime\n";
       }
       else if(gg==1){
        cout<<"setwise coprime\n";
       }
       else{
        cout<<"not coprime\n";
       }

    }

}































































































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

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

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

	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if((int)(log10(i))%2==0)
			ans++;
	}
	cout<<ans;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    double n; cin >> n;
    cout << n*PI*2 << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

ll pow2(ll x) {
	ll ret = 0;
	while(x % 2 == 0) {
		ret++;
		x /= 2;
	}
	return ret;
}

int main() {
//	cout << fixed << setprecision(15);
	ll n, m;
	cin >> n >> m;
	vll a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] /= 2;
	}
	ll p = pow2(a[0]);
	rep(i, n) if(p != pow2(a[i])) {
		cout << 0 << endl;
		return 0;
	}
	ll b = 1;
	rep(i, n) {
		b = b * a[i] / __gcd(b, a[i]);
		if(b > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << (m / b + 1) / 2 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b) swap(a, b);
    return b ? gcd(b, a % b) : a;
}
int main()
{
  int n,x;
  cin>>n>>x;
  int ans=0;
  for(int i=0;i<n;i++)
  {
      int a;cin>>a;
      if(i==0){ans=abs(x-a);continue;}
      ans=min(ans,gcd(abs(x-a),ans));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  int n, m;
  queue<int> que;

  cin >> n >> m;

  for (int i = 1; i <= 2 * n; i++){
    que.push(i);
  }

  for (int i = 0; i < m; i++){
    int k;
    cin >> k;
    if (k){
      for (int j = 0; j < k; j++){
        que.push(que.front());
        que.pop();
      }
    } else {
      queue<int> s;
      for (int j = 0; j < n; j++){
        s.push(que.front());
        que.pop();
      }
      for (int j = 0; j < n; j++){
        que.push(s.front());
        que.push(que.front());
        que.pop(); s.pop();
      }
    }
  }

  for (int i = 0; i < 2 * n; ++i){
    cout << que.front() << endl;
    que.pop();
  }
}

Measured memory_bytes: 3156