akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ld>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;
#include <iomanip>

int main(int argc, char const *argv[]) {
  ld n;std::cin >> n;
  vll t(n), v(n+1, 0), u(40002, 0);
  re(i, n) {
    std::cin >> t[i];
    if(i>=1) t[i] += t[i-1];
  }
  re(i, n) std::cin >> v[i];
  ld ans = 0;
  re(i, n){
    for(ld j=(i==0?0:t[i-1])+0.5;j<=t[i];j+=0.5){
      for(ld k=-0.5;k<=0.5;k+=0.5){
        ld tmp = u[j*2-1]+k;
        bool e = true;
        for(ld l=i+1;l<=n;l++) {
          //if(j==70.5) std::cout << (tmp-v[l]) << " " << (t[l-1]-j) << '\n';
          if((tmp-v[l])>(t[l-1]-j)) e = false;
        }
        if(tmp<=v[i]&&e) u[j*2] = tmp;
      }
      //if(j==70.5) std::cout << u[j*2-1] << " " << u[j*2] << '\n';
      if(u[j*2]==u[j*2-1]) ans += u[j*2]/2;
      else if(u[j*2]==u[j*2-1]-0.5) ans+=(u[j*2]/2)+0.125;
      else ans+=(u[j*2-1]/2)+0.125;
      //std::cout << "now" <<j << " " << ans << '\n';
    }
  }
  std::cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}


Measured memory_bytes: 1144
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pdd pair<d,d>
#define pdp pair<d,pdd>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    SPEED

    int n,k;
    cin>>n>>k;
    int h[n+1],dp[n+1]={0},i,j;
    for(i=1;i<=n;++i)
        cin>>h[i];
    for(i=2;i<=n;++i)
    {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(j=i-2;j>=max(1LL,i-k);--j)
        {
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n];


    return 0;
}


Measured memory_bytes: 1792
# include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int o=a-1;
int y =b-1;
int h = max(a,b);
int u=max(o,b);
int n =max (y ,a);
if (a>b && u==o ){
    cout<<a+o;
}
else if (b>a && n==y){
    cout<<b+y;
}
else if (a==b){
    cout<<a+b;
}
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
mod=10**9+7
A=1
for i in range(n,n-a,-1):
    A*=i
    A%=mod
y=1
for i in range(1,a+1):
    y*=i
    y%=mod
A*=pow(y,10**9+5,mod)
A%=mod
B=1
for i in range(n,n-b,-1):
    B*=i
    B%=mod
y=1
for i in range(1,b+1):
    y*=i
    y%=mod
B*=pow(y,10**9+5,mod)
B%=mod


print((pow(2,n,mod)-1-A-B)%mod)


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    //IOS;
    //ll t;cin>>t;while(t--)
    {
        ll x,a,b,c,d,i,j,k,l,m,n,sum=0,temp=0,f=0,cnt=0,t;
        string s;
        cin>>s;
        for(i=0;i<s.length();i++)
        {
            sum+=(s[i]-'0');
        }
        if(sum%9==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3692
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read


#n,k,*p = [int(i) for i in read().split()]
s,t,a,b,u = read().split()

a,b = int(a),int(b)

if s==u:
    print(a-1,b)
else:
    print(a,b-1)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int N;
    cin >> N;
    int x = 0;//4n
    int y = 0;//2n
    int z = 0;//odd

    REP(i,0,N){
        int tmp;
        cin >> tmp;
        if(tmp % 4 == 0){
            x++;
        }else if( tmp % 2 == 0){
            y++;
        }else{
            z++;
        }
    }

    if(y >= 1) z++;
    if(x + 1 >= z){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}


Measured memory_bytes: 256
import java.io.*;
import java.text.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		char  s[] = sc.nextLine().toCharArray();
		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			switch (s[i])  {

			case 'A':
			case 'G':
			case 'C':
			case 'T':
				count++;
				break;
			default : 
				max = max < count ? count : max;
				count = 0;
				break;
			}
				
		}
		max = max < count ? count : max;
		System.out.println(max);
		
		/*int N = sc.nextInt();
		int Q = sc.nextInt();
		String str = sc.nextLine();
		 str = sc.nextLine();

		String msg = "";
		int stArr[] = new int[Q];
		int endArr[] = new int[Q];

		Scanner sc3 = new Scanner(System.in);
		for (int i = 0; i < Q; i++) {
			stArr[i] = sc3.nextInt();
			endArr[i] = sc3.nextInt();
		}
		
		for (int i = 0; i < Q; i++) {
			String s = str.substring(stArr[i] - 1, endArr[i] - 1);
			int count = 0;
			for (int j = 0; j< s.length() - 1; j++) {
				if (s.substring(j, j + 1) == "AC") {
					count++;
				}
			}
			System.out.println(count);
		}
		*/
	}
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}


int main(void){
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    rep(i,0,m)cin>>a[i];
    int ret=accumulate(a.begin(),a.end(),0);
    cout<<max(-1,n-ret)<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 998244353;
ll inf = 1e18;
int main(){

    int n,k;
    cin >> n >> k;
    vector<int> l(k),r(k);
    vector<ll> f(2*n+5),a(2*n+5);
    vector<bool> num(2*n+5);
    rep(i,k){
        cin >> l[i] >> r[i];
        for(int j=l[i]; j<=r[i]; j++) num[j]=true;
    }

    a[0]=0; f[0]=0;
    rep2(i,1,n){
        if(num[i]){
            a[i]++;
            a[i+1]--;
        }
        f[i]=f[i-1]+a[i];
        f[i]%=mod;
        rep(j,k){
            a[i+l[j]]+=f[i];
            a[i+l[j]]%=mod;
            a[i+r[j]+1]-=f[i];
            a[i+r[j]+1]=(a[i+r[j]+1]+mod)%mod;
        }
    }
    // rep2(i,1,n) cout << i << ' ' << a[i] << ' ' << f[i] << endl;
    cout << f[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 9596
#include <iostream>

using namespace std;
int main(){
  int x, y ,z ,k = 0, q = 0;
  cin >> x >> y >> z;
for (int i = 0; i < 3;i++)
  {
	k = x;
	x = y;
	y = k;
}
for (int i = 0; i < 3;i ++)
{
	q = x;
	x = z;
	z = q;
}
  cout << x << " " << y << " " << z;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#define MAX 200010
typedef long long ll;
ll N,K,A[MAX];
ll loop_start=0,loop_end=0;
bool bit[MAX]={false};
ll memo[MAX];

void solve(ll town){
    bit[town] = true;
    memo[++loop_end] = town;
    if(bit[A[town]] == true){
        for(ll i=1;i<=loop_end;i++){
            if(memo[i] == A[town]){
                loop_start = i;
            }
        }
    }
    else solve(A[town]);
}
int main(){
    scanf("%lld %lld",&N,&K);
    for(ll i=1;i<=N;i++)
        scanf("%lld",A+i);
    solve(1);

  /*
    printf("%lld %lld\n",loop_start,loop_end);
    for(int i=1;i<=loop_end;i++){
        printf("%lld ",memo[i]);
    }
    printf("\n");
    */
  
    //printf("%lld %lld %lld\n", loop_start, loop_end , K);
    if(K < loop_start) printf("%lld",memo[K + 1]);
    else
        printf("%lld",memo[loop_start + (K-loop_start+1)%(loop_end-loop_start+1)]);
}



Measured memory_bytes: 5008
#include <stdio.h>

void insertionsort(int* A, int n){
  int i, j;
  for(i = 1; i < n; i++){
    int k;
    for(k = 0; k < n; k++){
      printf("%d", A[k]);
      if(k == n-1) printf("\n");
      else printf(" ");
    }
    j = i-1;
    while(j >= 0){
      if(A[j] > A[j+1]){
        int tmp = A[j+1];
        A[j+1] = A[j];
        A[j] = tmp;
        j--;
      }else{
        break;
      }
    }
  }
}

int main(void){
  int i;
  int n;
  int A[100];
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);

  insertionsort(A, n);

  for(i = 0; i < n-1; i++) printf("%d ", A[i]);
  printf("%d\n", A[n-1]);
  return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
int mod=1000000007;
long long t[900000];
long long maxa=0;
void update(int x,long long val,int tl,int tr,int v){
	if(tl==tr){
		t[v]=max(t[v],val);return;
	}
	int g=tl+(tr-tl)/2;
	if(g>=x){
		update(x,val,tl,g,2*v);
	}else{
		update(x,val,g+1,tr,2*v+1);
	}
	t[v]=max(t[v*2],t[2*v+1]);
}
long long query(int x,int tl,int tr,int v){
	if(tl>x){
		return 0;
	}
	if(tl>=0&&tr<=x){
		return t[v];
	}
	int g=tl+(tr-tl)/2;
	return max(query(x,tl,g,2*v),query(x,g+1,tr,2*v+1));
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin>>n;
	long long h[n],a[n];
	vector<long long> temp;
	for(int i=0;i<n;i++){
		cin>>h[i];
		temp.push_back(h[i]);
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(temp.begin(),temp.end());
	int idx[n];
	for(int i=0;i<n;i++){
		idx[i]=lower_bound(temp.begin(),temp.end(),h[i])-temp.begin();
	}
	memset(t,0,sizeof(t));
	for(int i=0;i<n;i++){
		int l=idx[i];
		//cout<<l<<" ";
		if(l==0){
			maxa=max(maxa,a[i]);
			update(l,a[i],0,n-1,1);
		}else{
			long long f=query(l-1,0,n-1,1);
			maxa=max(maxa,f+a[i]);
			update(l,f+a[i],0,n-1,1);
		}
	}
	cout<<maxa;
}

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

class items{
 public:   
    int val;
    int wei;
};
int main(){
    int N,W;
    cin>>N>>W;
    vector<items>item(N);
    rep(i,N)cin>>item[i].val>>item[i].wei;
    vector<vector<int> > c(N,vector<int>(W+1));
    rep(w,W+1){
        if(item[0].wei>w)c[0][w]=0;
        else c[0][w]=item[0].val;
    }
    for(int n=1;n<N;n++){
        for(int w=0;w<=W;w++){
            if(w-item[n].wei>=0){
                c[n][w]=max(c[n-1][w],c[n-1][w-item[n].wei]+item[n].val);
            }else c[n][w]=c[n-1][w];
        }
    }
    cout<<c[N-1][W]<<endl;
    /*rep(i,N){
        rep(j,W+1){
        cout<<"c["<<i<<"]["<<j<<"]"<<c[i][j]<<endl;
        }
    }*/
}


Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

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

  ll c1 = 0;
  bool f1 = false;
  REP(i, n) {
    if (s[n - 1 - i] == 'R') f1 = true;
    if (s[n - 1 - i] == 'W' && f1) c1++;
  }
  ll rc = 0;
  REP(i,n){
    if (s[i] == 'R') rc++;
  }

  ll c2 = 0;
  REP(i, n) {
    if (s[i] == 'R' && i >= rc) c2++;
  }
  cout << min(c1,c2) << "\n";
  return 0;
}


Measured memory_bytes: 3720
// https://atcoder.jp/contests/abc151/tasks/abc151_f
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// https://kmjp.hatenablog.jp/entry/2020/01/13/1030

void solve() {
    int N;
    cin >> N;
    vector<complex<double>> v;
    REP(i, N) {
        double x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    double ret = 1e9;
    const auto hoge = [&](complex<double> a) {
        double r = 0;
        for (auto &x : v) {
            r = max(r, abs(x - a));
        }
        ret = min(ret, r);
    };

    REP(z, N) REP(y, z) {
        // 2点間の中心からの距離最大値で更新
        double rx = (v[y].real() + v[z].real()) * 0.5;
        double ry = (v[y].imag() + v[z].imag()) * 0.5;
        hoge({rx, ry});

        // 3点を頂点とする三角形の外心からの距離最大値で更新
        REP(x, y) {
            double a = abs(v[y] - v[z]);
            double b = abs(v[z] - v[x]);
            double c = abs(v[x] - v[y]);

            // 三角形の最長の辺 = それ以外の2辺の和なら三角形が作れない
            if (abs(a + b - c) < 1e-9)
                continue;
            if (abs(a + c - b) < 1e-9)
                continue;
            if (abs(c + b - a) < 1e-9)
                continue;

            // 外心の中心座標を求める
            double rx = (a * a * (b * b + c * c - a * a) * v[x].real() +
                         b * b * (a * a + c * c - b * b) * v[y].real() +
                         c * c * (b * b + a * a - c * c) * v[z].real()) /
                        (a * a * (b * b + c * c - a * a) +
                         b * b * (a * a + c * c - b * b) +
                         c * c * (b * b + a * a - c * c));
            double ry = (a * a * (b * b + c * c - a * a) * v[x].imag() +
                         b * b * (a * a + c * c - b * b) * v[y].imag() +
                         c * c * (b * b + a * a - c * c) * v[z].imag()) /
                        (a * a * (b * b + c * c - a * a) +
                         b * b * (a * a + c * c - b * b) +
                         c * c * (b * b + a * a - c * c));
            hoge({rx, ry});
        }
    }
    cout << fixed << setprecision(12) << ret << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3752
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(){
    int N,D,X;
    int sum=0;
    scanf("%d%d%d",&N,&D,&X);
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<N;i++){
        for(int j=0;1+j*a[i]<=D;j++){
            sum++;
        }
    }
    printf("%d",sum+X);
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()

{

	string s;
	int start_index,last_index;
	cin>>s;
	for(int i=0;i<s.size();i++)

	{
		if(s[i]=='A')
		{
			start_index=i;
			break;
		}
	}

		for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='Z')
		{
          last_index=i;
          break;
		}
	}
	cout << last_index-start_index+1<<"\n";



}


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


struct edge{ ll to,cost; };
vector<edge> G[510];
ll d[510][510];

void dijkstra(ll s){
    fill(d[s],d[s]+510,inf);
    d[s][s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[s][v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[s][e.to]>d[s][v]+e.cost){
                    d[s][e.to]=d[s][v]+e.cost;
                    que.push(l_l(d[s][e.to],e.to));
                }
            }
        }
    }
}

vector<vector<ll>> K;

vector<ll> Desk;
bool Bol[1000];
ll Counter;
void Rep(ll x){
    if(Desk.size()==x){
        K.pb(Desk);
        Counter++;
        return ;
    }
    rep(i,0,x-1){
        if(!Bol[i]){
            Desk.pb(i);Bol[i]=true;
            Rep(x);
            Desk.pop_back();Bol[i]=false;
        }
    }
}


int main(){
    ll n,m,R;cin>>n>>m>>R;
    ll r[R];
    rep(i,0,R-1)cin>>r[i];
    ll a,b,c;
    edge e;
    rep(i,0,m-1){
        cin>>a>>b>>c;
        e.to=b;
        e.cost=c;
        G[a].pb(e);
        e.to=a;
        G[b].pb(e);
    }
    rep(i,1,n){
        dijkstra(i);
    }
    Rep(R);
    ll sum=0;
    ll ans=inf;
    vector<ll> vv;
    rep(i,0,K.size()-1){
        sum=0;
        vv=K[i];
        rep(j,0,R-2){
            sum+=d[r[vv[j]]][r[vv[j+1]]];
        }
        ans=min(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5944
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())

ss = []
for i in range(n):
	s = list(input())
	s.sort()
	ss.append("".join(s))

cs = collections.Counter(ss)
l = list(cs.values())
l.sort(reverse=True)

c = 0
for i in l:
	if i > 1:
		c+= cmb(i,2)
	elif i == 1:
		print(int(c))
		exit()
print(int(c))

Measured memory_bytes: 20016
s = input()

maxx = 0
count = 0
data = ["A","C","T","G"]
for i in range(len(s)): # i == 先頭の文字
    for j in range(i,len(s)): # j == 動かす文字
        if s[j] in data:
          count += 1
        else:
          break
    if maxx < count :
        maxx = count
    count = 0

print(maxx)


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  long long int a,b,k,i;
  scanf("%lld%lld%lld",&a,&b,&k);
  if(a>k)
    printf("%lld %lld\n",a-k,b);
  else if(a+b>k)
    printf("0 %lld\n",a+b-k);
  else
    printf("0 0\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <vector>
//#include <iostream>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

struct Edge {
    int to;
    int cost;
};

const int MAXV = 100010;
const int INF = 1001001001;

int V, E, r;
vector<vector<Edge>> g(MAXV);

void dijkstra() {
    vi d(V, INF);
    d[r] = 0;

    // int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義する場合
    priority_queue<P, vector<P>, greater<P>> q;
    q.push({r, 0});

    while(!q.empty()) {
        auto p = q.top(); q.pop();

        int from = p.first;

        rep(i, g[from].size()) {
            auto v = g[from][i];
            int to = v.to;
            int cost = v.cost;

            if(d[to] > d[from] + cost){
                d[to] = min(d[to], d[from] + cost);
                q.push({to, d[to]});
            }
        }
    }

    rep(i, V) {
        if(d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}

int main() {
    cin >> V >> E >> r;
    rep(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back(Edge{t, d});
    }

    dijkstra();

    return 0;
}



Measured memory_bytes: 20408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int x = sc.nextInt();
        final int n = sc.nextInt();

        final int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int diff = Integer.MAX_VALUE;
        int ans = 0;
        LOOP: for (int i = -1; i <= 101; i++) {
            for (int j = 0; j < n; j++) {
                if (p[j] == i) {
                    continue LOOP;
                }
            }
            if (Math.abs(x-i) < diff) {
                diff = Math.abs(x-i);
                ans = i;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35944
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 305;

string s;
int n;
int a[N];
double dp[N][N][N]; // dp[i][j] 捜査回数iの時の
int memo[4];


void cal(int i, int j, int k) {
  if(dp[i][j][k] >= 0) return;
  if(i) cal(i-1, j, k);
  if(j) cal(i + 1, j - 1, k);
  if(k) cal(i, j+1, k-1);

  dp[i][j][k] = (i ? dp[i - 1][j][k] * i : 0) + (j ? dp[i + 1][j - 1][k] * j : 0) + (k ? dp[i][j + 1][k - 1] * k : 0) + n;
  dp[i][j][k] *= 1.0 / (i + j + k);
}

int main () {
  cin >> n;
  memset(dp, -1, sizeof dp);
  rep(i,n) {
    cin >> a[i+1];
    memo[a[i+1]]++;
  }
  dp[0][0][0] = 0.0;
  cal(memo[1],memo[2],memo[3]);
  pd(dp[memo[1]][memo[2]][memo[3]]);br();
}


Measured memory_bytes: 221952
#include<iostream>

using namespace std;

#define NMAX 50

int main(){

	int n,q;
	int have[NMAX];
	int stone;
	int ans;
	bool f;

	while(1){

		cin>>n>>q;
		if(n==0&&q==0) break;

		stone=q;
		f=true;
		for(int i=0;i<n;i++) have[i]=0;
		while(f){
			for(int i=0;i<n;i++){
				if(stone!=0){
					stone--;
					have[i]++;
					if(have[i]==q){
						f=false;
						ans=i;
						break;
					}
				}
				else{
					stone+=have[i];
					have[i]=0;
				}
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>

using namespace std;


int main() {
	int K, N,sum = 0;
	cin >> N >> K;
	vector<int> l(N);
	for (int i = 0; i < N;i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end(),greater<int>());
	for (int i = 0; i < K;i++) {
		sum += l[i];
	}
	cout << sum << endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    int alice=0, bob=0;
    SORT(a); REVERSE(a);
    REP(i,N){
        if(i%2) bob += a[i];
        else alice += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll A, B, C;
  std::cin >> A >> B >> C;

  if (A + B == C || B + C == A || C + A == B) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


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

using namespace std;

void ReplaceStr(string& str, const string& from, const string& to)
{
	string::size_type pos = 0;
	while(pos = str.find(from, pos), pos != string::npos)
	{
		str.replace(pos, from.length( ), to);
		pos += to.length();
	}
}

void solve()
{
	int N;
	scanf("%d\n", &N);
	while(N--)
	{
		string str;
		getline(cin, str);
		string from = "Hoshino";
		string to = "Hoshina";
		ReplaceStr(str, from, to);
		cout << str << endl;
	}
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
    ll a, b;
    cin >> a >> b;

    ll x, y;
    extGCD(a, b, x, y);
    cout << x << " " << y << endl;
}



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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d, g, p[15], c[15];
  cin >> d >> g;
  for (int i = 0; i < d; ++i) {
    cin >> p[i] >> c[i];
  }
  
  int ans = 1e9;
  for (int i = 0; i < (1<<d); ++i) {
    bitset<10> b(i);
    int r, s = 0, totalp = 0;
    for (int j = 0; j < d; ++j) {
      if (b.test(j)) {
        s += (c[j] + (j + 1) * 100 * p[j]);
        totalp += p[j];
      }
      else r = j;
    }
    if (s < g) {
      int rs = (r+1) * 100;
      int need = (g - s + rs - 1) / rs;
      if (need >= p[r]) continue;
      totalp += need;
    }
    ans = min(ans, totalp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  ll h;
  cin >> h;

  ll ans = 1;

  ll now = 2;
  while(h / now){
    ans += now;
    now *= 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

void solve(char* str) {

  int i;
  int joi,ioi;
  int length = strlen(str);
  joi = 0;
  ioi = 0;

  for(i=0; i<length-2; i++) {
    if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I')
      joi++;
    if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I')
      ioi++;
  }

  printf("%d\n%d\n",joi,ioi);

}

int main(void) {
  char str[10005];

  while(scanf("%s",str) != EOF) {
    solve(str);

  }

  return 0;
}

Measured memory_bytes: 560
#include <bits/stdc++.h>
using namespace std;
void LCS(string x, string y)
{
  int m = x.length();
  int n = y.length();
  int L[m+1][n+1];
  for(int i = 0; i<= m; i++)
  {
    for(int j = 0 ;j<=n ;j++)
    {
      if(i == 0 || j == 0)
         L[i][j] = 0;
      else if(x[i-1] == y[j-1])
         L[i][j] = 1 + L[i-1][j-1];
      else L[i][j] = max(L[i-1][j], L[i][j-1]);
   }
  }
   int i = m,j = n;
   string s = ""; 
   while(i>0 && j>0)
   {
     if(x[i-1] == y[j-1])
     {
     	s = x[i-1] + s;
     	i--;
     	j--;
     }
     else if(L[i-1][j] > L[i][j-1])
       i--;
     else j--;
   }
    cout<<s<<"\n";
       
}
int main()
{
  string x, y;
  cin >> x >> y;
  LCS(x,y);
}

Measured memory_bytes: 35456
//        VIVEK UPADHYAY
    //        MANIT, BHOPAL(M.P)


//                         JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 + 10 ;
ll mod = 1e9 + 7 ;
int main() {
    
    
    int N ;
    
    cin >> N ;
    if(N<1200) cout<<"ABC\n" ;
    else if(N<2800) cout<<"ARC\n" ;
    else cout<<"AGC\n" ;
    
    return 0 ;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int cin;
  int r = 0, b = 0;

  while ((cin = getchar()) != EOF) {
    if (cin == '0') {
      r++;
    } else if (cin == '1') {
      b++;
    }
  }

  if (r < b) {
    printf("%d\n", r * 2);
  } else {
    printf("%d\n", b * 2);
  }

  return 0;
}


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

int ans;
string S;

int main() {
    cin >> S;
    if (S == "MON") {
        ans = 6;
    } else if (S == "TUE") {
        ans = 5;
    } else if (S == "WED") {
        ans = 4;
    } else if (S == "THU") {
        ans = 3;
    } else if (S == "FRI") {
        ans = 2;
    } else if (S == "SAT") {
        ans = 1;
    } else {
        ans = 7;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  char tmp='a';
  for(char c:s){
    if(tmp==c){
      cout << "Bad" << endl;
      return 0;
    }
    tmp=c;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	ll N;
	cin >> N;
	vector<string> S(N);
	REP(i, N) cin >> S[i];

	map<string, int> M;
	REP(i, N) {
		if (M.find(S[i]) != M.end()) M[S[i]]++;
		else M[S[i]] = 1;
	}

	ll max = 0;
	for (auto i = M.begin(); i!=M.end(); i++) {
		if (max < i->second) max = i->second;
	}
	set<string> res;
	for (auto i = M.begin(); i!=M.end(); i++) {
		if (i->second == max) res.insert(i->first);
	}
	for (auto i = res.begin(); i!=res.end(); i++) {
		cout << *i << "\n";
	}

}


Measured memory_bytes: 34816
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, A: int, B: int):
    answer = [["0"]*W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if i < B:
                if j < A:
                    answer[i][j] = "0"
                else:
                    answer[i][j] = "1"
            else:
                if j < A:
                    answer[i][j] = "1"
                else:
                    answer[i][j] = "0"

    for i in range(H):
        print(''.join(answer[i]))                
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(H, W, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11892
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int key;
    Node *prev, *next;
};

Node* nil;

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

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    // 番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node* cur = nil->next; //番兵の次の要素から辿る
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node* t){
    if (t == nil) return; //tが番兵の場合は処理をしない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key){
    // 検索したノードを削除
    deleteNode(listSearch(key));
}

void printList(){
    Node* cur = nil->next;
    int isf = 0; //is it the first element?
    
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main(){
    int key, n;
    int size = 0;
    char com[20]; //assign operational charaters (20 are enough)
    int np = 0, nd = 0;
    scanf("%d", &n); //assign the number of operations to n
    init();
    
    for (int i = 0; i < n; i++){
        scanf("%s%d", com, &key); //adopt scanf function for make it faster
        if(com[0] == 'i'){ insert(key); np++; size++; } //insert
        else if(com[0] == 'd') { //delete
            if(strlen(com) > 6){ //deleteBLAHBLAHBLAH
                if(com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }else{
                deleteKey(key); nd++;
            }
            size--; //delete method has removed 1 element
        }
    }
    
    printList();
    
    return 0;
}


Measured memory_bytes: 33852
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()


signed main(){
  string s,t;
  cin>>s>>t;
  rev(s);
  rev(t);
  int n=s.size();
  int a=0;
  int b;
  fo(i,s.size()){
    string u=s.substr(i,t.size());
    a=0;
    fo(j,t.size()){
      if(t[j]==u[j]||u[j]=='?'){
        u[j]=t[j];
        a=a;
      }
      else{
        a++;
      }
    }
    if(a==0){
      b=i;
      break;
    }
  }
  if(a==0){
    fo(i,t.size()){
      s[i+b]=t[i];
    }
    fo(i,n){
      if(s[i]=='?')
        s[i]='a';
    }
    rev(s);
    cout<<s<<endl;
    return 0;
  }
  cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();
        if (T.substring(0,T.length() - 1).equals(S)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35652
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    String n = sc.next();
    long sum = 0;

    for (int i = 0; i < (1<<n.length() - 1); i++) {
      String s = "";
      for (int j = 0; j < n.length(); j++) {
        if ((1 & i >> j) == 1) {
          s += n.charAt(j) + "+";
        }
        else {
          s += n.charAt(j);
        }
      }
      String a[] = s.replaceAll("\\+", " ").split(" ");
      //System.out.println(Arrays.toString(a));
      for (int j = 0; j < a.length; j++) {
        sum += Long.parseLong(a[j]);
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 25556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int out = (3*N + M)/2;

		System.out.println(out);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
import math

a, b, h, m = map(int, input().split())

arg = abs(30*h - 5.5*m)

if arg == 180:
    print(b+a)
    exit()

if arg == 0:
    print(abs(b-a))
    exit()

if arg > 180:
    arg = 360 - arg

length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(arg)))

print(length)

Measured memory_bytes: 9512
(defmacro while (test &body body)
  `(do ()
       ((not ,test))
     ,@body))

(defun main ()
  (let ((a (read))
        (b (read))
        (c (read))
        (d (read))
        (ans "No"))
    (while (not (or (<= a 0) (<= c 0)))
      (decf c b)
      (if (<= c 0)
        (setf ans "Yes"))
      (decf a d))
    (format t "~a~%" ans)))
(main)


Measured memory_bytes: 23732
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
int nCr_saturated(int n, int k, int infinity) {
	const int MaxK = 30;
	if(k > n) return 0;
	if(k > n / 2) k = n - k;
	if(k == 0) return 1;
	assert(0 <= k && k <= MaxK);
	int factors[MaxK];
	rep(i, k)
		factors[i] = n - i;
	rep(i, k) {
		int x = i + 1;
		rep(j, k) {
			int g = gcd(factors[j], x);
			factors[j] /= g;
			x /= g;
		}
		assert(x == 1);
	}
	int product = 1;
	rep(i, k) {
		long long P = (long long)product * factors[i];
		if(P >= infinity)
			return infinity;
		else
			product = (int)P;
	}
	return product;
}

vector<int> trans(const vector<int> &a, int t, bool naive = false) {
	assert(t >= 0);
	const int logT = 30;
	int M = (int)a.size();
	vector<int> res = a;
	if(t <= logT || naive) {
		rep(k, t) {
			rep(i, M - 1)
				amin((res[i + 1] += res[i]), INF);
		}
	} else {
		int X = min(logT, M);
		rep(i, X) {
			int sum = 0;
			for(int j = i; j >= 0; -- j) {
				int coeff = nCr_saturated((i - j) + t - 1, i - j, INF);
				long long S = sum + (long long)coeff * a[j];
				if(S > INF) {
					sum = INF;
					break;
				} else {
					sum = (int)S;
				}
			}
			res[i] = sum;
		}
		reu(i, X, M)
			res[i] = INF;
	}
	return res;
}

int solve(const vector<int> &a, const vector<int> &b) {
	int M = (int)a.size();
	if(b < a)
		return 0;
	if(b[0] > a[0])
		return INF;
	int t = (b[1] - a[1] + a[0] - 1) / a[0];
	vector<int> c = trans(a, t);
	return b < c ? t : t + 1;
}

int main() {
	int N; int M;
	while(~scanf("%d%d", &N, &M)) {
		vector<vector<int> > A(N, vector<int>(M));
		for(int i = 0; i < N; ++ i) for(int j = 0; j < M; ++ j)
			scanf("%d", &A[i][j]);
		if(M == 1) {
			bool ok = true;
			rep(i, N - 1)
				ok &= A[i][0] < A[i + 1][0];
			puts(!ok ? "-1" : "0");
			continue;
		}
		vector<int> g(N - 1);
		bool ok = true;
		rep(i, N - 1) {
			int x = solve(A[i + 1], A[i]);
			if(x == INF) {
				ok = false;
				break;
			} else if(x > 0) {
				g[i] = x;
			} else {
				int y = solve(A[i], A[i + 1]);
				if(y > 0 && y < INF && trans(A[i], y - 1) == A[i + 1])
					-- y;
				g[i] = -y + 1;
			}
		}
		if(!ok) {
			puts("-1");
			continue;
		}
		ll ans = 0;
		ll curt = 0;
		rep(i, N - 1) {
			curt = max(curt + g[i], 0LL);
			ans += curt;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String s = sc.next();

		pr.printf("%s %s\n", s.substring(0, 4), s.substring(4, 12));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 10316
#include <iostream> // cout, endl, cin
#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
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int X,Y;
    cin >> X >> Y;
    int i,k;
    k=0;
    
    for(i=0;i<=X;i++)
    {
   
         if(i*2+(X-i)*4==Y)
        {
            k=1;
            break;
        }
    }
    if(k==1)
    {
        cout << "Yes" << endl;
    }
    if(k==0)
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
n = int(input())
s = input()
e = s.count("E")
w = s.count("W")
cnt1 = 0
cnt2 = 0
ans = 10e9
for i in s:
    if i=="E":
        cnt1 += 1
        ans = min(ans,cnt2+e-cnt1)
    else:
        ans = min(ans,cnt2+e-cnt1)
        cnt2 += 1
print(ans)

Measured memory_bytes: 3700