akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {

	ll N, K;
	cin >> N >> K;

	vector<ll> to(N, 0);
	for (ll i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		to[i] = tmp-1;
	}

	vector<ll> dist(N, INF);

	ll current_dist = 0;

	ll pos = 0;
	ll last_pos = 0;

	ll roop_start = INF;
	ll roop_end = INF;
	ll roop_size = INF;

	while (true) {

		if (dist[pos] < INF) {
			roop_start = pos;
			roop_end = last_pos;
			roop_size = current_dist - dist[pos];
			break;
		}
		if (current_dist == K) {
			cout << pos+1 << endl;
			return 0;
		}

		dist[pos] = current_dist;
		last_pos = pos;
		pos = to[pos];
		current_dist++;
	}

	ll last_count = (K - current_dist) % roop_size;

	for (int i = 0; i < last_count; i++) {
		pos = to[pos];
	}


	cout << pos+1 << endl;

	return 0;

}


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

int main() {
  while (true) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0) {
      break;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        if (i == j) {
          continue;
        }
        int k = x - i - j;
        if (k != i && k != j && k >= j && k <= n) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  
}



Measured memory_bytes: 3084
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#include <cassert>
using namespace std;

struct TSolver
{
    int N;
    vector<int> Colors;

    bool Setup()
    {
        if (!(cin >> N)) {
            return false;
        }
        Colors.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> Colors[i];
        }
        return true;
    }

    void Solve()
    {
        int result = 0;
        for (int l = 0; l < N; ) {
            int r = l;
            while (Colors[r] == Colors[l] && r < N) {
                ++r;
            }
            result += (r - l) / 2;
            l = r;
        }
        cout << result << endl;
    }

    void TearDown()
    {
        cout.flush();
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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

    TSolver solver;
    while (solver.Setup()) {
        solver.Solve();
        solver.TearDown();
    }

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);

int H,W;
vector<string> maze;
vector<vector<int>> memo;

bool movable(int x,int y,int X,int Y)
{
  if(X<0||X>=W||Y<0||Y>=H) {return false;}
  if(maze.at(Y).at(X)=='#') {return false;}
  if(memo.at(Y).at(X)!=-1) {return false;}
  return true;
}


int main() 
{
  cin>>H>>W;
  int ans=0;
  maze=vector<string>(H);
  rep(i,H)
  {
    cin>>maze.at(i);
  }
  rep(i,H*W)
  {
    for(int j=0;j<i;j++)
    {
      int sx=i%W,sy=i/W,gx=j%W,gy=j/W;
      if(maze.at(sy).at(sx)=='#'||maze.at(gy).at(gx)=='#') {continue;}
      queue<vector<int>> next;
      memo=vector<vector<int>>(H,vector<int>(W,-1));
      memo.at(sy).at(sx)=0;
      next.push({sx,sy});
      while(!next.empty())
      {
        int x=next.front().at(0),y=next.front().at(1);
        //cout<<x<<" "<<y<<endl;
        next.pop();
        if(x==gx&&y==gy) {break;}
        
        if(movable(x,y,x+1,y))
        {
          memo.at(y).at(x+1)=memo.at(y).at(x)+1;
          next.push({x+1,y});
        }
        if(movable(x,y,x-1,y))
        {
          memo.at(y).at(x-1)=memo.at(y).at(x)+1;
          next.push({x-1,y});
        }
        if(movable(x,y,x,y+1))
        {
          memo.at(y+1).at(x)=memo.at(y).at(x)+1;
          next.push({x,y+1});
        }
        if(movable(x,y,x,y-1))
        {
          memo.at(y-1).at(x)=memo.at(y).at(x)+1;
          next.push({x,y-1});
        }
      }
      ans=max(ans,memo.at(gy).at(gx));
    }
  }
  cout<<ans<<endl;
      
    
  return 0;
}

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

using namespace std;

using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n,n){
        ll dp[31][50];
        vector<vector<int>>scd(31);
        for(int i=0;i<n;++i){
            int f;
            cin>>f;
            for(int j=0;j<f;++j){
                int c;
                cin>>c;
                scd[c].push_back(i);
            }
        }
        for(int i=0;i<n;++i){
            dp[0][i]=ll(1) << i;
        }
        int ans = -1;
        for(int i=1;i<31;++i){
            for(int j=0;j<n;++j){
                dp[i][j]=dp[i-1][j];
            }
            for(auto x:scd[i]){
                for(auto y:scd[i]){
                    if(x != y){
                        dp[i][x] |= dp[i][y];
                    }
                }
                if(dp[i][x] == (ll(1) << (n)) - 1){
                    ans=i;
                    goto end;
                }
            }
        }
        end:
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;
vs a;

int main(){
	cin>>h>>w;
	a=vs(h);
	for(int i=0;i<h;i++) cin>>a[i];
	vvi dp(h,vi(w,inf));
	if(a[0][0]=='#') dp[0][0]=1;
	else dp[0][0]=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(i){
			dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.'));
		}
		if(j){
			dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.'));
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 256
s=input()
L=[[s,0]]
for i in range(1,len(s)):
    M=[]
    for l in L:
        M.append([(l[0][:i+l[1]])+"+"+(l[0][i+l[1]:]),l[1]+1])
    L+=M
print(sum(map(lambda x:eval(x[0]),L)))

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict
import math

a, b = input().split()
a = int(a)
ans = 0
ans += a * int(b[-1])
ans += a * int(b[-2]) * 10
ans += a * int(b[:-3]) * 100
if len(str(ans)) < 3:
    print(0)
else:
    print(str(ans)[:-2])

Measured memory_bytes: 65172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ok = false;
    if (abs(a-c) <= d) ok = true;
    else if (abs(b-a) <= d && abs(c-b) <= d) ok = true;
    printf(ok?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    map<ll,ll> a;
    rep(i,n){
      ll x;
      cin>>x;
      a[x]++;
    }
    //vector<ll> b(m),c(m);
    rep(i,m){
      ll b,c;
      cin>>b>>c;
      a[c]+=b;
    }
    ll ans=0;
    ll cnt=0;
    for(auto itr=end(a);itr!=begin(a);itr--){
      if(itr==end(a)) continue;
      if(cnt==n) break;
      ans+=itr->first*itr->second;
      cnt+=itr->second;
      if(cnt>n){
        ans-=(itr->first)*(cnt-n);
        break;
      }
    }
    if(cnt<n){
      ans+=(begin(a)->first)*(n-cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int N, M;
vector<P> V;


void input() {
	cin >> N >> M;
	P tmp;
	for (int i = 0; i < M; i++) {
		cin >> tmp.first >> tmp.second;
		V.push_back(tmp);
	}
	sort(V.begin(), V.end());
}

void solve() {
	int ans = 0;

	int q = 0;
	while (q < M) {
		int end = V[q].second;
		q++;
		while (q < M && V[q].first < end) {
			if (V[q].second < end) end = V[q].second;
			q++;
		}
		ans++;
		// cout << end - 1 << " ";
	}
	cout << ans << endl;
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    int n;
    //int cost=0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
    }
    cout << dp[n - 1] << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N;
  cin >> N;
  N++;
  int nod = 0;
  while (N > 10) {
    N /= 10;
    nod++;
  }
  cout << N - 1 + 9 * nod << '\n';
  return 0;
}


Measured memory_bytes: 256
def read_input():
    n = int(input())
    s = input().strip()
    k = int(input())

    return n, s, k



if __name__ == '__main__':
    n, s, k = read_input()

    target_char = s[k - 1]

    result = ''
    for c in s:
        if c != target_char:
            result += '*'
        else:
            result += c

    print(result)

Measured memory_bytes: 3060
let scan1 f = stdin.ReadLine() |> f

let n = scan1 int

let eight m = // m は奇数と保証されている。偶数は約数にならない
  [1..2..m]
  |> List.filter (fun k -> m % k = 0)
  |> List.length
  |> (=) 8

[1..2..n]
|> List.filter eight
|> List.length
|> printfn "%d"

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

int main() {
string s;
int q;
cin >> s >> q;
int que;
int f;
char c;
bool flag=false;
for(int i=0;i<q;i++){
scanf("%d", &que);
if(que==1){
    if(flag){flag=false;
    continue;}
    flag=true;
}
else{
    scanf(" %d", &f);
    scanf(" %c", &c);
if(flag){if(f==1){s.insert(s.end(),c);}
else{s.insert(s.begin(),c);} 
continue;}
if(f==2){s.insert(s.end(),c);}
else{s.insert(s.begin(),c);}     
} }
if(flag)reverse(s.begin(),s.end());
cout << s;
}


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

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> p(n);
  UnionFind uf(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
    p[i]--;
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    uf.unite(x,y);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(uf.same(i,p[i]))ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
	int a, b, c, d;
	int count=0;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	while(a > 0 && c > 0){
		if(count==0)
			c -= b;
		else
			a -= d;
		count = !count;
	}
	
	if(a <= 0)
		printf("No");
	else
		printf("Yes");
	return 0;	
}

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

void solve(std::string S) {
  int n = S.length();
  int ans = 0;
  for (int i = 0; i < n / 2; i++) {
    if (S[i] != S[n - 1 - i]) ans++;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                int r = sc.nextInt();
                if (n==0&&r==0) break;
                int p[] = new int[r];
                int c[] = new int[r];
                for (int i = 0; i < r; i++) {
                    p[i] = sc.nextInt();
                    c[i] = sc.nextInt();
                }
                int num[] = new int[n];
                for (int i = 0; i < n; i++) {
                    num[i] = n - i;
                }
                for (int i = 0; i < r; i++) {
                    int tmp[] = new int[n];
                    for (int j = 0; j < c[i]; j++) {
                        tmp[j] = num[p[i]+j-1];
                    }
                    for (int k = 0; k < p[i]-1; k++) {
                        tmp[c[i] + k] = num[k];
                    }
                    for (int l = 0; l < p[i]+c[i]-1; l++) {
                        num[l] = tmp[l];
                    }
                }
                System.out.println(num[0]);
            }
        }
    }
}


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

int main(void) {
	double x1, x2, y1, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%.8lf", sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
	return 0;
}

Measured memory_bytes: 656
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nt = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var min = ar[0];
        var dif = new int[nt[0]];
        for(var i = 1; i < nt[0]; i++)
        {
            if (min > ar[i])
            {
                min = ar[i];
                dif[i] = 0;
            }
            else
                dif[i] = ar[i] - min;
        }
        var max = dif.Max();
        WriteLine(dif.Count(v => v == max));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 21088
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    string S;
    cin >> S;
    int max_ans = 0;
    for (int i=1;i<S.length();i++){
        int ans = 0;
        vector<char> first;
        vector<char> last;
        for (int j=0;j<i;j++){
            first.push_back(S[j]);
        }
        for (int j=i;j<S.length();j++){
            last.push_back(S[j]);
        }
        int cnt = 0;
        for (char c='a';c<='z';c++){
            bool left=false;
            bool right=false;
            vector<char>::iterator FIter = find(first.begin(),first.end(),c);
            vector<char>::iterator LIter = find(last.begin(),last.end(),c);
            if ((FIter != first.end()) && (LIter != last.end())) cnt += 1;
        }
        if (cnt>=max_ans) max_ans = cnt;
    }
    cout << max_ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int buf[10005];
int A[10005];
int B[10005];
int H,N;
int F(int x)
{
    int i,a,minf;
    if(x<=0) return 0;
    if(buf[x]!=-1)return buf[x];
    else
    {
        minf=1000000000;
        for(i=0; i<N; i++)
        {
            a=F(x-A[i])+B[i];
            if(minf>a)
            {
                minf=a;
            }
        }
        buf[x]=minf;
        return minf;
    }
}
int main()
{
    scanf("%d%d",&H,&N);
    int i;
    for(i=0; i<N; i++)
    {
        scanf("%d%d",&A[i],&B[i]);
    }
    for(i=0;i<10005;i++)
    {
        buf[i]=-1;
    }
    printf("%d\n",F(H));

    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 500001
int dp[101];
int main(void) {
	int N;
	scanf("%d", &N);
	dp[0] = 1;
	rep(i, 0, 101) {
		if(i >= 4)dp[i] |= dp[i - 4];
		if (i >= 7)dp[i] |= dp[i - 7];
	}
	puts(dp[N] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

long long cost[100008];
long long cost_d[100008];
int n,m;
using namespace std;
void add(int lf,int rg,int start,int d) {
	if(lf>rg) return;
	cost[lf]+=start;
	cost_d[lf+1]+=d;
	cost_d[rg+1]-=d;
	cost[rg+1]+=-start-d*(rg-lf);
}
int main() {
	cin >> n >> m;
	int vl[100008];
	for(int i=0;i<n;i++) cin >> vl[i];
	for(int i=1;i<n;i++) {
		if(vl[i-1]<vl[i]) {
			add(1,vl[i-1],vl[i]-vl[i-1],0);
			add(vl[i-1]+1,vl[i],vl[i]-vl[i-1],-1);
			add(vl[i]+1,m,vl[i]-vl[i-1],0);
		}
		if(vl[i-1]>vl[i]) {
			add(1,vl[i],vl[i],-1);
			add(vl[i]+1,vl[i-1],m-vl[i-1]+vl[i],0);
			add(vl[i-1]+1,m,m-vl[i-1]+vl[i],-1);
		}
	}
	for(int i=1;i<=m;i++) cost_d[i]+=cost_d[i-1];
	for(int i=1;i<=m;i++) cost[i]+=cost[i-1]+cost_d[i];
	long long minv=cost[1];
	for(int i=2;i<=m;i++) {
		if(minv>cost[i]) minv=cost[i];
	}
	cout << minv << endl;
	return 0;
}


Measured memory_bytes: 2176
{-# LANGUAGE BangPatterns      #-} --引数に!

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS
import Debug.Trace

cnt :: [Char] -> Int
cnt [] = 0
cnt (a:s) = if a == 'o' then 1 + (cnt s) else cnt s

main :: IO ()
main = do
  s <- getLine
  if (cnt s)+(15 - (length s)) >= 8 then putStrLn $ "YES" else putStrLn "NO"


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

int main(){
  int N;
  int s=0;
  cin>>N;
  int a[N];
  
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  for(int i=0;i<N;i++){
    int v = a[i];
    int j = i-1;
    while(j>=0 && a[j] < v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
  }
  
  for(int i=1;i<N;i++) s += a[i];
  if(s>a[0]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	if n%2 == 0 && s[0:n/2] == s[n/2:len(s)] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
def solve():
    n = int(input())
    a = []
    for i in range(n):
        key, value = input().split()
        value = -int(value)
        a.append([key, value, i + 1])
    a.sort()
    for i in a:
        print(i[2])
 
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
s = input()

l, r = 0, len(s)-1
ans = 0
i = 0

while l<r:
    left = s[l]
    right = s[r]
    
    if left == right:
        l += 1
        r -= 1
    else:
        if left == 'x':
            l += 1
            ans += 1
        elif right == 'x':
            r -= 1
            ans += 1
        else:
            print(-1)
            exit()
    i += 1

print(ans)

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

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

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

    int cnt=0;

    for(int i=1; i<n-1; i++){
            if(vec.at(i-1)<vec.at(i) && vec.at(i)<vec.at(i+1))cnt++;
            if(vec.at(i-1)>vec.at(i) && vec.at(i)>vec.at(i+1))cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
import heapq

N, M = map(int,input().split())
a = list(map(int,input().split()))
count = 0

for i in heapq.nlargest(M,a):
    if(1 / (4 * M) <= i / sum(a)):
        count += 1

if(count == M):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import sys

target = 753

s = sys.stdin.readline().rstrip()

def main():
    d = 642
    for i in range(len(s) - 2):
        d = min(d, abs(target - int(s[i:i+3])))
    
    return d

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

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        long add = 0;
        for (int i = n - 1; i >= 0; i--) {
            a[i] += add;
            long tarinai = a[i] % b[i];
            if (tarinai > 0) {
                add += b[i] - tarinai;
            }
        }
        System.out.println(add);
    }
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<string>> c(h + 1, vector<string>(w + 1));
  rep(i, h) {
    string temp;
    cin >> temp;
    rep(j, w) {
      c[i + 1][j + 1] = temp[j];
    }
  }

  for (int i = 1; i <= h * 2; i++) {
    for (int j = 1; j <= w; j++) {
      cout << c[(i + 1) / 2][j];
    }
    cout << endl;
  }

  return 0;
}


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

int gcd(int a,int b){
    int temp=a;
    while(a){
        b%=a;
        temp=b;
        b=a;
        a=temp;
    }
    return b;
}

int lcm(int a,int b){
    int c=gcd(a,b);
    return a*b/c;
}

int main(){
    int n;
    int a,b;
    cin>>n;
    cin>>a;
    for(int i=1;i<n;i++){
        cin>>b;
        a=lcm(a,b);
    }
    cout<<a<<endl;

    return 0;
}



Measured memory_bytes: 3096
# -*- coding: utf-8 -*-

import sys

u"""
最初にdictにいれ、key=number, value=count
それを元に (count, number)のリストをつくり、昇順にソート
リストの長さがK以下になるまでリストをたどる
"""

n, k = [int(e) for e in raw_input().split()]
al = [int(e) for e in raw_input().split()]

d = {}
for a in al:
    d[a] = d.get(a, 0) + 1
# print d

l = []
for dk, dv in d.iteritems():
    # l.append((dv, dk))
    l.append(dv)
l.sort(reverse=True)
# print l

b = 0
for e in l[k:]:
    b += e
    
# i = 0
# b = 0
# ll  = len(l)
# llc = ll
# while llc > k:
#     if i >= ll:
#         break
#     c = l[i]
#     llc -= c
#     b += c
#     i += 1
    
sys.stdout.write('%d\n' % b)
sys.stdout.flush()


Measured memory_bytes: 28656
#include <iostream>
using namespace std;
int main(){
    int n, x;
    cin >> n;
    for(int i = 1; i <= n; i++){
        x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }else{
            while(x){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }else{
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3084
k = int(input())

n = 50
ans = [i for i in range(n)]

for i in range(n):
    ans[i] += k // n

for i in range(k % n):
    ans[i] += n
    for j in range(n):
        if i == j:
            continue
        ans[j] -= 1

print(n)
a = [str(x) for x in ans]
print(' '.join(a))


Measured memory_bytes: 3064
l = [int(x) for x in list(input())]

ans=0
n1=n2=n3=0

for i in range(2):
    if ans==7:
        break
    for j in range(2):
        if ans==7:
            break
        for k in range(2):
            if ans==7:
                break
            ans=l[0]+l[1]*(-1)**i+l[2]*(-1)**j+l[3]*(-1)**k
            n1=i
            n2=j
            n3=k


print(l[0],end="")
print(str(n1).replace("0", '+').replace("1", '-'),end="")
print(l[1],end="")
print(str(n2).replace("0", '+').replace("1", '-'),end="")
print(l[2],end="")
print(str(n3).replace("0", '+').replace("1", '-'),end="")
print(l[3],end="")

print("="+str(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int A, B, ans = 0;
    cin >> A >> B;
    for (int i = 0; i < 2; i++) {
        if (A > B) {
            ans += A;
            A--;
        }
        else {
            ans += B;
            B--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, y = list(map(int,input().split()))
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n - i - j )==y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)

Measured memory_bytes: 40684
using System;
using System.Linq;


namespace _009_PrimeNumber
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] primeTable = new int[1000000];

			primeTable[2] = 1;

			for (int lp = 3; lp < primeTable.Length; lp++)
			{
				bool isOdd = lp % 2 == 1;

				if (isOdd)
				{
					int number = 3;
					bool isPrimeNumber = true;

					while (number <= Math.Sqrt (lp))
					{
						if (lp % number == 0 )
						{
							isPrimeNumber = false;
							break;
						}

						number += 2;
					}

					if (isPrimeNumber)
					{
						primeTable[lp] = primeTable[lp - 1] + 1;
					}
					else
					{
						primeTable[lp] = primeTable[lp - 1];						
					}
				}
				else
				{
					primeTable[lp] = primeTable[lp - 1];						
				}
			}

			string inputStr;
			while ((inputStr = Console.ReadLine ()) != null)
			{
				int index = int.Parse (inputStr);

				int count = primeTable[index];

				Console.WriteLine (count);
			}
		}
	}
}

Measured memory_bytes: 13044
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]
    ans = 0
    for i in range(N):
        val = sum(A[0][:i + 1]) + sum(A[1][i:])
        ans = max(ans, val)
    print(ans)


if __name__ == "__main__":
    main()


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

string st;
int a=1;

int main(){
	cin>>st;
	for(int i=0;i<st.length();i++){
		for(int j=1;j<=(st.length()-i-1);j++){
			if(st[i]==st[i+j]){
				a=0;
			}
		}
	}
	if(a==0){
		cout<<"no"<<endl;
	}else{
		cout<<"yes"<<endl;
	}
	return 0;
}

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

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = ni();
		}
		Arrays.parallelSort(a);

		out(a[n - 1] - a[0]);

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    for (char c = 'a'; c <= 'z'; c += 1) {
        for (int i = 0; i < N - 1; i++) {
            if (S[i] == c and S[i + 1] == c) {
                cout << i + 1 << " " << i + 2 << endl;
                return 0;
            }
        }

        for (int i = 0; i < N - 2; i++) {
            if (S[i] == c and S[i + 2] == c) {
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
x,y = map(int,input().split())
if 0<=x<=y:
    a = y-x
elif 0<=y<=x:
    if y>0:
        a = x-y+2
    else:
        a = x-y+1
elif 0>=x>=y:
    if x<0:
        a = x-y+2
    else:
        a = x-y+1
elif 0>=y>=x:
    a = y-x
elif y>=0>=x and abs(x)<=abs(y):
    a = min(y-x,y+x+1)
elif y>=0>=x and abs(x)>abs(y):
    a = min(y-x,-y-x+1)
elif x>=0>=y and abs(x)>=abs(y):
    a = y+x+1
elif x>=0>=y and abs(x)<abs(y):
    a = -y-x+1
print(a)

Measured memory_bytes: 61824
N = int(input())
S = input()
K = S
left = 0
right = 0
for i in range(N):
    if S[i] == "(":
        left += 1
    elif S[i] == ")":
        right = 1

    if right == 1 and left == 0:
        K = "(" + K
        right = 0
    elif right == 1 and left > 0:
        right = 0
        left -= 1

S = K
left = 0
right = 0
for i in range(1,N+1):
    if S[-i] == "(":
        left = 1
    elif S[-i] == ")":
        right += 1

    if right == 0 and left == 1:
        K = K + ")"
        left = 0
    elif right > 0 and left == 1:
        right -= 1
        left = 0
print(K)


Measured memory_bytes: 3064
N = int(input())
list = [list() for _ in range(N)]
if N == 1:
  print(1)
  exit()

for i in range(N):
  a = int(input())
  for j in range(a):
    x,y = map(int,input().split())
    list[i].append([x,y])

ans = 0
for i in range(2**N):
    flg = False
    do = [0] * N
    for j in range(N):
      if ((i >> j) & 1):
        do[j] = 1
    P = [-1] * N
    for n in range(N):
      if flg:break
      for p in list[n]:
        if P[p[0]-1] == -1:
          if do[n] == 1:
            P[p[0]-1] = p[1]
            if P[p[0]-1] != do[p[0]-1]:
              flg = True
          #else:
          #  if p[1] == 1:
          #    P[p[0]-1] = 0
          #  else:
          #    P[p[0]-1] = 1
        else:
          if do[n] == 1 and P[p[0]-1] != p[1]:
            flg = True
    if flg:
      continue
    ans = max(ans,sum(do))
print(ans)





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

namespace ABC150_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var count = 0;
            for (int i = 0; i < N-2; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:usize = read();
    let mut an = vec![vec![0,0,0]];
    for _ in 0..n{
        an.push(read_vec::<i64>());
    }
    let ans:bool = (0..n).all(|i|{
        let move_diff = an[i+1][0] -an[i][0];
        let point_diff = (an[i+1][1]-an[i][1]).abs() + (an[i+1][2]-an[i][2]).abs();
        (point_diff <= move_diff && point_diff % 2 == move_diff % 2)
    });
    println!("{}" ,if ans { "Yes"} else {"No"});
}

Measured memory_bytes: 10492
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, m, x; cin >> n >> m >> x;
  vector <int> c(n);
  vector <vector <int>> g(n);
  for(int i = 0; i < n; i++) {
    cin >> c[i];
    g[i].resize(m);
    for(int j = 0; j < m; j++) {
      cin >> g[i][j];
    }
  }
  int ans = 1e9;
  for(int i = 0; i < (1 << n); i++) {
    int cost = 0;
    vector <int> skill(m, 0);
    for(int j = 0; j < n; j++) {
      if(!((i >> j) & 1)) continue;
      cost += c[j];
      for(int k = 0; k < m; k++) {
        skill[k] += g[j][k];
      }
    }
    bool okay = 1;
    for(int k = 0; k < m; k++) {
      if(skill[k] < x) okay = 0;
    }
    if(okay) {
      ans = min(ans, cost);
    }
  } if(ans == 1000000000) ans = -1;
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


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

int main(){
  int N; double value;
  cin >> N;
  vector<double> v(N);
  for(double i = 0; i < N; i++)
    cin >> v[i];
    
  sort(v.begin(), v.end(), greater<double>());

  for(double i = 0; i < N - 1; i++){
    value += v[i] / pow(2, i + 1);
  }
  
  value += v[N - 1] / pow(2, N - 1); 
    
    cout << value << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc079a()
}

fun abc079a() {
    val n = readLine()!!.toCharArray()

    val answer = if (n.take(3).all { it == n[1] } || n.takeLast(3).all { it == n[1] }) "Yes" else "No"

    println(answer)

}


Measured memory_bytes: 34112
#include<bits/stdc++.h>
using namespace std;
int n;
int a[16];
int x[16][16],y[16][16];
bool aa[16];
bool check(){
	for(int i=1;i<=n;i++){
		if(aa[i]){
			for(int j=1;j<=a[i];j++){
				if(aa[x[i][j]]!=y[i][j])
					return false;
			}
		}
	}
	return true;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		for(int j=1;j<=a[i];j++){
			cin>>x[i][j]>>y[i][j];
		}
	}
	int ans=0;
	int cnt=0;
	while(1){
		int i;
		for(i=n;aa[i];i--){
			aa[i]=0;
			cnt--;
		}
		aa[i]=1;
		cnt++;
		if(aa[0]){
			break;
		}
		if(check())
			ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    int n, t; cin >> n >> t;
    vi a(n); REP(i, n) cin >> a[i];
    vi b(n);
    int min = a[0];
    b[0] = -INF;
    FOR(i, 1, n)
    {
        if(min > a[i-1]) min = a[i-1];
        b[i] = a[i] - min;
    }
    int m = -INF;
    int count = 0;
    REP(i, n)
    {
        if(m < b[i])
        {
            m = b[i];
            count = 1;
        }
        else if(m == b[i]) count++;
    }
    cout << count << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	char X,a,e,i,o,u;
	scanf("%c",&X);
	if(X=='a'||X=='e'||X=='i'||X=='o'||X=='u')
	{
		printf("vowel");
	}
	else
	{
		printf("consonant");
	}
	return 0;
} 


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , m = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      m += 1;
      break;
    }
  }
  
  if (m == 1) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
  
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<char> c(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> c[i];
    }

    int l = 0;
    int r = n - 1;
    int count = 0;
    while (l < r)
    {
        if (c[l] == 'W' && c[r] == 'R'){
            count++;
            l++;
            r--;
        }
        else if (c[l] == 'W' && c[r] == 'W')
        {
            r--;
        }
        else if (c[l] == 'R' && c[r] == 'R')
        {
            l++;
        }
        else
        {
            l++;
            r--;
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))
 
def solve(i, m_i):
    if m_i == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m_i) or solve(i + 1, m_i - a[i])
    return res
 
for m_tmp in m:
    if sum(a) < m_tmp:
        print("no")
    elif solve(0, m_tmp):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        var s = scaner.next();
        var t = scaner.next();

        String ans = "Yes";

        if (!(s.equals(s.toLowerCase()) && t.equals(t.toLowerCase()))) {
            ans = "No";
        }

        var l = s.length();
        if (!(1 <= l && l <= 10)) {
            ans = "No";
        }

        if (!(l+1 == t.length())) {
            ans = "No";
        }

        var tt = t.substring(0, s.length());
        if (!s.equals(tt)) {
            ans = "No";
        }

        System.out.println(ans);
        scaner.close();
    }

}


Measured memory_bytes: 35704
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		
		int a = N/2;
		
		if (N%2 == 0 ) {
			
			System.out.print(a);
		}else{
			System.out.print(a + 1);

		}

	}
	
}




Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int D, W;
  while (cin >> D >> W && D) {
    vector<vector<int>> garden(D, vector<int>(W));
    REP(i, D) REP(j, W) {
      cin >> garden[i][j];
    }
    int ans = 0;
    REP(is, D) REP(js, W) REP(ie, D) REP(je, W) {
      if (is + 1 >= ie || js + 1 >= je) { continue; }
      // cerr << stringify(is, js, ie, je) << "\n";
      int wall_height = infty<int>;
      FOR(x, is, ie) {
        chmin(wall_height, garden[x][js]);
        chmin(wall_height, garden[x][je]);
      }
      FOR(y, js, je) {
        chmin(wall_height, garden[is][y]);
        chmin(wall_height, garden[ie][y]);
      }
      // cerr << "wall_height: " << wall_height << "\n";
      int pond_height = -1;
      int water = 0;
      FOR(x, is+1, ie-1) FOR(y, js+1, je-1) {
        // cerr << stringify(x, y) << "\n";
        int const h = garden[x][y];
        chmax(pond_height, h);
        water += wall_height - h;
      }
      if (pond_height >= wall_height) { continue; }
      chmax(ans, water);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 4e4 + 5;
const int inf = 2e9 + 7;
int a[maxn], b[maxn];

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

	ll n, a, b;
	cin >> n >> a >> b;
	if (a == 0 && b == 0) { cout << "0\n"; return 0; }

	ll c = n / (a + b), d = min(a, n % (a + b));
	cout << c * a + d << endl;


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;

    rep(j,n)rep(i,j){
        chmax(ans,abs(a[i]-a[j]));
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if(a+W < b) {
        cout << b - (a+W) << endl;
        return 0;
    }
    else if(b+W < a){
        cout << a - (b+W);
    }
    else {
        cout << '0' << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3596