akhauriyash/Code-Regression huggingface dataset:
import math
import collections
def main():

    N = int(input())
    A = list(map(int, input().split()))

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    ispair = True
    isset = True

    d = dict()
    for v in A:
        for u in set(prime_factorize(v)):
            d[u] = d.get(u, 0) + 1
    # print(d)

    if any(d[p] > 1 for p in d):
        ispair = False
    if any(d[p] == N for p in d):
        isset = False

    if ispair:
        return "pairwise coprime"
    if isset:
        return "setwise coprime"

    return "not coprime"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 193948
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  	int N;
  	double dp[3000][3000] = {};
  	cin >> N;
  	dp[0][0] = 1.0;
  	for(int i = 0; i < N; i++){
    	double p;
      	cin >> p;
      	for(int j = 0; j <= N; j++){
        	if(j == 0){
            	dp[i + 1][j] = dp[i][j] * (1 - p);
            }else {
            	dp[i + 1][j] = dp[i][j] * (1 - p) + dp[i][j - 1] * p;
            }
        }
    }
  	double ans = 0;
  	for(int i = (N - 1) / 2 + 1; i <= N; i++){
    	ans += dp[N][i];
    }
  	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 70656
sumarray :: [Int] -> Int
sumarray [] = 0
sumarray (x:xs) = x + sumarray xs

libra :: Int -> Int -> String
libra l r
  | l > r = "Left"
  | l < r = "Right "
  | otherwise = "Balanced "


main = do
    ns <- fmap(read :: String -> Int) . words <$> getContents
    let l = sumarray $ take 2 ns
    let r = sumarray $ drop 2 ns
    putStrLn $ libra l r


Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,d,x,y,d1,d10,ans = 0;

	
	scanf("%d %d", &m, &d);
	
/*	if ( (d / 10) < 2) {
		printf("0\n");
		return 0;
	}
*/	
	if (DBG) printf("%d %d\n",m,d);
	for (i=1; i<=m; i++) {
		for(j=d; j>=22; j--) {
			d1  = j % 10;
			d10 = j / 10;
			if (DBG) printf("%d %d %d %d\n",i,j,d1,d10);
			if (d1 < 2) continue;
			if ( (d1*d10)==i ) ans++;
		}
	}
	
	printf("%d\n",ans);


	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

suma = 0

for i in range(n):
	suma += a[i]

for i in range(n):
	suma -= a[i]
	a[i] *= suma


sumall = 0
for i in range(n):
	sumall += a[i]

print(sumall % 1000000007)

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var whxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
            double maxarea = (double)whxy[0] * whxy[1] / 2;
            int judge = 0;
            if (whxy[2] + whxy[2] == whxy[0] && whxy[3] + whxy[3] == whxy[1]) judge = 1;
            Console.WriteLine(maxarea + " " + judge);
            
        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};

int H,W;
char fld[1010][1010];

int cnt[1010][1010];

signed main(){
    scanf("%lld%lld",&H,&W);
    rep(i,H)scanf("%s",fld[i]);

    queue<pint>que;

    rep(i,H)rep(j,W){
        if(fld[i][j]=='.')continue;
        rep(d,8){
            int ny=i+dy[d],nx=j+dx[d];
            if(fld[ny][nx]=='.')cnt[i][j]++;
        }
        if(cnt[i][j]>=fld[i][j]-'0')que.push(pint(i,j));
    }

    for(int t=0;;t++){
        if(que.size()==0){
            cout<<t<<endl;
            return 0;
        }
        queue<pint>que2;
        while(que.size()){
            int y,x;
            tie(y,x)=que.front();
            que.pop();
            fld[y][x]='.';
            rep(i,8){
                int ny=y+dy[i],nx=x+dx[i];
                if(fld[ny][nx]=='.')continue;
                if(++cnt[ny][nx]==fld[ny][nx]-'0'){
                    que2.push(pint(ny,nx));
                }
            }
        }
        que=que2;
    }

    return 0;
}

Measured memory_bytes: 12124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int mod = 1e9 + 7;
const int N = 2e6 + 9;

int fat[N], inv[N];

int fastexp(int b, int e) {
   if(e == 0) return 1;
   int ans = fastexp(b, e/2);
   ans = (ans*ans)%mod;
   if(e%2 == 1) ans = (ans * b)%mod;
   return ans;
}

void init() {
   fat[0] = fat[1] = 1;
   inv[0] = inv[1] = 1;
   for(int i = 2; i < N; i++) {
      fat[i] = (i * fat[i-1])%mod;
      inv[i] = fastexp(fat[i], mod - 2);
   }
}

int comb(int a, int b) {
   return fat[a] * inv[b] % mod * inv[a-b] % mod;
}

signed main(){
   IOS;
   init();
   int k; cin >> k;
   string s; cin >> s;
   int n = s.size();
   int ans = 0;
   for(int i = 0; i <= k; i++) {
      ans = (ans + fastexp(25, i) * fastexp(26, k - i) % mod * comb(i + n - 1, n - 1) % mod) % mod;
   }
   cout << ans << "\n";
}

Measured memory_bytes: 35476
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

class Card{
	private:
		string _name;
		string _mark;
		int _value;

	public:
		@property{
			string name() const { return _name; }
			int value() const { return _value; }
		}

		this(string name){
			_name = name;
			_mark = name[0..1];
			_value = name[1].to!int();
		}
}

void BubbleSort(Card[] arr, int n){
	for(int i = 0; i < n; ++i){
		for(int j = n-1; j > i; --j){
			if(arr[j].value < arr[j-1].value)
				swap(arr[j], arr[j-1]);
		}
	}
}

void SelectionSort(Card[] arr, int n){
	for(int i = 0; i < n; ++i){
		int minj = i;
		for(int j = i; j < n; ++j){
			if(arr[j].value < arr[minj].value)
				minj = j;
		}
		swap(arr[i], arr[minj]);
	}
}

int main(string[] argv)
{
	auto n = readln.chomp.to!int();
	Card[] b, s;

	string[] input = readln.split();
	for(int i = 0; i < n; i++){
		b ~= new Card(input[i]);
		s ~= new Card(input[i]);
	}

	BubbleSort(b, b.length.to!int());
	foreach(i, e; b){
		write(e.name);
		if(i == b.length.to!int() - 1) writeln();
		else write(" ");
	}
	writeln("Stable");
	SelectionSort(s, s.length.to!int());
	foreach(i, e; s){
		write(e.name);
		if(i == s.length.to!int() - 1) writeln();
		else write(" ");
	}

	for(int i = 0; i < n; ++i){
		if(b[i].name != s[i].name){
			writeln("Not stable");
			return 0;
		}
	}
	writeln("Stable");

    return 0;
}

Measured memory_bytes: 2452
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int n,m,i,j,P,cnt=0,p[1000],wa[100001],ac[100001],penalty=0;
char s ,t;
cin>>n>>m;
for(i=0;i<=n;i++)
{
    wa[i]=0;
    ac[i]=0;
    p[i]=0;
}

for(i=0;i<m;i++)
{
    cin>>P>>s>>t;
    if((s=='A' && t=='C' ))
    {
        ac[P]++;
    }
    if(s=='W' && t=='A')
    {
        if(ac[P]==0)
        {wa[P]++;}
    }
}
for(i=1;i<=n;i++)
{
if(ac[i]!=0)
{
    cnt++;
}
if(ac[i]!=0)
{
    penalty=penalty+(wa[i]);
}
//cout<<p[i]<<" "<<wa[i]<<endl;
}
//cout<<endl;
cout<<cnt<<" "<<penalty<<endl;

return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int n;cin>>n;
  int a[n+10];
  rep(i,0,n-1) {
    cin>>a[i];
  }

  int j=1;
  bool mrk=false;
  rep(i,0,n-1) {
    // pr(a[i],j);
    if(j==a[i]) {
      j++;
      mrk=true;
    }
  }

  if(mrk) {
    pr(n-j+1);
  } else {
    pr(-1);
  }

  return 0;
}


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


int main() {
  string s;
  cin >> s;

  if(stoi(s.substr(5, 2)) <= 4 && stoi(s.substr(8, 2)) <= 30) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
void work(int *max,int *min,int *def){
	int x,tmp;
	std::cin>>x;
	if(*max<x){
		*max=x;
		tmp=*max-*min;
		if(tmp>*def) *def=tmp;
	}else if(*min>x){
		*min=x;
	}else{
		tmp=x-*min;
		if(tmp>*def) *def=tmp;
	}
}
int main(){
	int n,x;
	std::cin>>n;
	int max,min,def=0;
	std::cin>>x;
	max=x;
	min=x;
	work(&max,&min,&def);
	if (x==max) def=min-x;
	else def=max-x;
	for(int i=2;i<n;i++){
		work(&max,&min,&def);
	}
	std::cout<<def<<'\n';
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main()
{
    char a[3];
    cin>>a;
    int b=strlen(a);
    if(b==2)
        cout<<a[0]<<a[1]<<endl;
    else
        cout<<a[2]<<a[1]<<a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using ll = long long;


std::pair<int, int> loop_detect(std::vector<ll> &cum, int X, int M)
{
    std::vector<int> pos_memo(M, -1);
    
    ll a = X;
    ll sum = 0;

    int i;
    for (i = 0; i <= M; i++)
    {
        if (pos_memo[a] >= 0)
        {
            break;
        }
        else
        {
            pos_memo[a] = i;
            sum += a;
            cum[i+1] = sum;
            a = (a * a) % M;
        }
    }

    int l = pos_memo[a];
    if (pos_memo[a] < 0)
        l = 0;

    return {l, i};
}

int main()
{
    ll N;
    int X, M;
    std::cin >> N >> X >> M;

    std::vector<ll> rui(M+1, 0);
    auto [loop_l, loop_r] = loop_detect(rui, X, M);
    
    ll loop_range = loop_r - loop_l;
    ll loop_count = (N - loop_l) / loop_range;
    ll rest = (N - loop_l) % loop_range;
    ll loop_total = (rui[loop_r] - rui[loop_l]) * loop_count;
    ll ans = loop_total + rui[loop_l+rest];
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4304
#include<cstdio>
using namespace std;
int era[250001];
int main(void)
{
	int i,j,n,wk,cnt;
	era[1]=0;
	for(i=2;i<250001;i++)	era[i]=1;
	for(i=2;i*i<=250000;i++)	{
		if(era[i]==1)	{
			for(j=2*i;j<=250000;j+=i)	{
				era[j]=0;
			}
		}
	}
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		cnt=0;
		for(i=n+1;i<=n*2;i++)	{
			if(era[i]==1)	cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 2008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++) 

using namespace std;

int main() {
  int n;cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  int m;cin>>m;
  vector<string> t(m);
  rep(i,m)cin>>t[i];
  int ans=0;
  rep(i,n){
    int cnt=0;
    for(int j=i;j<n;j++){
      if(s[i]==s[j])cnt++;
    }
    rep(k,m){
      if(s[i]==t[k])cnt--;
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

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

int main() {
  int a[4],b[4];
  while(cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int h=0, bl=0;
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    for(int i=0; i<4; i++) {
      if(a[i]==b[i]) h++;
      else {
	if(find(a, a+4, b[i])!=a+4) bl++;
      }
    }
    cout << h << " " << bl << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll h, w, k;  cin >> h >> w >> k;
    vector<vector<ll>> ori(h, vector<ll>(w));
    REP(i, h) REP(j, w){
        char c; cin >> c;
        ori[i][j] = c-'0';
    }
    
    ll res=0;
    REP(x, h){
        REP(y, w){
            ll tmp=0, times=0;
            bool flag=true;
            vector<vector<ll>> g = ori;
            g[x][y] = 0;
            for(int i=x; 0<i; i--){
                swap(g[i][y], g[i-1][y]);
            }
            // REP(i, h){
            //     REP(j, w) cout << g[i][j] << ' ';
            //     cout << endl;
            // }
            
            while(flag){
                flag = false;
                REP(i, h){
                    ll bef=g[i][0], cnt=0;
                    
                    REP(j, w){
                        if(g[i][j]==bef && 0<bef) cnt += 1;
                        else{
                            if(k<=cnt){
                                flag = true;
                                tmp += cnt*(1<<times)*bef;
                                for(int p=1; p<=cnt; p++)   g[i][j-p] = 0;
                            }
                            cnt = 1;
                        }
                        bef = g[i][j];
                    }
                    if(k<=cnt){
                        tmp += (1<<times)*cnt*bef;
                        for(int p=1; p<=cnt; p++)   g[i][w-p] = 0;
                        flag = true;
                    }
                }
                REPD(i, h){
                    REP(j, w){
                        if(!g[i][j]){
                            REPD(k, i){
                                if(!g[k][j]) continue;
                                swap(g[k][j], g[i][j]); break;
                            }
                        }
                    }
                }
                
                times += 1;
                //cout << tmp << ' ';
            }
            res = max(res, tmp);
            //cout << x <<':' << y << ' ' << tmp << endl << endl;
        }
    }
    
    cout << res << endl;
    
}

Measured memory_bytes: 3640
import math

a, b, c = map(float, input().split())
h = b * math.sin(math.radians(c))
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(c)))
L = a + b + c
S = 1 / 2 * a * h
print(S)
print(L)
print(h)


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

/*int solve(vector<int> v, int i){
if(i>=v.size()-1)return 0;
//if(i>v.size)return v[i-2];
if(dp[i])return dp[i];
else
        if((i+2)<v.size())
             dp[i]=min(abs(v[i]-v[i+1])+solve(v,i+1),abs(v[i]-v[i+2])+solve(v,i+2));
        else dp[i]=abs(v[i]-v[i+1]);

return dp[i];
}*/
int main(){
int n;
cin>>n;
vector <int> v(n);
vector<int>dp(n,1e9);
dp[0]=0;
for(auto & it : v)cin>>it;
if(v.size()==1)return 0;
else if(v.size()==2)cout<<abs(v[0]-v[1])<<endl;
else{
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=i+2;j++){
                if(j<n){
                    dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
                }
            }
        }
        cout<<dp[n-1]<<endl;
}

return 0;}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	double q, x;
	while (cin >> q&&q!=-1) {
		x = q / 2;
		while (abs((x*x*x) - q) > 0.00001*q) {
		x=x - (((x*x*x) - q) / (3 * x*x));
		}
		cout << fixed << setprecision(7) << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
n, k = map(int, input().split())
MOD = 10**9+7
ans = 0
for i in range(k, n+1):
    cnt = (2*n-i+1)*i // 2 - (i-1)*i//2 + 1
    ans = ans + cnt % MOD
print(ans % MOD + 1)


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

using namespace std;

using ll = long long;

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

    gcd(b, a % b);
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ab_abs = B - A  + 1;
    ll c_count = A % C == 0 ? abs(B / C) - abs(A / C) + 1 : abs(B / C) - abs(A / C);
    ll d_count = A % D == 0 ? abs(B / D) - abs(A / D) + 1 : abs(B / D) - abs(A / D);
    ll gcd_of_cd = gcd(C, D);
    ll cd = gcd_of_cd * (C / gcd_of_cd) * (D / gcd_of_cd);
    ll cd_count = A % cd == 0 ? abs(B / cd) - abs(A / cd) + 1 : abs(B / cd) - abs(A / cd);
    ab_abs -= c_count + d_count - cd_count;
    cout << ab_abs << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

bool check(int x, int y) {
    if (x > y) {
        int z = x-y;
        int w = 16-2*y;
        if (z*2 <= w) return true;
    } else {
        int z = y-x;
        int w = 16-2*x;
        if (z*2 <= w) return true;
    }
    return false;
}

int main () {
    int a, b;
    cin >> a >> b;
    if (check(a, b)) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int k = std.nextInt();
        int x = std.nextInt();
        int min = x - (k - 1);
        int max = x + (k - 1);
        IntStream.rangeClosed(min, max).forEach(System.out::println);
    }
}


Measured memory_bytes: 30164
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, R;
  cin >> N >> R;

  if (N < 10) R += 100 * (10 - N);
  cout << R;
}
#endif


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll a=in(),b=in();
    cout<<max(a-2*b,0ll)<<endl;
}


Measured memory_bytes: 256
x = int(input())

if x<=599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 9168
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define mp make_pair

int main() {
        int n;
        scanf("%d", &n);
        set<pair<int, int>> paint;
        for (int y = 0; y < n; y ++) {
                if (y % 6 == 1) {
                        for (int x = 2; x < n; x += 2) {
                                paint.insert(mp(x, y));
                        }
                }
                if (y % 6 == 4) {
                        for (int x = 1; x < n; x += 2) {
                                paint.insert(mp(x, y));
                        }
                }
        }
        for (int y = 0; y < n; y ++) {
                if (y & 1 && !paint.count(mp(0, y))) {
                        paint.insert(mp(0, y));
                }
        }
        for (int x = 0; x < n; x ++) {
                if ((x + n - 1) & 1 && !paint.count(mp(x, n - 1))) {
                        paint.insert(mp(x, n - 1));
                }
        }
        printf("%d\n", (int) paint.size());
        for (auto it : paint) {
                printf("%d %d\n", it.first, it.second);
        }
        return 0;
}



Measured memory_bytes: 9344
#include<stdio.h>
int main(void)
{
	double a,b,c,d,e,f,x,y;

	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
		x=(c*e-b*f)/(a*e-b*d);
		y=(a*f-c*d)/(a*e-b*d);
/*		if(x-(double)(int)x>=0.0005)x=(int)((x+0.0009)*1000)/1000;
		else x=(double)((int)(x*1000))/1000;

		if(y-(double)(int)y>=0.0005)y=(int)((y+0.0009)*1000)/1000;
		else y=(double)((int)(y*1000))/1000;

		if(x-(double)(int)x<=-0.0005)x=(int)((x+0.0009)*1000)/1000;
		else x=(double)((int)(x*1000))/1000;

		if(y-(double)(int)y<=-0.0005)y=(int)((y+0.0009)*1000)/1000;
		else y=(double)((int)(y*1000))/1000;
*/
		if((int)(x*1000)==0)x=0;
		if((int)(y*1000)==0)y=0;

		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}

Measured memory_bytes: 648
#include <stdio.h>

int hoge(int a, int n){
	if(n<1){return a;}
	a*=1.05;
	if(a%1000){
		a+=(1000-a%1000);
	}
	return hoge(a, n-1);
}

int main (void)
{
	int n, i;
	scanf("%d", &n);
	
	int money=100000;
	for(i=0; i<n; i++){
		money+=money*0.05;
		if(money%1000){
			money+=(1000-money%1000);
		}
	}
	
	printf("%d\n", money);
	
	return 0;
}

Measured memory_bytes: 0
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>


using namespace std;

int main()
{
	string s,sr,srr;
	//int count=0;

	cin >> s>>sr;
	//s.reserve();
	if (s.at(0)==sr.at(2) && s.at(1) == sr.at(1) && s.at(2) == sr.at(0)) 
	{
		cout << "YES"<< endl;
	}
	else cout << "NO" << endl;

		return 0;

}

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

int main() {
  int n[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << n[k - 1] << endl;
}

Measured memory_bytes: 256
N = int(input())

L = []
for i in range(N):
    t,a = map(int, input().split())
    L.append((t,a))
# print(L)

import math
from decimal import Decimal

check1 = (1, 1)
for i in range(N):
    check2 = L[i]
    
    x1 = check1[0]
    y1 = check1[1]
    
    x2 = check2[0]
    y2 = check2[1]
    check2 = L[i]
    
#     print('11', x1, y1)
#     print('22', x2, y2)
    
    a1 = Decimal(math.ceil(x1 / x2))
    a2 = Decimal(math.ceil(y1 / y2))
    
#     print('aa', a1, a2)
        
    a = max(a1, a2)
        
    check1 = (x2*a, y2*a) 
    
#     print(check1)
#     print('~~~~~~~~~~~~~~~~~~~~')

# print(check1)

print(sum(check1))

Measured memory_bytes: 5192
N, M, Q = map(int, input().split())

train = [[0 for _ in range(N+1)] for _ in range(N+1)]

for _ in range(M) :
    L, R = map(int, input().split())
    train[L][R] += 1

que = []
for _ in range(Q) :
    p, q = map(int, input().split())
    que.append((p, q))

# 累積和
S = [[0 for _ in range(N+1)] for _ in range(N+1)]  # ゼロパディング

for l in range(1, N+1) :
    for r in range(1, N+1) :
        S[l][r] = S[l-1][r] + S[l][r-1] - S[l-1][r-1] + train[l][r]

for p, q in que :
    ans = S[q][q] - S[p-1][q] - S[q][p-1] + S[p-1][p-1]
    print(ans)

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

int main()
{
    string s;
    cin>>s;
    int k=0;
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='7')
        {
            k=-1;
            break;
        }
    }
    if(k==0)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input","r",stdin)
#define write freopen("output","w",stdout)
#define fr first
#define sc second
#define ii pair < int , int >
using namespace std;
int main()
{
 int n,m;
 cin>>n>>m;
 char a[n+1][m+1];
 for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
     cin>>a[i][j];
 int vis[n+1][m+1];
 memset(vis,0,sizeof(vis));
 vis[0][0] = 1;
  int x = 0 , y = 0;
 while(1)
 {

   if(x >=n  && y >= m)
    break;
   if(a[x+1][y] == '#')
   {
     vis[x+1][y] = 1;
      x++;
   }
   else if(a[x][y+1] == '#')
   {
       vis[x][y+1] = 1;
       y++;
   }
   else
    break;
 }
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         if(a[i][j] == '#' && vis[i][j] == 0)
         {
             cout<<"Impossible";
             return 0;
         }
     }
 }
 cout<<"Possible";

}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int x,y,ans;
char s[100001];
string a,b;
int main(){
    cin>>a,b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++){
		if(a[i]=='d') a[i]='b';
		else if(a[i]=='q') a[i]='p';
        else if(a[i]=='b') a[i]='d';
        else if(a[i]=='p') a[i]='q';
    }
    if(a==b) printf("Yes");
    else printf("No");
    printf("\n");
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	string S[3]; rep(i, 3) cin >> S[i];
	int ans = 0;
	rep(i, N) {
		if (S[0][i] == S[1][i]) {
			if (S[0][i] != S[2][i]) ans++;
		}
		else {
			if (S[2][i] == S[0][i] || S[2][i] == S[1][i]) ans++;
			else ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int i, j;
    for (i = 1; i < 10; i++) {
        for (j = 1; j < 10; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}


Measured memory_bytes: 3080
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

list=[]
list.append(a)
list.append(b)
list.append(c)
list.append(d)
list.append(e)

yes="Yay!"
no=":("
flag=False

for i in range(5):
    for j in range(5):
        if i==j or i>j:
            continue
        if k<list[j]-list[i]:
            flag=True
if flag:
    print(no)
else:
    print(yes)

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

def count(n, k):
    # nまでの2進数の桁kの1の数
    pow2k = 2**k
    q, mod = divmod(n+1, 2**(k+1))
    c1 = max(mod-2**k, 0)
    c2 = q * 2**k
    return c1 + c2

def main():
    A, B = list(map(int, input().split()))
    K = 0
    tmp = 1
    while tmp <= B:
        K += 1
        tmp *= 2

    ret = 0
    for k in range(K):
        ca = count(A-1, k)
        cb = count(B, k)
        ret += ((cb-ca)%2) * (2**k)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

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

void print_vector(vector<ll> vt){
    for(auto v: vt){
        cout << v;
    }
    cout << endl;
}

vector<int> nums(3);

int main()
{
    for(int i=0; i<3; i++){
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());
    int ans=0;
    ans+=nums[2]-nums[1];
    nums[0]+=ans;
    nums[1]+=ans;
    int tmp=(nums[1]-nums[0])/2;
    if((nums[1]-nums[0])%2==1) tmp+=2;
    cout << ans+tmp << endl;

    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t;cin>>t;while(t--)
#define f(i,n) for (int i=0;i<n;i++)
#define fa(i,a,b) for (int i=a;i<b;i++)
#define b(i,a,b) for (int i=a;i>=b;i--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define fi first    
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<'>'<<#x<<" = "<<x<<endl;
#define MOD 1000000007
#define ce cout<<"\n"
int main()
{
    char c;
    cin>>c;
    cout<<char(c+1)<<'\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, p[10], q[10], r[10], s[10];
  cin>>n;
  REP(i, n){
    cin>>p[i];
    r[i]=p[i];
  }
  REP(i, n){
    cin>>q[i];
    s[i]=q[i];
  }
  int a=0;
  do{
    ++a;
  }while(next_permutation(p, p+n));
  int b=0;
  do{
    ++b;
  }while(next_permutation(q, q+n));
  cout<<abs(a-b)<<'\n';
  return 0;
}


Measured memory_bytes: 256
#unionfind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n


    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)


        if x == y:
            return


        if self.parents[x] > self.parents[y]:
            x, y = y, x


        self.parents[x] += self.parents[y]
        self.parents[y] = x


    def size(self, x):
        return -self.parents[self.find(x)]


    def same(self, x, y):
        return self.find(x) == self.find(y)


    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]


    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


    def group_count(self):
        return len(self.roots())


    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    uf.union(a,b)
s=set()
for i in range(n):
    s.add(uf.find(i))
print(len(s)-1)

Measured memory_bytes: 17884
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int count(string& s, int i) {
  unordered_set<char> a, b;
  rep(k, i) { a.insert(s[k]); }
  REP(k, i, s.size()) { b.insert(s[k]); }
  int ret = 0;
  for (auto& x : a) {
    if (b.find(x) != b.end()) ret++;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i, s.size()) cout << "x";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  
  if(a <= b){
    for(int i = 0;i < b;i++){
      printf("%d", a);
    }
  }
  else{
    for(int i = 0;i < a;i++){
      printf("%d", b);
    }
  }
  puts("");
  
  return 0;
}

Measured memory_bytes: 128
import numpy as np

A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

speed = V - W
L = np.abs(B - A)

if speed == 0:
    if L == 0:
        print('YES')
    else:
        print('NO')
    exit()

if 0 <= L / speed <= T:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 27160
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Measured memory_bytes: 19016
a=int(input())
b=a//3
c=a//5
d=a//15

z=0
y=0
w=0
v=0

for x in range(a+1):
  z=z+x

for x in range(b+1):
  y=y+x*3

for x in range(c+1):
  w=w+x*5

for x in range(d+1):
  v=v+x*15

print(z-y-w+v)

Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    LL count[n+1];
    for(int i=0;i<n+1;i++){
        count[i]=0;
    }
    for(int i=0;i<n;i++){
        count[a[i]]++;
    }
    LL ans=0;
    for(int i=1;i<n+1;i++){
        ans=ans+(count[i]*(count[i]-1))/2;
    }
    for(int i=0;i<n;i++){
        cout<<ans-count[a[i]]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  vi a(n);
  REP(i,n){
      cin>>a[i];
      if ((i+1)%2==1){
        if (a[i]%2==1)ans++;
      }
  } 

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

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll b;
int main(){
	while(1){
		cin>>b;
		if(b==0)break;
		b*=2;
		double t=sqrt(b);
		int ce;
		for(int i=1;i<t;i++)
			if(b%i==0){
				if(i%2==1||(b/i)%2==1)
				ce=i;
			}
		int cc=b/ce;
		cout<<(cc-ce-1)/2+1<<" "<<ce<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll m=pow(10,9)+7;
int main(){
    int n;
    cin >> n;
    ll a[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        ans+=(sum%m*a[i]%m)%m;
    }
    cout << ans%m << endl;
}

Measured memory_bytes: 5144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
int zombi_infect[300000] = {};
vector<int> vertexs[300000] = {};
long long ans[300000] = {};
int done[300000] = {};
int main() {
	long long n, m, k, s, p, q;
	cin >> n >> m >> k >> s >> p >> q;
	priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> zombie;
	REP(i, k) {
		int tmp;
		cin >> tmp;
		zombi_infect[tmp] = true;
		done[tmp] = true;
		zombie.push(make_pair(0,tmp));
	}
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	while (zombie.empty() == false) {
		pair<int,int> hoge = zombie.top();
		zombie.pop();
		if (hoge.first != s) {
			for (int i = 0;i < vertexs[hoge.second].size();++i) {
				if (zombi_infect[vertexs[hoge.second][i]] == false) {
					zombi_infect[vertexs[hoge.second][i]] = true;
					zombie.push(make_pair(hoge.first + 1, vertexs[hoge.second][i]));
				}
			}
		}
	}
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> www;
	www.push(make_pair(0, 1));
	for (int i = 0;i <= n;++i) {
		ans[i] = LONG_INF;
	}
	ans[1] = 0;
	while (www.empty() == false) {
		pair<long long, long long> wow = www.top();
		www.pop();
		if (done[wow.second] == false) {
			for (int i = 0;i < vertexs[wow.second].size();++i) {
				long long let = wow.first;
				if (zombi_infect[vertexs[wow.second][i]] == true) {
					let += q;
				}
				else let += p;
				if (ans[vertexs[wow.second][i]] > let) {
					ans[vertexs[wow.second][i]] = let;
					www.push(make_pair(let, vertexs[wow.second][i]));
				}
			}
		}
	}
	if (zombi_infect[n] == false) {
		ans[n] -= p;
	}
	else ans[n] -= q;
	cout << ans[n] << endl;
	return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int N, C;
	cin >> N >> C;
	vector<vector<int>> D(C,vector<int>(C));
	rep(i,C)rep(j,C) cin >> D[i][j];
	ll ans = 1e9;

	vector<vector<int>> color(N,vector<int>(N));
	rep(i,N){
		rep(j,N){
			cin >> color[i][j];
			color[i][j]--;
		}
	}

	vector<pair<long long, long long>> X(0),Y(0),Z(0);
	for(int k = 0; k < C; k++){
		int x = 0, y = 0, z = 0;
		rep(i,N)rep(j,N){
			if((i+j)%3 == 0) x += D[color[i][j]][k];
			if((i+j)%3 == 1) y += D[color[i][j]][k];
			if((i+j)%3 == 2) z += D[color[i][j]][k];
		}
		X.push_back({x,k});
		Y.push_back({y,k});
		Z.push_back({z,k});
	}
	SORT(X);
	SORT(Y);
	SORT(Z);
	rep(i,3)rep(j,3)rep(k,3){
		if(X[i].second == Y[j].second || X[i].second == Z[k].second || Y[j].second == Z[k].second) {
			continue;
		}
		ans = min(ans, X[i].first + Y[j].first + Z[k].first);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int face[7];
void roll(int a,int b,int c,int d){
    int t;
    t = face[a];
    face[a] = face[d];
    face[d] = face[c];
    face[c] = face[b];
    face[b] = t;
}
void direct(char cmd){
    switch (cmd){
    case 'S':
        roll(1,2,6,5); break;
    case 'N':
        roll(1,5,6,2); break;
    case 'W':
        roll(1,4,6,3); break;
    case 'E':
        roll(1,3,6,4); break;    
    default:           break;
    }
}
int main()
{   
    for(int i=1;i<=7;i++)
        cin>>face[i];
    
    char cmd;
    while ('\n'!=(cmd=getchar()))
        direct(cmd);
    cout<<face[1]<<endl;
    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D) {
    cout << "Left" <<endl;
  }
  if(A+B<C+D) {
    cout <<"Right" <<endl;
  }
  if(A+B==C+D) {
    cout <<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define NIL -1
void depth(int,int);
void printz(int);
struct Node{int s,l,r;};
struct Node A[MAX];
int n,X[MAX];
int main(){
  int i,j,a,b,c,l,r;
  scanf("%d",&n);
for(i=0;i<n;i++){
    A[i].s=NIL;
  A[i].l = NIL;
  A[i].r =NIL;
}
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0)
	A[a].l=c;
      else
	A[l].r=c;
      l=c;
      A[c].s=a;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].s==NIL) r=i;
  }
  depth(r,0);
  for(i=0;i<n;i++) printz(i);
  return 0;
}

void depth(int x,int y){
  X[x]=y;
  if(A[x].r!=NIL)
    depth(A[x].r,y);
  if(A[x].l!=NIL)
    depth(A[x].l,y+1);
}

void printz(int x){
int i,y,count=0;
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].s);
  printf("depth = %d, ",X[x]);
  if(A[x].s==NIL)
    printf("root, ");
  else if(A[x].l==NIL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0,y=A[x].l;y!=NIL;i++,y=A[y].r){
    if(i)
      printf(",");
if(i==0)
  printf("%d",y);
    else
    printf(" %d",y);
  }
  printf("]\n");
}



Measured memory_bytes: 6456
#define N 100005
#define Q 50005
#include <stdio.h>
int S[N], T[Q];

//这里用二分查找算法，查找给定x是否在S中
int isExist(int x, int n) {
    int left = 0, right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (x > S[mid]) {
            left = mid + 1;
        }
        else if (x < S[mid]) {
            right = mid;
        }
        else {
            return 1;
        }
    }
    return 0;
}

int main() {
    int cnt = 0;
    int n, q;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }
    for (int i = 0; i < q; i++) {
        if (isExist(T[i], n)) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2260
n,m = list(map(int,input().split(" ")))

x = list(map(int,input().split(" ")))
y = list(map(int,input().split(" ")))

def how(i):
    j = i
    l = [j-1 for i in range(i-1)]
    j = i-3
    for k in range(1,len(l)):
        l[k] = l[k-1]+j
        j -= 2
    return(l)

xh = how(n)
yh = how(m)

xd = [x[i+1]-x[i] for i in range(n-1)]
yd = [y[i+1]-y[i] for i in range(m-1)]

xs = sum([xd[i]*xh[i] for i in range(n-1)])
ys = sum([yd[i]*yh[i] for i in range(m-1)])

print((xs*ys)%(10**9+7))

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

string toUpper(string s){
    string t = s;
    for(int i=0;i<s.size();i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string word,T;
    int cnt=0;
    cin >> word;
    word = toUpper(word);
    while(1){
        cin >> T;
        if(T=="END_OF_TEXT") break;
        T = toUpper(T);
        if(T==word) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,k[105];
string s;

void solve(){
  rep(i,s.size()){
    rep(j,k[i%n]){
      if(s[i]=='A')s[i]='z';
      else if(s[i]=='a')s[i]='Z';
      else s[i]=char(int(s[i])-1);
    }
  }
  cout<<s<<endl;
}

int main(){
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>k[i];
    cin>>s;
    solve();
  }
  return 0;
}

Measured memory_bytes: 3224