akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var input = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var N = Math.Min(input[0],input[1]);
            var M = Math.Max(input[0],input[1]);
            if(N==1&&M==1){
                System.Console.WriteLine("1");
            }else if(N==1){
                System.Console.WriteLine(M-2);
            }else{
                System.Console.WriteLine((N-2)*(M-2));
            }

        }
    } 
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main(){
  int n,i,j,ans=0;
  cin >> n;
  for(i=1;i<=n;i=i+2){
    int count=0;
    for(j=1;j<=i;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    set<char> st;
    for(int i = 0; i < s.size(); i++)
    {
        st.insert(s[i]);
    }
    if(st.size() <= 1) cout << "No" << endl;
    else cout << "Yes" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                ans +=1
                
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;
	while( left < right ){
		mid = (left + right) / 2;
		if(key == A[mid]) return 1;
		if(key > A[mid]) left = mid + 1;
		else if(key < A[mid]) right = mid;
	}
	return 0;
}

int main(void){
	int i,q,k,sum = 0;
	
	scanf("%d",&n);
	for( i = 0; i < n; i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for( i = 0; i < q; i++){
	    scanf("%d",&k);
		if(binarySearch(k))sum++;
	}
	printf("%d\n",sum);
	
    return 0;
}

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

namespace B_keyencestring
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int N = str.Length;
            if(str.Substring(N-7,7)=="keyence"
                ||(str.Substring(0,1)=="k"&&str.Substring(N-6,6)=="eyence")
                || (str.Substring(0, 2) == "ke" && str.Substring(N - 5, 5) == "yence")
                || (str.Substring(0, 3) == "key" && str.Substring(N - 4, 4) == "ence")
                || (str.Substring(0, 4) == "keye" && str.Substring(N - 3, 3) == "nce")
                || (str.Substring(0, 5) == "keyen" && str.Substring(N - 2, 2) == "ce")
                || (str.Substring(0, 6) == "keyenc" && str.Substring(N - 1, 1) == "e")
                || str.Substring(0, 7) == "keyence")
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
        }
    }
}

Measured memory_bytes: 13140
#include"iostream"
#include"vector"
using namespace std;
#define N 8
#define FREE -1
#define NOT_FREE 1
int row[8];
int col[8];
int dpos[15];
int dneg[15];
void printBoard()
{
  for(int i=0;i<N;i++)
    {
      for(int j=0;j<N;j++)
        {
          if(row[i]==j)
            {
              cout<<'Q';
            }
          else
            {
              cout<<'.';
            }
        }
      cout<<endl;
    }
}
int putQueen(int i)
{
  //putQueen(i)
  if(i==N)
    {
      printBoard();
      return 1;
    }
  if(row[i]==FREE)
    {
      for(int j=0;j<N;j++)
        {
          if(col[j]==NOT_FREE||dpos[i+j]==NOT_FREE||dneg[i-j+N-1]==NOT_FREE)
            {
              continue;
            }
          row[i]=j;
          col[j]=NOT_FREE;
          dpos[i+j]=NOT_FREE;
          dneg[i-j+N-1]=NOT_FREE;
          //printBoard();
          //cout<<"---------"<<endl;
          if(putQueen(i+1))
            {
              return 1;
            }
          row[i]=FREE;
          col[j]=FREE;
          dpos[i+j]=FREE;
          dneg[i-j+N-1]=FREE;
        }
    }
  else
    {
      putQueen(i+1);
    }

  return 0;
}

int main()
{
  int n;
  cin>>n;
  for(int i=0;i<N;i++)
    {
      row[i]=FREE;
      col[i]=FREE;
    }
  for(int i=0;i<15;i++)
    {
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
  for(int k=0;k<n;k++)
    {
      int i,j;
      cin>>i;
      cin>>j;
      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    }
  putQueen(0);
  //printBoard();
  return 0;
}


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

signed main(){
    int n;
    cin >> n;
    int a[n];
    ll sum=0;
    rep(i,n){
        int aa;
        cin >>aa;
        sum+=aa;
        aa*=2;
        a[i]=aa;
    }
    ll save=0;
    for(int i=0;i<n-1;i+=2){
        save+=a[i];
    }
    int ans[n];
    ans[n-1]=sum-save;
    ans[0]=a[n-1]-ans[n-1];
    save=ans[0];
    rep(i,n-1){
        ans[i+1]=a[i]-save;
        save=ans[i+1];
    }
    rep(i,n) printf("%d ",ans[i]);


}

Measured memory_bytes: 2816
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, a, b; cin >> k >> a >> b;
    int ka = (a + k - 1) / k * k;
    if (a <= ka && ka <= b) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}


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

using namespace std;

#define lint long long

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

Measured memory_bytes: 3712
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}


Measured memory_bytes: 256
#A
H,W = map(int,input().split())
G = [list(str(input())) for _ in range(H)]
inf = float("inf")

dist = [[inf for w in range(W)] for h in range(H)]

if G[0][0] == "#":
    dist[0][0] = 1
else:
    dist[0][0] = 0

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            pass
        elif j == 0:
            dist[i][j] = dist[i-1][j]
            if G[i][j] == "#" and G[i-1][j] != "#":
                dist[i][j]+=1
        elif i == 0:
            dist[i][j] = dist[i][j-1]
            if G[i][j] == "#" and G[i][j-1] != "#":
                dist[i][j]+=1
        else:
            d1 = dist[i-1][j]
            d2 = dist[i][j-1]
            if G[i][j] == "#" and G[i-1][j] != "#":
                d1+=1
            if G[i][j] == "#" and G[i][j-1] != "#":
                d2+=1
            dist[i][j] = min(d1,d2)
        

print(dist[H-1][W-1])



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

int main(){
  int n;
  cin >> n;
  map<ll, int> m;
  rep(i, n){
    ll a;
    cin >> a;
    m[a]++;
  }
  ll x1 = 0, x2 = 0;
  for(auto x : m){
    if(x.second >= 4){
      x1 = x.first, x2 = x.first;
    } else if(x.second >= 2){
      x2 = x1, x1 = x.first;
    }
  }
  cout << x1*x2 << endl;
  return 0;
}


Measured memory_bytes: 6528
count = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  if i==0:
    print(0)
    exit()
    
for i in range(len(A)):
  ans = ans*A[i]
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)

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

int main() {
  int n,m;
  cin>>n>>m;
  int s[10],c[10];
  for(int i=0;i<m;i++) cin>>s[i]>>c[i];

  for(int i=0;i<=999;i++) {
    bool flag=true;
    string num=to_string(i);

    if(n!=num.size()) flag=false;

    for(int i=0;i<m;i++) {
      if(num[s[i]-1]-'0'!=c[i]) flag=false;
    }

    if(flag) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}


Measured memory_bytes: 3608
N, M = [int(s) for s in input().split()]
query = []
for _ in range(M):
    x, y = input().split()
    query.append((int(x), int(y)))

query = sorted(query, key=lambda x: x[1])
b_prev = 0
cnt = 0
for a, b in query:
    if b_prev <= a:
        cnt += 1
        b_prev = b

print(cnt)


Measured memory_bytes: 18984
#include<cstdio>
#include<iostream>
using namespace std;
int d[11][11],n,m,tot,now,sum;
int pa[110],pb[110];
bool vis[11][11];
struct edg{
	int a,b,c;
}ans[310];
void print()
{
	//for (int i=1;i<=sum;i++)
	//	printf("%d %d %d\n",ans[i].a,ans[i].b,ans[i].c);
	
	int numn=0,numm=0;
	for (int i=1;i<=sum;i++)
	{
		numm+=ans[i].a+ans[i].b+1;
		numn+=ans[i].a+ans[i].b;
	}
	numn+=2;
	if (numn>300) {while(1);printf("Impossible\n");return;}
	printf("Possible\n");
	printf("%d %d\n",numn,numm);
	int t=1,pre=1;
	for (int i=1;i<=sum;i++)
	{
		pre=1;
		printf("%d %d %d\n",pre,++t,ans[i].c),pre=t;
		for (int j=1;j<=ans[i].a;j++)
		{
			printf("%d %d %c\n",pre,(j==ans[i].a&&ans[i].b==0)?numn:++t,'X'),pre=t;
		}
		for (int j=1;j<=ans[i].b;j++)
			printf("%d %d %c\n",pre,(j==ans[i].b)?numn:++t,'Y'),pre=t;
		
	}
	printf("%d %d\n",1,numn);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&d[i][j]);
	for (int s=0;s<=300;s++)
		for (int a=0;a<=s&&a<=100;a++)
			for (int b=0;b<=s-a&&b<=100;b++)
				{
					int c=s-a-b;
					bool p=0,q=0;
					int now=0;
					for (int i=1;i<=n;i++)
					{
						for (int j=1;j<=m;j++)
						{
							if (a*i+b*j+c==d[i][j]&&!vis[i][j]) q=1,now++,pa[now]=i,pb[now]=j;
							else if (a*i+b*j+c<d[i][j]) {p=1;break;}
						}
						if (p==1) break;
					}
					if ((!p)&&q) 
					{
						//cout<<now<<endl;
						for (int i=1;i<=now;i++)
							vis[pa[i]][pb[i]]=1;
						tot+=now,ans[++sum].a=a,ans[sum].b=b,ans[sum].c=c;
						if (tot==n*m){print();return 0;}
					}
				}
	printf("Impossible\n");
}

Measured memory_bytes: 384
use std::io::stdin;
use std::io::Error;
use std::io::Read;

#[derive(Debug)]
struct Input {
    n: u64,
    a: Vec<u64>,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    let mut iter = input_str.split_whitespace();
    let n: u64 = iter.next().unwrap().parse().unwrap();
    let a: u64 = iter.next().unwrap().parse().unwrap();
    let b: u64 = iter.next().unwrap().parse().unwrap();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let d: u64 = iter.next().unwrap().parse().unwrap();
    let e: u64 = iter.next().unwrap().parse().unwrap();
    let input = Input {
        n: n,
        a: vec![a, b, c, d, e],
    };
    Ok(input)
}

fn handle_output(input: Input) -> Result<String, Error> {
    Ok(format!(
        "{}",
        (input.n - 1) / input.a.iter().min().unwrap() + 5
    ))
}

fn main() {
    let mut input_str = String::new();
    let stdin = stdin();
    stdin.lock().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

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

typedef long long llint;

int n, m;
map<int, int> mp;

llint ans = 0;

int main() {
    cin >> n >> m;
    int am = 0;

    mp[0] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        am = (am + a) % m;
        if (mp.find(am) == mp.end()) {
            mp[am] = 1;
        } else {
            mp[am]++;
        }
    }

    for (auto it = mp.begin(); it != mp.end(); it++) {
        llint l = it->second;
        ans += l * (l - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<int> sum(n+1);
	do{
		rep(i,n+1) sum[i]=0;
		rep(i,n){
			sum[max<int>(i-a[i],0)]++;
			sum[min<int>(i+a[i]+1,n)]--;
		}
		rep(i,n) sum[i+1]+=sum[i];
		rep(i,n) a[i]=sum[i];

		k--;
	}while(k>0 && count(a.begin(),a.end(),n)<n);

	rep(i,n) printf("%d%c",a[i],i<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 4836
#include<stdio.h>
#include<string.h>

/*
奇数なら、
(n-1)... 4 2 0 2 4 ...
偶数なら、
(n-1)... 3 1 1 3 ...
となる。2^(n/2)が答え。
*/

long long sum(long long a, long long b) {
	return (a + b) % 1000000007;
}

int main(void) {
	int N;
	int i,p,h;
	int A[100000];
	long long ans;
	scanf("%d", &N);

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

	h = 2;
	for (i = N - 1; i >= 1; i--) {
		if (A[i] != h) { printf("0\n"); return 0; }
		h = 2 - h;
	}

	ans = 1;
	for (i = 0; i < N / 2; i++) {
		ans = sum(ans, ans);
	}

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



	return 0;
}

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

int main() {
	int n, sum = 0;
	cin >> n;
	vector<int> abc(3);

	for (int i = 1; i <= n; i++) {
		abc.at(0) = i;
		for (int j = 1; j <= n; j++) {
			abc.at(1) = j;
			for (int k = 1; k <= n; k++) {
				abc.at(2) = k;
				sum += gcd(abc.at(0), gcd(abc.at(1), abc.at(2)));
			}
		}
	}
	cout << sum << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int n;
int a[N];

int main() {

	FAST;

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a * b, c) << '\n';
	return 0; 
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, i;
    cin >> n;
    vi b(n-1);
    for (i=0;i<n-1;i++) cin >> b[i];
    
    int sum = b[0] + b[n-2];
    for (i=1;i<n-1;i++)
        sum += min(b[i-1], b[i]);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

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

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

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

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

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


void solve(){
    int n;
    cin>>n;
    v(ar(int,2)) a(n);
    for(int i = 0; i<n; i++){
        cin>>a[i][0];
        a[i][1] = i+1;
    }
    sort(all(a));
    for(int i = 0; i<n; i++)cout<<a[i][1]<<' ';
    cout<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n, m;
  cin >> n >> m;
  int p[100000], y[100000];
  vector<ll> yd[100001];
  rep (i,m) scanf ("%d%d",&p[i],&y[i]), yd[p[i]].push_back(y[i]);
  rep (i,n) sor(yd[i+1]);
  rep (i,m) printf ("%012lld\n", ll(p[i])*1000000+ int(lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin())+1);
  return 0;
}


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

namespace exawizards2019_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var q = CIn.ReadInt();
      var s = CIn.Read().ToList();
      var t = new int[q];
      var d = new int[q];

      s.Insert(0, '_');
      s.Insert(n + 1, '_');

      for (var i = 0; i < q; i++)
      {
        t[i] = CIn.Read()[0];
        d[i] = CIn.Read()[0];
      }

      var l = 0;
      var r = n + 1;

      while (l < r)
      {
        var m = (l + r + 1) / 2;
        var p = m;

        for (var i = 0; i < q; i++)
        {
          if (t[i] == s[p])
          {
            if (d[i] == 'L')
            {
              p--;
            }
            else
            {
              p++;
            }
          }

          if (p <= 0 || p > n)
          {
            break;
          }
        }

        if (p <= 0)
        {
          l = m;
        }
        else
        {
          r = m - 1;
        }
      }

      var min = l + 1;

      l = 0;
      r = n + 1;

      while (l < r)
      {
        var m = (l + r) / 2;
        var p = m;

        for (var i = 0; i < q; i++)
        {
          if (t[i] == s[p])
          {
            if (d[i] == 'L')
            {
              p--;
            }
            else
            {
              p++;
            }
          }

          if (p <= 0 || p > n)
          {
            break;
          }
        }

        if (p > n)
        {
          r = m;
        }
        else
        {
          l = m + 1;
        }
      }

      var max = r;

      Console.WriteLine(max - min);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 19424
N, x = map(int, input().split())

if x in (1, 2*N-1):
    print('No')
else:
    print('Yes')
    ans = list(range(1, 2*N))
    st = (x-N) % (2*N-1)
    print('\n'.join(map(str, ans[st:] + ans[:st])))


Measured memory_bytes: 26584
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

// デバッグ

#ifdef DEBUG
#include <cassert>
#define my_assert(x) assert(x)
#else
#define my_assert(x)
#define assert(x)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector<int> candidate(n, -1);
    int m;
    cin >> m;
    bool good = true;
    rep(i, m)
    {
        int s, c;
        cin >> s >> c;
        --s;
        if (candidate[s] == -1)
        {
            candidate[s] = c;
            continue;
        }
        if (candidate[s] != c)
        {
            good = false;
        }
    }
    if (n > 1 && candidate[0] == 0)
    {
        good = false;
    }
    if (good)
    {
        if (n == 1)
        {
            cout << (candidate[0] == -1 ? 0 : candidate[0]);
        }
        else
        {
            cout << (candidate[0] == -1 ? 1 : candidate[0]);
            rep(i, n - 1)
            {
                cout << (candidate[i + 1] == -1 ? 0 : candidate[i + 1]);
            }
        }
    }
    else
    {
        cout << -1;
    }
    
    cout << "\n";

    return 0;
}


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

int n,m;
int a[100010];
int d[100010];
int main(){
  int i,j,sum=0,x;
  cin >> n;
  a[0] =0;
  for(i=1;i<=n;i++)cin >> a[i];
  a[n+1] = 0;
  for(i=1;i<=n+1;i++){
    d[i] = fabs(a[i-1]-a[i]);
    sum += d[i];
  }
  for(i=1;i<=n;i++){
    x = sum;
    x -=d[i];
    x -=d[i+1];
    x += fabs(a[i-1]-a[i+1]);
    cout << x << endl;
  }
  return 0;
    
}


Measured memory_bytes: 2048
#include<stdio.h>

int main(void) {
  int n, k;
  int* d;
  int** a;
  _Bool* hasOkashi;
  scanf("%d %d", &n, &k);
  int i, j;
  d = (int*)malloc(sizeof(int)*k);
  a = (int**)malloc(sizeof(int*)*k);
  hasOkashi = (_Bool*)malloc(sizeof(_Bool)*n);
  for(i=0; i<k; i++) {
    scanf("%d", &d[i]);
    a[i] = (int*)malloc(sizeof(int)*d[i]);
    for(j=0; j<d[i]; j++) {
      scanf("%d", &(a[i][j]));
      hasOkashi[a[i][j]-1] = 1;
    }
  }
  int count=0;
  for(i=0; i<n; i++) {
    if(hasOkashi[i] == 0) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 1768
import math

N, M = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for _ in range(M)]

forward_edges = {n+1:[] for n in range(N)}
reverse_edges = {n+1:[] for n in range(N)}
for e in edges:
  forward_edges[e[0]].append(e[1])
  reverse_edges[e[1]].append(e[0])
# print(  forward_edges)
# print(  reverse_edges)
estimated_distance = {n+1:None for n in range(N)}
estimated_distance[N] = 0
probability = {n+1:None for n in range(N)}
probability[1] = 1
def get_probability(n):
  if probability[n] is not None:
    return probability[n]
  prob = 0
  for m in reverse_edges[n]:
    prob += get_probability(m) / len(forward_edges[m])
  probability[n] = prob
  return prob
  
def get_distance(n):
  if estimated_distance[n] is not None:
    return estimated_distance[n]
  total_distance = 0
  for m in forward_edges[n]:
    total_distance += get_distance(m)
  estimated_distance[n] = 1 + total_distance / len(forward_edges[n])
  return estimated_distance[n]


before_distance = get_distance(1)
max_decrease = 0
for n in range(1, N):
  if len(forward_edges[n]) == 1:
    continue
  distances = [get_distance(m) for m in forward_edges[n]]
  distance_diff = sum(distances) / len(distances) - (
    sum(distances)-max(distances))/(len(distances)-1)
  decrease = get_probability(n) * distance_diff
  max_decrease = max(max_decrease, decrease)

print(before_distance - max_decrease)
    


Measured memory_bytes: 85208
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7
N = int(input())
A = inpl()
ans = 1
nc = [0] * 3
for i in range(N):
    k = 0
    a = A[i]
    while nc[k] > a:
        k += 1
        if k > 2:
            print(0)
            exit()
    if nc[k] < a:
        print(0)
        exit()
    if k <= 1 and nc[k+1] == a:
        s = 2
        if k == 0 and nc[k+2] == a:
            s = 3
        ans = ans * s % MOD
    nc[k] += 1
print(ans)


Measured memory_bytes: 53036
unittest
{
	assert( [ "2 3" ].parse.expand.solve == 6 );
	assert( [ "123 456" ].parse.expand.solve == 18696 );
	assert( [ "100000 99999" ].parse.expand.solve == 9999900000 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return lcm( a, b );
}

// 最小公倍数
auto lcm( long x, long y )
{
	import std.numeric;
	return x * y / x.gcd( y );
}


Measured memory_bytes: 256
H, W = map(int, input().split())
C = list(map(lambda x: int(x) - 1, input().split()))
D = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]
toGo = [[False if i != C[0] or j != C[1] else True for j in range(W)] for i in range(H)]
queue, mahou = [C], [C]
ans = 0

while True:
    tmp = queue.pop()
    mahou.append(tmp)
    dfs = [tmp]

    while len(dfs):
        a = dfs.pop()
        for move in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
            hh, ww = a[0] + move[0], a[1] + move[1]
            if hh >= H or hh < 0 or ww >= W or ww < 0:
                continue

            if not toGo[hh][ww] and S[hh][ww] == '.':
                toGo[hh][ww] = True
                dfs.append([hh, ww])
                mahou.append([hh, ww])

    if toGo[D[0]][D[1]]:
        break

    flag = True
    if not len(queue):
        ans += 1
        for k in mahou:
            for i in range(-2, 3):
                for j in range(-2, 3):
                    h, w = i + k[0], j + k[1]
                    if h >= H or h < 0 or w >= W or w < 0:
                        continue

                    if not toGo[h][w] and S[h][w] == '.':
                        flag = False
                        toGo[h][w] = True
                        queue.append([h, w])
        mahou = []

        if flag:
            print(-1)
            exit()

print(ans)

Measured memory_bytes: 102656
import sys


class UnionFind(object):
    def __init__(self, N):
        self._parent = list(range(N))
        self.__num_components = [1] * N

    def root(self, x):
        if self._parent[x] == x:
            return x
        else:
            # root abbreviation
            self._parent[x] = self.root(self._parent[x])
            return self._parent[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def num_connected(self, x):
        return self.__num_components[self.root(x)]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if (x == y):
            return
        rank_x = self.__num_components[x]
        rank_y = self.__num_components[y]
        if rank_x < rank_y:
            self._parent[x] = y
            self.__num_components[y] += rank_x
        else:
            self._parent[y] = x
            self.__num_components[x] += rank_y
        return


fin = sys.stdin.readline
N, M = [int(elem) for elem in fin().split()]
conditions = [tuple(int(elem) - 1 for elem in fin().split()) for _ in range(M)]
uf = UnionFind(N)
for X, Y, _ in conditions:
    uf.unite(X, Y)

num_distinct_components = 0
for i in range(N):
    if uf.root(i) == i:
        num_distinct_components += 1
print(num_distinct_components)


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    long long aw[a][b],ae[a][c] = {},aq[b][c];
    for(int i = 0;i < a;i++){
        for(int k = 0;k < b;k++){
            cin >> aw[i][k];
        }
    }
    for(int i = 0;i < b;i++){
        for(int j = 0;j < c;j++){
            cin >> aq[i][j];
        }
    }
    for(int i = 0;i < a;i++){
        for(int k = 0;k < b;k++){
            for(int j = 0;j < c;j++){
                ae[i][j] += aw[i][k] * aq[k][j];
            }
        }
    }
    for(int i = 0;i < a;i++){
        for(int k = 0;k < c;k++){
            cout << ae[i][k];
            if(k != c - 1)cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <int, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (1 << 20), MOD = 1e9 + 7;
int n, a[N], last[N], pr[N], z[N], used[N];
int fact[N], inv[N], rev[N];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

vi vec, val, dp;

int get(int pos, bool flag) {
	vec.clear();
	while (pos != -1) {
		vec.pb(pos);
		pos = pr[pos];
	}
	reverse(all(vec));
	int m = vec.size();
	val.clear();
	val.pb(0);
	for (int i = 1; i < m; i++) {
		val.pb(z[vec[i] - 1] - z[vec[i - 1]]);
		val[i] += val[i - 1];
	}
	dp.clear();
	dp.resize(m);
	int s = 0, sw = 0, res = 0;
	for (int i = 0; i < m; i++) {
		dp[i] = 1;
		add(dp[i], (ll)s * val[i] % MOD);
		add(dp[i], sw);
		add(res, dp[i]);
		
		add(s, dp[i]);
		int x = (ll)dp[i] * val[i] % MOD;
		x = (-x + MOD) % MOD;
		add(sw, x);
	}
	if (flag) {
		return dp[m - 1];
	}
	return res;
}

int c(int x, int y) {
	if (x > y) {
		return 0;
	}
	return ((ll)fact[y] * rev[x] % MOD) * rev[y - x] % MOD;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	fact[0] = rev[0] = inv[1] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = (ll)fact[i - 1] * i % MOD;
		int r = (i - MOD % i) % i;
		if (i > 1) {
			inv[i] = (ll)inv[r] * ((MOD + r) / i) % MOD;
		}
		rev[i] = (ll)rev[i - 1] * inv[i] % MOD;
	}
	cin >> n;
	memset(& last, -1, sizeof(last));
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] ^= a[i - 1];
		pr[i] = last[a[i]];
		last[a[i]] = i;
		z[i] = z[i - 1] + (a[i] == 0);
	}
	if (a[n] > 0) {
		cout << get(n, true);
		return 0;
	}
	int res = 0;
	for (int i = n - 1; i >= 1; i--) {
		if (a[i] == 0 || used[a[i]]) {
			continue;
		}
		used[a[i]] = 1;
		add(res, get(i, false));
	}
	for (int i = 1; i <= z[n]; i += 2) {
		add(res, c(i, z[n]));
	}
	cout << res;
}


Measured memory_bytes: 28912
word = list(input())

n = int(input())
orders = [list(input().split()) for i in range(n)]
for order in orders:
  if order[0] == "print":
    print("".join(word[int(order[1]):int(order[2])+1]))
  elif order[0] == "replace":
    replace_word = list(order[3])
    for i in range(len(replace_word)):
      word[int(order[1]) + i] = replace_word[i]
  elif order[0] == "reverse":
    reverse_word = list(reversed(word[int(order[1]):int(order[2])+1]))
    count = 0
    for j in range(int(order[1]),int(order[2])+1):
      word[j] = reverse_word[count] 
      count += 1



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


#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

int n;
char buf[1252521];
int w[125252][2];

int ans[26];

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",buf);
    int m = strlen(buf);
    w[i][0] = buf[0]-'a';
    w[i][1] = buf[m-1]-'a';
    REP(j,m+1)buf[j] = '\0';
  }
  REP(j,26)ans[j] = 1<<20;
  FORR(i,0,n){
    if(i==n-1){
      ans[w[i][0]] = 1;
      continue;
    }
    ans[w[i][0]] = min(ans[w[i][0]], ans[w[i][1]]+1);
  }
  printf("%d\n",ans[w[0][0]]);
  return 0;
}


Measured memory_bytes: 4012
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,sum,mi,i;
	scanf("%d",&n);
	mi=999; sum=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a);
		sum+=a;
		if(a%2==1)	mi=min(mi,a);
	}
	if(sum%2==1)	sum-=mi;
	sum/=2;
	printf("%d\n",sum);
	return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=2019;

const ll INF = 1LL << 60;

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

// a^n mod を計算 再帰
ll modpow(ll a,ll n,ll &mod){
  if(!n) return 1;
  ll x = modpow(a,n/2,mod)%mod;
  x *=x;
  if(n%2==1)x*=a;
  return x%mod;
}



int main(){
  string s;cin>>s;
  int n=s.size();
  vector<int> v(n+1);
  map<int,int> c;
  v[0]=0;
  c[0]=1;
  reps(i,n){
    v[i]=(v[i-1]+modpow(10,i-1,mod)*(s[n-i]-'0'))%mod;
    c[v[i]]++;
  }
  ll ans=0;
  for(auto x:c){
    int cc=x.second;
    ans+=cc*(cc-1)/2;
  }
  cout<<ans;
}


Measured memory_bytes: 4456
#include<stdio.h>

int main() {
    int m, f, b; //自分、Aくん、本の価格
    
    //入力
    scanf("%d %d %d", &m, &f, &b);
    
    //出力
    if (m >= b) { //自分で事足りる場合
        printf("0\n");
    }else{
        if (m + f >= b) { //２人合わせると足りる場合
            printf("%d\n", b - m);
        }else{  //詰んだ
            printf("NA\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 2048
a,b,c,d = map(int,input().split())
lisa = []
lisb = []
for n in range((b-a)+1):
  lisa.append(n + a)
for m in range((d-c)+1):
  lisb.append(m + c)
ans = 0
for i in range(101):
  if i in lisa and i in lisb:
    ans += 1
if ans > 0:
  print(ans-1)
else:
  print(ans)

Measured memory_bytes: 3064
r,c,k=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(k)]
dp=[[[0 for _ in range(c+1)]for _ in range(r+1)]for _ in range(5)]
for x,y,z in a:
    dp[4][x][y]=z
for i in range(1,r+1):
    for j in range(1,c+1):
        v=dp[4][i][j]
        dp[0][i][j]=max(dp[0][i][j-1],dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j-1]+v,dp[0][i-1][j]+v,dp[1][i-1][j]+v,dp[2][i-1][j]+v,dp[3][i-1][j]+v)
        dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+v)
        dp[3][i][j]=max(dp[3][i][j-1],dp[2][i][j-1]+v)
print(max([dp[i][r][c] for i in range(4)]))

Measured memory_bytes: 494216
#include<iostream>
#include<algorithm>
#include<vector>
#include <string>
using namespace std;
#define int int64_t
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)

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

    vector<char> T(Q),D(Q);
    rep(i,Q) cin >> T[i] >> D[i];
    

    int left = 0,right = N;
    while(left+1 < right){
        int mid = (left + right) / 2;

        int idx = mid;
        bool leftside = false;
        rep(i,Q){
            if(S[idx] == T[i]){
                if(D[i] == 'R') idx++;
                else idx--;
            }
            if(idx == -1){
                leftside = true;
                break;
            }
            else if(idx == N) break;
        }

        if(leftside) left = mid;
        else right = mid;
        //cout << left << " " << mid << " " << right << endl;
    }

    int ans = N;
    ans -= left + 1;

    left = 0,right = N;
    while(left+1 < right){
        int mid = (left + right) / 2;

        int idx = mid;
        bool rightside = false;
        rep(i,Q){
            if(S[idx] == T[i]){
                if(D[i] == 'R') idx++;
                else idx--;
            }
            if(idx == -1) break;
            else if(idx == N) {
                rightside = true;
                break;
            }
        }

        if(rightside) right = mid;
        else left = mid;

    }
    ans -= N-right;

    cout << ans << endl;    

}


Measured memory_bytes: 900
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_A
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  printf("%.8lf \n", sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
}

Measured memory_bytes: 1240
def main():
    A,B,C = map(int, input().split())

    f(A,B,C)


def f(A,B,C):
    """
    A: 545, 565, 666 ans=2
    B: 445,      555 ans=1
    C: 123, 233, A pattern ans=3
    D: 135, 245, 355, 555 ans=3
    E: 235, 345, 455, A pattern ans=4
    """
    A, B, C = sorted([A, B, C])
    ans = 0
    if B != C:
        ans += C - B
        B = C
        A += ans
    
    diff = B - A
    ans += diff // 2
    if diff % 2 != 0:
        # A+2,BC+1
        ans += 2

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;

    cin>> s;

    if(s[0] != 'A' )
    {
        cout<< "WA\n";
        return 0;
    }

    int cn= 0;

    for(int i=1; i<s.size(); i++)
    {
        if (i>=2 && i<= (s.size() -2 ))
        {
            if(s[i]== 'C')
            {
                cn++;
                continue;
            }
        }

        if(s[i]< 'a' || s[i] > 'z'  || cn>1)
        {
            {
                cout<< "WA\n";
                return 0;
            }
        }
    }

    if(cn==1)
    cout<< "AC\n";
    else
    cout<< "WA\n";




    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, ans = 0;
  cin >> n;
  vl a(n);
  vb ng(1e6 + 1, false);
  rep(i, n) cin >> a[i];
  sort(all(a));
  rep(i, n) {
    if(ng[a[i]]) continue;
    if(i == n - 1 || a[i] != a[i + 1]) ans++;
    for(ll k = a[i]; k <= 1e6; k += a[i]) ng[k] = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n; cin>>n;
	ll sum{};
	int m = 1e9;
	bool p{};
	for(int i=0; i<n; i++){
		int a; cin>>a;
		if(a<0) p^=1;
		sum += abs(a);
		m = min(m,abs(a));
	}
	if(p) sum -= 2*m;
	cout << sum << endl;
	
}

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

int  bubble_sort(int a[], int n);


int main(){
    
    int n;
    int a[200];

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

    int cnt = bubble_sort(a,n);
    
    cout << cnt << endl;
    return 0;
}


int bubble_sort(int a[], int n)
{
    int cnt = 0;

    for(int i = 0; i < n; ++i)  
    {        
        for(int j = n - 1; j > i; --j)
        {
            if(a[j]<a[j-1])
            {
                int temp = a[j-1];
                a[j-1] = a[j];
                a[j] = temp;
                ++cnt;
            }
        }
    }

    for(int k=0; k<n; k++)
    {
        if(k != n-1) {cout << a[k] << " ";}
        else {cout << a[k] << endl;}
    }

    return cnt;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;

bool check(int Cx, int Cy, int Ch, int x, int y, int h) {
    return h == max(Ch - abs(Cx - x) - abs(Cy - y), 0);
}

int main() {
    int N;
    cin >> N;
    int x[N], y[N], h[N];
    int first_i = -1;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0 && first_i < 0) first_i = i;
    }

    // check (Cx, Cy) = (i, j)
    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            int Ch = h[first_i] + abs(Cx - x[first_i]) + abs(Cy - y[first_i]);
            bool flag = true;
            for (int k = 0; k < N; k++) {
                if (!check(Cx, Cy, Ch, x[k], y[k], h[k])) flag = false;
            }
            if (flag) cout << Cx << " " << Cy << " " << Ch << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vi perm(n);
    iota(all(perm), 0);
    double ans = 0;
    int cnt = 0;
    do {
        cnt++;
        double now = 0;
        rep(i, n-1) {
            now += hypot(x[perm[i]] - x[perm[i+1]], y[perm[i]] - y[perm[i+1]]);
        }
        ans += now;
    } while (next_permutation(all(perm)));

    ans /= cnt;
    cout << fixed << setprecision(15) << ans << endl;
}

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

using namespace std;
int n,ac=0,wa=0,tle=0,re=0;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string a;
        cin>>a;
        if(a[0]=='A')ac++;
        if(a[0]=='W')wa++;
        if(a[0]=='T')tle++;
        if(a[0]=='R')re++;
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
}


Measured memory_bytes: 3716
#include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>
using namespace std;
using W = double;
using P = complex<W>;
using L = pair<P,P>;
using C = pair<P,W>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const W EPS = (1e-10), pi = acos(-1);

//円と円の交点
vector<P> cpcc(C a, C b){
  P ca = a.first, cb = b.first;
  W d = abs(ca-cb), ra = a.second, rb = b.second;
  W t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(cb-ca)*(cb-ca)+ca;
  vector<P> cp(2,m);
  P n = (ca-cb)*P(0,1);
  n *= h/abs(n);
  cp[0] -= n;
  cp[1] += n;
  return cp;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<P> Center;
  vector<W> Ci;
  for(int i = 0; i < N; ++i){
    double x, y, c;
    cin >> x >> y >> c;
    Center.emplace_back(x,y);
    Ci.emplace_back(c);
  }
  double ng = 0, ok = 1e9;
  for(int itr = 0; itr < 100; ++itr){
    double m = (ok+ng)/2;
    vector<C> M;
    for(int i = 0; i < N; ++i){
      M.push_back(C(Center[i],m/Ci[i]));
    }
    vector<P> cand = Center;
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < i; ++j){
        double d = abs(M[i].first-M[j].first);
        double ri = M[i].second, rj = M[j].second;
        if(d < ri+rj-EPS and d > abs(ri-rj)+EPS){
          auto tmp = cpcc(M[i],M[j]);
          for(auto p : tmp)
            cand.emplace_back(p);
        }
      }
    }
    bool f = false;
    for(auto p : cand){
      int cnt = 0;
      for(auto c : M){
        if(abs(c.first-p) < c.second+EPS)
          ++cnt;
      }
      if(cnt >= K){
        f = true;
        break;
      }
    }
    if(f) ok = m;
    else ng = m;
  }
  printf("%.12f\n",ok);
}


Measured memory_bytes: 384