akhauriyash/Code-Regression huggingface dataset:
/*
AizuOnline A2243
Title step step revolution
*/
#include <stdio.h>
#include <string.h>
#define min(x,y) (((x)<(y))?(x):(y))

#define RIGHT 0
#define LEFT  1
char steps[100000];
int rl;
char prev_l=0,prev_r=0;
int call_cnt=0;
int valid_step(char next,int rl)
{
        int ret,p,n,prev;

        n=next -= '0'; n %= 3;if(n==0)n=3;
        prev=(rl==RIGHT)?prev_l:prev_r;
        p=prev; p %=3;if(p==0)p=3;

#ifdef DEBUG
        printf("N:%d (%d)PL:%d PR:%d=>%d\n",next,n,prev_l,prev_r,p);
        printf("rl%d p<N%d\n",rl==RIGHT,p<n);
#endif
        if(call_cnt==0)
        {
                call_cnt++;
                ret=-1;
        }
        else if(p==n)
                ret=-1;
        else if(rl==RIGHT && (p<n))
                ret=(-1);
        else if(rl==LEFT &&  (p>n))
                ret=(-1);
        else
                ret=(0);
        if((ret && rl==RIGHT) ||(!ret && rl==LEFT))
                prev_r=next;
        else
                prev_l=next;
#if DEBUG
        printf("rl=%s ret=%d\n",rl?"LEFT":"RIGHT",ret);
#endif
        return(ret);
}
int solve(char * steps)
{
        int last_foot,cnt;
        char *p;
 
        p=steps;
        cnt=0;prev_l=prev_r=1;call_cnt=0;
        for(;*p;p++)
        {
                if(valid_step(*p,rl))
                {
                        rl = 1-rl;
                }
                else
                {
                        cnt++;
                }
                //printf("PL:%d PR:%d\n",prev_l,prev_r);
        }
        return(cnt);
}
//
main()
{
        int cnt_r,cnt_l;

        while(scanf("%s",steps) && strcmp("#",steps))
        {
                rl=RIGHT;
                cnt_r=solve(steps);
                rl=LEFT;
                cnt_l=solve(steps);
                printf("%d\n",min(cnt_r,cnt_l));
                memset(steps,'\0',sizeof(memset));
        }
return(0);
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll a;
    cin>>a;
    ll sum=1+a;
    for(ll i=(ll)(sqrt(a));i>=1;i--){
        if(!(a%i)){
            sum=min(sum,i+(a/i));
        }
    }
    cout<<(sum-2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>


int main() {
   int n,x,y;
   cin>>n>>x>>y;
   int ans[n]={0};
   for(int i=1;i<=n;i++)
   {
       for(int j=i+1;j<=n;j++)
       {
             int dis1=max(x,i)-min(x,i)+1+max(y,j)-min(y,j);
            // int dis2=max(x,j)-min(x,j)+1+max(y,i)-min(y,i);
             int dis3=j-i;
             int an=min(dis1,dis3);
             ans[an]++;
       }
   }
   for(int i=1;i<n;i++)
    cout<<ans[i]<<"\n";
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
    P.at(i)--;
    Q.at(P.at(i)) = i;
  }
  
  int ans = INF;
  int cnt = 1;
  for (int i = 1; i < N; i++)
  {
    if (Q.at(i - 1) < Q.at(i)) cnt++;
    else
    {
      chmin(ans, N - cnt);
      cnt = 1;
    }
  }
  chmin(ans, N - cnt);

  cout << ans << endl;
}

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

int N;
double t[102], T[102] = {0};
double V[102];

double velocity(double l, double r, double x, double v){
    if (0 <= x && x <= l) return v+l-x;
    else if(l <= x && x <= r) return v;
    else return v+x-r;
}

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> t[i];
        T[i+1] = T[i] + t[i];
    }
    for(int i=1;i<=N;i++) cin >> V[i];

    V[0] = 0;
    V[N+1] = 0;
    double time = 0;
    vector<double> F;
    while (time <= T[N+1]){
        double nowv = 1e9;
        for(int i=0;i<=N+1;i++){
            if (i==0) nowv = min(nowv, velocity(0, 0, time, 0));
            else if (i==N+1) nowv = min(nowv, velocity(T[N+1], T[N+1], time, 0));
            else nowv = min(nowv, velocity(T[i], T[i+1], time, V[i]));
        }
        F.push_back(nowv);
        time += 0.5;
    }
    double ans = 0;
    for(int i=0;i<F.size();i++){
        ans += 0.25*(F[i]+F[i+1]);
    }
    cout << fixed << setprecision(12);
    cout << ans << endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,a;
    int cnt[3]={};
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        cnt[a%3]++;
    }
    
    int ans = 0;
    if(cnt[0] < n) ans += cnt[0];
    if(cnt[1] > cnt[2]){
        cnt[1]--;
        ans++;
    } else if(cnt[2] > 0){
        cnt[2]--;
        ans++;
    }
    ans += min(cnt[1],cnt[2])*2;
    if(cnt[1] != cnt[2]) ans++;
    if(ans < n) ans++;
    
    cout << ans << endl;
    
    return(0);
}



Measured memory_bytes: 3104
a = int(input())

s = [input().split() for i in range(3)]

count =  0

num = s[0]
point = s[1]
bonus = s[2]


for p in range(int(len((num)))):
    count += int(point[int(num[p])-1])
    #print(count)

for q in range(int(len(num))-1):
    if int(num[q+1]) - int(num[q]) == 1:
        count += int(bonus[int(num[q])-1])
       # print(count)
    else:
        pass
print(count)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int y = in.nextInt();
            for (int n1 = 0; n1 <= n; n1++) {
                for (int n2 = 0; n2 <= n - n1; n2++) {
                    int n3 = (n - n1 - n2);
                    if (n1 * 1000 + n2 * 5000 + n3 * 10000 == y) {
                        out.println(n3 + " " + n2 + " " + n1);
                        return;
                    }
                }
            }
            out.println("-1 -1 -1");
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1) {
                        return -1;
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public int nextInt() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c)) {
                    throw new RuntimeException("Incorrect format");
                }
            }
            int val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c)) {
                    throw new RuntimeException("Incorrect format");
                }
                val = 10 * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                   c == '\n' ||
                   c == '\t' ||
                   c == '\r' ||
                   c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }
}



Measured memory_bytes: 36984
#include<bits/stdc++.h>
using namespace std;
int rev[100005];
pair<int,long long> qr[100005];
int main(){
    long long x;
    int n,q;
    scanf("%lld",&x);
    scanf("%d",&n);
    rev[0] = 0;
    for(int i=1;i<=n;i++){
        scanf("%d",&rev[i]);
    }
    rev[n+1] = 2000000000;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d%lld",&(qr[i].first), &(qr[i].second));
    }
    int cnt = 0;
    long long ss, ee, ll, rr;
    ss = 0; ee = x; ll = 0; rr = x;
    for(int i=0;i<=n;i++){
        while(cnt<q){
            int tt = qr[cnt].first;
            long long aa = qr[cnt].second;
            if(tt <= rev[i+1]){
                long long me;
                if(aa <= ss){
                    me = ll;
                }else if(aa <= ee){
                    me = ll + (aa - ss);
                }else{
                    me = rr;
                }
                if(i%2 == 0){
                    me -= tt - rev[i];
                }else{
                    me += tt - rev[i];
                }
                me = min(x, max(0LL, me));
                printf("%lld\n", me);
                cnt++;
            }else break;
        }
        int tm = rev[i+1] - rev[i];
        if(i%2 == 0){
            int mns = min(ll, (long long)tm);
            ll -= mns; rr -= mns;
            tm -= mns;
            if(tm > 0){
                ss = min(ss + tm, ee);
                ll = 0; rr = ee-ss;
            }
        }else{
            int mns = min(x - rr, (long long)tm);
            ll += mns; rr += mns;
            tm -= mns;
            if(tm > 0){
                ee = max(ee - tm, ss);
                rr = x; ll = x - (ee-ss);
            }
        }
        //printf("%d - %d: %lld>%lld %lld<%lld\n", rev[i], rev[i+1], ll, ss, ee, rr);
    }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define debug(n) cerr << #n << ':' << n << endl;
using namespace std;
using pii = pair<int, int>;

int n;
vector<pii> edge;
vector<int> depth;


main(){
  vector<int> dp[202];
  for(int i = 0; i < 202; ++i)dp[i].resize(202,1e+9);
  cin >> n;
  depth.resize(n,-1);depth[0]=0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      char x; cin >> x;
      if(x == '1'){
	edge.push_back({i,j});
	dp[i][j]=1;
      }
    }
  }
  int idx = 0;
  while(idx++ < n){
    for(auto e : edge){
      int from = e.first;
      int to = e.second;
      int fd = depth[from],ft = depth[to];
      if(fd == -1)continue;
      else if(ft == -1){
	depth[to]=fd+1;
      }
      else if(abs(fd-ft)%2==0){
	cout << -1 << endl;
	return 0;
      }
    }
  }


  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; j++){
	dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(dp[i][j]==1e+9||i==j)continue;
      ans = max(ans,dp[i][j]);
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	private static int res;

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

		while (true) {
			String[] str = in.readLine().split(" ");
			int a = Integer.parseInt(str[0]);
			String op = str[1];
			int b = Integer.parseInt(str[2]);

			if (op.equals("+")) {
				res = a + b;
			} else if (op.equals("-")) {
				res = a - b;
			} else if (op.equals("*")) {
				res = a * b;
			} else if (op.equals("/")) {
				res = a / b;
			} else if (op.equals("?")) {
				break;
			}
			System.out.printf("%d%n", res);
		}
	}
}

Measured memory_bytes: 16960
import Foundation

struct Mojiretu: Equatable {
    var characters: [Int]
    
    init(characters: [Int]) {
        
        self.characters = characters
    }
    init(_ slice: ArraySlice<Int>) {
        
        self.characters = Array(slice)
    }
}

extension Mojiretu {
    struct KeyCode {
        static let space = 0x20
        static let lf = 0x0A
    }
    
    static func readLine() -> Mojiretu {
        .init(characters:
            (0...)
                .lazy
                .map { _ in Int(getchar()) }
                .prefix { $0 != KeyCode.lf }
        )
    }
    
    static func readToken() -> Mojiretu {
        .init(characters:
            (0...)
                .lazy
                .map { _ in Int(getchar()) }
                .prefix { $0 != KeyCode.lf && $0 != KeyCode.space }
        )
    }
    
    var tokens: [Mojiretu] {
        characters
            .split { $0 == KeyCode.lf || $0 == KeyCode.space }
            .map(Mojiretu.init)
    }
}

struct MojiretuCharacterIterator: IteratorProtocol {
    private var iter: IndexingIterator<Array<Int>>
    
    init(_ Mojiretu: Mojiretu) {
        iter = Mojiretu.characters.makeIterator()
    }
    
    mutating func next() -> Character? {
        guard let i = iter.next() else { return nil }
        
        return Unicode.Scalar(i).map(Character.init)
    }
}

extension Mojiretu: Sequence {
    
    func makeIterator() -> MojiretuCharacterIterator {
        MojiretuCharacterIterator(self)
    }
}


extension Mojiretu {
    var integer: Int {
        characters
            .lazy
            .map { $0 - Int("0".utf8.first!) }
            .prefix { (0...9) ~= $0 }
            .reduce(0) { r, i in r * 10 + i }
    }
    
    var string: String {
        .init(
            characters
                .compactMap(Unicode.Scalar.init)
                .map(Character.init)
        )
    }
}


extension Mojiretu {
    
    static func == (lhs: Mojiretu, rhs: String) -> Bool {
        lhs.string == rhs
    }
    
    static func == (lhs: String, rhs: Mojiretu) -> Bool {
        lhs == rhs.string
    }
    
    static func ~= (lhs: Mojiretu, rhs: String) -> Bool {
        lhs == rhs
    }
    
    static func ~= (lhs: String, rhs: Mojiretu) -> Bool {
        lhs == rhs
    }
}


let n = Mojiretu.readLine().integer

let judge = (1...n)
  .map { _ in Mojiretu.readLine() }
  .reduce((0, 0, 0, 0)) { r, m in
    switch m {
      case "AC": return (r.0 + 1, r.1, r.2, r.3)
      case "WA": return (r.0, r.1 + 1, r.2, r.3)
      case "TLE": return (r.0, r.1, r.2 + 1, r.3)
      case "RE": return (r.0, r.1, r.2, r.3 + 1)
      default: return (r.0, r.1, r.2, r.3)
    }
  }

print("AC x", judge.0)
print("WA x", judge.1)
print("TLE x", judge.2)
print("RE x", judge.3)



Measured memory_bytes: 19228
#!/usr/bin/env python3

def main():
    N,M = list(map(int, input().split()))

    if N == 1 and M == 1:
        print(1)
    elif N == 1 or M == 1:
        print(N*M-2)
    else:
        print(N*M - (2*(N+M)-4))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import copy

n,m = map(int,input().split())
h = list(map(int, input().split()))
li = copy.copy(h)

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1]<h[b-1]:
    li[a-1]=0
  if h[a-1]>h[b-1]:
  	li[b-1]=0
  if h[a-1]==h[b-1]:
    li[a-1]=0
    li[b-1]=0

print(len(li)-li.count(0))

Measured memory_bytes: 81772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll>mp;
    vector<ll>As;
    
    for(int i=0; i<N; i++){
        int ai, bi;
        cin >> ai >> bi;
        if (mp[ai] == 0){As.push_back(ai);}
        mp[ai] += bi;
        
    }
    sort(As.begin(), As.end());
    for(int i=0; i<As.size(); i++){
        K -= mp[As.at(i)];
        if (K<=0){
            cout << As.at(i) << endl;
            return 0;
        }
    }
}


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

using namespace std;
const int N = 305;
int dp[N][N][N];

int main()
{
    string s; cin >> s;
    int n = s.size(), k; cin >> k;
    for (int i = 0; i < n; i++) for (int j = 0; j <= k; j++) dp[i][i][j] = 1;
    for (int len = 2; len <= n; len++) {
        for (int l = 0, r = len - 1; r < n; l++,r++) {
            for (int j = 0; j <= k; j++) {
                dp[l][r][j] = max(dp[l+1][r][j], dp[l][r-1][j]);
                if (j - (s[l] != s[r]) >= 0) dp[l][r][j] = max(dp[l][r][j], dp[l+1][r-1][j - (s[l] != s[r])] + 2);
            }
        }
    }
    cout << dp[0][n-1][k] << "\n";
}


Measured memory_bytes: 110848
#include "bits/stdc++.h"

using namespace std;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = 0, r = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '<')
			l++;
		else
			break;
	}
	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == '>')
			r++;
		else
			break;
	}
	cout << n - min(l, r) << endl;
}



Measured memory_bytes: 3344
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!

posi_size = posi.size
nega_size = nega.size

ng = -(10**18 + 1)
ok = 10**18 + 1
while ok - ng > 1
  mid = (ok + ng) / 2
  cnt = 0

  if mid >= 0
    cnt += zeros * (zeros - 1) / 2 + zeros * (N - zeros)
  end

  if mid > 0
    cnt += nega_size * posi_size
    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        while l < r && a[l] * a[r] > mid
          r -= 1
        end
        cnt += r - l
        l += 1
      end
    end
  else
    r = nega_size - 1
    0.upto(posi.size - 1) do |l|
      while r >= 0 && posi[l] * nega[r] <= mid
        r -= 1
      end
      cnt += nega_size - r - 1
    end
  end

  if cnt >= K
    ok = mid
  else
    ng = mid
  end
end
puts ok

Measured memory_bytes: 20464
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int pa[100000];//親
int ra[100000];//木の高さ
map<int,int> m;
void init(int x){//初期化
	f(i,x){
		pa[i]=i;
		ra[i]=0;
	}
}
int find(int x){//根を求める
	if(pa[x]==x) return x;
	else return pa[x]=find(pa[x]);
}
void unite(int x,int y){//木の併合
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(ra[x]<ra[y])pa[x]=y;
	else{
		pa[y]=x;
		if(ra[x]==ra[y]) ra[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	init(a);
	f(i,b){
		int c,d,e;
		cin>>c>>d>>e;
		unite(c-1,d-1);
	}
	f(i,a){
		if(!m[find(i)])m[find(i)]++;
	}
	for(P p:m){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
S=str(input())
T=str(input())

if len(S)>=len(T):
    emptylists=[]
    flag=True
    for x in range(len(S)+1-len(T)):
        judgement=1 if all(  S[-(x+j)]=="?" or S[-(x+j)]==T[-j] for j in range(1,len(T)+1)) else 0
        if judgement==1:
            flag=False
            if x==0:
                words=str(S[:-len(T)]+T)
                changed=words.replace("?","a")
                emptylists.append(changed)
                
                
            else:
                words=S[:-len(T)-x]+T+S[-x:]
                changed=words.replace("?","a")
                emptylists.append(changed)
        else:
            continue
        ans=sorted(emptylists)

    if flag:
        print("UNRESTORABLE")
    else:
        print(ans[0])
        
if len(S)<len(T):
    print("UNRESTORABLE")

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


int main(){
  	int n;
	string s,t;
  	cin >> n >> s >> t;
  
  	rep(i,0,n){
      rep(j,0,n-i){
        if(s[i+j] != t[j]){
          break;
        }
        else if(j == n-i-1){
          cout << i + t.size() << endl;
          return 0;
        }
      }
    }
  
  	cout << s.size() + t.size() << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>


#include <string>


#include <algorithm>


#include <utility>


#include <iomanip>


#include <functional>


#include <queue>


#include <stack>


#include <map>


#include <vector>


#include <cmath>


#include <cctype>


#include <cstdio>


#define ll long long


#define INF 1e+9


#define MOD 1000000007


using namespace std;



int main(){


    int A,B;


    cin >> A >> B;


    int K;


    cin >> K;


    for(int i=min(A,B); i>=1; i--){


        if(A%i==0 && B%i==0){


            K--;


        }


        if(K==0){


            cout<<i<<endl;


            return 0;


        }


    }


    return 0;


}

Measured memory_bytes: 256
import sys


def main(n: int, s: str):
    if n % 2 != 0:
        print('No')
        return

    p = int(n / 2)
    if s[:p] == s[p:]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    args = [input() for i in range(2)]
    main(int(args[0]), args[1])


Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
#include <vector>
 
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
using namespace std;
 
ll p10[15];
int nbits=-1;
char a[2],b[2],c[2],d[2];
int num[15];
 
ll get(int n) {
    ll ret=0;
    for (int i=0;i<n;i++) {
        ret=ret*10+num[i];
    }
    return ret;
}
 
int main() {
    p10[0]=1;
    for (int i=1;i<13;i++) p10[i]=p10[i-1]*10;
/*
    printf("? 1\n");fflush(stdout);
    scanf("%s",a);
    printf("? 9\n");fflush(stdout);
    scanf("%s",b);
    for (int i=2;i<11;i++) {
        printf("? %lld\n",p10[i-1]);fflush(stdout);
        scanf("%s",c);
        printf("? %lld\n",p10[i]-1);fflush(stdout);
        scanf("%s",d);
        if (a[0]!=c[0]||b[0]!=d[0]) {
            if (c[0]=='Y') nbits=i;
            else nbits=i-1;
            break;
        }
        a[0]=c[0];b[0]=d[0];
    }
    //printf("nbits:%d\n",nbits);
    for (int i=0;i<15;i++) num[i]=9;
    for (int i=0;i<nbits;i++) {
        int lo=(i==0)?1:0;
        int hi=9;
        while (lo<hi) {
            int mid=(lo+hi)>>1;
            num[i]=mid;
            printf("? %lld\n",get(nbits+1));fflush(stdout);
            scanf("%s",a);
            if (a[0]=='Y') hi=mid;
            else lo=mid+1;
        }
        num[i]=lo;
    }*/
    for (int i = 0; i <= 10; i++) {
        printf("? %lld\n",p10[i]);fflush(stdout);
        scanf("%s",a);
        if (a[0] == 'N') {
            nbits = i;
	    break;
        }
    }
    if (nbits == -1) {
        for (int i = 1; i <= 10; i++) {
            printf("? %lld\n",p10[i]+1);fflush(stdout);
            scanf("%s",a);
            if (a[0]=='Y') {
                nbits = i + 1;
		break;
            }
        }
        if (nbits == 2) {
            printf("? 2\n");fflush(stdout);
            scanf("%s",a);
            if (a[0] == 'Y') {
                nbits = 1;
            }
        }
    }
    ll lo=p10[nbits-1],hi=p10[nbits]-1;
    while (lo<hi) {
        ll mid=(lo+hi)>>1;
        printf("? %lld\n",mid*10);fflush(stdout);
        scanf("%s",a);
        if (a[0]=='Y') hi=mid;
        else lo=mid+1;
    }
    printf("! %lld\n",lo);fflush(stdout);
}

Measured memory_bytes: 504
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define replb(i,a,b) for(ll i=a;i>=b;i--)
#define repl(i,a,b) for(ll i=a;i<b;i++)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define sortA(arr)   sort(arr.begin(),arr.end())
#define ssort stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
vi fl(10000001,0);
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x,t,ans=0;cin>>n;vi V;
    rep(i,0,n){
        cin>>x;V.pb(x);fl[x]++;
    }
    rep(i,0,n){
        if(V[i]==1){
            if(fl[V[i]]>1){ans=0;}
            else ans=1;
            break;
        }
        t=0;
        if(fl[V[i]]>1)continue;
        for(int j=2;j<=int(sqrt(V[i]));j++){
            if(V[i]%j==0){
                if(fl[j]||fl[(V[i]/j)]){t=1;break;}
            }
        }
        if(!t)ans++;
    }
    cout<<ans;
    return 0;
}

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

int main() {
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<long long> A(4);
  A.at(0)=a*c;
  A.at(1)=a*d;
  A.at(2)=b*c;
  A.at(3)=b*d;
  sort(A.begin(),A.end());
  cout << A.at(3) << endl;
}

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

typedef vector<bool> vb;

int N;
vector<vb> T, F;

void input_init(void) {
	cin >> N;
	T.resize(N, vb(N, false));
	F.resize(N, vb(N, false));
	for (int j = 0; j < N; ++j) {
		int a;
		cin >> a;
		for (int i = 0; i < a; ++i) {
			int x, y;
			cin >> x >> y;
			--x;
			if (y == 1)
				T[j][x] = true;
			else
				F[j][x] = true;
		}
	}
}

int bits_count(int bits) {
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int solve(void) {
	const int full_bit = (1 << N) - 1;
	int max_cnt = -1;
	for (int bit = 0; bit <= full_bit; ++bit) {
		bool res = true;
		for (int x = 0; x < N; ++x) {
			if ((bit & (1 << x)) == 0) continue;
			for (int i = 0; i < N; ++i) {
				if (i == x) continue;
				if (T[x][i]) {
					if ((bit & (1 << i)) == 0) {
						res = false;
						break;
					}
				}
				if (F[x][i]) {
					if ((bit & (1 << i)) != 0) {
						res = false;
						break;
					}
				}
			}
			for (int i = 0; i < N; ++i) {
				if (i == x) continue;
				if (F[i][x]) {
					if ((bit & (1 << i)) != 0) {
						res = false;
						break;
					}
				}
			}
		}
		if (res) {
			int bits = bits_count(bit);
			max_cnt = max(bits, max_cnt);
		}
	}
	return max_cnt;
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		while(true) {
			int leng=sc.nextInt();
			if(leng==0) {
				System.exit(0);
			}
			int shopsnum=sc.nextInt();
			int order=sc.nextInt();
			int[] shop=new int[shopsnum+1];
			shop[shopsnum]=leng;
			shop[0]=0;
			for(int i=0; i<shopsnum-1; i++) {
				shop[i+1]=sc.nextInt();
			}
			Arrays.sort(shop);
			long sum=0;
			for(int i=0; i<order; i++) {
				int d=sc.nextInt();
				int place_exceed=lowerBound(shop,d);
				int place_fall=place_exceed-1;
				if(place_exceed==0) {
					place_fall=0;
				}
				sum+=Math.min(Math.abs(shop[place_exceed]-d), Math.abs(d-shop[place_fall]));
			}
			pl(sum);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static final int lowerBound(final int[] arr, final int value) {
		int low = 0;
		int high = arr.length;
		int mid;
		while (low < high) {
			mid = (high+low)/2;
			if (arr[mid] < value) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}
		if(low<arr.length) {
			return low;
		}
		else {
			return -1;
		}
	}
}


Measured memory_bytes: 47996
#!/usr/bin/env python

import sys

n,m = [ int(x) for x in sys.stdin.readline().split() ]
s = list()
for _ in range(m):
    t= [ int(x) for x in sys.stdin.readline().split() ][1:]
    flag = 0
    for x in t: flag|= 2**(x-1)
    s.append( flag )
p = [ int(x) for x in sys.stdin.readline().split() ]
#
ans= 0
for test in range(2**n):
    fail= False
    for i in range(m):
        if bin(s[i]&test).count("1")%2 != p[i]:
            fail= True
            break
    #
    if not fail: ans+= 1
#
print( ans )


Measured memory_bytes: 3316
#include<stdio.h>
int main(){
	char S[15];
	scanf("%s",S);
	char reset[15];
	int id= 0;
	for(int i = 0;S[i]!='\0';i++){
		if(S[i]== '0'){
			reset[id]= '0';
			id++;
		}if(S[i]=='1'){
			reset[id]='1';
			id++;
		}if(S[i]=='B'){
			if(id>0){
				id--;
				reset[id]='\0';
			}
		}
	}
	reset[id]='\0';
	printf("%s\n", reset);
	
	
	return 0;
}

Measured memory_bytes: 1628
from collections import deque

h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())

ch-=1
cw-=1
dh-=1
dw-=1

S=[]
for _ in range(h):
  s=input()
  sl=[]
  for i in range(w):
    sl.append(s[i])
  S.append(sl)

def isable(X):
  xh,xw=X[0],X[1]
  if 0<=xh<=h-1 and 0<=xw<=w-1 and S[xh][xw]=='.':
    return True
  else:
    return False

def stepA(X):
  xh,xw=X[0],X[1]
  A=[]
  for p,q in [(-1,0),(0,1),(1,0),(0,-1)]:
    if isable([xh+p,xw+q]):
      A.append([xh+p,xw+q])
  return A
    
def stepB(X):
  xh,xw=X[0],X[1]
  B=[]
  for i in range(-2,3):
    for j in range(-2,3):
      if i==0 and j==0:
        continue
      if isable([xh+i,xw+j]):
        B.append([xh+i,xw+j])
  return B

Q=deque()
Q.appendleft((ch,cw))
cost=[[float('inf') for i in range(w)] for j in range(h)]
cost[ch][cw]=0

while Q:
  ph,pw=Q.popleft()
  for v in stepA([ph,pw]):
    ah,aw=v[0],v[1]
    if isable([ah,aw]):
      if cost[ah][aw]>cost[ph][pw]:
        cost[ah][aw]=cost[ph][pw]
        Q.appendleft([ah,aw])
  for bh,bw in stepB([ph,pw]):
    if isable([bh,bw]):
      if cost[bh][bw]>cost[ph][pw]+1:
        cost[bh][bw]=cost[ph][pw]+1
        Q.append([bh,bw])

if cost[dh][dw]==float('inf'):
  print(-1)
else:
  print(cost[dh][dw])

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

int main(){
    long long a,b,x;
    cin >> a >> b >> x;
    if(a > 0){
        cout << b/x - (a-1)/x  << endl;
    }else{
        cout << b/x + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int T, X;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                T = line[0];
                X = line[1];
            }
          
            Console.WriteLine((double)T / (double)X);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int xin[N];
  vector<int> X;
  for (int i = 0; i < N; i++) {
    cin >> xin[i];
    X.push_back(xin[i]);
  }
  sort(X.begin(), X.end());
  for (int i = 0; i < N; i++) {
    if (xin[i] < X[N / 2]) {
      cout << X[N / 2] << endl;
    } else {
      cout << X[(N / 2) - 1] << endl;
    }
  }
}


Measured memory_bytes: 3828
# alpha = ('A'..'Z').to_a


n = gets.chomp.to_i

s = gets.chomp.downcase

# p alpha[n]

def chr2int(c)
	c.ord - 'a'.ord
end

def int2chr(i)
	(i + 'a'.ord).chr
end

def caesar(str, x)
	result = ""
	str.each_char{|c|
		result << int2chr((chr2int(c) + x) % 26)
	}
	result
end

puts caesar(s, n).upcase

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	float a,b;
	while(scanf("%f %f",&a,&b)!=EOF){
	if(a<35.50&&b<71.00){
		printf("AAA\n");
	}
	else if(a<37.50&&b<77.00){
		printf("AA\n");
	}
	else if(a<40.00&&b<83.00){
		printf("A\n");
	}
	else if(a<43.00&&b<89.00){
		printf("B\n");
	}
	else if(a<50.00&&b<105.00){
		printf("C\n");
	}
	else if(a<55.00&&b<116.00){
		printf("D\n");
	}
	else if (a<70.00&&b<148.00){
		printf("E\n");
	}
	else {
		printf("NA\n");
	}
	}
	return 0;
}

Measured memory_bytes: 604
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int n,h[100000],a[100000]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(i&&h[i-1]>=h[i]) a[i]=a[i-1]+1;
    }
    sort(a,a+n);
    cout<<a[n-1]<<endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    
    multiset<int> s;

    for(int i = 0; i < n; i++){
        int t;
        cin>>t;
        auto it = s.lower_bound(t);
        if(it!=s.begin()){
            s.erase(--it);
        }
        s.insert(t);
    }
    cout<<(int)s.size();
}




Measured memory_bytes: 4992
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//mint
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   ll n,k,q;cin >> n >> k >> q;
   vl a(n);
   rep(i,n) cin >> a[i];
   vl b(n);
   rep(i,n) b[i] = a[i];
   sort(all(b));
   
   ll ans = INF;
   for(int i = 0;i < n;i++){
      int x = b[i];
      vector<ll> c[2010];
      int j = 0;
      for(int y = 0;y < n;y++){
         if(a[y] >= x)c[j].pb(a[y]);
         else j++;
      }
      vl d;
      for(int y = 0;y <= j;y++){
         sort(all(c[y]));
         if(c[y].size() >= k){
            for(int z = 0;z < c[y].size() - k + 1;z++)  d.pb(c[y][z]);
         }
      }
      if(d.size() >= q){
         sort(all(d));
         mins(ans,d[q-1] - d[0]);
      }
   }
   
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 384
#include<iostream>
typedef long long ll;
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)

ll p2(ll i){
  ll t=1;
  if(i == 0) return 1;
  else return 2*p2(i-1);
}

int main(){
  ll n,p,a[50],od,ev,tmp;
  cin >> n >> p;
  fr(i,n) cin >> a[i];
  fr(i,n) (a[i]%2==0)? ev++:od++;
  if(od>0) cout << p2(n-1);
  else cout <<((p==0)?p2(n):0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=11;
int n;
char s[N];
void dfs(int x,int up){
	if(x==n){
		printf("%s\n",s);
		return;
	}
	for(int i=1;i<=up;++i){
		s[x]=i-1+'a';
		dfs(x+1,up);
	}
	s[x]=up+'a';
	dfs(x+1,up+1);
}
int main(){
	scanf("%d",&n);
	dfs(0,0);
	return 0;
}

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

using namespace std;

#define endl "\n"

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
   long long int d,t,s;
   cin>>d>>t>>s;
   if(t*s>=d)
     cout<<"Yes";
     
   else
    cout<<"No";
   
     return 0;
}

Measured memory_bytes: 3596
s = input()
acgt = ["A", "C", "G", "T"]

ans = 0
cnt = 0
suffix = 0

while suffix < len(s):
    if s[suffix] in acgt:
        cnt += 1
    else:
        cnt = 0
    ans = max(ans, cnt)
    suffix += 1
print(ans)


Measured memory_bytes: 2940
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

//最大公約数、最小公倍数、拡張ユークリッドの互除法
//計算量 O(log(max(A, B)))

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

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

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

int main(){
    ll a, b, x, y;
    cin >> a >> b;
    ll g = extgcd(a, b, x, y);
    a /= g, b /= g;
    x = (x+b*inf)%b, y = (y+a*inf)%a;
    if(x == 0) cout << 0 << ' ' << 1 << endl;
    elif(y == 0) cout << 1 << ' ' << 0 << endl;
    elif(a+x-y < b-x+y) cout << x << ' ' << y-a << endl;
    else cout << x-b << ' ' << y << endl;
}


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

int vals[10];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  vals[a] = 1;
  vals[b] = 1;
  vals[c] = 1;
  int ans = 0;
  for (int i = 0; i < 10; i++) ans += vals[i];
  cout << (ans == 2?"Yes\n":"No\n");
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
    FIO;
    int n; cin >> n;
    string s; cin >> s;

    int i = 0, j = n - 1;
    int cnt = 0;
    while(i < j)
    {
        if(s[i] == 'R')
            ++i;

        if(s[j] == 'W')
            --j;

        if(s[i] == 'W' && s[j] == 'R')
        {
            ++i;
            --j;
            ++cnt;
        }
    } 

    cout << cnt << '\n';
    return 0;
}

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

#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX
#define llinf       LLONG_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    string s;
    cin>>s;
    if(s[sz(s)-1]=='s')s+="es";
    else s+="s";
    cout<<s;
    cout<<endl;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

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

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		if (a%3 != 0) {
			if (b%3 != 0) {
				if ((a+b)%3 != 0) {
					System.out.println("Impossible");
				}else {
					System.out.println("Possible");
				}
			}else {
				System.out.println("Possible");
			}
		}else {
			System.out.println("Possible");
		}
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main() {
	ll w, h, x, y, c;
	cin >> w >> h >> x >> y;
	double res = w * h / 2.0;
	if (x == w/2.0 && y == h/2.0)c = 1;
	else c = 0;
	cout << res << ' ' << c << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
int A,B,C;
int main(){
	scanf("%d%d%d",&A,&B,&C);
	if (A<B)
		swap(A,B);
	if (A<C)
		swap(A,C);
	int ans=A-B+A-C;
	if (ans%2)
		ans+=3;
	ans/=2;
	printf("%d",ans);
	return 0;
}

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

long long int func(long long int n)
{
    if(n==1)
        return 1;
    else
        return (2*func(n/2))+1;
}

int main()
{
    long long int h,ans;
    cin>>h;
    ans = func(h);
    cout<<ans;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n;
	cin >>n;
	vector<ll> a(n);
	ll sum = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}

	ll diff_eve = 0;
	ll diff_odd = 0;
	for(int i = 0; i < n / 2; ++i)
	{
		diff_eve += a[(i * 2 + 1) % n]; // i = 0
		diff_odd += a[(i * 2 + 2) % n]; // i = 1
	}

	for(int i = 0; i < n / 2; ++i)
	{
		/*
		for(int j = 0; j < n / 2; ++j)
		{
			diff += a[(i + 2 * j + 1) % n];
		}
		*/
		cout << sum - 2 * diff_eve << " " << sum - 2 * diff_odd << " ";// << endl;
		//cout << "eve: minus " << (i * 2 + 1) % n << " : plus " << (i * 2 + 1 + n/2*2) % n << endl;
		// cout << "odd: minus " << (i * 2 + 2) % n << " : plus " << (i * 2 + 2 + n/2*2) % n << endl;
		diff_eve += a[(i * 2 + 1 + n/2*2) % n] - a[(i * 2 + 1) % n];
		diff_odd += a[(i * 2 + 2 + n/2*2) % n] - a[(i * 2 + 2) % n];
	}
	if (n & 1)
	{
		// 最後表示されないので表示
		cout << sum - 2 * diff_eve;
	}


}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define en '\n'
#define fs first
#define sd second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> v(n);
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        a[i] = i - v[i];
        b[i] = i + v[i];
    }
    sort(begin(a), end(a));
    sort(begin(b), end(b));
    ll res = 0;
    for(int i = 0; i < n; ++i){
        auto r = equal_range(begin(b), end(b), a[i]);
        res += r.second - r.first;
    }
    cout << res << endl;
}

Measured memory_bytes: 7948