akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int n,a[510][510],m;
void fu(int x,int y,int p,int q){
	for (int i=1;i<=m;i++){
		if (i%2==1)a[x][y]=p;else a[x][y]=q;
		x=(x+1)%m;y=(y+1)%m;
	}
}
int main(){
	cin>>n;
	if (n<=500){
		cout<<n<<endl;m=n;
		for (int i=1;i<=n;i++)fu(0,i-1,i,i);
	}else{
		cout<<500<<endl;m=500;
		int nu=0;
		for (int i=1;i<=n-500;i++){fu(0,i-1,nu+1,nu+2);nu+=2;}
		for (int i=n-500+1;i<=500;i++){fu(0,i-1,nu+1,nu+1);nu++;}
	}
	for (int i=0;i<m;i++){
		for (int j=0;j<m;j++)cout<<a[i][j]<<' ';cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     ll           long long int
#define     int          ll
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

const ld EPS=1e-10;

void solve()
{
    cout<<fixed<<setprecision(10);

    int l;
    cin>>l;

    if(l%3==0)
    {
        ld a=l/3.0,b=l/3.0,c=l/3.0;
        ld res=a*b*c;
        cout<<res;
    }
    else if(l%3==1)
    {
        ld a=l/3.0,b=l/3.0,c=l/3.0+EPS;
        ld res=a*b*c;
        cout<<res;
    }
    else
    {
        ld a=l/3.0,b=l/3.0,c=l/3.0+EPS;
        ld res=a*b*c;
        cout<<res;
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}





Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	
	bool r[100][100] = {false};
	REP(i, m)
	{
		int a,b;
		cin >> a >> b;
		r[a][b] = true;
		r[b][a] = true;
	}
	stack<int> st;
	st.push(1);
	vector<bool> f(100, false);
	stack<vector<bool> > mem;
	mem.push(f);
	
	int ans = 0;
	while (!st.empty())
	{
		int now = st.top(); st.pop();
		dbg(now);
		vector<bool> nowf = mem.top(); mem.pop();
		
		nowf[now] = true;
		bool bAll = true;
		for(int i = 1; i <=n; i++)
		{
			if (r[now][i])
			{
				if (!nowf[i])
				{
					st.push(i);
					mem.push(nowf);
					bAll=false;
				}
			}
		}
		if(bAll)
		{
			for(int i = 1; i <= n; i++)
			{
				if (!nowf[i])
				{
					bAll = false;
					break;
				}
			}
		}
		if(bAll)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
}


Measured memory_bytes: 107788
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  priority_queue<pair<int, int>> pq;
  int k,t; cin >> k >> t;
  rep(i, t) {
    int a; cin >> a;
    pq.push(make_pair(a, i));
  }

  int ans = 0;
  int beforeT = -1;
  while(!pq.empty()) {
    auto top = pq.top(); pq.pop();

    if(beforeT == top.second) {
      if(pq.size() == 0) {
        ++ans;
        --top.first;
        if(top.first == 0) {
          break;
        } else {
          pq.push(top);
          continue;
        }
      }

      auto prev = pq.top(); pq.pop();
      --prev.first;
      beforeT = prev.second;
      if(prev.first > 0) {
        pq.push(prev);
      }
      pq.push(top);
      continue;
    }

    beforeT = top.second;
    --top.first;
    if(top.first != 0) {
      pq.push(top);
    }
  }

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


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<functional>
#include<cstring>

using namespace std;

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

	long long a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	long long sol = -1000000000000000000;

	if (a <= 0 && b >= 0 || c <= 0 && d >= 0)
	{
		sol = 0;
	}

	if (a*c > sol)
	{
		sol = a*c;
	}

	if (a*d > sol)
	{
		sol = a*d;
	}

	if (b*c > sol)
	{
		sol = b*c;
	}

	if (b*d > sol)
	{
		sol = b*d;
	}
	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 1732
// C - Grand Garden
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using PI = pair<int,int>;
using QPI = queue<PI>;
#define mp(a,b) make_pair(a,b)

int N;
vi H;
QPI q;

void calc(int l, int r, bool del_flg){
	int lr = l;
	while(lr < r){
		if(del_flg) H[lr]--;
		if(H[lr] <= 0){
			if(l != lr) q.push(mp(l, lr));
			l = lr + 1;
			lr = l;
		}
		else lr++;
	}
	if(l < r) q.push(mp(l, r));
}

int in(){int x;cin>>x;return x;}

int main(){
	N = in();
	for(int i=0; i<N; ++i) H.push_back(in());

	int l=0, r=N;
	calc(l, r, false);

	int ans = 0;
	while(q.size()>0){
		ans++;
		tie(l, r) = q.front(); q.pop();
		calc(l, r, true);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
N=int(input())
for i in range (N):
    a,b,c=map(int,input().split())
    if a**2+b**2==c**2:
        print("YES")
    elif a**2+c**2==b**2:
        print("YES")
    elif b**2+c**2==a**2:
        print("YES")
    else:
        print("NO")


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


ll dp[1 << 21];
int a[22][22];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> a[i][j];

    dp[0] = 1;
    for (int msk = 1; msk < (1 << n); msk++)
    {
        int k = __builtin_popcount(msk);
        for (int i = 1; i <= n; i++)
        {
            int bit = 1 << (i-1);
            if (!(bit & msk) || !a[k][i]) continue;
            dp[msk] += dp[msk ^ bit];
            dp[msk] %= 1000000007;
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 16640
#include<stdio.h>
#include<string.h>
int min(int, int, int);
int levenshtein(char*, char*);
main()
{
        char s1[1001], s2[1001];
        scanf("%s%*c%s", s1, s2);
        printf("%d\n", levenshtein(s1, s2));
}
int min(int a, int b, int c){
        int mini = a;
        if(mini > b){
                mini = b;
        }
        if(mini > c){
                mini = c;
        }
        return mini;
}
int levenshtein(char *s1, char*s2)
{
        int i, j;
        const int len1 = strlen(s1) + 1, len2 = strlen(s2) + 1;
        int dp[len1][len2];
        for(i = 0; i < len1; i++){
                dp[i][0] = i;
        }
        for(j = 0; j < len2; j++){
        dp[0][j] = j;
    }
        for(i = 1; i < len1; i++){
                for(j = 1; j < len2; j++){
                        int cost =(s1[i - 1] == s2[j - 1]) ? 0 : 1;
                        dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1
                                                   , dp[i - 1][j - 1] + cost);
                }
        }
        return dp[len1 - 1][len2 - 1];
}

Measured memory_bytes: 5748
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char s[15],a[15];
	while(scanf("%s",s)!=EOF)
	{
		int o=0,l=strlen(s);
		for(int i=0;i<l;i++)
		{
			if(s[i]=='0')
			{
				a[o++]=s[i];
			}
			else if(s[i]=='1')
			{
				a[o++]=s[i];
			}
			else
			{
				if(o>0)
				o--;
			}
		}
		for(int i=0;i<o;i++)
		printf("%c",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
sum_A=sum(A)
count=0
for i in range(M):
    if A[i]/sum_A>=1/(4*M):
        count+=1

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

Measured memory_bytes: 9184
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

    vector<char> res;
    rep(num, 4){
        vector<char> a(n);
        a[0] = (num&1) ? 'S' : 'W';
        a[1] = (num&(1<<1)) ? 'S' : 'W';
        rept(i, 1, n-1){
            char nx;
            if(a[i] == 'S' && s[i]== 'o' || a[i] == 'W' && s[i] == 'x') nx = a[i-1];
            else nx = a[i-1] == 'S' ? 'W' : 'S';
            a[i+1] = nx;
        }
        //判定
        if(a[n-1] == 'S'){
            if(s[n-1] == 'o' && a[n-2] != a[0])continue;
            if(s[n-1] == 'x' && a[n-2] == a[0])continue;
        }else{
            if(s[n-1] == 'o' && a[n-2] == a[0])continue;
            if(s[n-1] == 'x' && a[n-2] != a[0])continue;            
        }
        if(a[0] == 'S'){
            if(s[0] == 'o' && a[n-1] != a[1])continue;
            if(s[0] == 'x' && a[n-1] == a[1])continue;
        }else{
            if(s[0] == 'o' && a[n-1] == a[1])continue;
            if(s[0] == 'x' && a[n-1] != a[1])continue;            
        }
        res = a;
        break;
    }

    if(res.size()){
        for(char c: res) cout << c; cout << ln;
    }else cout << -1 << ln;
}

Measured memory_bytes: 3744
if __name__ == '__main__':
    H,W=list(map(int,input().split()))
    A=[list(map(int,input().split())) for j in range(H)]
    N=0
    ans=[]
    XY=[]
    reverse=False
    for i in range(H):
        if not reverse:
            for j in range(W):
                XY.append((i,j))
            reverse=True
        else:
            for j in range(W-1,-1,-1):
                XY.append((i,j))
                reverse=False
    for i,(x,y) in enumerate(XY):
        if i!=len(XY)-1:
            if A[x][y]%2==1:
                A[x][y]-=1
                x2,y2=XY[i+1]
                A[x2][y2]+=1
                N+=1
                ans.append(((x,y),(x2,y2)))

    print(N)
    for a in ans:
        b,c=a[0]
        d,e=a[1]
        print("{} {} {} {}".format(b+1,c+1,d+1,e+1))


Measured memory_bytes: 72872
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, A, B, S;

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d", &N, &A, &B);
	for(int i = 1; i <= N; i++){
		string s = to_string(i);
		int t = 0;
		for(int j = 0; j < s.length(); j++) t += s[j] - '0';
		if(t >= A && t <= B) S += i;
	}
	printf("%d\n", S);
}

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

string s;
bool playable;
int32_t main() {
	playable = true; 
	cin >> s;
	for(int i = 0; i < s.length(); ++i) {
		if (i % 2 == 0) {
			if (s[i] == 'R' || s[i] == 'D' || s[i] == 'U') {
				continue;
			}
			else {
				playable = false;
				break;
			}
		} 
		if (i % 2 == 1) {
			if (s[i] == 'L' || s[i] == 'D' || s[i] == 'U') {
				continue;
			}
			else {
				playable = false;
				break;
			}
		} 
	}
	cout << ((playable) ? "Yes" : "No");
}

Measured memory_bytes: 3544
import numpy as np
from numba import njit
 
@njit('i8,i8,i8[::1]', cache=True)
def fn(N, K, A):
    for _ in range(K):
        B = np.zeros(N, dtype=np.int64)
        for i in range(N):
            l = max(0, i - A[i])
            r = min(N - 1, i + A[i])

            B[l] += 1
            if (r + 1 < N):
                B[r + 1] -= 1

        A = np.cumsum(B)
        if (np.all(A == N)):
            return A
    return A

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A, dtype=np.int64)

B = fn(N, K, A)
print(" ".join(B.astype(str)))


Measured memory_bytes: 149172
while (n=gets.to_i) != 0
	ma = 0
	mi = 2000
	sum = 0
	n.times{
		point = gets.to_i
		ma = point if point > ma
		mi = point if point < mi
		sum += point
	}
	p (sum - ma - mi) / (n - 2)
end


Measured memory_bytes: 6868
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())
ans = 0
for _ in range(N):
    l, r = map(int, sys.stdin.readline().split())
    ans += r - l + 1
print(ans)

Measured memory_bytes: 64492
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    double T, X;
    cin >> T >> X;
    cout << std::fixed << std::setprecision(8) << T / X << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
static const int INF = 1 << 30;

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i = 0; i < N; i++){
		cin >> a[i];
		a[i]--;
	}
	vector<int> num(K, 0);
	int res = INF;
	int cnt = 0;
	int j = 0;
	for(int i = 0; i < N; i++){
		for(; j < N; j++){
			if(cnt >= K) break;
			if(a[j] < K){
				if(num[a[j]] == 0) cnt++;
				num[a[j]]++;
			}
		}
		if(cnt >= K){
			res = min(res, j - i);
		}
		if(a[i] < K){
			num[a[i]]--;
			if(num[a[i]] == 0) cnt--;
		}
	}
	cout << (res == INF ? 0 : res) << endl;
	return 0;
}



Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b,c,d;
    cin>>x;
    d=x%10;
    x/=10;
    c=x%10;
    x/=10;
    b=x%10;
    x/=10;
    a=x%10;
    if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
    else cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
    return 0;
}


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

int n, m, tmp1, tmp2, c[MAX_N] = {0};
int cnt[3] = {0};
vector<vector<int>> graph(MAX_N, vector<int>{});

bool dfs(int v, int col = 1) {
  c[v] = col;
  cnt[col]++;
  for (int j = 0; j < graph[v].size(); ++j) {
    int nei = graph[v][j];
    if (c[nei] == col) {return false;}
    if (c[nei] == 0 && !dfs(nei, (3 - col))) {return false;}
  }
  return true;
}

int main(void){
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d", &tmp1, &tmp2);
    graph[tmp1].push_back(tmp2);
    graph[tmp2].push_back(tmp1);
  }
  bool temp = dfs(1);
  if (temp) {printf("%lld\n", 1LL * cnt[1] * cnt[2] - m);}
	else {printf("%lld\n", 1LL * n * (n - 1) / 2 - m);}
}


Measured memory_bytes: 6528
//https://discuss.codechef.com/t/robagain-editorial/20734
#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>


/*
#define x real()
#define y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
//#define polar(r,ang)            ((r)*exp(point(0,ang)))  ==> Already added in c++11
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
*/

//#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
#define NOT(x) (1^x)

const double PI  = acos(-1.0);
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const int N=500009,M=1000000;
const double EPS= 1e-9,eps=-1e9;
const int N =500005;

int a,b;
 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;


cin>>a>>b;
b*=2;
cout<<max(0,a-b);


return 0;
}


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

int main()
{
	string str;
	getline(cin,str);

	for (int i = 0; i < str.size(); ++i)
		if (str[i] >= 'a' && str[i] <= 'z')
			str[i] += 'A'-'a';

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] eratosu = new int[100000];
		for(int i = 1 ; i <= 100 ; i++) {
			for(int j = 1 ; j <= 100 ; j++) {
				for(int k = 1 ; k <= 100 ; k++) {
                  if(i * i + j * j + k * k >= 100000)
                    continue;
					int result = i * i + j * j + k * k + i * j + j * k + k * i;
					eratosu[result]++;
				}
			}

		}
		String s = eratosu[1] + "";
		StringBuilder sb = new StringBuilder(s);

		for(int i = 2 ; i <= n ; i++) {
			sb.append("\n" + eratosu[i]);
		}

		sc.close();
		System.out.println(sb.toString());

	}
}



Measured memory_bytes: 40668
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { {0,0,-1,1},{-1,1,0,0} };
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
struct H {
int x, y;
};
bool operator<(H a, H b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
if (b <= c || d <= a) return 0;
return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n,h;
int a,b[100000];
signed main() {
	cin>>n>>h;
	for(int i=0;i<n;i++){
		int u;
		cin>>u>>b[i];
		a=max(a,u);
	}
	sort(b,b+n);
	reverse(b,b+n);
	int sum=0,i=0;
	while(h>0&&b[i]>a){
		h-=b[i];
		sum++;
		i++;
	}
	sum+=max(0ll,(int)ceil(h*1.0/a));
	cout<<sum<<endl;
	getchar(); getchar();
}


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

using namespace std;
using lint = long long;

const int N_ = int(1.1e5);

int N, T;
int A[N_];

int pref[N_], suff[N_];

int main() {
#ifdef IN_MY_COMPUTER
  freopen("d.in", "r", stdin);
#endif
  scanf("%d%d", &N, &T);
  for(int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }

  pref[1] = A[1];
  for(int i = 2; i <= N; i++) {
    pref[i] = min(pref[i-1], A[i]);
  }

  lint max_profit = 0;
  for(int i = 2; i <= N; i++) {
    lint cur_profit = (lint)(A[i] - pref[i-1]) * (T/2);
    max_profit = max(max_profit, cur_profit);
  }

  int ans = 0;
  for(int i = 2; i <= N; i++) {
    lint cur_profit = (lint)(A[i] - pref[i-1]) * (T/2);
    if(cur_profit == max_profit) {
      ans += 1;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int a, b, c, d;

signed main()
{
	//File("");
    a = gi <int> (), b = gi <int> (), c = gi <int> (), d = gi <int> ();
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
	return 0;
}

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;cin>> n;
    int c=0;
    
    for(int i=1;i<=n;i++) {
        int x;cin>>x;
        if(i%2==1 and x%2==1)
        c++;
    }
    
    cout << c << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<double >    vecd;
typedef vector<vector<int> >  vec2int;
typedef vector<vector<double> >  vec2d;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<vector< bool > > vec2bool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int n;
vector<vector< pair<int, int>>> u; // u[i].first = node from u[i], u[i].second = cost
//output
vecint ans;
////////////////////////////////////////////////
void dfs(int pos, int color)
{
  ans[pos] = color;
  REPvec(itr, u[pos]){
    if(ans[itr->first] != -1)continue;
    dfs(itr->first, (color + (itr->second))%2);
  }
}
////////////////////////////////////////////////
int main()
{
  cin >> n;
  u.resize(n);
  ans.resize(n);
  ll a, b, c;
  REP(i,n - 1){
    cin >> a >> b >> c;
    a --; b --;
    u[a].push_back(make_pair(b, c));
    u[b].push_back(make_pair(a, c));
  }
  REP(i,n){
    ans[i] = -1;
  }
  dfs(0,0);
  REP(i,n){
    cout << ans[i] << endl;
  }
}


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

string S;
int n=0,ans=0;

int main(){
    cin >> S;
    for(int i = 0;i<S.length();++i){
        if(S[i]=='R'){
            ++n;
            ans=max(ans,n);
        }
        else n = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#define MAX 120
using namespace std;

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    int graph[MAX][MAX];
    cin >> n;

    // init
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            graph[i][j] = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            graph[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << graph[i][j];
            if (j != n - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  c = c - (a - b);
  if(c < 0){
    printf("0\n");
  }else{
    printf("%d",c);
  }
  return 0;
}


Measured memory_bytes: 128
N,M = map(int,input().split())
sc = [tuple(map(int,input().split())) for _ in range(M)]
sc = set(sc)

ans = -1
begin = 10**(N-1) - (1 if N == 1 else 0)
end = 10**N
for i in range(begin,end):
    num = str(i)
    for s,c in sc:
        if int(num[s-1]) != c:
            break
    else: ans = i
    if ans != -1:
        break

print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = in.readLine()) != null)
		{
			StringTokenizer st = new StringTokenizer(line);
			int a = Integer.parseInt(st.nextToken()), b = Integer.parseInt(st.nextToken());
			int c = a+b;
			int cnt = 0;
			while (c > 0)
			{
				cnt++;
				c/=10;
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 16912
from functools import lru_cache

N, M = map(int, input().split())

@lru_cache(maxsize=None)
def mod_inv(x):
  x1, y1, z1 = 1, 0, x
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def gen_Y(i):
  # sC2/1, (s-2)C2/2, (s-4)C2/3  ...
  s = 3*(N-i)
  r = s*(s-1)>>1
  d_r = (s<<1)-3
  for j in range(1, N-i+1):
    yield r * mod_inv(j)
    r -= d_r
    d_r -= 4

def gen_X():
  # sC3*2/1, (s-3)C3*2/2, (s-6)C3*2/3  ...
  a = N
  b = 3*N - 1
  for i in range(1, N+1):
    yield a * b * (b-1) * mod_inv(i)
    a -= 1
    b -= 3

def acc_mulmod(it, init=1):
  x = init
  yield x
  for y in it:
    x = x*y % M
    yield x

ans = sum(sum(acc_mulmod(gen_Y(i), A)) for i, A in enumerate(acc_mulmod(gen_X())))%M

print(ans)


Measured memory_bytes: 46300
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge {
    int from, to, cost;
};

int main(void) {
    int N, M, P; cin >> N >> M >> P;
    vector<vector<Edge>> G(N+1);
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        G[a].push_back({a, b, c});
    }

    long long INF = 10000000000000000;
    vector<vector<long long>> v(10001, vector<long long>(N+1, -INF));
    v[0][0] = 0;
    for (int time = 0; time < 10000; time++) {
        for (int i = 0; i < N; i++) {
            if (v[time][i] == -INF) continue;

            for (int j = 0; j < G[i].size(); j++) {
                Edge e = G[i][j];
                v[time+1][e.to] = max(v[time][e.from] + e.cost, v[time+1][e.to]);
            }
            v[time+1][i] = max(v[time][i], v[time+1][i]);
            if (i == N-1) {
                v[time+1][N] = max(v[time][N-1], v[time+1][N]);
            }
            if (time > 5000 && v[time+1][i] > v[time][i]) {
                v[time+1][i] = INF;
            }   
        }
    }
    if (INF <= v[10000][N-1]) cout << -1 << endl;
    else cout << max(v[10000][N-1], 0LL) << endl;
}


Measured memory_bytes: 196224
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

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

//long longしか使わない
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	}
	else {
		ll res = min(a - 1, n - b) + 1;
		res += (b - a - 1) / 2;
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, N = 3e7 + 1;
const int l1 = 10000000;
const int l2 = 25500000;
int d[N];

int sub(int x, int y) {
  return (x -= y) < 0 ? x + mod : x;
}

int add(int x, int y) {
  return (x += y) >= mod ? x - mod : x;
}

void Add(int &x, int y) {
  x = add(x, y);
}

int mul(int x, int y) {
  return 1ll * x * y % mod;
}

void Mul(int &x, int y) {
  x = mul(x, y);
}

int q_pow(int x, int y) {
  int ans = 1;
  for(; y; y >>= 1) {
    if(y & 1) Mul(ans, x);
    Mul(x, x);
  }
  return ans;
}

void init() {
  for(int i = 1, k = 1; i < l1; i *= 10, ++k) {
    for(int j = i; j < i * 10; ++j) d[j] = k;
  }
  for(int i = l1; i <= l2; ++i) d[i] = 8;
}

int cal1(int n) {
  int ans = 0;
  for(int l = 1, r = 1, cnt = 1; l < l1; ++l) {
    for(; r + 1 <= l2 && cnt + d[r + 1] <= n; ++r, cnt += d[r]);
    if(cnt == n) ans++;
//    printf("%d %d\n", l,r);
    cnt -= d[l];
    if(r == l2) break;
  }
//  printf("%d\n", ans);
  return ans;
}

int cal2(int n) {
  int p = n / 8, ans = p;
  for(int i = 1; i <= p; ++i) {
    if(n % i == 0) {
      Add(ans, sub(mul(9, q_pow(10, n / i - 1)), i));
    }
  }
  return ans;
}

int main() {
  init();
  int n;
  scanf("%d", &n);
  printf("%d\n", add(cal1(n), cal2(n)));
  return 0;
}

Measured memory_bytes: 100736
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s;
int ans = 1e9;

int main(){
	cin >> s;
	for(int i=0; i<26; ++i){
		bool f = false;
		for(int j=0; j<s.size(); ++j)
			if(s[j] == 'a' + i){
				f = true;
				break;
			}
		if(!f) continue;
		string t = s;
		int c = 0;
		while(1){
			bool f = true;
			for(int j=0; j<t.size(); ++j)
				if(t[j] != 'a' + i)
					f = false;
			if(f) break;
			++c;
			string tmp = t.substr(1, t.size()-1);
			for(int j=0; j<tmp.size(); ++j)
				if(t[j] == 'a' + i)
					tmp[j] = 'a' + i;
			t = tmp;
		}
		ans = min(ans, c);
	}
	printf("%d\n", ans);
}

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

using namespace std;

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

	long long n;
	cin >> n;

	long long v[3] = {0};

	for(long long i = 0; i < n; i++){
		long long a, b, c;
		cin >> a >> b>> c;
		if(!i){
			v[0] = a;
			v[1] = b;
			v[2] = c;
		}
		else{
			long long t0=v[0], t1=v[1], t2=v[2];
			v[0] = a + max(t1, t2);
			v[1] = b + max(t0, t2);
			v[2] = c + max(t0, t1);
		}
	}

	cout << max({v[0], v[1], v[2]});

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N, M, A, i;
    scanf("%d%d", &N, &M);
    for (i=0; i<M; i++) {
        scanf("%d", &A);
        N-=A;
    }
    if (N>=0) printf("%d", N);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n, m;
	cin>>n>>m;
	if(n>=2*m)cout<<n-2*m;
	else cout<<0;	
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    string S; cin >> S;
    int ans = 0;
    stack<char> s;
    REP(i,S.size()){
        if(s.size() && s.top() != S[i]){
            s.pop();
            ans += 2;
        }
        else s.push(S[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()

fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod

s = input()
dp = [[0] * n for _ in range(n)]
dp[0][0] = 1
for i in range(1, n):
    ret = 0
    if s[i - 1] == "<":
        for j in range(i - 1, -1, -1):
            ret += dp[i - 1][j]
            ret %= mod
            dp[i][j] = ret
    else:
        for j in range(i):
            ret += dp[i - 1][j]
            dp[i][j + 1] = ret
        dp[i][i] = ret

print(sum(dp[-1]) % mod)


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

#define INF 100000000
typedef pair<string, int>P;

string S;

int main(){
	while(true){
	cin >> S;
	if(S == "0") return 0;
	queue<P>que;
	set<string>st;
	que.push(P(S, 0));
	int res = INF;
	while(!que.empty()){
		P p = que.front();
		que.pop();
		string s = p.first;
		if(st.find(s) != st.end()) continue;
		st.insert(s);
		bool foo = true;
		for(int i = 0; i < s.size(); i++){
			if(s[i] != s[0]) foo = false;
		}
		if(foo){
			res = p.second;
			break;
		}
		for(int i = 0; i < s.size() - 1; i++){
			if(s[i] != s[i + 1]){
				if(s[i] == 'g'&&s[i+1] == 'b'){
					s[i] = s[i+1] = 'r';
					que.push(P(s, p.second + 1));
					s[i] = 'g';s[i+1]='b';
				}
				if(s[i] == 'b'&&s[i+1] == 'g'){
					s[i] = s[i+1] = 'r';
					que.push(P(s, p.second + 1));
					s[i] = 'b';s[i+1]='g';
				}
				if(s[i] == 'r'&&s[i+1] == 'g'){
					s[i] = s[i+1] = 'b';
					que.push(P(s, p.second + 1));
					s[i] = 'r';s[i+1]='g';
				}
				if(s[i] == 'g'&&s[i+1] == 'r'){
					s[i] = s[i+1] = 'b';
					que.push(P(s, p.second + 1));
					s[i] = 'g';s[i+1]='r';
				}
				if(s[i] == 'r'&&s[i+1] == 'b'){
					s[i] = s[i+1] = 'g';
					que.push(P(s, p.second + 1));
					s[i] = 'r';s[i+1]='b';
				}
				if(s[i] == 'b'&&s[i+1] == 'r'){
					s[i] = s[i+1] = 'g';
					que.push(P(s, p.second + 1));
					s[i] = 'b';s[i+1]='r';
				}
			}
		}
	}
	if(res == INF) cout <<"NA" << endl;
	else cout << res << endl;
}
}



Measured memory_bytes: 4708
s = gets.chomp("")

easy = true
(s.length).times do |i|
  if (i+1)%2 != 0
    if s[i] == "L"
      easy = false
      break
    end
  else
    if s[i] == "R"
      easy = false
      break
    end
  end
end

if easy
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

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

	cin >> str;
	if(str == "ABC") cout << "ARC" << "\n";
	else cout << "ABC" << "\n";
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    ll n;
    cin>>n;
    ll c;
    cin>>c;
    vector<ll> xs(n);
    vector<ll> vs(n);
    rep(i, n) cin>>xs[i]>>vs[i];

    vector<ll> ss(n + 1, 0);
    vector<ll> rs(n + 1, 0);
    rep(i, n) {
        ss[i + 1] += ss[i] + vs[i];
        rs[i + 1] += rs[i] + vs[n - i  - 1];
    }

    vector<ll> dp(n + 1, 0);
    rep(i, n) {
        dp[i + 1] = max(dp[i], ss[i + 1] - 2 * xs[i]);
    }
    ll ans = dp[n];
    rep(i, n) {
        ans = max(ans, dp[n - i - 1] + rs[i + 1] - (c - xs[n - i - 1]));
    }
    vector<ll> dpr(n + 1, 0);
    rep(i, n) {
        dpr[i + 1] = max(dpr[i], rs[i + 1] - 2 * (c - xs[n - i - 1]));
    }
    ll ansr = dpr[n];
    rep(i, n) {
        ansr = max(ansr, dpr[n - i - 1] + ss[i + 1] - xs[i]);
    }
    cout<<max(ans, ansr)<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	int t=1;
	while(t)
	{
		int n; cin>>n;
		int a=0,b=0,c=0,d=0;
		string a2="AC",b2="WA",c2="TLE",d2="RE";
		for(int i=0;i<n;i++)
		{
			string s; cin>>s;
			if(s==a2) a++;
			else if(s==b2) b++;
			else if(s==c2) c++;
			else d++;
		}
		cout<<"AC x "<<a<<"\n";
		cout<<"WA x "<<b<<"\n";
		cout<<"TLE x "<<c<<"\n";
		cout<<"RE x "<<d<<"\n";
		t--;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
int n;
struct Card {
	int value;
	char mark;
	bool operator!=(const Card& card) {
		return value != card.value || mark != card.mark;
	}
};
Card A[MAX_N], S[MAX_N];


int Partition(int p, int r) {
	int x = A[r].value, i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j].value <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void QuickSort(int p, int r) {
	if (p < r) {
		int q = Partition(p, r);
		QuickSort(p, q - 1);
		QuickSort(q + 1, r);
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i].mark >> A[i].value;
		S[i] = A[i];
	}
	stable_sort(S, S + n, [](const Card& l, const Card& r) { return l.value < r.value; });
	QuickSort(0, n - 1);
	bool st = true;
	for (int i = 0; i < n; i++) {
		if (A[i] != S[i]) {
			st = false;
			break;
		}
	}
	cout << (st ? "Stable" : "Not stable") << endl;
	for_each(A, A + n, [](const Card& c) {
		cout << c.mark << ' ' << c.value << endl;
	});
	return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int a, b;

	//標準入力
	cin >> a >> b;

	//
	if (a > b)
	{
		cout << "a > b" << endl;
	}
	else if (a < b)
	{
		cout << "a < b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
 
	return 0;
    
}


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

int main () {
  string s;
  cin >> s;
  bool isEven =!(s.size() % 2);
  bool isMatch = (s[0] == s[s.size() - 1]);
  cout << (isEven ^ isMatch ? "Second" : "First") << endl;
  return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

X, N = map(int, input().split())
if N==0:
    print(X)
    exit()
P = map(int, input().split())

l = [0] * 100

for p in P:
    l[p-1] = 1
    
i = 0
while 1:
    if X-i-1 < 0:
        print(0)
        exit()
    elif l[X-i-1] == 0:
        print(X-i)
        exit()
    elif X+i-1 >= 100:
        print(101)
        exit()
    elif l[X+i-1] == 0:
        print(X+i)
        exit()
    i+=1

Measured memory_bytes: 9204
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Strange Bank
// メモ化再帰
int N;
int ans = 200000;
int memo[101000];
const int upb = 200000;

int solve(int n){
    int res = 200000;
    if(n == 0) return 0;
    if(memo[n] != upb) return memo[n];

    rep(i, 0, 7){
        if(n >= (int)pow(6, i)){
            res = min(res, solve(n - pow(6, i)) + 1);
            memo[n] = res;
        }
    }
    rep(i, 0, 7){
        if(n >= (int)pow(9, i)){
            res = min(res, solve(n - pow(9, i)) + 1);
            memo[n] = res;
        }
    }
    return res;
}

int main(){
    cin >> N;
    rep(i, 0, 101000){
        memo[i] = upb;
    }
    ans = solve(N);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 6912