akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<queue>

using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
typedef long long int64;

const int64 INF = 1LL << 55;
bool calc( int64 value, vector< int64 >& A){ // value以上で全部切り出せる？
  for(int i = 0; i < A.size() / 2; i++){
    vector< int64 >::iterator beg = A.begin() + i, end = A.begin() + i + A.size() / 2 + 1;
    int64 base = A[i];
    vector< int64 >::iterator itr1 = lower_bound( beg, end, value + base);
    if(itr1 == end) continue;
    vector< int64 >::iterator itr2 = lower_bound( itr1, end, *itr1 + value);
    if(itr2 == end) continue;
    vector< int64 >::iterator itr3 = lower_bound( itr2, end, *itr2 + value);
    if(itr3 == end) continue;
    return true;
  }
  return false;
}

int main()
{
  int N;
  cin >> N;
  vector< int64 > A(N * 2 + 1);
  A[0] = 0;
  for(int i = 1; i <= N; i++){
    cin >> A[i];
    A[N + i] = A[i];
  }
  for(int i = 1; i < A.size(); i++){
    A[i] += A[i - 1];
  }
  
  int64 row = 0, high = INF;
   while(high - row > 0){
     int64 mid = (row + high + 1) / 2;
      if(calc(mid, A)) row = mid;
     else high = mid - 1;
  }

  cout << row << endl;
}

Measured memory_bytes: 2588
/*
  AOJ 1137
  Title:Numeral System
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
char keta[]="ixcm";
int exp_10(int n)
{
  if(n==0)
    return(1);
  else
    return(10*exp_10(n-1));
}

int mcxi2n(char s[])
{
  char *p;

  int st=1,ret;
  ret=0;st=1;
  for(;*s;s++)
    {
      if(isdigit(*s))
	st=*s-'0';
      else if((p=strchr(keta,*s)))
	{
	  ret+=st*exp_10(p-keta);
	  st=1;
	}
    }
  return(ret);
}
void n2mcxi(char s[],int n)
{
  int i,j;
  char buf[10],c;
  sprintf(buf,"%dm%dc%dx%di",n/1000,(n/100)%10,(n/10)%10,n%10);
  for(i=j=0;buf[i];i++)
    {
      c=buf[i];
      if(c=='1')
	continue;
      if(c=='0')
	{
	  i++;
	  continue;
	}
      s[j++]=c;
    }
  s[j]='\0';
}
main()
{
  int i,ret,na,nb,N;
  char a[10],b[10],c[10];
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%s %s",a,b);
      na=mcxi2n(a);
      nb=mcxi2n(b);
      //printf("%d %d\n",na,nb);
      n2mcxi(c,na+nb);
      printf("%s\n",c);
    }
  return(0);
}

Measured memory_bytes: 620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
	ALL(it, v) {
		cout << *it << " ";
	}
	cout << endl;

}


int main() {
	int n,k;
	cin >> n >> k;
	ll result = 0;
	ll saidai = n / k;
	result = saidai * saidai * saidai;
	if (k % 2 == 0) {
		saidai = (n - k/2) / k + 1;
		if (n >= k/2) {
			result += saidai * saidai * saidai;
		}
	}
	cout << result << endl;

}



Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	static String matrix[][];
	static int fin[][];
	static int color[][];

	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;

	static int w;
	static int h;

	static int sx;
	static int sy;

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

	static int count = 0;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {

			String str[] = br.readLine().split(" ");
			w = Integer.parseInt(str[0]);
			h = Integer.parseInt(str[1]);

			if (w == 0 && h == 0)
				break;

			matrix = new String[h][w];
			fin = new int[h][w];
			color = new int[h][w];

			for (int i = 0; i < h; i++) {
				str = br.readLine().split("");
				for (int j = 0; j < w; j++) {
					if (str[j].equals("@")) {
						sx = j;
						sy = i;
					}
					matrix[i][j] = str[j];
				}
			}
			dfs(sx, sy);
			System.out.println(count);
		}
	}

	static void dfs(int x, int y) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				fin[i][j] = -1;
				color[i][j] = WHITE;
			}
		}
		count = 0;
		dfs_visit(x, y);
	}

	static void dfs_visit(int x, int y) {
		color[y][x] = GRAY;

		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];

			if (nx < w && nx >= 0 && ny >= 0 && ny < h) {
				if (color[ny][nx] == WHITE && matrix[ny][nx].equals(".")) {
					dfs_visit(nx, ny);
				}
			}
		}

		color[y][x] = BLACK;
		fin[y][x] = ++count;
	}
}


Measured memory_bytes: 38780
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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


void solve(long long A, long long B, long long C){
    if (A == B) {
        cout << C << endl;
    } else if( B == C) {
        cout << A << endl;
    } else if (A == C) {
        cout << B << endl;
    }
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = x;
      int fx = 0;
      while(x >= 1){
      	fx += x%10;
        x = x/10;
      }
      if(y/fx == (double)y/fx ) System.out.println("Yes");
      else System.out.println("No");
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
bool check(string s) {
    int n = s.length();
    for(int i=0; i<n/2; i++) {
        if(s[i] != s[n-1-i])
            return 0;
    }
    for(int i=0; i<n/4; i++) {
        if(s[i] != s[n/2-1-i])
            return 0;
    }
    for(int i=n/2+1; i<(3*n)/4; i++) {
        if(s[i] != s[n-i-1])
            return 0;
    }
    return 1;
}
int main() {
    string s; cin >> s;
    if(check(s))
        cout << "Yes";
    else
        cout << "No";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int a,b,c,x; cin >> a >> b >> c >> x;
    
    int cnt  = 0;
    
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i+100*j+50*k == x) cnt++;
            }
        }
    }
    
    cout << cnt << endl;
}
    
    






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;

    vector<int> lcnt(K + 2), rcnt(K + 2);
    lcnt[0] = -1e9;
    int cnt = 0;
    for (int i = 0; i < N; ++i)
        if (S[i] == 'o' && i - lcnt[cnt] >= C + 1 && cnt < K)
            lcnt[++cnt] = i;

    rcnt[K + 1] = 1e9;
    cnt = K + 1;
    for (int i = N - 1; i >= 0; --i)
        if (S[i] == 'o' && rcnt[cnt] - i >= C + 1 && cnt > 0)
            rcnt[--cnt] = i;

    for (int i = 1; i <= K; ++i) {
        if (lcnt[i] == rcnt[i])
            cout << lcnt[i] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

    size_t a = s.find_first_of('A');
    size_t z = s.find_last_of('Z');

    cout << z - a + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pil;
ll ans=0;
vector<pil> BC;
int N;
int K;
int openum=0;
vector<pair<int,int> > operation;
int main(void)
{
    cin >> N >> K;
    int nowedge=0;
    int dif;
    if(N==2)
    {
        if(K!=0) 
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            cout << 1 << endl;
            cout << 1 << ' ' << 2 << endl;
            return 0;
        }      
    }
    for(int i=1;i<=N-2;i++)
    {
        nowedge+=i;
    }
    for(int i=2;i<=N;i++)
    {
        operation.push_back(make_pair(1,i));
        openum++;
    }
    if(nowedge<K)
    {
        cout << -1 << endl;
        return 0;
    }
    dif=nowedge-K;
    if(dif==0)
    {
        cout << openum << endl;
        for(int i=0;i<openum;i++)
        {
            cout << operation[i].first << ' ' << operation[i].second << endl;
        }
        return 0;
    }
    bool clear=false;
    for (int i = 2; i <= N-1 ; i++)
    {
        for (int j = i+1; j <= N; j++)
        {
            if((dif-1)>=0)
            {
                dif--;
                operation.push_back(make_pair(i,j));
                openum++;
                if(dif==0)
                {
                    clear=true;
                    break;
                }
            } 
            else break;
        }
        if(clear) break;
    }
    if(!clear)
    {
        cout << -1 << endl;
        return 0;
    }
    if(clear)
    {
        cout << openum << endl;
        for(int i=0;i<openum;i++)
        {
            cout << operation[i].first << ' ' << operation[i].second << endl;
        }
    }
    return 0;
}


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

using namespace std;
int main() 
{
	long long n,m;
	cin >> n >> m;
	vector<pair<long long, long long> > v;
	
	for (long long i = 0; i < n; ++i)
	{
		long long a,b;
		cin >> a>> b;
		v.push_back({a,b});
	}
	sort(v.begin(), v.end());
	unsigned long long sum =0;
	long long sec=0;
	for (long long i = 0; i < n; ++i)
	{
		sum += v[i].first * v[i].second;
		sec += v[i].second;
		if(sec > m)
		{
			sum -= v[i].first * v[i].second;
			sec -= v[i].second;
			sum += v[i].first * (m-sec);
			break;
		}
	}
	cout << sum<< endl;
    return 0;
} 

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, h;
    cin >> a >> b >> h;
    int ans = (a+b)*h/2;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<utility>
#define rep(i,n) for(i = 0; i < n; i++)
using namespace std;

int main2(), main();
int getDigit(long long ll) {
	if (ll == 0) return 0;
	return getDigit(ll / 10) + 1;
}

int main() {
	int i, j, n, m, k, q;
	
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) cin >> a[i] >> b[i];

	rep(i, n) {
		int count = 0;
		rep(j, m) {
			if (a[j] == i + 1 || b[j] == i + 1) count++;
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

n, m = map(int, input().split())
nums = [int(s) for s in input().split()]

asobi = n - sum(nums)

if asobi < 0:
    print(-1)
else:
    print(asobi)

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

int main(){
	string s;
	cin >> s;
	bool a = false, b = false;
	for(int i = 0; i < s.size(); i++)
		if(s[i] == 'A') a = true;
		else if(s[i] == 'B') b = true;
	if(a && b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    int t;
    cin >> t;
    int a = t%10;
    if(a == 2 || a==4 || a==5 || a==7 || a==9){
        cout << "hon\n";
    }
    else if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon\n";
    }
    else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
// ITP1_4_D:   Min, Max and Sum
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n;
    int d, min, max;
    long long sum;
 
    scanf("%d%d", &n, &d);
    sum = min = max = d;
    while (--n > 0) {
        scanf("%d", &d);
        if (d < min) min = d;
        if (d > max) max = d;
        sum += d;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}


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

using namespace std;

const int N = 1e5+10;

int dp[N][3];

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

	for(int i = 1; i <= n; i++) {
		int a, b, c;
		cin >> a >> b >> c;

		dp[i][0] = a+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c+max(dp[i-1][0], dp[i-1][1]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 4796
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Point
{
public:
    int x, y;
    bool operator<(const Point& p) const{
        return y < p.y;
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<Point> p(n);
    for(int i=0; i<n; ++i)
        cin >> p[i].x >> p[i].y;
    sort(p.begin(), p.end());

    long long ans = LLONG_MAX;
    for(int i=0; i<n; ++i){
        for(int j=0; j<i; ++j){
            int x1 = p[i].x;
            int x2 = p[j].x;
            if(x2 < x1)
                swap(x1, x2);

            for(int a=0; a<n; ++a){
                int cnt = 0;
                for(int b=a; b<n; ++b){
                    if(x1 <= p[b].x && p[b].x <= x2)
                        ++ cnt;
                    if(cnt == k){
                        ans = min(ans, (x2 - x1) * (long long)(p[b].y - p[a].y));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
int main()
{
  int64 N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
 
  B -= A;
  A -= A;
 
  for(int i = 0; i < N; i++) { // AからCを足す回数
    int64 small1 = C * i;
    int64 large1 = D * i;
    int64 small2 = C * (N - i - 1);
    int64 large2 = D * (N - i - 1);
    if(small1 - large2 <= B && B <= large1 - small2) {
      cout << "YES" << endl;
      return (0);
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main(){

	int n;
	map<int,vector<int> > escape;

	int data[100];
	int field[17];
	fill(field,field+17,-1);

	queue<int> waitQueue;
	int group=0;
	int time=0;
	
	vector<int> c;
	while(cin>>n){
		c.push_back(n);
	}
	
	for(int i=0;;i++){
		time=i;
		if(i%5==0){
			waitQueue.push(group);
			group++;
		}
		// Ü¸ÔØêO[vðÈ©çÇ©·
		for(map<int,vector<int> >::iterator it = escape.begin(); it != escape.end(); it++){
			if(it->first==i){
				for(int j = 0; j < 17; j++){
					for(int k = 0; k< it->second.size(); k++){
						if(field[j]==it->second[k]){
							field[j]=-1;
							break;
						}
					}
				}
				it->second.clear();
				break;
			}
		}
		
		bool f=false;
		int prvCand=-1;
		// ·íêé¾¯·íç¹é
		while(1){
			if(waitQueue.size()==0)
				break;
			// ¡ñÀç¹él
			int cand=waitQueue.front();
			if(prvCand==cand)
				break;
			int s;
			int mergen=-1;
			for(int j = 0; j < 17; j++){
				if(field[j]==-1&&j!=16){
					if(mergen==-1){
						s=j;
						mergen=1;
					}
					else{
						mergen++;
					}
				}
				else{
					if(j==16){
						if(field[j]==-1){
							mergen++;
						}
					}

					if(cand%5==1){
						if(mergen>=5){
							// ·íç¹é
							for(int k = s; k < 5+s; k++){
								field[k]=cand;
							}
							//								cout<<cand<<endl;
							
							data[cand]=time-cand*5;
							waitQueue.pop();
							escape[17*(cand%2)+3*(cand%3)+19+i].push_back(cand);
							if(cand==99){
								f=true;
								break;
							}
							break;
						}
						else{
							mergen=-1;
						}
					}
					else{
						if(mergen>=2){
							// ·íç¹é
							for(int k = s; k < 2+s; k++){
								field[k]=cand;
							}
							data[cand]=time-cand*5;
							waitQueue.pop();
							escape[17*(cand%2)+3*(cand%3)+19+i].push_back(cand);
							if(cand==99){
								f=true;
								break;
							}
							break;
						}
						else
							mergen=-1;
					}
				}
				if(f)
					break;
			}
			if(f)
				break;
			prvCand=cand;
		}
		if(f)
			break;
		
	}
	for(int i = 0; i < c.size(); i++){
		// ±±ÅÜ¿Ôð\¦
		cout<<data[c[i]]<<endl;
	}
	//	}
	
	return 0;
}

Measured memory_bytes: 0
def main():
    n, k, *x = map(int, open(0).read().split())
    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))

    for i, j in zip(x, x[k - 1:]):
        y = j - i + min(abs(i), abs(j))
        if y < l:
            l = y

    print(l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] W = new int[N+1];
    for (int i = 1; i <= N; i++) {
      W[i] = sc.nextInt();
    }

    int[] sumL2R = new int[N+1];
    for (int i = 1; i <= N; i++) {
      sumL2R[i] = sumL2R[i-1] + W[i];
    }
    int[] sumR2L = new int[N+1];
    sumR2L[N] = W[N];
    for (int i = N-1; i >= 1; i--) {
      sumR2L[i] = sumR2L[i+1] + W[i];
    }
    
    int minIndex = 1;
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i <= N-1; i++) {
      int diff = Math.abs(sumL2R[i]-sumR2L[i+1]);
      if (diff < minDiff) {
        minIndex = i;
        minDiff = diff;
      }
    }
    
//    System.out.println(Arrays.toString(sumL2R));
//    System.out.println(Arrays.toString(sumR2L));
//    System.out.println("index: " + minIndex);
//    System.out.println("diff: " + minDiff);
    System.out.println(minDiff);
  }  
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    ll n; cin >> n;
    ll a = (ll)sqrt(n);
    ll b = 0;
    for(int i = a; i >= 1; --i) {
        if(n % i == 0) {
            b = n / i;
            break;
        }
    }
    a = n / b;
    cout << a + b - 2 << endl;

    return 0;
}

Measured memory_bytes: 384
def solve():
    a,b,c = map(int,input().split())
    k = int(input())
    cnt = 0
    while b<=a:
        b*=2
        cnt+=1
    while c<=b:
        c*=2
        cnt+=1
    if cnt<=k:
        print('Yes')
    else:
        print('No')
if __name__=='__main__':
    solve()

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
typedef pair<int,int> P;
typedef pair<P,P> PP;

int main(void)
{
	int i,j,k,u,n,flg[10001],v,c,sum,ky[10001],t,min,g;
	PP ke[10001];
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++) ky[i]=M,flg[i]=0;
	ky[0]=0;
	for(i=0;i<n;i++){
		scanf("%d%d",&u,&k);
		for(j=sum;j<k+sum;j++){
			scanf("%d%d",&v,&c);
			ke[j].ff=u , ke[j].fs=v , ke[j].sf=c;
		}
		sum+=k;
	}
	sort(ke,ke+sum);
	//for(i=0;i<sum;i++) printf("ke[%d].ff=%d ke[%d].fs=%d ke[%d].sf=%d\n",i,ke[i].ff,i,ke[i].fs,i,ke[i].sf);
	for(i=0;i<sum;i++){
		/*min=M;
		for(j=0;j<sum;j++) if(flg[j]==0&&min>ky[j]) g=j,min=j;
		flg[g]=1;
		if(min==M) break;*/
		for(j=0;j<sum;j++){
			t=ky[ke[j].ff]+ke[j].sf;
			if(ky[ke[j].fs]>t) ky[ke[j].fs]=t;
		}
	}
	for(i=0;i<n;i++) printf("%d %d\n",i,ky[i]);
	return 0;
}


Measured memory_bytes: 3388
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
static const double EPS = 1e-10;
static const int mod = 1000000007;
static const int INF = 1<<25;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n,m;
int mem[50050];
int ans=INF;
int coin[25];
int dfs(int sum){
    if(sum==0)return 0;
    if(mem[sum]!=0)return mem[sum];
    int ans=INF;
    for(int i=0;i<m;i++){
        if(sum-coin[i]>=0&&coin[i]>0){
           int temp=dfs(sum-coin[i]);
               if(ans>temp){
                ans=temp;
            }
        }
    }
    return mem[sum]=ans+1;
}


signed main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>coin[i];
    }
    cout<<dfs(n)<<endl;
}

Measured memory_bytes: 3108
#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(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;

  if (r > l) {
    cout << "Right";
  } else if (l > r) {
    cout << "Left";
  } else {
    cout << "Balanced";
  }
  return 0;
}

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

#define MAX 10*10*10*10*10*10*10*10

int prime(int);

int main(){
  int A[10000];
  int n, i, j, sosuu=0;

  scanf("%d",&n);
  if(n < 1 || 10000 < n) exit(1);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
    if(A[i] < 2 || MAX < A[i]) exit(2);
  }

  for(j=0; j<n; j++){
    if(prime(A[j]) == 1) sosuu++;
  }

  printf("%d\n", sosuu);

  return 0;
}

int prime(int A){
  int i;

  for(i=2; i*i<=A; i++){
    if(A%i == 0) return 0;
  }
  return 1;
}

    
  



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

ans = 0
for i in range(0, max(x,y)+1):
    s = a*max(0,x-i)+b*max(0,y-i)+c*2*i
    if ans == 0:
      ans = s
    else:
      ans = min(ans,s)
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int n, m, c;
    scanf("%d%d%d", &n, &m, &c);
    int a[n][m];
    int b[m];
    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++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    int tmp = 0, count = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            tmp += a[i][j] * b[j];
        }
        if (tmp + c > 0)
        {
            count++;
        }
        tmp = 0;
    }

    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int main(void){
	int n, x, cost[101], min_cost, ans;

	scanf("%d %d", &n, &x);

	ans = n;
	min_cost = INT_MAX;
	for(int i=0; i<n; i++){
		scanf("%d", &cost[i]);
		x-= cost[i];
		min_cost = min(min_cost, cost[i]);
	}

	ans += (x/min_cost);

	printf("%d\n", ans);

	return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int max;
	int a[5];
	int i,j;
	int harasyo;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++){
		for(j=0;j<5;j++){
			max=a[i];
			if(max<a[j]){
				harasyo=a[i];
				max=a[j];
				a[j]=harasyo;
				a[i]=max;
			}
		}
	}
	for(i=4;i>0;i--){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 596
n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

def qwe(y):
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in y:
        if i == 'M':
            m += 1
        elif i == 'A':
            a += 1
        elif i == 'R':
            r += 1
        elif i == 'C':
            c += 1
        elif i == 'H':
            h += 1
        else:
            pass
    q = [m,a,r,c,h]
    return q

def qwer(arr):
    count = 0
    for j in range(len(arr)):
        if arr[j] == 0:
            count += 1
            arr[j] = "D"
    while "D" in arr:
        arr.remove("D")
    if count == 5:
        return 0
    if count == 4:
        return 0
    if count == 3:
        return 0
    if count == 2:
        wer = arr[0] * arr[1] * arr[2]
        return wer
    if count == 1:
        asd_1 = arr[0]*arr[1]*arr[2]
        asd_2 = arr[0]*arr[1]*arr[3]
        asd_3 = arr[0]*arr[2]*arr[3]
        asd_4 = arr[1]*arr[2]*arr[3]
        asde = asd_1 + asd_2 + asd_3 + asd_4
        return asde
    if count == 0:
        asf_1 = arr[0]*arr[1]*arr[2]
        asf_2 = arr[0]*arr[1]*arr[3]
        asf_3 = arr[0]*arr[1]*arr[4]
        asf_4 = arr[0]*arr[2]*arr[3]
        asf_5 = arr[0]*arr[2]*arr[4]
        asf_6 = arr[0]*arr[3]*arr[4]
        asf_7 = arr[1]*arr[2]*arr[3]
        asf_8 = arr[1]*arr[2]*arr[4]
        asf_9 = arr[1]*arr[3]*arr[4]
        asf_10 = arr[2]*arr[3]*arr[4]
        asdf =  asf_1 + asf_2 + asf_3 + asf_4 + asf_5 + asf_6 + asf_7 + asf_8 + asf_9 + asf_10
        return asdf
v = qwe(s)
print(qwer(v))


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<vector<int>>to(N),cost(N);
  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    to[u].push_back(v);cost[u].push_back(w);
    to[v].push_back(u);cost[v].push_back(w);
  }
  vector<int>ans(N,-1);
  queue<int>q;
  ans[0]=0;
  q.push(0);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int i=0;i<to[v].size();i++){
      int u=to[v][i];
      int w=cost[v][i];
      if(ans[u]!=-1){continue;}
      ans[u]=(ans[v]+w)%2;
      q.push(u);
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
  return 0;  
}

Measured memory_bytes: 14508
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
        int n,a[100],i,j,tmp,s=0;
        scanf("%d",&n);
        for(i=0;i<n;i++) scanf("%d",&a[i]);
        for(i=1;i<n;i++){
                j=i;
                while((j>0)&&(a[j]>a[j-1])){
                        tmp=a[j]; a[j]=a[j-1]; a[j-1]=tmp;
                        j=j-1;
                }
        }
        for(i=0;i<n;i++){
                if(i%2==0) s+=a[i];
                else s-=a[i];
        }
        printf("%d\n",abs(s));
        return 0;
}


Measured memory_bytes: 128
def levenshtein(X,Y):
    f=[[0 for i in range(len(Y)+1)]for j in range(len(X)+1)]
    for i in range(len(X)+1):
        f[i][0]=i
    for j in range(len(Y)+1):
        f[0][j]=j
    for i in range(1,len(X)+1):
        for j in range(1,len(Y)+1):
            if X[i-1]==Y[j-1]:
                f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1])
            else:
                f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)
    return f[len(X)][len(Y)]

X=input()
Y=input()

print(levenshtein(X,Y))



Measured memory_bytes: 43480
a, b, c, x = map(int, [input() for i in range(4)])

ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500 * i + 100* j + 50 * k == x:
        ans += 1
        
print(ans)
        

Measured memory_bytes: 2940
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        x: i64,
        y: i64,
    }
    for i in 0..=x {
        if 2 * i + 4 * (x - i) == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2168
#include <iostream>


void swap(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void swap_each_pair() {
  int x, y;
  char deli = ' ';
  for (int i = 0; i < 3000; i ++) {

    std::cin >> x >> y;

    if (x == 0 && y == 0) break;
    if (x > y) {
      swap(&x, &y);
    }
    std::cout << x << deli << y << std::endl;
  }
}


int main() {

  swap_each_pair();

  return 0;
}



Measured memory_bytes: 2980
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;

using P = pair<int, int>;
bool flg1[100001];
priority_queue<P, vector<P>, greater<P>> q1_r;
priority_queue<P> q1_l;

bool flg2[100001];
priority_queue<P, vector<P>, greater<P>> q2_r;
priority_queue<P> q2_l;

int Calc(priority_queue<P, vector<P>, greater<P>>& q_r, priority_queue<P>& q_l, bool flg[100001], bool is_r)
{
	int sum = 0;

	int cur = 0;

	if (is_r)
	{
		P p = q_r.top();
		q_r.pop();
		sum += abs(cur - p.first);
		cur = p.first;
		flg[p.second] = true;
	}

	while (true)
	{
		while (true)
		{
			if (q_l.size() <= 0)
			{
				sum += abs(cur);
				return sum;
			}

			P p = q_l.top();
			if (flg[p.second])
			{
				q_l.pop();
				continue;
			}
			if (p.first <= cur)
			{
				sum += abs(cur);
				return sum;
			}
			q_l.pop();
			sum += abs(cur - p.first);
			cur = p.first;
			flg[p.second] = true;
			break;
		}

		while (true)
		{
			if (q_r.size() <= 0)
			{
				sum += abs(cur);
				return sum;
			}

			P p = q_r.top();
			if (flg[p.second])
			{
				q_r.pop();
				continue;
			}
			if (p.first >= cur)
			{
				sum += abs(cur);
				return sum;
			}
			q_r.pop();
			sum += abs(cur - p.first);
			cur = p.first;
			flg[p.second] = true;
			break;
		}
	}

	sum += abs(cur);
	return sum;
}

signed main()
{
	cin >> N;
	REP(i, N)
	{
		int l, r;
		cin >> l >> r;
		q1_r.push(P(r, i));
		q1_l.push(P(l, i));
		q2_r.push(P(r, i));
		q2_l.push(P(l, i));
	}

	int ans = 0;
	if (q1_r.top().first < 0)
	{
		int calc = Calc(q1_r, q1_l, flg1, true);
		ans = MAX(ans, calc);
	}
	if (q2_l.top().first > 0)
	{
		int calc = Calc(q2_r, q2_l, flg2, false);
		ans = MAX(ans, calc);
	}

	cout << ans << endl;
}







Measured memory_bytes: 6852
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
input = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
N,Q=map(int,input().split())
E=[]
for a in range(N):
    s,t,x=map(int,input().split())
    E.append((s-x,1,x))
    E.append((t-x,0,x))

for a in range(Q):
    E.append((int(input()),2,0))
E.sort()
 
S=set()
H=[]
for time_,type_,x in E:
    if type_==1:
        S.add(x)
        heappush(H,x)
    elif type_==0:
        S.remove(x)
    else:
        while H and H[0] not in S:
            heappop(H)
        print(H[0] if H else -1)

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

using namespace std;


int main(void){
    int N;
    cin >> N;
    map<string, int> m;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        if(m.count(s)) m[s] += 1;
        else m[s] = 1;
    }

    int M;
    cin >> M;
    for(int i=0;i<M;i++){
        string s;
        cin >> s;
        if(m.count(s)){
            int x = m[s];
            m[s] = max(x-1, 0);
        }
        else m[s] = 0;
    }

    int ans = 0;
    for(auto& it : m){
        ans = max(ans, it.second);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;

	cin >> n;

	vector<int> b(n);

	for (int i = 0; i < n; ++i)
		cin >> b[i];

	bool ok = true;
	vector<int> a(n);

	for (int i = 0; i < n; ++i) {
		int j = b.size()-1;
		for ( ; j >= 0; --j)
			if (b[j] == j+1)
				break;

		if (j < 0) {
			ok = false;
			break;
		}

		a[n-1-i] = j+1;
		b.erase(b.begin() + j);
	}

	if (ok)
		for (int i = 0; i < n; ++i)
			cout << a[i] << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}



int main(){
  ld a,b,x;
  ld unit_r = 180.0 /M_PI; 
  ld ay;
  cin >> a>> b >> x;
  ld c=(2*x/a/a)-b;
  if(c>=0){
    ay = atan((b-c)/a) * unit_r;
    cout << stpr(10) << ay << endl;
  }
  else{
    ay =atan(b/(2*x/a/b)) *unit_r;
    cout << stpr(10) << ay << endl;
  }
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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


int main()
{
	ll H, W, N, sr, sc;
	cin >> H >> W >> N >> sr >> sc;
	string S, T;
	cin >> S >> T;
	sr--; sc--;

  ll l = 0;
	ll r = W;
	if (S[N-1] == 'L') l++;
	if (S[N-1] == 'R') r--;
	REPR(i, N-1) {
		if (T[i] == 'L') r = min(r+1, W);
		if (T[i] == 'R') l = max(l-1, 0LL);
		if (S[i] == 'L') l++;
		if (S[i] == 'R') r--;
		if (l >= r) {
			PRINT("NO");
			return 0;
		}
	}
	if (!(l <= sc && sc < r)) {
		PRINT("NO");
		return 0;
	}
	l = 0;
	r = H;
	if (S[N-1] == 'U') l++;
	if (S[N-1] == 'D') r--;
	REPR(i, N-1) {
		if (T[i] == 'U') r = min(r+1, H);
		if (T[i] == 'D') l = max(l-1, 0LL);
		if (S[i] == 'U') l++;
		if (S[i] == 'D') r--;
		if (l >= r) {
			PRINT("NO");
			return 0;
		}
	}
	if (!(l <= sr && sr < r)) {
		PRINT("NO");
		return 0;
	}
	PRINT("YES");
	return 0;
}




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

int main() {
    int n, t, a, ret, tmp, min_diff = 100000000;
    cin >>n >>t >>a;
    t *= 1000;
    a *= 1000;
    for (int i = 1; i <= n; i++) {
        cin >> tmp;
        tmp = abs(a-(t-tmp*6));
        if (tmp < min_diff) {
            ret = i;
            min_diff = tmp;
        }
    }
    cout << ret<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    //猫A　犬or猫B 猫がちょうど猫Xいることはありえるか
    //A B X
    int A,B,X;
    scanf("%d %d %d",&A,&B,&X);
    
    if(A>X){
        printf("NO");
        return 0;
    }
    if((A+B)<X){
        printf("NO");
        return 0;
    }

    printf("YES");
    
    return 0;
    
}


Measured memory_bytes: 128
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var w = data[0].toLowerCase();
  
  var cnt = 0;
  for( var i=1; i<data.length; i++ ) {
    var t = data[i].split( ' ' );
    for( var j=0; j<t.length; j++ ) {
      if( w == t[j].toLowerCase() ) {
        cnt++;  
      }
    }
  }
  console.log( cnt );
});

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

int main() {

    int A, B;
    cin >> A >> B;

    if (A > B) {
        if ((A - B) % 2 == 0) {
            cout << B + (A - B) / 2 << endl;
        }
        else {
            cout << "IMPOSSIBLE" << endl;
        }
    }
    else if (A < B) {
        if ((B - A) % 2 == 0) {
            cout << A + (B - A) / 2 << endl;
        }
        else {
            cout << "IMPOSSIBLE" << endl;
        }
    }
    else {
        cout << A << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# C - Vacation AC
N = int(input())
A = []
for _ in range(N):
    a,b,c = map(int,input().split())
    A.append((a,b,c))
    
# 無限大の値
INF = 10**10

# DP テーブル (値と前に選んだ活動を保持)
# a (j = 0), b (j = 1), c (j = 2)に記録
dp = [[0]*3 for _ in range(100010)]

# DP テーブル全体を初期化
for i in range(100010):
    for j in range(3):
        dp[i][j] = -INF# 最大化問題
        
# 初期条件
dp[0][0],dp[0][1],dp[0][2] = 0,0,0
        
# v 日目以前に (v 日目以前の幸福度最大値を求める)
for v in range(1,N+1):
    # v 日目の活動
    for w in range(3):
        # v-1 日目の活動
        for k in range(3):
            # 前日と活動が同じならスルー
            if w == k:
                continue
            # v 日目の情報は A[v-1] であることに注意
            dp[v][w] = max(dp[v][w], dp[v-1][k] + A[v-1][w])

# N 日目以前の幸福度最大値を出力
ans = max(dp[N])            
print(ans)

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

int main() {
  string S;
  cin>>S;
  int C=0;
  if (S=="RRR") C=3;
  else if(S=="RRS") C=2;
  else if(S=="RSR") C=1;
  else if(S=="RSS") C=1;
  else if(S=="SRR") C=2;
  else if(S=="SRS") C=1;
  else if(S=="SSR") C=1;
  else if(S=="SSS") C=0;
  cout<<C<<endl;
  return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    cin >> H >> W;
    vector<string>grid(H);
    for(auto & s : grid) cin >> s;
    vector<vector<int>>edge(400,vector<int>(400,INF));
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            int idx = i * W + j;
            rep(k,4){
                int tx = j + dx[k];
                int ty = i + dy[k];
                if(valid(tx, ty) and grid[ty][tx] != '#' and grid[i][j] != '#'){
                    int tdix = 0;
                    if(tx == j) {
                        if(ty > i) tdix = idx + W;
                        else tdix = idx - W;
                    } else {
                        tdix = idx + (tx - j);
                    }
                    edge[idx][tdix] = edge[tdix][idx] = 1;
                }
            }
        }
    }
    rep(k,400)rep(i,400)rep(j,400) cmin(edge[i][j],edge[i][k] + edge[k][j]);
    int maxi = 0;
    rep(i,400)rep(j,400)if(edge[i][j] != INF and i != j) cmax(maxi, edge[i][j]);
    cout << maxi << endl;
    
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int a[5];
int main()
{
	int ans=0;
	for(int i=0;i<3;i++)a[i]=read();
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]==a[2])return puts("0"),0;
	if(a[1]==a[2])
	{
		if(!((a[1]-a[0])&1))
		return printf("%d",(a[1]-a[0])/2),0;
		else
		return printf("%d",1+(a[1]+1-a[0])/2),0;
	}
	if(((a[2]-a[0])&1)==((a[2]-a[1])&1))
	{
		if(!((a[2]-a[0])&1))return printf("%d",(a[2]-a[0])/2+(a[2]-a[1])/2),0;
		else return printf("%d",1+(a[2]-a[0]-1)/2+(a[2]-a[1]-1)/2),0;
	}
	ans=a[2]-a[1];
	a[0]+=(a[2]-a[1]);a[1]=a[2];
	if((a[2]-a[0])&1)printf("%d",ans+1+(a[2]+1-a[0])/2);
	else printf("%d",ans+(a[2]-a[0])/2);
}

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

using namespace std;

#ifdef LOCAL
#define fre() freopen("in", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

#define IOS std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define repi(a,b) for(int i=a;i<b;i++)
#define repj(a,b) for(int j=a;j<b;j++)
#define mst(a,b) memset(a,b,sizeof(a))

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >>d1 >> m2 >>d2;
    if(d2 == 1)cout << "1\n";
    else cout<<"0\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC159B()
{
	string S;
	cin >> S;
	int N = S.size();
	for (int i = 0; i < N; ++i)
	{
		if (S[i] != S[N - i - 1])
		{
			cout << "No" << endl;
			return;
		}
	}
	int M = (N - 1) / 2;
	for (int i = 0; i < M; ++i)
	{
		if (S[i] != S[M - i - 1])
		{
			cout << "No" << endl;
			return;
		}
		if (S[M + 1 + i] != S[N - i - 1])
		{
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}
int main()
{
	ABC159B();
	return 0;
}


Measured memory_bytes: 256