akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1, T2> P)
{
	return s << '<' << P.first << ", " << P.second << '>';
}
template<class T> ostream& operator << (ostream &s, vector<T> P)
{
	for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s;
}
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{
	for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl;
}

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

string s;
string t;
int S = s.size();
int T = t.size();

bool match(int k) {
	for (int i = 0; i < t.size(); i++) {
		if (t[i] != s[i + k] && s[i + k] != '?') {
			return false;
		}
	}

	return true;
}
string construct(int k) {
	string ans = s;
	for (int i = 0; i < t.size(); i++) {
		ans[k + i] = t[i];
	}
	for (int i = 0; i < s.size(); i++) {
		if (ans[i] == '?') {
			ans[i] = 'a';
		}
	}
	return ans;
}


int main() {

	cin >> s >> t;
	vector<string>v;
	int cnt = 0;
	int len_s = s.size(), len_t = t.size();
	if (len_s-len_t< 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	for (int k = 0; k <= (s.size() - t.size()); k++) {
		if (match(k)) {
			v.push_back(construct(k));
			cnt++;
			//cout<<construct(k)<<endl;
		}


	}
	if (cnt == 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	sort(v.begin(), v.end());
	cout << v[0] << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int H,W; cin >> H >> W;
  vvi G(H,vi(W));
  rep(h, H) rep(w, W) cin >> G[h][w];

  int n = 0;
  vi h1,w1,h2,w2;
  int dir = 0;
  int h = 0, w = 0;
  bool seen[H][W];
  memset(seen,false,sizeof(seen));
  rep(i, H*W-1){
    //std::cout << G[h][w] << '\n';
    seen[h][w] = true;
    int nh = h + dh[dir];
    int nw = w + dw[dir];
    if(nh < 0 || nh == H || nw < 0 || nw == W){
      dir = (dir + 1)%4;
      nh = h + dh[dir];
      nw = w + dw[dir];
    }
    //printf("%d,%d %d,%d\n",h,w,nh,nw );
    if(seen[nh][nw]){
      dir = (dir + 1)%4;
      nh = h + dh[dir];
      nw = w + dw[dir];
      //std::cout << "aaa" << '\n';
    }
    if(G[h][w]%2 == 1){
      n++;
      h1.pb(h+1); h2.pb(nh+1); w1.pb(w+1); w2.pb(nw+1);
      G[nh][nw]++;
    }
    h = nh; w = nw;
  }
  std::cout << n << '\n';
  rep(i, n) printf("%d %d %d %d\n", h1[i], w1[i], h2[i], w2[i]);
}


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

int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"safe"<<endl;
    }
    else
    {
        cout<<"unsafe"<<endl;
    }
    */

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool flag = true;
    for(int i=0;i<200;i++)
    {
        if(i%2==0)
        {
            c = c-b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else
        {
            a = a-d;
            if(a<=0)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    		int N = sc.nextInt();
    		int K = sc.nextInt();
    		int ans = (int) (K * Math.pow(K-1, N-1));
    		System.out.println (ans);
    		
    		
    }	
}
    
   

Measured memory_bytes: 9680
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}




int main() {

	ll X, Y, Z,K;
	cin >> X >> Y >> Z>>K;

	vector<ll> A(X);
	vector<ll> B(Y);
	vector<ll> C(Z);
	vector<ll> AB(max(K,X*Y));
	rep(i, X) {
		cin >> A[i];
	}
	rep(i, Y) {
		cin >> B[i];
	}
	rep(i,Z) {
		cin >> C[i];
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());
	reverse(C.begin(), C.end());
	rep(i, X) {
		rep(j, Y) {
			AB[i * Y + j] = A[i] + B[j];
		}
	}
	if (X * Y < K) {
		for (ll i = X * Y; i < K; i++) {
			AB[i] = 0;
		}
	}
	sort(AB.begin(), AB.end());
	reverse(AB.begin(), AB.end());

	vector<ll> ABC(Z*K);
	rep(i, K) {
		rep(j, Z) {
			ABC[i * Z + j] = AB[i] + C[j];
		}
	}
	sort(ABC.begin(), ABC.end());
	reverse(ABC.begin(), ABC.end());
	rep(i, K) {
		cout << ABC[i] << endl;
	}

}

Measured memory_bytes: 34676
import numpy as np

def tansaku(N, A):
    for i in range(1, 101):
        for j in range(i, 101):
            for k in range(j, 101):
                n = i*i + j*j + k*k + i*j + j*k + k*i
                if(n>N):
                    break;
                if((i==j) and (j==k)):
                    A[n] += 1
                if((i==j) and (j!=k)):
                    A[n] += 3
                if((i!=j) and (j==k)):
                    A[n] += 3
                if((i!=j) and (j!=k)):
                    A[n] += 6
    return A

def main():
    N = int(input())
    A = np.zeros(N+1)
    A = tansaku(N, A)
    for i in range(1,N+1):
        print('{:d}'.format(int(A[i])))


main()


Measured memory_bytes: 27104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long x = Long.parseLong(sc.next());
		long money = 100;
		int year = 0;

		while(money < x){
			money = (long) (money * 1.01);
			year++;				
		}

		System.out.println(year);
	}
}

Measured memory_bytes: 35472
#入力
n, k = map(int, input().split())
rsp_score = list(map(int, input().split()))
rsp = input("")
rsp_order = list(rsp)
t_score = []
t_order = []
#
for i in range(n):
    if rsp_order[i] == "r":
        if i < k:
            t_score.append(rsp_score[2])
            t_order.append("p")

        elif i >= k:
            if rsp_order[i] != rsp_order[i - k] or t_order[i - k] == "c":
                t_score.append(rsp_score[2])
                t_order.append("p")

            else:
                t_score.append(0)
                t_order.append("c")

    elif rsp_order[i] == "s":
        if i < k:
            t_score.append(rsp_score[0])
            t_order.append("r")

        elif i >= k:
            if rsp_order[i] != rsp_order[i - k] or t_order[i - k] == "c":
                t_score.append(rsp_score[0])
                t_order.append("r")

            else:
                t_score.append(0)
                t_order.append("c")

    elif rsp_order[i] == "p":
        if i < k:
            t_score.append(rsp_score[1])
            t_order.append("s")

        elif i >= k:
            if rsp_order[i] != rsp_order[i - k] or t_order[i - k] == "c":
                t_score.append(rsp_score[1])
                t_order.append("s")

            else:
                t_score.append(0)
                t_order.append("c")

print(sum(t_score))


Measured memory_bytes: 5876
import sys
sys.setrecursionlimit(500000)

n = int(input())
mod = 10 ** 9 + 7
node = [[] for _ in range(n)]
memo_f, memo_g = [0] * n, [0] * n
for i in range(n - 1):
    x, y = map(int, input().split())
    node[x - 1].append(y - 1)
    node[y - 1].append(x - 1)

def f(x, prev):
    if memo_f[x]:
        return memo_f[x]
    memo_f[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_f[x] = (memo_f[x] * g(i, x)) % mod
    memo_f[x] = (memo_f[x] + g(x, prev)) % mod
    return memo_f[x]

def g(x, prev):
    if memo_g[x]:
        return memo_g[x]
    memo_g[x] = 1
    for i in node[x]:
        if i == prev:
            continue
        memo_g[x] = (memo_g[x] * f(i, x)) % mod
    return memo_g[x]

print(f(0, -1))

Measured memory_bytes: 101296
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;
int n , k , c;
int t[N] ; 
main(){
	scanf("%lld%lld%lld" , &n , &c , &k);
	rep(i , 1,  n)
		scanf("%lld" , t + i);
	sort(t + 1 , t + 1 + n);
	int ans = 0;
	int l = 1 , r = 1;
	while(1){
		while(r + 1 <= n and t[l] + k >= t[r + 1] and (r + 1 - l + 1) <= c)
			r++;
		ans++;
		l = r + 1;
		r = l;
		if(l > n)ret(ans);
	}
		
}

Measured memory_bytes: 1024
#include<stdio.h>
int main() {
	int a, b, c = 0;
	scanf("%d %d %d", &a, &b, &c);
	a -= b;
	c -= a;
	if (c < 0) {
		c = 0;
	}
	printf("%d\n", c);
	return 0;
}



Measured memory_bytes: 128
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class pole {

		double x;

		double y;

		double r;

		boolean hit;

		pole(int x, int y, int r) {

			this.x = x;

			this.y = y;

			this.r = r;

		}



		pole(pole p, point org) {

			this.x = p.x - org.x;

			this.y = p.y - org.y;

			this.r = p.r;

		}

		

		void rotate(point x1){

			double nx = this.x * x1.norm().x + this.y * x1.norm().y;

			double ny = this.y * x1.norm().x - this.x * x1.norm().y;

			this.x = nx;

			this.y = ny;

			setHit(x1);

		}

		void setHit(point x1){

			double size = x1.abs();

			if(Math.abs(this.y) > this.r + 1e-7 ){ // ~ªÚµÈ¢

				hit = false;

				return;

			}

			if(Math.abs(Math.abs(this.y) - this.r) < 1e-7 ){ // ~ªÚ·é

				if(this.x > 0 && this.x < size){

					hit = true;

				}else{

					hit = false;

				}

				return;

			}

			// ~ªðíéÆ O½ûIÉ±¤

			double amari = Math.sqrt(this.r*this.r - this.y*this.y);

			double x_1 = this.x - amari;

			double x_2 = this.x + amari;

			if(x_1 > 0 && x_1 < size){

				hit = true;

			}else if(x_2 > 0 && x_2 < size){

				hit = true;

			}else{

				hit = false;

			}

		}

	}



	class point {

		double x;

		double y;



		point(int x, int y) {

			this.x = x;

			this.y = y;

		}



		point(point p, point org) {

			this.x = p.x - org.x;

			this.y = p.y - org.y;

		}

		

		double abs(){

			return Math.sqrt(this.x*this.x+this.y*this.y);

		}

		point norm(){

			point ret = new point(0,0);

			ret.x = this.x/abs();

			ret.y = this.y/abs();

			return ret;

		}

	}



	void run() {

		for (;;) {

			int n = sc.nextInt();

			if (n == 0) {

				break;

			}

			pole[] p = new pole[n];

			for (int i = 0; i < n; i++) {

				p[i] = new pole(sc.nextInt(), sc.nextInt(), sc.nextInt());

			}

			int m = sc.nextInt();

			for (int j = 0; j < m; j++) {



				point taro_temp = new point(sc.nextInt(), sc.nextInt());

				point oni_temp = new point(sc.nextInt(), sc.nextInt());



				pole[] p2 = new pole[n];

				point oni = new point(oni_temp, taro_temp);

				boolean bra = false;

				for (int i = 0; i < n; i++) {

					p2[i] = new pole(p[i], taro_temp);

					p2[i].rotate(oni);

					if(p2[i].hit){

						System.out.println("Safe");

						bra = true;

						break;

					}

				}

				if(bra){

					continue;

				}

				System.out.println("Danger");				

			}

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

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

int main() {
    unsigned int n;
    cin >> n;

    vector<unsigned int> a(n), b(n);
    vector<unsigned int> c(n-1);

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

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

    for(unsigned int i = 0; i < n-1; ++i) {
        cin >> c.at(i);
    }

    for(unsigned int i = 0; i < n-1; ++i) {
        if (a.at(i + 1) == 1 + a.at(i)) {
            b.at(a.at(i)-1) += c.at(a.at(i)-1);
        }
    }

    //for(unsigned int i = 0; i < n; ++i ) {
    //    cout << b.at(i) << endl;
    //}

    unsigned int result = 0;
    for(unsigned int i = 0; i < n; ++i) {
        result += b.at(a.at(i)-1);
    }
    cout << result << endl;

}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
a = []
an = [0] * (N + 1)
for i in range(Q):
    a.append(list(map(int, input().split())))

for i in range(len(S) - 1):
    an[i + 1] = an[i]
    if S[i:i + 2] == "AC":
        an[i + 1] += 1
for i in range(Q):
    print(an[a[i][1] - 1] - an[a[i][0] - 1])

Measured memory_bytes: 68440
n,k=map(int,input().split())
s=list(input())*3
p=['A' if s[i]=='B' else 'B' for i in range(n)]*3
head,tail=0,n
if k>2*n:
	k=2*n+k%2
for i in range(k):
	if s[head]=='A':
		s[head],p[head]='B','A'
	else:
		s,p=p,s
		head+=1
		s[tail],p[tail]='A','B'		
		tail+=1
print(''.join(s[head:tail]))

Measured memory_bytes: 69804
import java.util.*;

public class Main{
  
  
  
   public static long kstones(int k,int arr[][]){
	
	 long dp[][]=new long[arr.length][3];
	 
	 
	 
	 for(int i=0;i<3;i++) {
		 dp[0][i]=arr[0][i];
	 }
	    	
	 
	 for(int i=1;i<arr.length;i++) {
		 
		 for(int j=0;j<3;j++) {
			 
			 if(j==0) {
				 dp[i][j]=arr[i][j]+	Math.max(dp[i-1][1],dp[i-1][2]);
			 }
			 
			 
			 if(j==1) {
				 dp[i][j]=arr[i][j]+Math.max(dp[i-1][0],dp[i-1][2]);
			 }
			 
			 if(j==2) {
				 dp[i][j]=arr[i][j]+Math.max(dp[i-1][0],dp[i-1][1]);
			 }
			 
		 }
		 
	 }
	 
//	 
//	 for(int i=0;i<arr.length;i++) {
//			for(int j=0;j<3;j++)
//			{ System.out.print(dp[i][j]+" ");
//	 
//			}System.out.println();
//	 }
//	 
	 long out=Long.MIN_VALUE;
	 for(int i=0;i<3;i++) {
		 
		 
//		 System.out.println(dp[arr.length-1][i]);
		 
		 
		 out=Math.max(out,dp[arr.length-1][i]);
	 }
	    	
	    	return out;
	    }
	    
	    
	    
		  
		    
	    
	    
	    
	    
	    
	    
	   
public static void main(String[]args) {
	Scanner s=new Scanner(System.in);
	
	int n=s.nextInt();
	
	int dp[][]=new int[n][3];
	
	for(int i=0;i<n;i++) {
		for(int j=0;j<3;j++)
		{
			dp[i][j]=s.nextInt();
			
		}
	
	
	
	}

System.out.println(kstones(3,dp));
}
	   

}

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

int main(){
	//宣言
	int ans=0;	
	int a,p;

	//入力
	cin >> a >> p;

	//計算
	ans = (a*3+p)/2;

	//出力
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//written by Aman Mishra(aspro)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,s,e) for(ll i=s;i<=e;i++)
#define aspro ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define pii pair<int,int>
#define INF 10000000000000
#define MOD 1000000007
#define N 2050
#define test int t;cin>>t;while(t--)
/*int histogram(int arr[],int n)
{
    f(j,1,n) cout<<arr[j]<<" ";cout<<endl;
    while(!s.empty()) s.pop();
    int i=1;int ans=0,area,top,ptop;
    while(i<=n)
    {
        if(s.empty() or arr[i]>=arr[s.top()])
        {
            s.push(i++);
            //i++;
        }
        else if(arr[i]<arr[s.top()])
        {
            top=s.top();
            s.pop();
            if(s.empty())    area=arr[top]*(i-1);
            else
            {
                ptop=s.top();
                area=arr[top]*(i-ptop-1);
            }
            ans=max(ans,area);
        }
    }
    while(!s.empty())
    {
        top=s.top();
        s.pop();
        if(s.empty())   area=arr[top]*(i-1);
        else
        {
            ptop=s.top();
            area=arr[top]*(i-ptop-1);
        }
         ans=max(ans,area);
    }
    //cout<<"returning  "<<ans<<endl;
    return ans;//cout<<ans<<endl;
}*/
string mat[N];
int s[N],parent[N],sz[N],ans,cnt,in[N];
vector<pii> vec;
int n,m;
int findset(int x)
{
    //cout<<"aman\n";
	//return x==parent[x]?x:parent[x]=findset(parent[x]);
	while(x!=parent[x])
        x=parent[x];
    return parent[x];
}
void union1(int x,int y)
{
	int p1=findset(x);
	int p2=findset(y);
	if(p1==p2) return ;
	parent[p1]=p2;
	sz[p2]+=sz[p1];
}
void findans()
{
	vec.clear();
	f(i,1,m-1) vec.pb({s[i],i});
	sort(vec.begin(),vec.end(),greater<pii>() );
    /*int si=vec.size();
    cout<<"sorted :\n";
    f(i,0,si-1)
    {
        cout<<i<<" "<<v[i].first<<" "<<v[i].second<<endl;
    }*/
    f(i,0,m-1) parent[i]=i;
    f(i,0,m-1) sz[i]=1;
	++cnt;
	for(auto it:vec)
	{
		int x=it.second;
		in[x]=cnt;
		if(in[x-1]==cnt) union1(x-1,x);
		if(in[x+1]==cnt) union1(x+1,x);
		ans=max(ans,  it.first*(sz[findset(x)]+1 ));
	}
}
int main()
{
    aspro
    cin>>n>>m;
    f(i,0,n-1) cin>>mat[i];
    ans=max(n,m);
    f(i,1,m-1) s[i]=1;
    f(i,1,n-1)
    {
    	f(j,1,m-1)
    	{
    		int x=(mat[i][j]==mat[i][j-1])?1:0 ;
    		int y=(mat[i-1][j]==mat[i-1][j-1])?1:0 ;
    		if(x==y) s[j]++;
    		else s[j]=1;
    	}
    	//f(j,0,m) cout<<s[j]<<" ";cout<<endl;
    	findans();
        //cout<<i<<" --- "<<ans<<endl;
    	//ans=max(ans,histo(s,m));
    }
    cout<<ans<<endl;
}
/*
10 8
##...#.#
##...#.#
..###.#.
#.##.#.#
.#..#.#.
..##.#.#
##.#.#..
...#.#..
###.#.##
###..###
*/


Measured memory_bytes: 4608
from math import cos, sqrt, radians

A, B, H, M = [int(i) for i in input().split()]
time = 60*H + M
hoge = time * 0.5 - 6*M
d = min(abs(hoge), abs(360-hoge))

c = cos(radians(d))

res = sqrt(-(c*2*A*B-A**2-B**2))
print(res)

Measured memory_bytes: 9504
N,M,X,Y = map(int, input().split())
num_list = [list(map(int, input().split())) for _ in range(2)]

Z = list(range(X+1,Y+1))

for z in Z:
    if max(num_list[0]) < z and min(num_list[1]) >= z:
        print('No War')
        break
    if z == Z[-1]:
        print('War')

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
		
    public void solve(){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int hozon;
		
		if(a > b){
			hozon = a;
			a = b;
			b = hozon;
		}
		if(b > c){
			hozon = b;
			b = c;
			c = hozon;
		}
		if(a > b){
			hozon = a;
			a = b;
			b = hozon;
    	}
		
		System.out.println(a +" "+ b +" "+ c);
		
    }
		
		
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17160
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int length;
    string str;

    cin >> length >> str;

    if(length % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    int sub_length = length / 2;

    string former = str.substr(0, sub_length);
    string latter = str.substr(sub_length);

    if(former.compare(latter)){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted([-x for x in map(int, input().split())])
B = sorted([-x for x in map(int, input().split())])
C = sorted([-x for x in map(int, input().split())])

check = set()  # priority queueに入れたかどうかを管理する

heap = []
heapq.heappush(heap, (A[0] + B[0] + C[0], 0, 0, 0))
check.add((0, 0, 0))

for i in range(K):
    s, a, b, c = heapq.heappop(heap)
    print(-s)
    if a + 1 < X and (a + 1, b, c) not in check:
        heapq.heappush(heap, (A[a + 1] + B[b] + C[c], a + 1, b, c))
        check.add((a + 1, b, c))
    if b + 1 < Y and (a, b + 1, c) not in check:
        heapq.heappush(heap, (A[a] + B[b + 1] + C[c], a, b + 1, c))
        check.add((a, b + 1, c))
    if c + 1 < Z and (a, b, c + 1) not in check:
        heapq.heappush(heap, (A[a] + B[b] + C[c + 1], a, b, c + 1))
        check.add((a, b, c + 1))



Measured memory_bytes: 4976
#include "bits/stdc++.h"
using namespace std;

bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) return false;
	}
	return n != 1;  // 1の場合は例外
}

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];

	int cnt=0;
	for (int i = 0; i < n; i++) {
		if(is_prime(a[i])) cnt++;
	}

	cout << cnt << endl;
}
	



Measured memory_bytes: 3100
program main
  
  implicit none
  integer(8) :: n, ans, i
  
  read(*,*) n
  
  ans = 0 
  do i = 1, n
    if( mod(i,3) == 0 .and. mod(i,5) == 0 ) then
    else if( mod(i,3) == 0 ) then
    else if( mod(i,5) == 0 ) then
    else
      ans = ans + i
    end if
  end do

  print*, ans 
   
end program main


Measured memory_bytes: 2792
N,P = map(int,input().split(" "))
S = input()
ans = 0
if P in [2,5]:
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
else:
    lis = [0 for _ in range(N+1)]
    ten = 1
    for i in reversed(range(N)):
        tmp = int(S[i])*ten%P
        lis[i] = (lis[i+1]+tmp)%P
        ten *= 10
        ten %= P
    cnt = [0 for _ in range(P)]
    for i in reversed(range(N+1)):
        ans += cnt[lis[i]]
        cnt[lis[i]] += 1

print(ans)  

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string s, std::string t)
{
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    cout << ((s < t) ? "Yes" : "No") << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		
		int[] i = {P,Q,R};
		Arrays.sort(i);
		System.out.println(i[0] + i[1]);
		
		sc.close();
		
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
//cin>>str;
//cout<<str<<endl;
  cin>>N;
  if(N%10==3){
    cout<<"bon";
  }else if(N%10==0||N%10==1||N%10==6||N%10==8){
    cout<<"pon";
  }else{
    cout<<"hon";
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n ; cin >> n;
    vector<ll> prime(55555,1);
    prime.at(0) = 0;
    prime.at(1) = 0;
    prime.at(2) = 1;
    for(int i=2;i<=55554;i++){
        if(!prime.at(i)) continue;
        ll x = i;
        while(true){
            x+=i;
            if(x>55554) break;
            prime.at(x) = 0;
        }
    }
    //prvec(prime);
    ll cnt = 0;
    rep(i,55554){
        if(i%5!=1) continue;
        if(prime.at(i)){
            cout << i;
            cnt++;
        }else{
            continue;
        }
        if(cnt==n) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	if(400 <= n && n <= 599) puts("8");
	if(600 <= n && n <= 799) puts("7");
	if(800 <= n && n <= 999) puts("6");
	if(1000 <= n && n <= 1199) puts("5");
	if(1200 <= n && n <= 1399) puts("4");
	if(1400 <= n && n <= 1599) puts("3");
	if(1600 <= n && n <= 1799) puts("2");
	if(1800 <= n && n <= 1999) puts("1");
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define int long long
int h;
void maxHeapify(int *A,int i) {
	int l=i*2+1;
	int r=i*2+2;
	int largest;
	if(l<h&&A[l]>A[i]) largest=l;
	else largest=i;
	if(r<h&&A[r]>A[largest]) largest=r;
	if(largest!=i) {
		swap(A[i],A[largest]);
		maxHeapify(A,largest);
	}
}
void buildMaxHeap(int *A) {
	for(int i=h/2; i>=0; i--)
		maxHeapify(A,i);
}
signed main() {
	cin>>h;
	int A[h];
	for(int i=0; i<h; i++) cin>>A[i];
	buildMaxHeap(A);
	for(int i=0; i<h; i++) cout<<" "<<A[i];
	cout<<endl;
	return 0;
}


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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int h,w,d;
  cin>>h>>w>>d;
  vector<vector<int>> a(h, vector<int>(w, 0));
  vector<ii> f(h*w+1);
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      int t;cin>>t;
      a[i][j]=t;
      f[t] = make_pair(i,j);
    }
  }
  int q; cin>>q;
  vector<ll> memo(h*w+1,0);
  for (int i=d+1; i<=h*w; i++) {
    memo[i] = memo[i-d]+abs(f[i].first-f[i-d].first)+abs(f[i].second-f[i-d].second);
  }
  vector<ll> ans(q,0);
  for (int i=0; i<q; i++) {
    int l,r;
    cin>>l>>r;
    ans[i] = memo[r]-memo[l];
  }
  for (int i=0; i<q; i++) {
    cout << ans[i] << endl;
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 10004
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
void solve()
{

    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = x;
    ll t = x * x;
    ll c = 0;
    map<ll, ll> mp;
    n--;
    ll s[m + 1];
    mem0(s);
    ll tans = 0;
    ll tmp;
    for (ll i = 1; i <= m + 1; i++)
    {
        ll md = t % m;
        if (!mp.count(md))
        {
            tans += md;
            t = md * md;
        }
        else
        {
            c = i - mp[md];
            tmp = mp[md];
            break;
        }
        mp[md] = i;
        s[i] = tans;
    }
    if (mp.count(0))
    {
        ans += tans;
        cout << ans << endl;
        return;
    }
    tmp--;
    n -= tmp;
    ll div = n / c;
    ll md = n % c;
    ans += (div * (s[c + tmp] - s[tmp]));
    ans += s[tmp];
    ans += s[tmp + md] - s[tmp];
    cout << ans << endl;
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {

        solve();
    }

    return 0;
}

Measured memory_bytes: 7416
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (long n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		String str=scan.next();
		if(str.equals("AKIHABARA")) {
			System.out.println("YES");
		}else if(str.equals("AKIHABAR")) {
			System.out.println("YES");
		}else if(str.equals("AKIHABRA")) {
			System.out.println("YES");
		}else if(str.equals("AKIHBARA")) {
			System.out.println("YES");
		}else if(str.equals("KIHABARA")) {//ここまでがAが一つない場合
			System.out.println("YES");
		}else if(str.equals("AKIHABR")) {
			System.out.println("YES");
		}else if(str.equals("AKIHBAR")) {
			System.out.println("YES");
		}else if(str.equals("KIHABAR")) {
			System.out.println("YES");
		}else if(str.equals("AKIHBRA")) {
			System.out.println("YES");
		}else if(str.equals("KIHABRA")) {
			System.out.println("YES");
		}else if(str.equals("KIHBARA")) {//2つ
			System.out.println("YES");
		}else if(str.equals("AKIHBR")) {
			System.out.println("YES");
		}else if(str.equals("KIHABR")) {
			System.out.println("YES");
		}else if(str.equals("KIHBAR")) {
			System.out.println("YES");
		}else if(str.equals("KIHBRA")) {//3つ
			System.out.println("YES");
		}else if(str.equals("KIHBR")) {//4つ
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23764
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

fn main() {
    // bufの準備
    let mut buf = String::new();

    // 標準入力から1行読み込む
    std::io::stdin().read_line(&mut buf).unwrap();

    // aの設定
    let a: usize = buf.trim().parse().unwrap();

    if a >= 3200 {
        buf.clear();
        std::io::stdin().read_line(&mut buf).unwrap();
        println!("{}", buf.trim());
    } else {
        println!("red");
    }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } 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; }

void solve() {
  int r; cin >> r;
  cout << 3 * r * r << '\n';
}


Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }

/*****/

void Main()
{
	vector<vector<int>> G{
		{1,3,5,7,8,10,12},
		{4,6,9,11},
		{2},
	};
	int x, y;
	std::cin >> x >> y;
	int gx, gy;
	rep(i, 3)
	{
		if (exist_in(G[i], x))
			gx = i;
	}
	rep(i, 3)
	{
		if (exist_in(G[i], y))
			gy = i;
	}
	cout << (gx == gy ? "Yes" : "No");
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    min_len = 0
    if float.is_integer(N ** 0.5):
        print(len(str(int(N ** 0.5))))
        return
    A = int(N ** 0.5) + 1
    for a in range(A, 0, -1):
        if N % a == 0:
            print(len(str(N // a)))
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int make_gcd(int x,int y){
    if(x>y)swap(x,y);
    if(x==y||x==0) return y;
    return make_gcd(y%x,x);
}
int main(void){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int r[n],l[n],m[n];
    for(int i=0;i<n;i++){
        if(i==0)r[i]=0;
        else{
            r[i]=make_gcd(r[i-1],a[i-1]);
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1)l[i]=0;
        else{
            l[i]=make_gcd(l[i+1],a[i+1]);
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        m[i]=make_gcd(r[i],l[i]);
        res=max(m[i],res);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
lis = ['' for _ in range(len(t))]
ans = 0

for i in range(k):
  if t[i] == 'r':
    ans += p
    lis[i] = 'p'
  elif t[i] == 'p':
    ans += s
    lis[i] = 's'
  else:
    ans += r
    lis[i] ='r'
    
for j in range(k,len(t)):
  if t[j] == 'p' and lis[j-k] != 's':
    ans+=s
    lis[j] = 's'
  elif t[j] == 'p' and lis[j-k] == 's':
    lis[j] = 'katenai'

    
  elif t[j] == 's' and lis[j-k] != 'r':
    ans+=r
    lis[j] = 'r'

  elif t[j] == 's' and lis[j-k] == 'r':
    lis[j] = 'katenai'

    
  elif t[j] == 'r' and lis[j-k] != 'p':
    ans+=p
    lis[j] = 'p'

  elif t[j] == 'r' and lis[j-k] == 'p':
    lis[j] = 'katenai'
      

print(ans)

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		1010101010
#define MINF		-2000000007
#define MAX 		200050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int N,A,B,C;
V L(10);
int dfs(int cur,int a,int b,int c){
	if(cur == N)
		return (min(a,min(b,c)) > 0 ? abs(A-a)+abs(B-b)+abs(C-c)-30 : INF);
	int ret0 = dfs(cur+1,a,b,c);
	int ret1 = dfs(cur+1,a+L[cur],b,c)+10;
	int ret2 = dfs(cur+1,a,b+L[cur],c)+10;
	int ret3 = dfs(cur+1,a,b,c+L[cur])+10;
	return min(min(ret0,ret1),min(ret2,ret3));
}

//
int main(){
	// 入力
	cin >> N >> A >> B >> C;

	REP(i,N)cin>>L[i];

	cout << dfs(0,0,0,0) << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << (d1 > d2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;
#define rep(i, n) for(int i = 0; i < int(n); i++)

signed main(){
	int n, ans = 0; cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i], ans += b[i];
	rep(i, n - 1) cin >> c[i];
	rep(i, n - 1){
		if(a[i] == a[i + 1] - 1) ans += c[a[i] - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,bool>h;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	string a;
	while(n--)
	{
		cin>>a;
		if(!h[a])
		{
			h[a]=1;
			ans++;
		}	
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19180
import sys
import math
N, D = map(int, input().split())
XY = [list(map(int, sys.stdin.readline().split())) for i in range(N)]
ans = 0
for i in XY:
    x, y = i
    if math.sqrt(x ** 2 +  y ** 2) <= D:
        ans += 1
print(ans)

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

class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, A):
        if self.parent[A] == A:
            return A
        self.parent[A] = self.root(self.parent[A]) #経路縮約
        return self.parent[A]

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        self.parent[A] = B
        
uni1 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    if uni1.root(p-1) != uni1.root(q-1):
        uni1.connect(p-1,q-1)

uni2 = UnionFind(N)
for _ in range(L):
    r, s = map(int, input().split())
    if uni2.root(r-1) != uni2.root(s-1):
        uni2.connect(r-1,s-1)

# print (uni1.parent)
# print (uni2.parent)

ans = dict()
key_list = []
for i in range(N): #各都市を検索
    root1 = uni1.root(i) #都市の親を探す
    root2 = uni2.root(i)
    key = str(root1) + '_' + str(root2) #2つの親を連結したものをkeyとする
    key_list.append(key) #リストにkeyを足しておく(=i番目の都市が属するグループとして前からメモ)
    if key in ans.keys(): #dict andに親の組を記録していく
        ans[key] += 1
    else:
        ans[key] = 1
    
for i in range(N):
    print (ans[key_list[i]], end = ' ') #i番目の都市の親の組はkeyで読み出せる
print ()






# for i in range(1, N+1):
#     ans = 0
#     for j in range(1, N+1):
#         # print (uni1.root(i), uni1.root(j), uni2.root(i), uni2.root(j))
#         if uni1.root(i) == uni1.root(j) and uni2.root(i) == uni2.root(j):
#             ans += 1
#     print (ans, end = ' ')
print ()

# print (uni1.parent)
# print (uni2.parent)


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

using namespace std;

const int N = 125;

int a[N*2];

void solve() {
    int n; cin >> n;
    auto q = [&](int x){
        cout << "? ";
        for (int i = 0; i < n; i++) {
            cout << x+i << ' ';
        }
        cout << endl;
        string s; cin >> s;
        return s[0] == 'R';
    };
    a[1] = q(1); a[n+1] = a[1]^1;
    int l = 1, r = n+1;
    while (r-l > 1) {
        int m = (r+l)/2;
        a[m] = q(m);
        if (a[m] == a[l]) {
            l = m;
        } else {
            r = m;
        }
    }
    assert(r-l == 1);
    assert(a[l] != a[r]);
    a[l+n] = a[r];

    auto qoth = [&](int x){
        cout << "? ";
        cout << x << ' ';
        for (int i = l+1; i < l+n; i++) {
            cout << i << ' ';
        }
        cout << endl;
        string s; cin >> s;
        return s[0] == 'R';
    };
    for (int i = 1; i <= 2*n; i++) {
        if (i < l || i > l+n) {
            a[i] = qoth(i);
        }
    }

    int m = (n-1)/2;
    int cnt[2] = {m,m};
    vector<int> pos;
    for (int i = 1; i <= 2*n; i++) {
        if (i <= l || i >= l+n) {
            if (cnt[a[i]] > 0) {
                pos.push_back(i);
                cnt[a[i]]--;
            }
        }
    }

    auto qin = [&](int x){
        cout << "? ";
        cout << x << ' ';
        for (int i: pos) {
            cout << i << ' ';
        }
        cout << endl;
        string s; cin >> s;
        return s[0] == 'R';
    };
    for (int i = 1; i <= 2*n; i++) {
        if (l < i && i < l+n) {
            a[i] = qin(i);
        }
    }
    string res;
    for (int i = 1; i <= 2*n; i++) {
        char x = a[i]?'R':'B';
        res += x;
    }
    cout << "! ";
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    if(A+B >= C*2){
        if(X >= Y){
            if(C*2*Y + A*(X-Y) <= C*2*X) cout << C*2*Y + A*(X-Y) << endl;
            else cout << C*2*X << endl;
        }
        else{
            if(C*2*X + B*(Y-X) <= C*2*Y) cout << C*2*X + B*(Y-X) << endl;
            else cout << C*2*Y << endl;
        }
    }
    else cout << A*X + B*Y << endl;
}


Measured memory_bytes: 256