akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------
int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    string s;cin>>s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        for(int j = i; j < s.size(); j++) {
            int cnt = 0;
            for(int k = i; k <= j; k++) {
                if(s[k]!='A'&&s[k]!='C'&&s[k]!='G'&&s[k]!='T'){
                    cnt = 0;break;
                }
                cnt++;
            }
            ans = max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  long long N,D,x,y;
  cin>>N>>D;
  int Ans=0;
  D=D*D;
  rep(i,N){cin >> x>>y;
           if(x*x+y*y<=D){Ans++;}
          }
  cout<<Ans<<endl;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int main(){
  int n;
  lint k;
  cin>>n>>k;
  vector<lint>a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  lint m=0;
  while(1){
    lint sum=0;
    rep(i,n)
      if((a[i]&k)==a[i])sum+=b[i];
    m=max(m,sum);
    if(k==0)break;
    k+=1;
    k&=k-1;
    k=max(k-1,0LL);
  }
  cout<<m<<endl;
}


Measured memory_bytes: 1792
def makelist(n, m, p):
	return [[[0 for k in range(p)] for i in range(m)] for j in range(n)]

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

dp = makelist(N+1, N+1, N*A+1)
dp[0][0][0] = 1
for i in range(N):
	for j in range(i+1):
		for k in range(N*A):
			if k + x[i] <= N * A:
				dp[i+1][j+1][k+x[i]] += dp[i][j][k]
			dp[i+1][j][k] += dp[i][j][k]

ans = 0
for i in range(1, N+1):
	ans += dp[N][i][i*A]

print(ans)

Measured memory_bytes: 99932
#include <stdio.h>
#include <math.h>

int a[100][100],b[100],c[100];

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
 	}
 	for(int i=0;i<m;i++){
 		scanf("%d",&b[i]);
 	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			c[i]+=a[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 1064
(N,),A,B=$<.map{|s|s.split.map &:to_i}
c=0
v=[]
w=0
A.zip(B).map{|a,b|
  if a<b
    w+=b-a
    c+=1
  elsif a>b
    v<<a-b
  end
}
v.sort!.reverse!
v.map{|d|
  if w>0
    c+=1
  end
  w-=d
}
p w>0 ? -1 : c

Measured memory_bytes: 22584
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e6+5;
void solve(){
	int n,m; 
	cin>>n>>m; 
	if(n==m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

#define  NUM1  20
#define  NUM2  100

void show_data(int n, int s[NUM1]) {
	int i;
	for (i = 0; i < n; ++i) {
		printf("%d ", s[i]);
	}
	putchar('\n');
}

int main(void) {

	int i, j, k;
	int set_num;

	int n[NUM1] = { 0 };
	int s[NUM1][NUM2] = { { 0 } };
	int p[NUM1] = { 0 };

	/* ?????????????´???¨ */
	scanf("%d", &n[0]);
	for (j = 0; j < n[0]; ++j) {
		scanf("%d", &s[0][j]);
	}
	for (i = 1; n[i - 1] != 0; ++i) {
		scanf("%d", &n[i]);
		for (j = 0; j < n[i]; ++j) {
			scanf("%d", &s[i][j]);
		}
	}
	set_num = i - 1;

	/* ??????????????????(?????????) */
	for (i = 0; i < set_num; ++i) {
		for (j = 0; j < n[i]; ++j) {
			for (k = n[i] - 1; k > j; --k) {
				if (s[i][k - 1] > s[i][k]) {
					int tmp = s[i][k - 1];
					s[i][k - 1] = s[i][k];
					s[i][k] = tmp;
				}
				// show_data(n[i], s[i]);
			}
		}
	}


	/* ?????°?????? */
	for (i = 0; i < set_num; ++i) {
		for (j = 1; j < n[i] - 1; ++j) {
			p[i] = p[i] + s[i][j];
		}
		p[i] = p[i] / (n[i] - 2);
	}


	/* ???????????? */
	for (i = 0; n[i] != 0; ++i) {
		printf("%d\n", p[i]);
	}

	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

bool comp(const pii &a, const pii &b){
  return b.first*a.second > a.first*b.second;
}

int main(){
  int n,w;
  scanf("%d%d",&n,&w);
  double res = 0;

  vector<pii> item;
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=0 && b>=0)w+=-a, res+=b;
    else if(a<0 && b<0){
      w+=-a, res+=b;
      item.push_back(pii(-a,-b));
    }else if(a>0 && b>0){
      item.push_back(pii(a,b));
    }      
  }
  
  sort(item.begin(),item.end(),comp);

  for(pii p : item){
    if(w>p.first){
      w -= p.first; res += p.second;
    }else{
      res += (double)w/p.first * p.second;
      break;
    }
  }
  printf("%.9lf\n",res);
}

Measured memory_bytes: 1316
#include <cstdio>
#include <queue>

using namespace std;


char a[101][101];
int c[101][101];

int w,h;

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

queue<int> xque;
queue<int> yque;


int main(){
	
	
	
	while(1){
		
		
		scanf(" %d",&h);
		scanf(" %d",&w);
		
		if(h==0 && w==0) break;
		
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				c[i][j] = 0;
			}
		}
		
		int si=0,sj=0;
		for(int j=0;j<h;j++){
			for(int i=0;i<w;i++){
				scanf(" %c",&a[i][j]);
			}
		}
		int ans=0;
		for(int p=0;p<w;p++){
			for(int q=0;q<h;q++){
				
				if(c[p][q]) continue;
				
				char mk = a[p][q];
				ans++;
				xque.push(p);
				yque.push(q);
				c[si][sj] = 1;
				while(xque.size()){
					int i = xque.front(); xque.pop();
					int j = yque.front(); yque.pop();
					for(int k=0;k<4;k++){
						int nx = i+dx[k];
						int ny = j+dy[k];
						if((0<=nx)&&(nx<w)&&(0<=ny)&&(ny<h)&&(a[nx][ny]==mk)&&(c[nx][ny]==0)){
							xque.push(nx);
							yque.push(ny);
							c[nx][ny] = 1;
						}		
					}
				}
			}
		}
		
		printf("%d\n", ans);
	
	}
	
	
	return 0;
}

Measured memory_bytes: 1096
a, b, c, d = map(int, input().split())

if b >= 0 and d >= 0 and a <= 0 and c <= 0:# - + - + = +
    e = b*d
    f = a*c
    if e > f:
        print(e)
    else:
        print(f)
elif a >= 0 and b >= 0 and c >= 0 and d >= 0: #+ + + +
    print(b*d)
elif a <= 0 and b <= 0 and c <= 0 and d <= 0: #- - - - = -
    print(a*c)
elif a >= 0 and b >= 0 and c <= 0 and d <= 0: #+ + - -
    print(a*d)
elif a >= 0 and b >= 0 and c <= 0 and d >= 0: # + + - +
    print(b*d)
elif a <= 0 and b <= 0 and c >= 0 and d >= 0: # - - + +
    print(b*c)
elif a <= 0 and b <= 0 and c <= 0 and d >= 0: # - - - +
    print(a*c)
elif a <= 0 and b >= 0 and c >= 0 and d >= 0: # - + + +
    print(b*d)
elif a <= 0 and b >= 0 and c <= 0 and d <= 0: # - + - -
    print(a*c)


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector< int > a(n), b(n), c(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i];
    }
    int ans = 0;
    ans += b[a[0]];
    for (int i = 1; i < n; i++) {
        ans += b[a[i]];
        if (a[i] - a[i - 1] == 1) {
            ans += c[a[i - 1]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	char a[3];
	int i;
	cin>>a[0]>>a[1]>>a[2];
	for(i=0;i<3;i++)
	{
		if(a[i]=='1')
			cout<<9;
		else
		{
			if(a[i]=='9')
				cout<<1;
			else
				cout<<a[i];
		}
	} 
	cout<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> l = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            l.add(sc.nextLong());
        }
        int ans = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for (int k = j + 1; k < n; k++) {
                    long a = l.get(i);
                    long b = l.get(j);
                    long c = l.get(k);
                    if(a != b && b != c && a != c) {
                        long sum = a + b + c;
                        long max = Math.max(a, Math.max(b, c));
                        if(max < sum - max ) {
                            ans++;
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36984
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>
#include <array>

using namespace std;

vector<int> table;
vector<bool> a;

int PRIME = 1000000007;

vector<vector<int>> map_w;
vector<vector<int>> map_h;


int main(int argc, char* argv[]){
    int H, W;

    cin >> H >> W;
    map_w.resize(H, vector<int>(W, 0));
    map_h.resize(H, vector<int>(W, 0));
    string s;

    cin >> s;

    if(s[0] == '.'){
        map_w[0][0] = 1;
        map_h[0][0] = 1;
    }
    for(int j = 1; j < W; ++j){
        if(s[j] == '.'){
            map_w[0][j] = map_w[0][j-1] + 1;
            map_h[0][j] = 1;
        }
    }

    for(int i = 1; i < H; ++i){
        cin >> s;

        if(s[0] == '.'){
            map_w[i][0] = 1;
            map_h[i][0] = 1 + map_h[i-1][0];
        }
        for(int j = 1; j < W; ++j){
            if(s[j] == '.'){
                map_w[i][j] = map_w[i][j-1] + 1;
                map_h[i][j] = map_h[i-1][j] + 1;
            }
        }
    }

    for(int i = 0; i < H; ++i){
        int pos = W - 1;
        while(pos >= 0){
            if(map_w[i][pos] == 0){
                --pos;
                continue;
            }

            int value = map_w[i][pos];
            --pos;
            while(pos >= 0 && map_w[i][pos] != 0){
                map_w[i][pos--] = value;
            }

        }
    }

    for(int i = 0; i < W; ++i){
        int pos = H - 1;
        while(pos >= 0){
            if(map_h[pos][i] == 0){
                --pos;
                continue;
            }

            int value = map_h[pos][i];
            --pos;
            while(pos >= 0 && map_h[pos][i] != 0){
                map_h[pos--][i] = value;
            }
        }
    }

    int res = 0;

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            res = max(res, map_w[i][j] + map_h[i][j] - 1);
        }
    }


    cout << res << endl;

}


Measured memory_bytes: 31616
def c(n,a):
    a.sort()
    max = a.pop()
    min = a.pop(0)
    opr = []
    for i in a:
        if i >= 0:
            opr.append('{} {}'.format(min, i))
            min-=i
        else:
            opr.append('{} {}'.format(max, i))
            max-=i
    opr.append('{} {}'.format(max, min))
    return str(max - min) + '\n' + '\n'.join(opr)

n = int(input())
a = list(map(int, input().split()))
print(c(n, a))

Measured memory_bytes: 18728
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args){
    		 Scanner INPUT_R = new Scanner(System.in);
    		 int R = INPUT_R.nextInt();
     
    		 int G = INPUT_R.nextInt();
     
    		 int B = INPUT_R.nextInt();
     
    		 if(((R * 100) + (G * 10) + B) % 4 ==0) {
    			 System.out.println("YES");
    		 }else {
    			 System.out.println("NO");
    		 }
     
    	}
    }

Measured memory_bytes: 23764
#include<stdio.h>
#define MAX 10000
#define M 500
#define NOT_FOUND -1

int Search(int *,int,int);

int main()
{
  int i,j,n,q,a,count;
  int A[MAX],B[M];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(j = 0;j < q;j++){
    scanf("%d",&B[j]);
  }

  for(j = 0;j < q;j++){
    a = Search(A,n,B[j]);
    if(a != NOT_FOUND) count++;
  }
  printf("%d\n",count);
  return 0;
}

int Search(int *A,int n,int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key){
    i++;
    if(i == n) return NOT_FOUND;
  }
  return i;
}

Measured memory_bytes: 640
import itertools
H,W = map(int, input().strip().split(' '))

board = ['.'*(W+2)]
board += ['.'+input().strip()+'.' for _ in range(H)]
board.append('.'*(W+2))

# 全ての黒マスの周囲4マスに黒マスがあればよい
for x,y in itertools.product(range(1,W+1), range(1,H+1)):
  if board[y][x] == '.' : continue
  flag = False
  for dx,dy in [(1,0),(-1,0),(0,1),(0,-1)]:
    if board[y+dy][x+dx] == '#': flag = True
  if not flag:
    print('No')
    exit()
print('Yes')

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

int N, M;

struct Node {
  int x;
  int y;
};

struct Link {
  int node1;
  int node2;
  double len;
};

bool compare(const Link& left, const Link& right);

int main(void) {
  cin >> N >> M;
  vector<vector<int> > array;
  int i, j, k, t1, t2, s, t;
  double ans = 0.0;
  struct Node nodes[N];
  struct Link links[M];

  for(i = 0; i < N; i++) {
    vector<int> temp;
    temp.push_back(i + 1);
    array.push_back(temp);
  }

  for(i = 0; i < N; i++)
    cin >> nodes[i].x >> nodes[i].y;
  for(i = 0; i < M; i++) {
    cin >> links[i].node1 >> links[i].node2;
    links[i].len = sqrt(pow(nodes[links[i].node1 - 1].x - nodes[links[i].node2 - 1].x, 2.0) + pow(nodes[links[i].node1 - 1].y - nodes[links[i].node2 - 1].y, 2.0));
  }

  sort(links, links + M, compare);

  for(i = 0; i < M; i++) {
    for(j = 0; j < array.size(); j++){
      for(k = 0; k < array.at(j).size(); k++) {
	if(links[i].node1 == array.at(j).at(k))
	  t1 = j;
	else if(links[i].node2 == array.at(j).at(k))
	  t2 = j;
      }
    }
    if(t1 == t2)
      ans += links[i].len;
    else {
      if(t1 > t2)
	swap(t1, t2);
      while(!array.at(t2).empty()) {
	array.at(t1).push_back(array.at(t2).back());
	array.at(t2).pop_back();
      }
      array.erase(array.begin() + t2);
    }
  }

  printf("%.3f", ans);

  return 0;
}

bool compare(const Link& left, const Link& right) {
        return left.len > right.len;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200010;
int n,m,i,j,k,a[N],j1,j2,l,r,mid;
long long b[N],ans;
long long f(int j1,int k,int j2,int n){
	if (j1==k||j2==n||j2==k||j1==0) return b[n];
	long long x=b[j1],y=b[k]-b[j1],z=b[j2]-b[k],w=b[n]-b[j2];
	return max(max(max(x,y),z),w)-min(min(min(x,y),z),w);
}
int find(int x,int y){
	if (a[x]>(b[y]-b[x-1])/2) return x-1;
	l=x;r=y-1;while (l<r){
		mid=(l+r)/2+1;if (b[mid]-b[x-1]<=(b[y]-b[x-1])/2) l=mid; else r=mid-1;
	}
	return l;
}
void doit(int k){
	j1=find(1,k);j2=find(k+1,n);
	ans=min(ans,min(f(j1,k,j2,n),f(j1+1,k,j2,n)));ans=min(ans,min(f(j1,k,j2+1,n),f(j1+1,k,j2+1,n)));
}
int main(){
	scanf("%d",&n);for (i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=b[i-1]+a[i];
	ans=b[n];for (i=2;i<=n-2;i++) doit(i);printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 2560
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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



// ***************************************

int main(){

    string S;
    cin >> S;
    for(auto& s: S){
        if (s == '7'){
            cout << YES << endl;
            return 0;
        }
    }

    cout << NO << endl;

    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;


public class B
{	
	public static void Main()
	{	
		long[] time = new long[5];
		for(int i = 0; i < 5; i++)
			time[i] = Int64.Parse(Console.ReadLine());
		
		long muda = 9;
		long result = 0;
		bool just = true;
		for(int i = 0; i < 5; i++)
		{
			if((time[i] % 10) == 0)
			{
				result += time[i];
			}
			else
			{
				just = false;
				result += ((time[i] + 10)/10)*10;
				muda = Math.Min(muda, time[i] % 10);
			}
		}
		
		if(!just)
			result -= (10 - muda);			
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
#define N 36
void BubbleSort(int, char [][3]);
void SelectionSort(int, char [][3]);
int isStable(char [][3], char [][3],int);

int main(){
  int i,j,n;
  char array[N][3],arrayB[N][3],arrayS[N][3];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",arrayB[i]);
    strcpy(arrayS[i],arrayB[i]);
    strcpy(array[i],arrayB[i]);
  }
  BubbleSort(n, arrayB);
  if( isStable(array,arrayB,n) ){
    printf("Stable\n");
  }
  else {
    printf("Not Stable\n");
  }
  SelectionSort(n, arrayS);
  if( isStable(array,arrayS,n) ){
    printf("Stable\n");
  }
  else {
    printf("Not stable\n");
  }

  return 0;
}

void BubbleSort(int n,char array[n][3]){
  int i,j,flag;
  char buf[3];
  flag = 1;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if( (int)array[j-1][1] > (int)array[j][1]){
	strcpy(buf,array[j-1]);
	strcpy(array[j-1],array[j]);
	strcpy(array[j],buf);
	flag = 1;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%s ",array[i]);
  }
  printf("%s\n",array[i]);
  return;
}
void SelectionSort(int n,char array[n][3]){
  int i,j,mini;
  char buf[3];

  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if( (int)array[mini][1] > (int)array[j][1] ){
	mini = j;
      }
    }
    strcpy(buf,array[i]);
    strcpy(array[i],array[mini]);
    strcpy(array[mini],buf);
  }
  for(i=0;i<n-1;i++){
    printf("%s ",array[i]);
  }
  printf("%s\n",array[i]);
     
  return;
}
int isStable(char in[][3],char out[][3],int n){
  int i,j,a,b;

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if( ((int)in[i][1] == (int)in[j][1] )&&
	      (!strcmp(in[i],out[b]))&&
	      (!strcmp(in[j],out[a]))){
	    return 0;
	  }
	}
      }
    }
  }
  return 1;
}

Measured memory_bytes: 624
N = int(raw_input())
S = raw_input()
left = 0
right = 0
for i in range(1, N):
	if S[i] == 'E': right += 1
min = right
for i in range(1, N):
	if S[i-1] == 'W': left += 1
	if S[i] == 'E': right -= 1
	if left + right < min: min = left + right
print min

Measured memory_bytes: 33132
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int x = stoi(s);
  ll cnt = 0;
  rep1(i,x){
    string ss = to_string(i);
    string tt = ss;
    reverse(ss.begin(), ss.end());
    if(ss[0]=='0') continue;
    int y = stoi(ss);
    //    cout << y << "\n";
    if(i>y){
      // if(ss[0]==ss[ss.size()-1]){
      // 	cnt+=2;
      // }
      if(ss[0]==ss[ss.size()-1]){
	ll z = 1;
	cnt++;
	if(ss.size()>=2){
	  cnt+=2;
	  rep(j,ss.size()-2){
	    cnt +=2* z;
	    z *= 10;
	  }
	}
	if(ss.size()>=3){
	  string sss = tt.substr(1,tt.size()-2);
	  int xx = stoi(sss);
	  cnt +=2*xx;
	}	
      }
      else{
	ll z = 1;
	rep(j,ss.size()-1){
	  cnt += 2*z;
	  z *= 10;
	}
      }
    }
    else if(i==y){
      cnt++;
      ll z = 1;
      if(ss.size()>=2){
	cnt+=2;
	rep(j,ss.size()-2){
	  cnt += 2*z;
	  z *= 10;
	}
      }
      if(ss.size()>=3){
	string sss = tt.substr(1,tt.size()-2);
	int xx = stoi(sss);
	cnt += 2*xx;
      }
    }
    else{
      if(ss[0]==ss[ss.size()-1]){
	cnt++;
	ll z = 1;
	if(ss.size()>=2){
	  cnt+=2;
	  rep(j,ss.size()-2){
	    cnt += 2*z;
	    z *= 10;
	  }
	}
	if(ss.size()>=3){
	  string sss = tt.substr(1,tt.size()-2);
	  int xx = stoi(sss);
	  cnt += 2*xx;
	}	
      }
      else{
	ll z = 1;
	if(ss.size()>=2){
	  rep(j,ss.size()-2){
	    cnt += 2*z;
	    z *= 10;
	  }
	}
      }
    }
    //    cout << i << ":" << cnt << "\n";
  }
  cout << cnt << "\n";
  return 0;
}


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

int main()
{
  int peri,n;
  cin>>peri>>n;
  int loc[n]={0},dist[n]={0};
  for(int i=0;i<n;i++)
  {
    cin>>loc[i];
  }
  for(int i=0;i<n;i++)
  {
    if(i==(n-1))
    {
      dist[i]=peri+loc[0]-loc[i];
    }
    else 
    {
      dist[i]=loc[i+1]-loc[i];
    }
  }
  int max=-1;
  for(int i=0;i<n;i++)
  {
    if(max<dist[i])
    {
      max=dist[i];
    }
  }
  max=peri-max;
  cout<<max<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,k,n;
    double p;
    cin>>n;
    vector<double> dp(n+1,0);
    dp[0]=1;
    for(k=1;k<=n;k++)
    {
        cin>>p;
        for(i=k;i>=0;i--)
        {
            dp[i]=(i==0 ? 0:dp[i-1]*p)+dp[i]*(1-p);
        }
    }
    double s=0;
    for(i=0;i<=n;i++)
    {
        if(i>n-i)
            s+=dp[i];
    }
    cout<<fixed;
    cout<<setprecision(10);
    cout<<s;
    return 0;
}



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

int main(){
    int n;
    multiset<ll> s, status, tmp;
    //sは与えられる集合、statusはシミュレーションの状態、tmpはstatusのコピー先
    
    //入力部
    cin >> n;
    int j;
    for(int i = 0; i < (1 << n); i++){
        cin >> j;
        s.insert(j);
    }

    status.insert(*(s.rbegin()));
    s.erase(*(s.rbegin()));
    for(int i = 0; i < n; i++){
        tmp = multiset<ll> (status); //状態を保存しておき、tmpを変化させていく、statusは参照するだけ
        for(auto e : status){ //現在の状態の最小の値から見ていく
            auto itr = s.lower_bound(e); //現在見ている値の中で最も左にあるものを参照
            if(itr == s.begin()){ //その位置が最左端ならシミュレーション失敗
                cout << "No" << endl;
                return 0;
            }
            tmp.insert(*prev(itr)); //見ている値よりも小さい物を取る
            s.erase(prev(itr));
        }
        status = tmp; //状態を更新する
    }

    //シミュレーションに成功したらYes
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 24832
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){

  string str;
  int a[4]={};

  getline(cin,str);
  
  for(int i=0;i<str.size();i++){
    if(str[i] == 'K') a[0]++;
    if(str[i] == 'U') a[1]++;
    if(str[i] == 'P') a[2]++;
    if(str[i] == 'C') a[3]++;
  }

  cout << *min_element(a,a+4) << endl;
  return (0);
}

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

int main() {
  int N,K,R,S,P,shou,amari,ans;
  cin>>N>>K>>R>>S>>P;
  string T;
  cin>>T;
  shou=N/K;
  amari=N%K;
  ans=0;
  for(int i=0;i<K;i++){
    int len;
    if(i<amari){
      len=shou+1;
    }
    else{
      len=shou;
    }
    vector<char> line(len);
    for(int j=0;j<len;j++){
      line.at(j)=T.at(j*K+i);
    }//Kで割った余りが等しい部分列ができた
    
    int part=0;//部分点
    int renzoku=0;
    for(int j=0;j<len;j++){
      
      if(j==len-1 && renzoku==0){
        if(line.at(len-1-j)=='r'){part+=P;}
        if(line.at(len-1-j)=='s'){part+=R;}
        if(line.at(len-1-j)=='p'){part+=S;}
      }
      if(j==len-1 && renzoku>0){
        renzoku++;
        int chance=0;
        chance=(renzoku+1)/2;
        if(line.at(len-1-j)=='r'){part+=P*chance;}
        if(line.at(len-1-j)=='s'){part+=R*chance;}
        if(line.at(len-1-j)=='p'){part+=S*chance;}
        renzoku=0;
      }
      if(j<len-1){
        if(renzoku==0 && line.at(len-1-j) != line.at(len-2-j)){
          if(line.at(len-1-j)=='r'){part+=P;}
          if(line.at(len-1-j)=='s'){part+=R;}
          if(line.at(len-1-j)=='p'){part+=S;}
        }
        if(line.at(len-1-j) == line.at(len-2-j)){
          renzoku++;
        }
        if(renzoku>0 && line.at(len-1-j) != line.at(len-2-j)){
          renzoku++;
          int chance=0;
          chance=(renzoku+1)/2;
          if(line.at(len-1-j)=='r'){part+=P*chance;}
          if(line.at(len-1-j)=='s'){part+=R*chance;}
          if(line.at(len-1-j)=='p'){part+=S*chance;}
          renzoku=0;
        }
      }
    }
    
    ans+=part;//最大値を足していく
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
loop do
  s, t = gets.chomp, gets.chomp rescue break
  s, t = t, s if s.length > t.length
  max_l = (s.chars & t.chars).map do |a|
    [s.count(a), t.count(a)].min
  end.inject(:+).to_i

  answer = 0
  0.upto(t.length).each do |i|
    break if t.length - i <= answer
    max = [max_l+1, t.length - i + 1].min - 1
    (answer + 1).upto(max) do |j|
      if s.include?(t[i...i+j])
        answer = j
      else
        break
      end
    end
  end

  puts answer
end

Measured memory_bytes: 11492
#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <set>
#include <queue>
#include <ctime>
#include <cmath>
#include <bitset>
#include <random>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define X first
#define Y second

const int MAXN = 100100, M = 1000000009;

long long n, x[MAXN], v[MAXN], c, ans = 0, tc;
long long xx[MAXN], mx[MAXN], ma = 0, inx[MAXN], m[MAXN], in[MAXN];

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("advent.in", "r", stdin);
	//freopen("advent.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin >> n >> c;
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i] >> v[i];
		xx[i] = c - x[i];
	}

	m[0] = 0;
	in[0] = 0;
	tc = 0;
	for (int i = 1; i <= n; i++)
	{
		m[i] = m[i - 1];
		in[i] = in[i - 1];
		tc += v[i];
		if (m[i] - in[i] < tc - x[i])
		{
			m[i] = tc;
			in[i] = x[i];
		}
	}

	mx[n + 1] = 0;
	inx[n + 1] = 0;
	tc = 0;
	for (int i = n; i >= 1; i--)
	{
		mx[i] = mx[i + 1];
		inx[i] = inx[i + 1];
		tc += v[i];
		if (mx[i] - inx[i] < tc - xx[i])
		{
			mx[i] = tc;
			inx[i] = xx[i];
		}
	}

	tc = 0;
	for (int i = 0; i <= n; i++)
	{
		ans = max(ans, 
			m[i] + mx[i + 1] - min(in[i], inx[i + 1]) - in[i] - inx[i + 1]);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define maxn 25
#define maxs 2100000
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,m,f[maxs][maxn];
char str[maxs];
int main()
{
	read(n,m);
	for(int i=0;i<=n;i++)
	{
		scanf("%s",str);
		for(int j=0;j<(1<<i);j++)
			f[(1<<i)|j][i]=str[j]=='1';
	}
	for(int i=n;i>=0;i--)
		for(int s=0;s<(1<<i);s++)
			for(int j=i;j>=0;j--)
				if(f[(1<<i)|s][j])
				{
					int v=f[(1<<i)|s][j];
					int s1=s>>j,s2=s&((1<<j)-1);
					if(j)f[(1<<(i-j))|s1][0]+=v;
					if(s2)
					{
						int p=j-1;
						while(((s2>>p)&1)==0)
							p-=1;
						f[(1<<(i-(j-1-p)))|s1<<(p+1)|(1<<p)|(s2&((1<<p)-1))][p]+=v;
					}
					if(s2!=(1<<j)-1)
					{
						int p=j-1;
						while(((s2>>p)&1)==1)
							p-=1;
						f[(1<<(i-(j-1-p)))|s1<<(p+1)|(s2&((1<<p)-1))][p]+=v;
					}
				}
	for(int i=n;i>=0;i--)
		for(int j=0;j<(1<<i);j++)
			if(f[(1<<i)|j][0]>=m)
			{
				for(int k=i-1;k>=0;k--)
					putchar(((j>>k)&1)+'0');
				return 0;
			}
    return 0;
}


Measured memory_bytes: 206208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  string s;
  cin >> s;
  int count=0;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+')
    count++;
    else
    count--;
  }
  cout << count << endl;
}



Measured memory_bytes: 3612
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(LL i=0;i<n;i++)
#define repn(i,n) for(LL i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,t[100010],d[100010],ans=0,have=0,rans=0;
bool vis[100010];
vector <pii> v,swp;
vector <LL> ks[100010],all[100010],canbe;

bool cmp(pii a,pii b)
{
	return a.fi>b.fi;
}

bool cmp2(LL a,LL b)
{
	return a>b;
}

int main()
{
	cin>>n>>k;
	rep(i,n)
	{
		cin>>t[i]>>d[i];
		v.pb({d[i],t[i]});
		all[t[i]].pb(d[i]);
	}
	sort(v.begin(),v.end(),cmp);
	rep(i,k) ks[v[i].se].pb(v[i].fi),ans+=v[i].fi;
	//cout<<ans<<endl;
	repn(i,n) sort(ks[i].begin(),ks[i].end()),sort(all[i].begin(),all[i].end(),cmp2);
	repn(i,n)
	{
		//cout<<i<<' '<<ks[i].size()<<endl;
		if(ks[i].size()==0)
		{
			if(all[i].size()>0) swp.pb({all[i][0],i});
			continue;
		}
		have++;
		//cout<<i<<endl;
		if(ks[i].size()>0) for(LL j=0;j<ks[i].size()-1;j++) canbe.pb(ks[i][j]);//,cout<<ks[i][j]<<endl;
		//cout<<'p'<<endl;
	}
	sort(canbe.begin(),canbe.end());
	sort(swp.begin(),swp.end());
	reverse(swp.begin(),swp.end());
	LL use=0;
	rans=ans+sqr(have);
	rep(i,swp.size())
	{
		if(use>=canbe.size()) break;
		have++;
		ans=ans-canbe[use++]+swp[i].fi;
		rans=max(rans,ans+sqr(have));
		//cout<<ans<<' '<<have<<' '<<canbe[use-1]<<' '<<swp[i].fi<<endl;
	}
	cout<<rans<<endl;
	rt0;
}

Measured memory_bytes: 14704
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

vector<long long> getRSum(vector<long long> v){
	reverse(all(v));
	vector<long long> res(v.size() + 1);
	rep(i,v.size()){
		res[i + 1] = res[i] + v[i];
	}
	return res;
}

vector<long long> getSum(vector<long long> v){
	vector<long long> res(v.size() + 1);
	rep(i,v.size()){
		res[i + 1] = res[i] + v[i];
	}
	return res;
}

const long long INF = (1LL << 60);

int main(){
	int n;
	long long c;
	cin >> n >> c;

	vector<long long> x(n), v(n);
	rep(i,n){
		cin >> x[i] >> v[i];
	}
	long long last = x.back();
	for(int i = n - 1; i >= 1; i--){
		x[i] = x[i] - x[i - 1];
	}

	vector<long long> fx, bx;
	fx = getSum(x);

	vector<long long> cx(n);
	rep(i,n - 1){
		cx[i] = x[i + 1];
	}
	cx.back() = c - last;
	bx = getRSum(cx);
	//cout << cx << endl;
	//cout << bx << endl;

	vector<long long> fp, bp;
	fp = getSum(v);
	bp = getRSum(v);
	//cout << fx  << endl;
	//cout << bx  << endl;

	long long ans = 0;
	rep(i,n + 1){
		ans = max(ans, fp[i] - fx[i]);
	}
	rep(i,n + 1){
		ans = max(ans, bp[i] - bx[i]);
	}

	vector<long long> fr(n + 1), br(n + 1);
	rep(i,n + 1){
		//'cout << fp[i + 1] - fx[i + 1] * 2 << endl;
		fr[i] = fp[i] - fx[i] * 2;
	}
	rep(i,n + 1){
		br[i] = bp[i] - bx[i] * 2;
	}

	vector<long long> fmax(n + 1), bmax(n + 1);
	long long fmaxi = -INF, bmaxi = -INF;
	rep(i,n + 1){
		//cout << fp[i + 1] << ' ' << fx[i + 1] << endl;
		fmaxi = max(fmaxi, fp[i] - fx[i]);
		fmax[i] = fmaxi;
	}
	rep(i,n + 1){
		bmaxi = max(bmaxi, bp[i] - bx[i]);
		bmax[i] = bmaxi;
	}
	//cout << fr << endl;
	//cout << br << endl;
	//cout << fmax << endl;
	//cout << bmax << endl;

	rep(i,n + 1){
		//cout << fr[i] << ' ' << bmax[ n - i] << endl;
		ans = max(ans, fr[i] + bmax[n - i]);
	}
	rep(i,n){
		ans = max(ans, br[i] + fmax[n - i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 9584
import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    tmp_min=heapq.heappop(a)
    heapq.heappush(a,(-1)*(-tmp_min//2))
print(-sum(a))

Measured memory_bytes: 14380
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll N;

int main(){
    cin>>N;
    out(N*(N-1)/2);

}


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

int main () {
    int x, y, group[] = {1234567890,1,3,1,2,1,2,1,1,2,1,2,1};
    cin >> x >> y;
    if ( group[x] == group[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <set>
#include <vector>
using namespace std;
#define ll long long
int main(){

    double a,b,c,d;
    int flag = 0;
    cin>>a>>b>>c>>d;
    double ans = a*b/2;
    if(c == a/2 && d == b/2){
        flag = 1;
    }
    printf("%.6lf ",ans);
    if(flag)
    {
        cout<<"1"<<endl;
    }else{
        cout<<"0"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//container util
//------------------------------------------
#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) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int k = SZ(s);
    int win = 0;
    REP(i,k)if(s[i]=='o')win++;
    if(win + (15 - k) >= 8){
        PUTS("YES");
    }else{
        PUTS("NO");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
s.at(3)='8';
cout<<s<<endl;
}









Measured memory_bytes: 256
/* ABC141-A
   Takatan */

#include<stdio.h>
#include<string.h>
int main(void){
    char weather[7];

    scanf( "%s" , weather);
    if(strcmp(weather, "Sunny" )==0){
        printf( "Cloudy\n" );
    }else if(strcmp(weather, "Cloudy" )==0){
        printf( "Rainy\n" );
    }else if(strcmp(weather, "Rainy" )==0){
        printf( "Sunny\n" );
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
pair<int, int>p[55];
signed main() {
	cin >> n;
	if (n == 1) {
		cout << 1 << endl; return 0;
	}
	rep(i, n)cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	int ans = inf;
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			int x = p[i].first - p[j].first, y = p[i].second - p[j].second;
			int cnt = 0;
			rep(k, n) {
				if (upper_bound(p, p + n, make_pair( p[k].first - x,p[k].second - y )) - lower_bound(p, p + n, make_pair( p[k].first - x,p[k].second - y ))) {
					;
				}
				else {
					cnt++;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int mae = n/100;
    int usiro = n-mae*100;
    
    if(mae>0 && mae<=12 && usiro>0 && usiro<=12) {
    	System.out.print("AMBIGUOUS");
    }else if(mae>0 && mae<=12 && usiro==0) {
    		System.out.println("MMYY");
    }else if(mae>0 && mae<=12 && usiro>12) {
		System.out.println("MMYY");
    }else if(usiro>0 && usiro<=12 && mae==0) {
		System.out.println("YYMM");
    }else if(usiro>0 && usiro<=12 && mae>12) {
    	System.out.println("YYMM");
    }else {
    	System.out.println("NA");
    }
    }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
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++)

int main() {
	int n,a;
	cin >> n >> a;
	n%=500;
	if(n<=a) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	int A[M];
	int total=0;
	for (int i = 0; i < M; ++i)
	{
		scanf("%d",&A[i]);
		total+=A[i];
	}

	if(total <= N){
		printf("%d",N-total);
	}else{
		printf("-1");
	}
	return 0;
}


Measured memory_bytes: 2152
#include <stdio.h>
#include <stdlib.h>

#define INF 1010101010

int N, K;
int h[114514];

int satorina[114514];

int asumikana(int pos) {
	int kitaeri = INF, kugyu;
	int i;
	if (pos == N) return 0;
	if (pos > N) return INF;
	if (satorina[pos]) return ~satorina[pos];

	for (i = 1; i <= K; i++) {
		kugyu = asumikana(pos + i) + abs(h[pos] - h[pos + i]);
		if (kugyu < kitaeri) kitaeri = kugyu;
	}

	return ~(satorina[pos] = ~kitaeri);
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &h[i]) != 1) return 1;
	}
	printf("%d\n", asumikana(1));
	return 0;
}


Measured memory_bytes: 10260
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    long double l;
    cin >> l;

    long double ans = l*l*l/27;

    printf("%.10Lf",ans);
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << max(0LL, (B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int K = sc.nextInt();
		int X = sc.nextInt();
		
		for (int index=(-1*K)+1; index<K; index++){
		    System.out.print(X+index);
		    System.out.print(" ");
		}

		sc.close();
	}
}

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

string solve(int x)
{
    string a("Eve ");
    string b = "";
    for (int i = 0; i < 25-x; i++)
    {
       b += a;
    }
    return b;
}
int main()
{
    int n;
    cin >> n;
    string ans = solve(n);
    cout << "Christmas" << " "<< ans << endl;
    return 0;
}

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



int main() {
  
  long long a,b,c;
  cin >> a >> b >> c;

  long long d = c-a-b;
  if(d > 0 && 4*a*b < d*d) cout << "Yes" << endl;
  else cout << "No" << endl;

   
  
}


Measured memory_bytes: 256
N = int(input())
L = [list(map(str, input().split())) for _ in range(N)]

for i in range(N):
    L[i][1] = int(L[i][1])
    L[i].append(i+1)

L.sort(key=lambda x:x[1], reverse=True)
L.sort(key=lambda x:x[0])

for l in L:
    print(l[2])
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <string>

using namespace std;

int N, M;
 
void solve() {
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	} 
	else {
		cout << "No" << endl;
	}
 
}
 
int main() {
	solve();
	return 0;
}

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

using namespace std;

int main() {
  int32_t n, w;
  cin >> n >> w;
  int32_t vmax = 1000 * n;
  vector<int32_t> weight(n+1, 0);
  vector<int32_t> value(n+1, 0);
  for (int32_t i = 1; i <= n; ++i) {
    cin >> weight[i] >> value[i];
  }

  vector<vector<int32_t>> dp(n+1, vector<int32_t>(vmax+1, w+1));
  dp[0][0] = 0;
  for (int32_t i = 1; i <= n; ++i) {
    int32_t wi = weight[i];
    int32_t vi = value[i];
    for (int32_t j = 0; j < vi; ++j) {
      dp[i][j] = min(dp[i-1][j], wi);
    }
    for (int32_t j = vi; j <= vmax; ++j) {
      dp[i][j] = min(dp[i-1][j], wi + dp[i-1][j-vi]);
    }
  }

  auto itr = upper_bound(dp[n].begin(), dp[n].end(), w);
  cout << distance(dp[n].begin(), itr) - 1 << endl;
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

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

	char c; cin >> c;

	if ('a' <= c && c <= 'z') cout << 'a';
	else cout << 'A';

	return 0;
}

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

ll dp[100005];
int main(){
ll n ;  ll K ; 
cin >> n >> K;
ll arr[n+1];
for(ll i=0; i< n;i++){
 cin >> arr[i+1];
    
}

for(ll i=1;i<=n ;i++){
if(i==1){ dp[i]= 0;}
else { dp[i] = 1000000000000;
    for(ll j =1 ; j<=K; j++){
   if(i-j>=1){ dp[i]= min((dp[i-j]+ abs(arr[i]- arr[i-j])), dp[i]); }
   else { break; }
}}

}
 cout << dp[n] << endl;

}

Measured memory_bytes: 5132
a, b, c, x, y = map(int, input().split())

i = 0
ans = float('inf')
while i // 2 <= max(x, y):
    price = a * max(0, x - i // 2) + b * max(0, y - i // 2) + c * i
    ans = min(price, ans)
    i += 2

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        String S = sc.next();

        int[] len = new int[(N - 1) * N];
        int max = 0;
        char[] chars = S.toCharArray();
        for (int i = 0; i < N - 1; i++) {
            char c = chars[i];
            for (int offset = N - i - 1; offset > max; offset--) {
                if (c != chars[i + offset]) continue;
                int combo = i > 0 ? len[(offset - 1) * N + i - 1] + 1 : 1;
                if (combo >= offset){
                    max = offset;
                    break;
                }
                max = Math.max(max, len[(offset - 1) * N + i] = combo);
            }
        }
        System.out.println(max);
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 121532