akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
    char a;
    scanf("%c",&a);
    if (a >= 'A' && a <= 'Z')
    {
        printf("A\n");
    }
    else if (a >= 'a' && a <= 'z')
    {
        printf("a\n");
    }

    return 0;
}

Measured memory_bytes: 1540
#pragma GCC optimize(2)
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
#define pii pair<long long,long long>
#define ll long long
#define fi first
#define se second
#define y1 yy1
//const long long mx=1e11;
//const long long mod=1e9+7;
const long long mod=998244353;
const long long maxn=2e5+10;
 
long long p[2]={1000000007,998244353};
long long seed[2]={500000004,500000004};
 
/*long long hh[maxn],hn[maxn*2],hy[maxn*2],ht;
void link(long long x,long long y){
	ht++;
	hn[ht]=hh[x];
	hh[x]=ht;
	hy[ht]=y;
}*/ 
 
/*long long ksm(long long x,long long y){
	long long re=1,xx=x%mod;
	while(y>0){
		if(y&1){
			re*=xx;
			re%=mod;
		}
		xx*=xx;
		xx%=mod;
		y>>=1;
	} 
	return re;
}*/
 
int tt,n,m,x,y,z;
 
int main(){
	
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);
	
	cin>>x>>y>>n>>m>>z;
	
	cout<<(n-x)*60+(m-y)-z<<endl;
	
	
	return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

string S, T;
int Q;
int A[100010];
int B[100010];
int C[100010];
int D[100010];

int sums_s[2][100010];
int sums_t[2][100010];

int main(){

    cin >> S >> T;

    for(int i = 0; i < (int)S.size(); i++){
        sums_s[0][i + 1] = sums_s[0][i] + (S[i] == 'A');
        sums_s[1][i + 1] = sums_s[1][i] + (S[i] == 'B');
    }
    for(int i = 0; i < (int)T.size(); i++){
        sums_t[0][i + 1] = sums_t[0][i] + (T[i] == 'A');
        sums_t[1][i + 1] = sums_t[1][i] + (T[i] == 'B');
    }

    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;B[i]--;C[i]--;D[i]--;
        ll a = (sums_s[0][B[i] + 1] - sums_s[0][A[i]]) + (sums_s[1][B[i] + 1] - sums_s[1][A[i]]) * 2;
        ll b = (sums_t[0][D[i] + 1] - sums_t[0][C[i]]) + (sums_t[1][D[i] + 1] - sums_t[1][C[i]]) * 2;
        if(abs(a - b) % 3 == 0){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    
    

    return 0;
}


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(is, 1<<h) rep(js, 1<<w){
        int cnt = 0;
        rep(i ,h) rep(j, w){
            if (is>>i & 1) continue;
            if (js>>j & 1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    } 
    cout << ans << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if(i == s.size()-1)
    {
      if(s[i] == 's')
      {
        cout <<s + "es";
      }
      else
      {
        cout <<s + 's';
      }
    }
  }
	return 0;
}


Measured memory_bytes: 3528
#include <stdio.h>
#include <stdlib.h>

int
comp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int
main()
{
	int x;
	int num[3];
	int i;

	scanf("%d", &x);
	
	for(i=0; i<x; i++){
		scanf("%d %d %d", &num[0], &num[1], &num[2]);

		qsort(num, 3 ,sizeof(int), comp);

		if(num[0]*num[0] + num[1]*num[1] == num[2]*num[2])
			printf("YES\n");
		else
			printf("NO\n");
	}

	return(0);
}

Measured memory_bytes: 584
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {int pr,left,right} node;
node T[MAX];
int n;

//先行準巡回//
void preP(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preP(T[u].left);
  preP(T[u].right);
}

//中間順巡回//
void inP(int u){
  if(u == NIL) return;
  inP(T[u].left);
  printf(" %d",u);
  inP(T[u].right);
}

//後行順巡回//
void posP(int u){
  if(u == NIL) return;
  posP(T[u].left);
  posP(T[u].right);
  printf(" %d",u);
}

int main(){
  int i,id,left,right,root;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].pr = NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    T[id].left = left; T[id].right = right;
    if(left != NIL) T[left].pr = id; if(right != NIL) T[right].pr = id;
  }
  for(i=0;i<n;i++) if(T[i].pr == NIL) root = i;

  printf("Preorder\n"); preP(root); printf("\n");
  printf("Inorder\n"); inP(root); printf("\n");
  printf("Postorder\n"); posP(root); printf("\n");

  return 0;
}



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

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

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

int main()
{
	int a, b;
	cin >> a >> b;
	long long l = a * b;
	long long ans = lcm(a,b);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int> > dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
	for (int i = 0; i < H; ++i) { //上から
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) { //bitshift
				// Check if two horizontal lines are connecting
				// 2 つの横線がつながっていないか調べる
                // ２進数で横棒を表現　
                // ex W = 3, k = 0, 1, 2, 3 ーー＞ 00 01 10 11 --> | | |,  | |-|,  |-| |,  |-|-|false
                // 
				bool ok = true;
				for (int l = 0; l < W - 2; ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						// The case which goes left
						// 左方向に横線をたどるケース
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						// The case which goes right
						// 右方向に横線をたどるケース
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						// The case which goes straight
						// 横線をたどらないケース
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) {
		cout << a - 1 << ' ' << b << endl;
	}
	else {
		cout << a << ' ' << b - 1 << endl;
	}
	return 0;
}

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

using namespace std;

#define MAX 10000
#define INFTY (1 << 29)

class DisjointSet{
	public:
		vector<int> rank, p;

		DisjointSet(){}
		DisjointSet(int size){
			rank.resize(size,0);
			p.resize(size,0);
			for(int i=0;i < size;i++) makeSet(i);
		}

		void makeSet(int x){
			p[x] = x;
			rank[x] = 0;
		}

		bool same(int x, int y){
			return findSet(x) == findSet(y);
		}
		void unite(int x, int y){
			link(findSet(x), findSet(y));
		}

		void link(int x, int y){
			if(rank[x] > rank[y]){
				p[y] = x;
			}else{
				p[x] = y;
				if(rank[x] == rank[y]){
					rank[y]++;
				}
			}
		}

		int findSet(int x){
			if(x != p[x]){
				p[x] = findSet(p[x]);
			}
			return p[x];
		}
};

class Edge{
public:
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0):
	source(source), target(target), cost(cost){}
	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges){
	int totalCost = 0;
	sort(edges.begin(), edges.end());

	DisjointSet dset = DisjointSet(N + 1);

	for(int i = 0; i < N; i++) dset.makeSet(i);

	int source, target;
	for(int i = 0; i < edges.size(); i++){
		Edge e = edges[i];
		if(!dset.same(e.source, e.target)){

			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}


int main(){
	int N, M, cost;
	int source, target;

	cin >> N >> M;

	vector<Edge> edges;
	for(int i = 0; i < M; i++){
		cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	}

	cout << kruskal(N, edges) << endl;

	return 0;
}

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

#define int long long
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 rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n,k; cin >> n >> k;
    int res=0;
    while(n>0){
        n/=k;
        res++;
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   bool is_ok = true;
   for(int i = 0; i < N; i++){
      if(A[i] % 2 != 0){
         is_ok = false;
         break;
      }
   }

   int ans = 0;
   if(is_ok){
      while(is_ok){
         // change
         for(int i = 0; i < N; i++){
            A[i] /= 2;
         }
         ans++;

         // check
         for(int i = 0; i < N; i++){
            if(A[i] % 2 != 0){
               is_ok = false;
               break;
            }
         }
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    string S;
    cin >> S;

    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }
    
    return 0;
}

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

int main()
{
    int n = 0;
    std::cin >> n;

    int sum = 0;
    int ncopy = n;

    for( int i = 0; i < 8; ++i)
    {
        sum += ncopy % 10;
        ncopy /= 10;
    }

    bool debug = false;

    if(debug)
    {
        std::cout << "sum:" << sum << std::endl;
        std::cout << "n\%s:" << n%sum << std::endl;
    }

    if(n%sum==0)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }


    return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
const int inf = 1e9;
 
int main(){
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > adj(n);
    for(int i=0; i<n; i++){
    	int c;
        cin >> c;
        if(c == 0){
        	for(int j=1; j<=6 && i+j<n; j++){
        		adj[i].push_back(make_pair(i+j, 1));
        	} 
        }else{
        	adj[i].push_back(make_pair(i+c, 0));
        }
    }
    
    priority_queue<pair<int, int> > wait;
    wait.push(make_pair(0,0));
    vector<int> mincost(n, inf);
    while(!wait.empty()){
        int pos = wait.top().second;
        int cost = -wait.top().first;
        wait.pop();
        if(cost > mincost[pos]) continue;
        if(pos == n-1){
            cout << cost << endl;
            break;
        }
        for(int i=0; i<(int)adj[pos].size(); i++){
        	int npos = adj[pos][i].first;
        	int ncost = adj[pos][i].second;
            if(cost +ncost < mincost[npos]){
            	wait.push(make_pair(-(cost+ncost), npos));
            	mincost[npos] = cost+ncost;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  
  vector<int> num(m);
  
  rep(i,n) {
    int k;
    cin>>k;
    
    rep(i,k) {
      int a;
      cin>>a;
      
      num[a-1]+=1;
    }
  }

  int ans = 0;
  rep(i,m) {
    if(num[i]==n) {
      ++ans;
    }
  }
  
  cout<<ans;
    
  return 0;
}

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

using namespace std;

#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   int right = 0,left = 0;
   for(int i=0;i<s.size();i++){
      if(s[i] == 'A'){
         right = i;
         break;
      }
   }
   for(int i=0;i<s.size();i++){
      if(s[s.size()-i-1] == 'Z'){
         left = s.size()-i-1;
         break;
      }
   }
   cout << left+1 - right << endl;
   return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int W = sc.nextInt();
    long[] v = new long[n+1];
    int[] w = new int[n+1];
    long[][] dp = new long[n+1][W+1];
    for(int i=0;i<n;i++){
      w[i]=sc.nextInt();
      v[i]=sc.nextLong();
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<=W;j++){
        if(j<w[i])dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=Math.max(dp[i][j],dp[i][j-w[i]]+v[i]);
      }
    }
    System.out.println(dp[n][W]);
  }
}

Measured memory_bytes: 127444
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	long long int N, A, B, tmp, r, ans;

	cin >> N >> A >> B;

	tmp = N / (A + B);
	r = N % (A + B);
	
	if (A <= r) { ans = (tmp + 1) * A; }
	else { ans = tmp * A + r; }

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n; cin>>n;
 ll x=0,y=0;
 int a[n];
 REP(i,n){
     cin>>a[i];
     y+=a[i];
 }
 ll min_sa=2*1000000000+1;
 REP(i,n-1){
     x+=a[i];
     y-=a[i];
   //cout<<abs(x-y)<<endl;
     if(abs(x-y)<=min_sa)min_sa=abs(x-y);
 }
 cout<<min_sa<<endl;
 
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>

using namespace std;

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

  int d, n;
  cin >> d >> n;
  const int s = d == 0 ? 1 : pow(100, d);

  if (n == 100)
    cout << s * n + s << endl;
  else
    cout << s * n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll L[200007],R[200007];

int main(){
  ll N,K,C;
  string S;
  cin >> N >> K >> C;
  cin >> S;
  ll cnt=0,dif=0;
  rep(i,N){
    if(S[i]=='o'){
      if(cnt==0 || dif>=C){
        cnt++;
        dif=-1;
      }
    }
    dif++;
    L[i+1]=cnt;
  }
  cnt=0,dif=0;
  rrep(i,N){
    if(S[i]=='o'){
      if(cnt==0 || dif>=C){
        cnt++;
        dif=-1;
      }
    }
    dif++;
    R[i+1]=cnt;
  }
  R[0]=cnt;
  // rep(i,N+1){
  //   cout << L[i] ;
  // }
  // cout << endl;
  // rep(i,N+1){
  //   cout << R[i] ;
  // }
  // cout << endl;
  Rep(i,1,N+1){
    if(L[i]>L[i-1]&&(R[i]>R[i+1] && L[i]+R[i]-1==K)){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 6892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class Main {

    /** ???????????????????????? */
    public static int CIRCLE_INDEX = 0;
    /** ??????????????????????? */
    public static int CROSS_INDEX = 1;

    /** ??? */
    public static char CIRCLE = 'o';
    /** ?? */
    public static char CROSS = 'x';
    /** ???????????? */
    public static char DRAW = 'd';

    /** ?????????????????? */
    private static final Pattern[] winPattern = { Pattern.compile(".*1.*4.*7.*"), Pattern.compile(".*2.*5.*8.*"),
            Pattern.compile(".*3.*6.*9.*"), Pattern.compile(".*1.*2.*3.*"), Pattern.compile(".*4.*5.*6.*"),
            Pattern.compile(".*7.*8.*9.*"), Pattern.compile(".*1.*5.*9.*"), Pattern.compile(".*3.*5.*7.*") };

    public static void main(String[] args) throws IOException {
        for (String[] result : createResults()) {
            System.out.println(judge(result));
        }
    }

    /**
     * ?????? ????????????????????????????????????
     * 
     * @return ?????????????????????
     * @throws IOException
     */
    public static List<String[]> createResults() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
        List<String[]> results = new ArrayList<>();
        while ((line = reader.readLine()) != null) {
            String[] result = toPatternStrings(line);
            results.add(result);
        }
        return results;
    }

    /**
     * ?????????????????????regex???????????????????????????????????????
     * 
     * @return ?????????????????????????????????
     */
    public static String[] toPatternStrings(String input) {
        StringBuilder o = new StringBuilder("");
        StringBuilder x = new StringBuilder("");
        String[] result = new String[2];
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == CIRCLE) {
                o.append(i + 1);
            } else if (input.charAt(i) == CROSS) {
                x.append(i + 1);
            }
        }

        result[CIRCLE_INDEX] = o.toString();
        result[CROSS_INDEX] = x.toString();

        return result;
    }

    /**
     * ???????????????????????????????????´????????????????????????o???x??????????????????????????????????????´??????d????????????
     * 
     * @param result
     * @return ?????????
     */
    public static char judge(String[] result) {

        // Check o
        for (Pattern p : winPattern) {
            if (p.matcher(result[CIRCLE_INDEX]).matches()) {
                return CIRCLE;
            }
        }
        // Check x
        for (Pattern p : winPattern) {
            if (p.matcher(result[CROSS_INDEX]).matches()) {
                return CROSS;
            }
        }
        return DRAW;
    }

}

Measured memory_bytes: 24380
#include<stdio.h>  
#include<string.h>  
#include<queue>  
using namespace std;  
const int maxn=1005;  
int n,m,k,dx[]={-1,1,0,0},dy[]={0,0,1,-1},vis[maxn][maxn];  
char map[maxn][maxn];  
struct maze  
{  
    int x,y,time;  
};  
maze bfs(int bx,int by,char ch)  
{  
    memset(vis,0,sizeof(vis));  
    queue<maze> q;  
    maze st={bx,by,0};  
    q.push(st);vis[bx][by]=1;  
    while(!q.empty())  
    {  
        st=q.front();q.pop();  
        if(map[st.x][st.y]==ch)  
        {  
            return st;  
        }  
        for(int i=0;i<4;++i)  
        {  
            int tx=st.x+dx[i],ty=st.y+dy[i];  
            if(tx<0||tx>=n||ty<0||ty>=m||map[tx][ty]=='X') 
            {  
                continue;  
            }  
            maze tp={tx,ty,st.time+1};  
            if(!vis[tx][ty])  
            {  
                vis[tx][ty]=1;  
                q.push(tp);  
            }  
        }  
    }  
}  
int main()  
{  
    while(~scanf("%d%d%d",&n,&m,&k))  
    {  
        int bx,by;  
        for(int i=0;i<n;++i)  
        {  
            scanf("%s",map[i]);  
            for(int j=0;j<m;++j)  
            {  
                if(map[i][j]=='S')  
                {  
                    bx=i;by=j;  
                    map[i][j]='0';  
                }  
            }  
        }  
        int ans=0;  
        for(int i=0;i<k;i++)  
        {  
            maze tp=bfs(bx,by,map[bx][by]+1);  
            ans+=tp.time;  
            bx=tp.x;by=tp.y;  
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}


Measured memory_bytes: 7720
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] *= - 1

heapq.heapify(A)

for i in range(M):
    big = (heapq.heappop(A) * -1) // 2
    heapq.heappush(A, big * -1)

print(-sum(A))


Measured memory_bytes: 72300
PROGRAM ATCODER

implicit none
integer :: a(3), c5, c7,i

read(*,*) (a(i), i=1,3)   !ここが入力欄

! ここに計算式
c5 = 0 ; c7 = 0
do i = 1, 3
if (a(i) == 5)then
	c5 = c5 + 1
else if (a(i) == 7)then
	c7 = c7 + 1
end if
end do

! ここに出力結果
if (c5 == 2 .and. c7 == 1) then
	write(*,'(a)') 'YES'
else
	write(*,'(a)') 'NO'
end if

END PROGRAM ATCODER

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int N;
	cin >> N;
	int A[100];
	rep(i, N) cin >> A[i];

	int saishou = 1e9;
	for (int i = -100; i <= 100; i++) {
		int kari = 0;
		rep(ii, N) {
			kari += (A[ii] - i) * (A[ii] - i);
		}
		saishou = min(saishou, kari);
	}
	co(saishou);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '?') printf("D");
		else cout << s[i];
	}
	return 0;
}



Measured memory_bytes: 3756
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"\n"
"input();s=input()\n"
"a,*b=map(s.count,set(s));a+=1\n"
"for t in b:a=-~t*a%(10**9+7)\n"
"print(a-1)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 4160
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {

    int a,b;
    cin>>a>>b;

    string ans;


    if(a%2!=0&&b%2!=0)ans="Odd";
    else ans="Even";

    cout<<ans<<endl;




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int h, w, k;
    cin >> h >> w >> k;

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;

    int stride = w + 1;
    int n = (h + 2) * stride;

    auto f = [&](int i, int j) {
        return stride * (i + 1) + (j + 1);
    };

    vector<char> c(n, -1);
    string s;
    for (int i = 0; i < h; i++) {
        cin >> s;
        for (int j = 0; j < w; j++) {
            c[f(i, j)] = s[j] != '.';
        }
    }

    vector<int> d(n, -1);
    vector<int> q(h * w);

    int j0 = 0, j1 = 0;
    d[q[j1++] = f(x1, y1)] = 0;

    while (j0 < j1) {
        int i = q[j0++];
        int d1 = d[i] + 1;

        for (int l : { -1, 1, -stride, stride }) {
            int i1 = i;
            for (int _ = 0; _ < k; _++) {
                i1 += l;
                if (c[i1]) break;
                if (d[i1] >= 0) {
                    if (d[i1] < d1) break;
                    continue;
                }
                d[i1] = d1;
                q[j1++] = i1;
            }
        }
    }

    cout << d[f(x2, y2)] << endl;

    return 0;
}

Measured memory_bytes: 22764
n, x = map(int, input().split())
a = [ int(x) for x in input().split() ]

ans = 0

for i in range(n-1):
    # greedy
    if a[i] + a[i+1] > x:
        cost = ((a[i] + a[i+1]) - x)
        if a[i+1] >= cost:
            a[i+1] -= cost
        else:
            a[i+1] = 0
        ans += cost

print(ans)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


const ll mo=1000000007;
 
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	ini(n);
	ini(n1);
	vi morty;
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
	}
	sort(all(morty));
	int tmp = 0;
	FOR(i,n1-1,n){
		tmp+=(morty[i]*comb(i,n1-1))%mo;
	}
	FOR(i,0,n-n1+1){
		tmp-=(morty[i]*comb(n-i-1,n1-1))%mo;
	}
  tmp%=mo;
	out(tmp);













	return 0;
}


Measured memory_bytes: 10484
a, b, c = map(int, input().split())

if a<=b and b<=c:
    print(a,b,c)
elif a<=c and c<=b:
    print(a,c,b)
elif b<=a and a<=c:
    print(b,a,c)
elif c<=a and a<=b:
    print(c,a,b)
elif b<=c and c<=a:
    print(b,c,a)
elif c<=b and b<=a:
    print(c,b,a)


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int data[N];
  for(int i=0;i<N;i++){
    cin>>data[i];
  }
  int cnt = 0;
  int flag = 0;
  while (true)
  {
    for (int i = 0; i < N; i++)
    {
      if (data[i] % 2 != 0)
      {
        flag = 1;
        break;
      }
      else
      {
        data[i] = data[i] / 2;
        if (i == N - 1)
        {
          cnt++;
        }
      }
      //cout << data[i] << " ";
    }
    cout << endl;
    if (flag == 1)
      break;
  }
  cout << cnt<< endl;
  return 0;
}

Measured memory_bytes: 256
r,g,b,n = map(int,input().split())
a = [0 for i in range(n+1)]
a[0] = 1
for j in range(n+1-r):
    a[j+r]=a[j]
for j in range(n+1-b):
    a[j+b]+=a[j]
for j in range(n+1-g):
    a[j+g]+=a[j]
    #print(a)
print(a[n])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;              
	long long ans=0;
	cin>>s;
	int k=0;
    for(long long i=0;i<s.size();i++)
    {
    	if(s[i]=='A')
    	{
    		k++;
    		continue;
    	}
    	if(s[i]=='B' && s[i+1]=='C')
    		i++,ans+=k;
    	else
    	{
    		k=0;
			continue;  
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int len = s.size();
    int pos = 0;
    for (int i = len - 1; i > 0; --i) {
        if (s[i] != '9') {
            pos = i;
            break;
        }
    }
    if (pos == 0) {
        cout << 9 * (len - 1) + s[0] - '0' << endl;
    } else {
        cout << 9 * (len - 1) + s[0] - '0' - 1 << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var input   = Console.ReadLine().Split(' ');
			int charNum = int.Parse(input[0]);
			int qNum    = int.Parse(input[1]);

			var str = Console.ReadLine().ToCharArray();
			char[] s = new char[str.Length];
			for ( int i = 0; i < charNum - 1; i++ ) {
				if ( str[i] == 'A' && str[i + 1] == 'C' ) s[i] = 'a';
			}

			int[] t = new int[charNum];
			t[0] = 0;
			for ( int i = 0; i < charNum - 1; i++ ) {
				// ここで累積していく
				if ( s[i] == 'a' ) {
					t[i + 1] = t[i] + 1;
				}
				else {
					t[i + 1] = t[i];
				}
			}

			//List<string> questions = new List<string>();

			for ( int i = 0; i < qNum; i++ ) {
				var question = Console.ReadLine();

				string[] q = question.Split(' ');

				int start = int.Parse(q[0]) - 1;
				int end   = int.Parse(q[1]) - 1;

				Console.WriteLine(t[end] - t[start]);

			}

			// foreach ( var question in questions ) {
			// 	string[] q = question.Split(' ');
			//
			// 	int start = int.Parse(q[0]) - 1;
			// 	int end   = int.Parse(q[1]) - 1;
			//
			// 	Console.WriteLine(t[end] - t[start]);

				// var count      = 0;
				// var tmpCount   = 0;
				// var countStart = false;
				//
				// for ( int i = start; i <= end; i++ ) {
				// 	if ( str[i] == 'A' && str[i + 1] == 'C' && (i + 1) <= end) {
				// 		count++;
				// 		// tmpCount++;
				// 		// if ( count < tmpCount ) count = tmpCount;
				// 	}
				// 	else {
				// 		// tmpCount = 0;
				// 	}
				// }
				// Console.WriteLine(count);
			// }
		}
	}
}

Measured memory_bytes: 17800
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int N,mcount;
  long v1, min1;
  cin >> N;
  cin >> min1;
  if (min1<0){
    min1 = min1*(-1);
    mcount++;
  }
  long ans = min1;
  
  for ( int i = 1; i< N; i++ ){
  cin >> v1;
  if(v1 < 0){
    v1 = v1*(-1);
    mcount++;
  }
  ans = ans + v1;
  min1 = min(min1,v1); 
  }
  
  if (mcount%2 != 0){
    min1 = 2 * min1;
    ans = ans - min1;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    puts(s == t.substr(0, t.size() - 1) ? "Yes" : "No");
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int m,n;
    while (cin>>m>>n)
    {
        char a[m][n];
        int k=0;
        for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
            {
                cin>>a[i][j];
            }
        }
        for (int i=1;i<m-1;i++)
        {
            for (int j=1;j<n-1;j++)
            {
                if (a[i][j]=='#')
                {
                    if(a[i-1][j]!='#'&&a[i+1][j]!='#'&&a[i][j-1]!='#'&&a[i][j+1]!='#')
                    {
                        k=2;
                    }
                }
            }
        }
        if (k==2)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    ($t:ty) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty ;) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ; $n:expr) => {
        (0..$n).map(|_|
            input!($t)
        ).collect::<Vec<_>>()
    };
}

fn main(){
    let c = input!(String);
    let mut ans = "consonant";
    let vowels = vec!["a","i","u","e","o"];
    if vowels.contains(&c.as_str()){
        ans = "vowel";
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 502;

int n, ans = 0;
int dist[N][N];
int alive[N][N], p[N * N];
bool vis[N][N];
int dx[4] = {-1, +1, 0, 0};
int dy[4] = {0, 0, +1, -1};
pair<int, int> store[N * N];

void work(int x, int y, int d)
{
	queue<pair<pair<int, int>, int> > q;
	q.push({{x, y}, d});
	while(!q.empty())
	{
		auto p = q.front();
		q.pop();
		int x = p.first.first;
		int y = p.first.second;
		int d = p.second;
		for(int k = 0; k < 4; k++)
		{
			int nx = x + dx[k];
			int ny = y + dy[k];
			if(nx < 1 || nx > n || ny < 1 || ny > n)
				continue;
			if(dist[nx][ny] > d + alive[x][y])
			{
				dist[nx][ny] = d + alive[x][y];
				q.push({{nx, ny}, d + alive[x][y]});
			}
		}
	}
}

int32_t main()
{
	IOS;
	cin >> n;
	int cur = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			++cur;
			alive[i][j] = 1;
			store[cur] = {i, j};
			dist[i][j] = min({i - 1, n - i, j - 1, n - j});
		}
	}
	for(int i = 1; i <= n * n; i++)
	{
		cin >> p[i];
		int x = store[p[i]].first, y = store[p[i]].second;
		int val = dist[x][y];
		ans += val;
		alive[x][y] = 0;
		work(x, y, val);
	}
	cout << ans;
	return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5+5;

int main()
{
   string h,ans;
   cin>>h;
   for(int i=0;i<h.length();i++)
    if(i%2==0)
    ans.push_back(h[i]);
   cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512
<?php

fscanf(STDIN, "%d%d%d", $a, $b, $c);

if ($a === $b && $b === $c) {
    echo 'No';
} elseif ($a !== $b && $b !== $c && $c !== $a) {
    echo 'No';
} else {
    echo 'Yes';
}


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

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<string> svec;

int n; ll g, s;
void solve() {
	g--; s--;
	string ans;
	while (n > 0) {
		ll k = (ll)1 << (n-1);
		if (g % 4 == 0 || g % 4 == 3) {
			if (s < k) {
				ans.push_back('R');
				
			}
			else {
				ans.push_back('L');
				s -= k;
			}
			ll d = g / 4; d *= 2;
			if (g % 4)d++;
			g = d; n--;
		}
		else {
			if (s < k) {
				ans.push_back('L');
				s = k - 1 - s;
			}
			else {
				ans.push_back('R');
				s -= k; s = k - 1 - s;
			}
			ll d = g / 4; d *= 2;
			if (g % 4 == 2)d++;
			g = d; n--;
		}
	}
	if (ans.back() == 'R')ans.back() = 'L';
	else ans.back() = 'R';
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(11);
	while (cin >> n>>g>>s, n) {
		solve();
	}
	//solve();
	//stop
	return 0;
}



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

int main(void){
    ll n,k;
    cin>>n>>k;
    ll res = 0;
    if(k==0) {
        cout<<n*n<<endl;
        return 0;
    }
    for (int b=k+1;b<=n;b++){
        res += (b-k)*(n/b) + max(n%b - k + 1,0LL);
    }
    cout<<res<<endl;
    return 0;
}


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

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

  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for(int i = 0; i < N; ++i) cin >> P.at(i);
  for(int i = 0; i < N; ++i) cin >> Q.at(i);
  vector<int> v(N);
  for(int i = 1; i <= N; ++i) v.at(i - 1) = i;

  int a, b, cnt = 0;
  do{
    cnt++;
    bool a_judge = true, b_judge = true;
    for(int i = 0; i < N; ++i){
      if(v.at(i) == P.at(i)){
        if(a_judge == true) {
          a_judge = true;
        }
      }
      else {
        a_judge = false;
      }
      if(v.at(i) == Q.at(i)){
        if(b_judge == true) {
          b_judge = true;
        }
      }
      else {
        b_judge = false;
      }
      if(i == N - 1 && a_judge == true){
        a = cnt;
        // cout << "a: " << i << endl;
      }
      if(i == N - 1 && b_judge == true){
        b = cnt;
        // cout << "b: " << i << endl;
      }
    }
  }while(next_permutation(v.begin(),v.end()));

  cout << abs(a - b) << endl;
  return 0;
}


Measured memory_bytes: 256
n1 = int(raw_input())
nums1 = map(int, raw_input().split(" "))
n2 = int(raw_input())
nums2 = map(int, raw_input().split(" "))
nums1.append(-1)
count = 0

for key in nums2:
    nums1[len(nums1)-1] = key
    idx = 0

    while nums1[idx] != key:
        idx += 1

    if idx != len(nums1)-1:
        count += 1

print(count)

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

ll n,ans;
string s;

int main(){
    cin>>n>>s;
    rep(i,n){
        ll num=0;
        FOR(j,i,n){
            if(s[j]==s[j-i])num++;
            else{
                ans=max(ans,min(num,i));
                num=0;
            }
        }
        ans=max(ans,min(num,i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
n,y = map(int,input().split())
for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i+5000*j+1000*(n-i-j) == y:
      print("{} {} {}".format(i,j,n-i-j))
      sys.exit()
print("-1 -1 -1")
      

Measured memory_bytes: 40684
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <iterator>
#include <set>

using namespace std;

int N;
stack<int> s;

int gcd(int a, int b) {
    if (a == 0) return b;
    if (b == 0) return a;

    if (a <= b) return gcd(a, b % a);
    else return gcd(a % b, b);
}

int sol() {
    while (s.size() > 1) {
        int a = s.top(); s.pop();
        int b = s.top(); s.pop();
        s.push(gcd(a, b));
    }

    return s.top();
}


int main()
{
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int tmp; 
        cin >> tmp;
        s.push(tmp);
    }
    cout << sol() << endl;
}

Measured memory_bytes: 640
#include <atcoder/dsu>
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    //input
    ll n,q;
    cin >> n >> q;
    dsu d(n);
    rep(i,q){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            d.merge(u,v);
        }
        else{
            if(d.same(u,v))cout<<1<<endl;
            else cout << 0 << endl;
        }
    }

    
    return 0;
}


Measured memory_bytes: 4020
while True:
    n = int(input())
    if n == 0:
        break

    data = list()
    for i in range(n):
        li = list(map(int, input().split()))
        data.append(set(li[1:]))
    
    flow = list(map(int, input().split()))
    flow = set(flow[1:])
    ans = list()
    for idx, li in enumerate(data):
        if flow.issubset(li):
            ans.append(idx + 1)

    if len(ans) == 1:
        print(ans[0])
    else:
        print(-1)


Measured memory_bytes: 6324
from collections import deque

H, W = map(int, input().split())
maze = [input() for _ in range(H)]

v = {(1,0), (-1,0), (0,1), (0,-1)}
q = deque()
ans = 0

for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
                    
            #bfs
            dist = [[-1 for _ in range(W)] for _ in range(H)]
            dist[i][j] = 0
            q.append([j, i])
            while len(q) > 0:
                now = q.popleft()
                x, y = now[0], now[1]
                d = dist[y][x]
                for dx, dy in v:
                    nx, ny = x+dx, y+dy
                    if 0<=nx<W and 0<=ny<H and dist[ny][nx]==-1 and maze[ny][nx]=='.':
                        dist[ny][nx] = d+1
                        q.append([nx, ny])
            
            ans = max(ans, d)
print(ans)

Measured memory_bytes: 9408
#include<iostream>
#define mod 1000000007
using namespace std;

long long int power(long long int a,long long int n)
{

    long long int res = 1;

    while(n>0)
    {
        if(n&1)
            res = (res*a)%mod;

        a = (a*a)%mod;
        n = n>>1;
    }

    return (res%mod);
}
int main()
{
	long long int n,ans;
	cin>>n;

	ans = power(10,n)-power(9,n)-power(9,n)+power(8,n);
	ans%=mod;
	ans = (ans+mod)%mod;

	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

const int max_int = 10;
bool G[max_int][max_int];

int visit(int v, int n, vector<bool> &visited){
  bool all_visited = true;
  for(int i = 0; i < visited.size(); i++){
    if(visited[i] == false) all_visited = false;
  }
  
  int ret = 0;
  if(all_visited) return 1;
  else{
    for(int j = 0; j < n ;j++){
      if(G[v][j] == false) continue;
      if(visited[j]) continue;
      visited[j] = true;
      ret += visit(j, n, visited); 
      visited[j] = false;
    }
    return ret;
  }
  
}
 
int main(){
  int N, M;
  cin >> N >> M;
    
  for(int i = 0; i < M; i++){
    int a = 0, b = 0;
    cin >> a >> b;
    a--, b--;
    G[a][b] = G[b][a] = true;
  }//グラフ読み込み
  
  vector<bool> visited(N,false);
  //頂点1からスタート
  visited[0] = true;
  int ans = visit(0, N, visited);
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string S;
  cin >> S;
  bool a[26];
  rep(i, 26)
  {
    a[i] = false;
  }
  rep(i, S.size())
  {
    a[S.at(i) - 'a'] = true;
  }
  rep(i, 26)
  {
    if (!a[i])
    {
      char tmp = i + 'a';
      cout << tmp << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
H, W = list(map(int, input().split()))
A = [input() for _ in range(H)]
b = "#"
w = "."

wc = 0
L = []
wb = [[0] * W for _ in range(H)]
for i in range(H):
  for j in range(W):
    if A[i][j] == w:
      wc += 1
    else:
      L.append([i, j])
      wb[i][j] = 1

Ans = 0
while wc > 0:
  L2 = []
  Ans += 1
  for ki, kj in L:
    if ki - 1 >= 0:
      if wb[ki - 1][kj] == 0:
        wb[ki - 1][kj] = 1
        wc -= 1
        L2.append([ki - 1 , kj])
    if ki + 1 < H:
      if wb[ki + 1][kj] == 0:
        wb[ki + 1][kj] = 1
        wc -= 1
        L2.append([ki + 1 , kj])
    if kj - 1 >= 0:
      if wb[ki][kj - 1] == 0:
        wb[ki][kj - 1] = 1
        wc -= 1
        L2.append([ki, kj - 1])
    if kj + 1 < W:
      if wb[ki][kj + 1] == 0:
        wb[ki][kj + 1] = 1
        wc -= 1
        L2.append([ki, kj + 1])
  L = L2
print(Ans)

Measured memory_bytes: 142604