akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    vector<ll> A(3); 
    cin >> A[0] >> A[1] >> A[2];
    
    sort(ALL(A));

    if (A[0] == A[1] && A[1] < A[2]) {
        _PR("Yes");
    } 
    else if (A[0] < A[1] && A[1] == A[2]){
        _PR("Yes");
    }
    else {
        _PR("No");
    }

    return 0;
}

/*



*/

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

int main(){
    string temp;
    char c;
    int ans=0;
    
    while(1){
        cin >> temp;
        if(temp == "0"){
            break;
        }
        for(int i = 0; i < temp.size(); i++){
            ans += ((int)temp[i] -48);
        }
        cout << ans << endl;
        ans = 0;
    }
}



Measured memory_bytes: 3164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
LL calc(LL x,LL y)
{
	if(x>=y)return x*(x+1)/2+y*(y-1)/2;
	else return x*(x-1)/2+y*(y+1)/2;
}
int main(){
	string s;cin>>s;
	
	LL a=0,b=0;
	LL ans=0;
	char ima='>';
	for(int i=0;i<s.length();i++)
	{
		if(ima=='<')
		{
			if(s[i]=='<')a++;
			else ima='>',b++;
		}	
		else
		{
			if(s[i]=='>')b++;
			else
			{
				ima='<';
				ans+=calc(a,b);
				a=1,b=0;
			}
		}
	
	}
	ans+=calc(a,b);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 900
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        List<int> size = new List<int>();

        for (int i = 0; i < num; i++) size.Add(int.Parse(Console.ReadLine()));

        int result = size.Distinct().Count();
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13268
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    d = {}
    for a in A:
        if not a in d:
            d[a] = 1
        else:
            d[a] += 1
    tup = sorted([(k, v) for k, v in d.items() if v > 1], key=lambda x: x[0])
    #print(tup)
    hd = []
    while len(tup) > 0:
        length, cnt = tup.pop()
        if cnt >= 4:
            hd.append(length)
        if cnt >= 2:
            hd.append(length)
        if len(hd) >= 2:
            print(hd[0]*hd[1])
            return
    print(0)




if '__main__' == __name__:
    resolve()

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

int all(int &n, int m, int &roop, int D, vector<int> full_score, vector<int> full_count, vector<int> &count){
  int sum=0;
//  cout << "n:" << n;
  if(n==m) return 0;
  for(int i=0; i<D; i++){
    if(n%2==0){
      n/=2;
      continue;
    }
    else{
      n/=2;
      sum+= full_score.at(i);
      count.at(i)= full_count.at(i);
      roop+= count.at(i);
    }
  }
  return sum;
}

int part(int n, int m, int &roop, int D, int G, vector<int> count, vector<int> full_count,vector<int> full_score){
  int sum=all(n,m,roop,D,full_score,full_count,count);
//  cout << " sum:" << sum;
//  cout << " roop:" << roop;
  if(sum>= G){
    return roop;
  }
  for(int i=D-1; i>-1; i--){
    if(count.at(i)!=0) continue;
    sum+= (i+1)*(full_count.at(i)-1)*100;
    roop+= full_count.at(i)-1;
//    cout << " sum_roop:" << sum << "_" << roop;
    if(sum<G) return 0;//部分加算をすべて足してもGに達しなければ終了 
    for(int j=1; j<full_count.at(i); j++){
      sum-= (i+1)*100;
      if(sum<G) return roop;
      roop--;
//      cout << " sum_roop2:" << sum << "_" << roop;
    }
  }
}

int my_min(int x, int y) {
  if(x<1) return y;
  if(y<1) return x;
  if (x < y) {
    return x;
  }
  else {
    return y;
  }
}

int main(){
//全部とく、全部とかない、少し解く、の3パターンで分ける
//入力
  int D,G;
  cin >> D >> G;
  vector<vector<int>> score(D,vector<int>(100));
  vector<int> full_score(D);
  vector<int> full_count(D);
  for(int i=0; i<D; i++){
    int p,c;
    int sum=0;
    cin >> p >> c;
    full_count.at(i)= p;
    for(int j=0; j<p; j++){
      score.at(i).at(j)= 100*(i+1);
      if(j==p-1){
        score.at(i).at(j)+= c;
      }      
      sum+= score.at(i).at(j);
      if(j==p-1){
        full_score.at(i)= sum;
      }
    }
  }
  int roop=0;
  int n=0;
  int m=1;
  for(int i=0; i<D; i++){
    m*=2;
  }
  vector<int> count(D,0);
  int ans= part(n,m,roop,D,G,count,full_count,full_score);
//  cout << " part:" << ans << endl;
  for(int n=1; n<m; n++){
    int roop=0;
    int p=part(n,m,roop,D,G,count,full_count,full_score);
    ans=my_min(ans, p);
//    cout << " part:" << p << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#'){
        if (i == 0 && j == 0){
          if (data.at(i+1).at(j) == '.' && data.at(i).at(j+1) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (i == 0 && j == W-1){
          if (data.at(i+1).at(j) == '.' && data.at(i).at(j-1) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (i == H-1 && j == 0){
          if (data.at(i-1).at(j) == '.' && data.at(i).at(j+1) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (i == H-1 && j == W-1){
          if (data.at(i-1).at(j) == '.' && data.at(i).at(j-1) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (i == 0){
          if (data.at(i).at(j+1) == '.' && data.at(i).at(j-1) == '.' && data.at(i+1).at(j) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (j == 0){
          if (data.at(i).at(j+1) == '.' && data.at(i-1).at(j) == '.' && data.at(i+1).at(j) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (i == H-1){
          if (data.at(i).at(j+1) == '.' && data.at(i).at(j-1) == '.' && data.at(i-1).at(j) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else if (j == W-1){
          if (data.at(i).at(j-1) == '.' && data.at(i-1).at(j) == '.' && data.at(i+1).at(j) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
        else {
          if (data.at(i).at(j-1) == '.' && data.at(i).at(j+1) == '.' &&data.at(i-1).at(j) == '.' && data.at(i+1).at(j) == '.'){
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}
          
 
  

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

int main(){
    long N, M;
    cin >> N >> M;
    if(M <= N)return 0 & puts("0");
    vector<long> l(M);
    for(auto& i : l)cin >> i;
    sort(l.begin(), l.end());
    for(int i = M - 1; i > 0; --i)l[i] -= l[i - 1];
    l[0] = 0;
    sort(l.rbegin(), l.rend());
    cout << accumulate(l.begin() + N - 1, l.end(), 0L) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int l;
    cin >> l;
    v.push_back(l);
  }
  sort(ALLOF(v));

  ll ret = 0;
  rep(i,v.size()){
    REP(j,i+1,v.size()){
      int a = v[i];
      int b = v[j];
      int cnt = 0;
      if(v[v.size()-1] < a+b){
        cnt = N-1 - j;
      }else{
        int lb=j,ub=N-1;
        while(ub-lb>1){
          int m = (lb+ub)/2;
          if(v[m]<a+b) lb = m;
          else ub = m;
        }
        cnt = lb - j;
      }
      ret += cnt;
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int a;
  cin >>a;
  int judge;
  rep(i, 9){
  rep(j, 9){
  judge=(i+1)*(j+1);
    if(judge==a){
    cout << "Yes" << endl;
      return 0;
    }
  }
  }
  cout << "No" << endl;
}

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

// Author: Ashish

const int maxn=2e5+5;
const int mod=1e9+7;
int factorials[maxn];
void pre()
{
	factorials[0]=1;
	for(int i=1;i<maxn;i++)
		factorials[i]=(i*factorials[i-1])%mod;
}
int binpow(int base,int exp)
{
	int answer=1;
	while(exp)
	{
		if(exp&1){answer*=base; answer%=mod;}
		exp/=2;
		base*=base;
		base%=mod;
	}
	return answer;
}
int ncr(int n,int r)
{
	if(n<r) return 0;
	int answer=factorials[n];
	answer*=binpow(factorials[r],mod-2);
	answer%=mod;
	answer*=binpow(factorials[n-r],mod-2);
	answer%=mod;
	return answer;
}
int n;
int ways[maxn];
int sz[maxn];
vector<int> g[maxn];
int answers[maxn];
int dp1(int node,int parent)
{
	sz[node]=1;
	for(auto&itr:g[node])
		if(itr!=parent)
			sz[node]+=dp1(itr,node);
	return sz[node];
}
int dp2(int node,int parent)
{
	ways[node]=1;
	int options=sz[node]-1;
	for(auto&itr:g[node])
		if(itr!=parent)
		{
			ways[node]*=ncr(options,sz[itr]);
			ways[node]%=mod;
			ways[node]*=dp2(itr,node);
			ways[node]%=mod;
			// ways[node]*=ncr(options,sz[itr])*dp2(itr,node);
			options-=sz[itr];
		}
	return ways[node];
}
void dp3(int node,int parent)
{
	if(parent==-1)
		answers[node]=ways[node];
	else
	{
		answers[node]=ways[node];
		answers[node]*=ncr(n-1,n-sz[node]);
		answers[node]%=mod;
		
		answers[node]*=answers[parent];
		answers[node]%=mod;

		answers[node]*=binpow(ways[node],mod-2);
		answers[node]%=mod;

		answers[node]*=binpow(ncr(n-1,sz[node]),mod-2);
		answers[node]%=mod;
	}
	for(auto&itr:g[node])
		if(itr!=parent)
			dp3(itr,node);
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  pre();
  cin>>n;
  for(int i=1;i<n;i++)
  {
  	int u,v;
  	cin>>u>>v;
  	g[u].push_back(v);
  	g[v].push_back(u);
  }
  dp1(1,-1);
  dp2(1,-1);
  dp3(1,-1);
  for(int i=1;i<=n;i++) cout<<answers[i]<<'\n';
  return 0;
	cout<<"Correct answers->\n";
  for(int i=1;i<=n;i++) dp1(i,-1),cout<<dp2(i,-1)<<'\n';



  return 0;
}

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

using ll = long long;

int main(){
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;

  vector<int> sum(N+1, 0);
  for (int i = 0; i < N; i++) {
    if (i+1 < N && s[i]=='A' && s[i+1]=='C') sum[i+1]=sum[i]+1;
    else  sum[i+1]=sum[i];
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    cout << sum[r]-sum[l] << endl;
  }

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n,x,y;
    cin>>n>>x>>y;
    vector<ll>a[n+1];
    for(ll i=1;i<=n;i++){
            if(i!=n){
        a[i].push_back(i+1);
        a[i+1].push_back(i);}
    }
    a[n].push_back(n-1);
    a[x].push_back(y);
    a[y].push_back(x);
    ll ans[n+1]={0};
    for(ll i=1;i<=n-1;i++){
        ll d[n+1];
        for(ll j=0;j<=n;j++)d[j]=1e9;
        queue<ll>q;
        q.push(i);
        map<ll,ll>visited;
        d[i]=0;
        visited[i]++;
        while(!q.empty()){
            ll x=q.front();
            q.pop();
            for(auto it:a[x]){
                if(visited[it]==0){
                    visited[it]++;
                    d[it]=d[x]+1;
                    q.push(it);
                }
            }}
            visited.clear();
            while(!q.empty())q.pop();
            for(ll j=i+1;j<=n;j++)ans[d[j]]++;
    }
    for(ll i=1;i<=n-1;i++)cout<<ans[i]<<endl;


return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    String val1[] = {"yotta", "zetta", "exa", "peta", "tera", "giga", "mega", "kilo"};
    String val2[] = {"yocto", "zepto", "ato", "femto", "pico", "nano", "micro", "milli"};

    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = Integer.parseInt(sc.nextLine());
	    for(int k = 0; k < n; k++){
		String[] str = (sc.nextLine()).split(" ");
		int v = 0;
		String s1, s2;
		if(str.length == 3){
		    s1 = str[2];
		    v = convertTo(str[1]);
		} else {
		    s1 = str[1];
		    v = 0;
		}		
		char[] ch = str[0].toCharArray();
		if(ch.length > 1){
		    if(ch[0] != '0' && ch[1] == '.'){
			s2 = str[0];
		    } else {
			if(ch[0] == '0'){
			    int p = 2;
			    while(ch[p] == '0'){
				p++;
			    }
			    v -= (p-1);
			    s2 = String.valueOf(ch[p]) + ".";
			    for(int i = p+1, l = ch.length; i < l; i++){
				if(ch[i] == '.'){
				    continue;
				}
				s2 += String.valueOf(ch[i]);
			    }
			    if(s2.length() == 2){
				s2 = s2.substring(0, 1);
			    }
			} else {
			    int p = ch.length;
			    for(int i = 2; i < p; i++){
				if(ch[i] == '.'){
				    p = i;
				    break;
				}
			    }
			    v += (p-1);			   
			    s2 = String.valueOf(ch[0]) + ".";
			    for(int i = 1, l = ch.length; i < l; i++){
				if(ch[i] == '.'){
				    continue;
				}
				s2 += String.valueOf(ch[i]);
			    }
			    if(s2.length() == 2){
				s2 = s2.substring(0, 1);
			    }
			}
		    }
		} else {
		    s2 = str[0];
		}

		System.out.println(s2+ " * 10^"+Integer.toString(v)+" "+s1);
	    }
	}
    }


    int convertTo(String str){
	if(str.equals("hecto")){
	    return 2;
	} else if(str.equals("deca")){
	    return 1;
	} else if(str.equals("deci")){
	    return -1;
	} else if(str.equals("centi")){
	    return -2;
	}

	int v = 24;
	boolean f = false;
	for(int i = 0, l = val1.length; i < l; i++, v-=3){
	    if(str.equals(val1[i])){
		f = true;
		break;
	    }
	}

	if(f){
	    return v;
	}
	v = -24;
	for(int i = 0, l = val2.length; i < l; i++, v+=3){
	    if(str.equals(val2[i])){
		break;
	    }
	}

	return v;
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
#define ld long double
// main() is where program execution begins.

long double dp[301][301][301];
long double ttal(int a, int b, int c, ld N){

	if(a < 0 || b < 0 || c < 0) return 0;
	if(a == 0 && b == 0 & c ==0) return 0;
	if(dp[a][b][c] != 0) return dp[a][b][c];
	long double x;
	x = N/(a+b+c);
	x += 1.0*a/(1.0*(a+b+c))*ttal(a-1, b+1, c,N);
	x += 1.0*b/(1.0*(a+b+c))*ttal(a, b-1, c+1, N);
	x += 1.0*c/(1.0*(a+b+c))*ttal(a, b, c-1, N);
	dp[a][b][c] = x;
	return x;
}

int main() {
int N;
cin >> N;
int a;
ld x=0, y=0, z=0;
for (int i = 0; i < N; ++i)
{
	cin >> a;
	if(a == 1) x++;
	if(a == 2) y++;
	if(a == 3) z++;
	}
	cout <<setprecision(12)<<ttal(z, y, x, N)<<endl;
}


Measured memory_bytes: 426368
function main(input) {
  const N = Number(input.split("\n")[0]);
  const H = input.split("\n")[1].split(" ");
  var max = 0;
  var count = 0;
  for(var i=0; i<N-1; i++){
    if(Number(H[i]) >= Number(H[i+1])){
      count++;
      
    }else{
      if(max < count){
        max = count;
      }
      count = 0;
    }
  }
  if(max < count){
    max = count;
  }
  // 2,3,5,3,5,6,8,8,5,3,6,8,9
  //  0 0 1 0 0 0 1 1 1 0 0 0
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 17816
import Text.Printf

gcd' :: Int -> Int -> Int
gcd' x 0 = x
gcd' x y = gcd' y (x `mod` y)

ans :: Int -> Int -> (Int,Int)
ans x y =
    let g = if x >= y
            then gcd x y
            else gcd y x
        l = (x `div` g) * (y `div` g) * g
    in
      (g, l)

main = do
  c <- getContents
  let i0 = map words $ lines c
      i  = map (map read) i0 :: [[Int]]
      o  = map (\(x0:x1:xs) -> ans x0 x1) i
  mapM_ (\(a,b) -> printf "%d %d\n" a b) o

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

#define endl '\n'
#define Int long long
#define Double long double
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define CLR(a, b) memset(a, b, sizeof a)
#define debug(x) cerr << #x << " " << x << endl;
#define MOD 1000000007
#define MAXN 1000010

using namespace std;

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

    int a[3];
    for(int i = 0; i < 3; ++i)
        cin >> a[i];
    sort(a, a + 3);

    if(a[0] == 5 && a[1] == 5 && a[2] == 7) {
        puts("YES");
        return 0;
    }
    
    puts("NO");
    return 0;
}


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

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

struct SegTree { // 区間sum
	int n;
	vector<int> Sum;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Sum.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Sum[i] = 0;
		}
	}
	void add(int idx, int val) {
		idx += n - 1;
		Sum[idx] += val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Sum[idx] = Sum[idx * 2 + 1] + Sum[idx * 2 + 2];
		}
	}
	int get_sum(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のsum
		if (r == -1) r = n;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return Sum[k];
		int vl = get_sum(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_sum(a, b, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int Q;
int rui[100010];

bool is_prime[100010];

void sieve()
{
	memset(is_prime, true, sizeof is_prime);

	is_prime[1] = false;

	for (int i = 2; i <= 100000; ++i) {
		if (not is_prime[i]) continue;
		for (int j = i + i; j <= 100000; j += i) {
			is_prime[j] = false;
		}
	}
}

signed main()
{
	cin >> Q;

	sieve();

	for (int i = 1; i <= 100000; ++i) {
		rui[i] = rui[i - 1];
		if ((i % 2) and is_prime[i] and is_prime[(i + 1) / 2]) {
			rui[i]++;
		}
	}

	rep(_, Q) {
		int l, r; cin >> l >> r;
		cout << rui[r] - rui[l - 1] << endl;
	}
}




Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    int n; n = s.length();
    
    bool flag = true;
    
    int i = 0, j = n-1;
    
    while( i < j && flag){
        if( s[i] == s[j]){
            i++;
            j--;
        }
        else
            flag = false;
    }
    i = 0; j = ((n-1)/2) - 1;
    while( i < j && flag){
        if( s[i] == s[j]){
            i++;
            j--;
        }
        else
            flag = false;
    }
    
    i = ((n+3)/2)-1; j = n-1;
    while( i < j && flag){
        if( s[i] == s[j]){
            i++;
            j--;
        }
        else
            flag = false;
    }
    
    if(flag == true)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
	return 0;
}






Measured memory_bytes: 256
x = int(input())

x_tmp = x

n_6_5 = x_tmp // 11
x_tmp -= 11 * n_6_5

if x_tmp == 0:
    n_6 = n_5 = 0
elif x_tmp <= 6:
    n_6, n_5 = (1, 0)
else:
    n_6, n_5 = (1, 1)

print(2 * n_6_5 + n_6 + n_5)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int a,b;
  while(cin>>a>>b){
    cout << keta(a+b) <<"\n";
  }
}


Measured memory_bytes: 2988
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b;
    cin >> a>> b;
    int m = (b - 1) % (a - 1) == 0 ? (b - 1) / (a - 1) : (b - 1) / (a - 1) + 1;
    cout <<  m << endl;
}

    
    


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>bool chmax(T &a, const T &b);
template <class T>bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t,std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

int dp[100001];

void Main()
{
  int n, k;
  cin >> n >> k;
  priority_queue<int> q;
  rep(i, n){
    int tmp;
    cin >> tmp;
    q.push(tmp);
  }

  int ans = 0;
  rep(i, k){
    ans += q.top();
    q.pop();
  }

  std::cout << ans << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }
  
  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if(n % i == 0){
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }
  
  return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
    int n,k;
    cin>>n>>k;
    int c=n;
    int cmin=INT_MAX;
    long long int sum=0;
    while(n--)
    {
        int h;
        cin>>h;
        cmin=min(cmin,h);
       sum+=h;
    }
    int diff=k-sum;
    diff=diff/cmin;
    c+=diff;
    
    cout<<c;

 return 0;
}








Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
const int N=30;
int n,m,t,dis[N][N],dx[4]={-1,0,0,1},dy[4]={0,1,-1,0},ans;char c[N][N];
queue<pair<int,int> >q;
bool can(int x,int y){return x>=1&&x<=n&&y>=1&&y<=m&&c[x][y]!='#';}
void bfs(int sx,int sy){
    memset(dis,0,sizeof(dis));
    q.push(make_pair(sx,sy));dis[sx][sy]=1;
    while(q.size()){
        int x=q.front().first,y=q.front().second;q.pop();
        for(int i=0;i<4;i++){
            int xx=x+dx[i],yy=y+dy[i];
            if(can(xx,yy)&&!dis[xx][yy]){
                ans=max(ans,dis[x][y]);
                dis[xx][yy]=dis[x][y]+1,q.push(make_pair(xx,yy));
            }
        }
    }
}
int main(){
    // freopen("test.in","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",c[i]+1);
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(c[i][j]!='#')bfs(i,j);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(2000)


N = int(stdin.readline().rstrip())
As = [int(x) for x in stdin.readline().rstrip().split()]

A_mat = []
for i,A in enumerate(As):
    A_mat.append([A,i])

A_mat.sort(reverse=True)

map1 = []

for i in range(N+1):
    temp = [-1]*(N+1)
    map1.append(temp)



def DP(x, y): #Asのなかからx+y個の数列をすでに端に移動していて、x個左端に, y個右端に移動している状態から始めたときに追加で得られるスコア
    if map1[x][y]>=0:
        return map1[x][y]
    
    if x+y == N:
        return 0

    a_val = A_mat[x+y][0]
    a_pos = A_mat[x+y][1]

    left_case = abs(a_pos-x)
    right_case = abs((N-y-1)-a_pos)

    map1[x][y] = max(DP(x+1,y)+left_case*a_val, DP(x,y+1)+right_case*a_val)

    return map1[x][y]

print(DP(0,0))
    

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

class MyComparator implements Comparator<Integer>{
	@Override
	public int compare(Integer x, Integer y){
		return x > y ? -1 : 1;
	}
}

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

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[3*n];
        for(int i=0;i<3*n;i++){
        	a[i] = sc.nextInt();
        }
        long[] left = new long[n+1];
        long[] right = new long[n+1];
        Queue<Integer> que = new PriorityQueue<Integer>();
        long count = 0;
        for(int i=0;i<n;i++){
        	count += (long)a[i];
        	que.add(a[i]);
        }
        left[0] = count;
        for(int i=n;i<2*n;i++){
        	count += (long)a[i];
        	que.add(a[i]);
        	int x = que.poll();
        	count -= (long)x;
            left[i-n+1] = count;
        }

        count = 0;
        Queue<Integer> qu = new PriorityQueue<Integer>(new MyComparator());
        for(int i=3*n-1;i>=2*n;i--){
        	count += (long)a[i];
        	qu.add(a[i]);
        }
        right[n] = count;
        for(int i=2*n-1;i>=n;i--){
        	count += (long)a[i];
        	qu.add(a[i]);
        	int x = qu.poll();
        	count -= (long)x;
        	right[i-n] = count;
        }

        long ans = left[0] - right[0];
        for(int i=1;i<n+1;i++){
        	ans = (long)Math.max(ans, left[i] - right[i]);
        	//System.out.println(left[i] - right[i]);
        }

        System.out.println(ans);
    }
}

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

template<typename T>
class UnionFind {
  public:
    vector<T> parent;

    UnionFind(T n) {
      parent = vector<T>(n, -1);
    }

    T root(T a) {
      if (parent[a] < 0) return a;
      else return parent[a] = root(parent[a]);
    }

    T size(T a) {
      return -parent[root(a)];
    }

    bool connect(T a, T b) {
      a = root(a);
      b = root(b);
      if (a == b) {
        return false;
      }

      if (size(a) < size(b)) swap(a, b);

      parent[a] += parent[b];
      parent[b] = a;
      return true;
    }
};

void Main() {
  int N, M;
  cin >> N >> M;
  UnionFind<int> group = UnionFind<int>(N);
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    group.connect(x - 1, y - 1);
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (group.root(i) == group.root(p[i] - 1)) ans++;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 1024
//JSD
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#define ll long long 
using namespace std;
int main(){
	ll n,X;
	cin>>n>>X;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll D[n+1]={0};
	for(ll i=1;i<=n;i++){
		D[i]=D[i-1]+a[i-1];
	}
	cout<<upper_bound(D,D+n+1,X)-D<<"\n";;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;


int main(){
    ios::sync_with_stdio(0);
	cin.tie(NULL);
    string s; cin>>s;
    string aux (s.rbegin(),s.rend());

    if(aux==s){
        string aux1 (s.begin(),s.begin()+(s.size()-1)/2);
        string aux2 (aux1.rbegin(),aux1.rend());
        string aux3 (s.begin()+(s.size()+3)/2-1,s.end());
        string aux4 (aux3.rbegin(),aux3.rend());

        if(aux1==aux2&&aux3==aux4){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }else{
        cout<<"No\n";
    }
    return 0;
}

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

using namespace std;



int main () {

    int n;
    cin >> n;

    vector<string> s;
    string temp;

    for (int i = 0; i < n; i++){
        cin >> temp;
        s.push_back(temp);
    }
    
    // find the lexigraphical smallest common substring among all strings

    // lexigraphical_compare

    // find character in common, count them

    // only 50 x 50

    int alph_cnt[50][26];

    for (int i = 0; i < 50; i++){
        for (int j = 0; j < 26; j++){
            alph_cnt[i][j] = 0;
        }
    }

    for (int i = 0; i < s.size(); i++){
        for (int j = 0; j < s[i].size(); j++){
            alph_cnt[i][s[i][j] - 'a']++;
        }
    }

    // for (int i = 0; i < s.size(); i++){
    //     for (int j = 0; j < s[i].size(); j++){
    //         cout << alph_cnt[i][j] << " ";
    //     } cout << endl;
    // }

    string res = "";

    for (int i = 0; i < 26; i++){
        
        int mn = INT_MAX;

        for (int j = 0; j < n; j++){
            mn = min(mn, alph_cnt[j][i]);
        }

        if (mn != 0 || mn != INT_MAX){
            while (mn){
                // cout << " here : " << mn << endl;
                res += (i + 'a');
                mn--;
            }
        }
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[10];
	scanf("%s", s);
	if (s[0] == 'S')
		printf("Cloudy\n");
	else if (s[0] == 'C')
		printf("Rainy\n");
	else
		printf("Sunny\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
}

Measured memory_bytes: 256
def resolve():
    n, m = map(int, input().split())
    ans = n
    if m < 2:
        return print(0)
    if m <= 2*n:
        return print(m//2)
    diff = m - 2*n
    ans += diff//4

    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << '+';
    else if (a * b == 15) cout << '*';
    else cout << 'x';
}


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


int main(){
    int N;
    cin >> N;
    map<int,int> A;
    rep(i,N){
        int n;
        cin >> n;
        A[n] = i;
    }
    for (auto a : A){
        cout << (a.second + 1) << endl;
    }
}

Measured memory_bytes: 5504
import numpy as np

N,D=list(map(int,input().split()))

listX=[] #appendのために宣言が必要
while True:
    try:
        listX.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。
X=np.array(listX)
flag=0
for  i in range(N):
    for j in range(N):

        if i>=j:
            continue
        #print(i,j)
        dist=X[i,:]-X[j,:]
        dist=np.linalg.norm(dist)

        if dist%1==0:
            #print(dist)
            flag+=1
print(flag)


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  string S; cin >> S;
  ll K; cin >> K;
  
  int cnt = 0;
  char ans = 'a';
  REP(i, S.size()) {
    if(S[i] == '1') {
      cnt++;
    } else if(S[i] != '1') {
      ans = S[i];
      break;
    }
  }

  if(S[0] == '1') {
    if(K <= cnt) {
      cout << 1 << endl;
    } else {
      cout << ans << endl;
    }
  } else {
    cout << S[0] << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);                           //コストの配列
    vector<vector<int>> vec(n, vector<int>(m)); //教科書で学べるアルゴリズムとその理解度
    rep(i, n)                                   //n冊分
    {
        cin >> c[i]; //教科書の価格
        rep(j, m)    //アルゴリズム分
        {
            cin >> vec[i][j]; //学べるアルゴリズムと理解度の表
        }
    }

    int ans = inf; // 最小コストを割り出すため
    for (int bit = 0; bit < (1 << n); ++bit) // (1<<n)は2^n。2^n（全パターン数）繰り返す
    {
        int cost = 0;
        vector<int> d(m); //各アルゴリズムの理解度の配列
        rep(i, n) // n冊分、各桁調べる
        {
            if (bit & (1 << i)) // 1のフラグが立ってたら=その本を買う場合
            {
                cost += c[i]; // 教科書の価格を加算
                rep(j, m)
                {
                    d[j] += vec[i][j]; // その教科書で得られる各理解度を各アルゴリズムに加算
                }
            }
        }
        bool ok = true;
        rep(j, m)
        {
            if (d[j] < x) // 一つでもx以下なら
            {
                ok = false;
            }
        }
        if (ok)
        {
            ans = min(ans, cost); // 一番コストが低いものを保持
        }
    }
    if (ans == inf)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535
#define EPS (1e-10)

// i < j 
ll mindis(ll i, ll j, ll x, ll y)
{
    if(j <= x) return j - i;
    else if(x < j && j <= y && i <= x){
        return min(j - i, y - j + 1 + x - i);
    }else if(x < j && j <= y && x < i){
        return min(j - i, i - x + y - j + 1);
    }else if(j > y && i <= x){
        return j - y + 1 + x - i;
    }else if(j > y && x < i && i < y){
        return min(j - i, j - y + 1 + i - x);
    }else{
        return j - i;
    }
}

int main()
{
    ll n, x, y;
    cin >> n >> x >> y;
    vector<ll> ans(n);
    for(ll i = 1; i < n; i++){
        for(ll j = i + 1; j <= n; j++){
            ans[mindis(i, j, x, y)]++;
        }
    }
    for(ll i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin >> N;
    VL d(N);
    map<ll,ll> mp;
    rep(i,0,N){
        cin>>d[i];
        mp[d[i]]=1;
    }
    ll ans=0;
    for(auto p:mp){
        if(p.second==1)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt(),b=sc.nextInt();
        if(b%a==0)out.println(a+b);
        else out.println(b-a);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, Q;
std::string s;
std::string t[200010], d[200010];
int ans;

bool C1( int x )
{
  rep( q, Q )
  {
    if( s[x] == t[q][0] )
      x += (d[q][0]=='L'?-1:1);

    if( x < 0 )
      return false;
  }

  return true;
}

bool C2( int x )
{
  rep( q, Q )
  {
    if( s[x] == t[q][0] )
      x += (d[q][0]=='L'?-1:1);

    if( x >= N )
      return false;
  }

  return true;
}

int main()
{
  std::cin >> N >> Q >> s;

  rep( i, Q )
    std::cin >> t[i] >> d[i];

  int lb = -1, ub = N;

  while( ub-lb > 1 )
  {
    int mid = (lb+ub)/2;

    (C1(mid)?ub:lb) = mid;
  }

  ans += ub;

  lb = -1, ub = N;

  while( ub-lb > 1 )
  {
    int mid = (lb+ub)/2;

    (C2(mid)?lb:ub) = mid;
  }

  ans += N-ub;

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

  return 0;
}

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

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

  int answer = 0 ;
  for(int i = 1 ; i < s.size() ; i++)
  {
    int count = 0 ;
    string a = s.substr(0, i) ;
    string b = s.substr(i) ;

    set<char> da ;
    set<char> db ;
    for(int j = 0 ; j < a.size() ; j++)
    {
      da.insert(a.at(j)) ;
    }

    for(int k = 0 ; k < b.size() ; k++)
    {
      db.insert(b.at(k)) ;
    }

    for(auto x : da)
    {
      if(db.count(x))
      {
        count++ ;
      }
    }
    answer = max(answer, count) ; 
  }

  cout << answer << endl ;


}


Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline

abcd = int(input())
for i in range(int(4-math.log10(abcd))):
    abcd = '0'+str(abcd)
a, b, c, d = str(abcd)
a = int(a);b = int(b);c = int(c);d = int(d)
if a+b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'+'+d+'=7'
elif a+b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'-'+d+'=7'
elif a+b-c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'-'+c+'-'+d+'=7'
elif a+b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'-'+c+'+'+d+'=7'
elif a-b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'+'+d+'=7'
elif a-b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'-'+d+'=7'
elif a-b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'+'+d+'=7'
else:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'-'+d+'=7'
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>

#define INF 10000000000;
using namespace std;

int main(void){
   int N;
   cin>>N;
   long h[N];
   for(int i=0;i<N;i++){
       cin>>h[i];
   }
   long dp[100005];
   for(int i=0;i<100005;i++){
       dp[i]=INF;
   }
   dp[0]=0;
   for(int i=1;i<N;i++){
      dp[i]=min(dp[i],dp[i-1]+abs(h[i-1]-h[i]));
      if(i>1){dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));}
   }
   cout<<dp[N-1]<<endl;
   return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        scan.close();
        List<Integer> group1 = new ArrayList<Integer>(Arrays.asList(1, 3, 5, 7, 8, 10, 12));
        List<Integer> group2 = new ArrayList<Integer>(Arrays.asList(4, 6, 9, 11));
        if (group1.containsAll(Arrays.asList(x, y)) || group2.containsAll(Arrays.asList(x, y)))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

bool isSame(vector<int> a, vector<int> b) {
	for (int i = 0; i < 6; ++i) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

bool areSame(vector<int> s, vector<int> b) {
	string com = "NNNNEEEE";
	int tmp;
	for (int n = 0; n < 8; ++n) {
		do {
			for (int i = 0; i < n; ++i) {
				if(isSame(s, b)) {
					return true;
				}
				if (com[i] == 'N') {
					tmp = s[5];
					s[5] = s[4];
					s[4] = s[0];
					s[0] = s[1];
					s[1] = tmp;
				}
				else if (com[i] == 'E') {
					tmp = s[5];
					s[5] = s[2];
					s[2] = s[0];
					s[0] = s[3];
					s[3] = tmp;
				}
			}
		} while (next_permutation(com.begin(), com.end()));
	}
	return false;
}

signed main() {
	vector<int> s(6), b(6);
	int n;
	cin >> n;

	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}

	for (int loop = 1; loop < n; ++loop) {
		for (int i = 0; i < 6; ++i) {
			cin >> b[i];
		}
		if (areSame(s, b)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

#ifndef GCD
#define GCD
// solve ax+by=gcd(a, b)
// return gcd(a, b)
template<typename T>
T gcd(const T a, const T b, T* const px = nullptr, T* const py = nullptr){
	if(py == nullptr){
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	T d = a;
	if(b != 0){
		d = gcd(b, a % b, py, px);
		*py -= (a / b) * *px;
	}else{
		*px = 1; *py = 0;
	}
	return d;
}
#endif

#ifndef LCM
#define LCM
// return lcm(a, b)
template<typename T>
T lcm(const T a, const T b){
	T ret = a / gcd(a, b);
	ret *= b;
	return ret;
}
#endif

int main(void){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];

	vector<int> L(N), R(N);
	L[0] = A[0];
	for(int i = 1; i < N; i++){
		L[i] = gcd(L[i-1], A[i]);
	}
	R[N-1] = A[N-1];
	for(int i = N-2; i >= 0; i--){
		R[i] = gcd(R[i+1], A[i]);
	}

	int res = max(R[1], L[N-2]);
	for(int i = 1; i < N-1; i++){
		res = max(res, gcd(L[i-1], R[i+1]));
	}

	cout << res << '\n';

	return 0;
}

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

using namespace std;

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

	if (S == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}


}






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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	string s;
	cin >> s;

	int max_cnt = 0, cnt = 0;
	char last = 'x';

	for (char c: s) {
		if (c == 'R') {
			if (last == 'R') {
				cnt++;
			} else
				cnt = 1;

			max_cnt = max(max_cnt, cnt);
		}

		last = c;
	}

	cout << cnt;


	return 0;
}


Measured memory_bytes: 3648
N, K, C = [int(i) for i in input().split()]
S = input()
ok_days = []
fdp = []
bdp = []

for ind, s in enumerate(S):
    if(s=='o'):
        ok_days.append(ind+1)

last = 0
fseen = set()
for i in ok_days:
    if(i>last):
        fseen.add(i)
        last = i+C

last = ok_days[-1]+1
bseen = set()
for i in ok_days[::-1]:
    if(i<last):
        bseen.add(i)
        last = i-C

ans = fseen&bseen
if(len(fseen)<=K and len(bseen)<=K):
    for i in sorted(list(ans)):
        print(i)
    

Measured memory_bytes: 43804
#include <iostream>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string.h>

const int maxn=1000;
using namespace std;

int main()
{
    char s[maxn];
    int i;
    int flag;
    while(scanf("%s", &s) != EOF)
    {
        flag = 1;
        for(i = 0;s[i] != '\0';i++)
        {
            if((i+1)%2 && s[i] == 'L')
            {
                flag = 0;
                break;
            }
            if((i+1)%2 == 0 && s[i] == 'R')
            {
                flag = 0;
                break;
            }
        }
        if(flag)
            printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int cmp(const void*a,const void*b){
  return *(int*)a-*(int*)b;}
int main(){
  int n;
  scanf("%d",&n);
  int L[n];
  int i,j,m;
  for(i=0;i<n;i++)
    scanf("%d",&L[i]);
  int count=0;
  qsort(L,n,sizeof(int),cmp);
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      for(m=j+1;m<n;m++){
	if(L[i]+L[j]>L[m]&&L[i]+L[m]>L[j])
	  count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;}


Measured memory_bytes: 128