akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,d,x,sum=0,c;cin>>n;cin>>d>>x;sum=n;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	REP(i,0,n-1){
		c=1;
		while(c*a[i]+1<=d){
			sum++;
			c++;
		}
	}
	sum+=x;
	cout<<sum;
	
	return 0;

//   TimeTaken();
}



Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>

#define rep(i, j) for(int i = 0; i < j; i++)
#define For(i, a, j) for(int i = a; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

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

	int N, Pair = 0; cin >> N;
	vector<int> dat(N + 1, 0);
	For(i, 1, N + 1)
	{
		cin >> dat[i];
	}
	For(i, 1, N + 1)
	{
		if (i == dat[dat[i]] && dat[i] != i)
		{
			Pair += 1;
			dat[i] = 0;
			dat[dat[i]] = 0;
		}
	}

	cout << Pair << "\n";

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int x,y,p[N];
struct node{int l,r;ll s,mn[2],tag;}a[N];
inline void down(int o)
{	a[o].s+=a[o].tag; a[o].mn[0]+=a[o].tag; a[o].mn[1]+=a[o].tag;
	if(a[o].l!=a[o].r) a[o+o].tag+=a[o].tag,a[o+o+1].tag+=a[o].tag; a[o].tag=0;
}
inline void update(int o)
{	if(a[o+o].tag) down(o+o); if(a[o+o+1].tag) down(o+o+1);
	a[o].s=min(a[o+o].s,a[o+o+1].s);
	for(rint i=0;i<=1;i++) a[o].mn[i]=min(a[o+o].mn[i],a[o+o+1].mn[i]);
}
void build(int l,int r,int o)
{	a[o].l=l; a[o].r=r;
	if(l==r)
	{	a[o].s=1e18; if(l==x) a[o].s=abs(y-p[1]); if(l==y) a[o].s=abs(x-p[1]);
		a[o].mn[0]=a[o].s-l; a[o].mn[1]=a[o].s+l; return;
	}
	int mid=(l+r)>>1;
	build(l,mid,o+o); build(mid+1,r,o+o+1); update(o);
}
void mdf(int pos,ll y,int o)
{	if(a[o].tag) down(o);
	if(a[o].l==a[o].r)
	{	a[o].mn[0]=min(a[o].mn[0],y-a[o].l),a[o].mn[1]=min(a[o].mn[1],y+a[o].l);
		a[o].s=min(a[o].s,y); return;
	}
	int mid=(a[o].l+a[o].r)>>1;
	if(pos<=mid) mdf(pos,y,o+o); else mdf(pos,y,o+o+1); update(o);
}
ll query(int l,int r,int g,int o)
{//	cerr<<l<<" "<<r<<" "<<a[o].l<<" "<<a[o].r<<endl;
	if(a[o].tag) down(o);
	if(a[o].l==l&&a[o].r==r) return a[o].mn[g];
	int mid=(a[o].l+a[o].r)>>1;
	if(r<=mid) return query(l,r,g,o+o);
	else if(l>mid) return query(l,r,g,o+o+1);
	else return min(query(l,mid,g,o+o),query(mid+1,r,g,o+o+1));
}
int main()
{	int n,q; cin>>n>>q>>x>>y;
	for(rint i=1;i<=q;i++) scanf("%d",&p[i]);
	build(1,n,1);
	for(rint i=2;i<=q;i++)
	{	ll f=min(p[i]+query(1,p[i],0,1),query(p[i],n,1,1)-p[i]);
		a[1].tag+=abs(p[i]-p[i-1]); mdf(p[i-1],f,1);// debug(a[1].s);debug(f);
	//	if(i==4) exit(0);
	}
	cout<<a[1].s;
	return 0;
}


Measured memory_bytes: 24832
import fractions

N,M = map(int,input().split())
S = list(input())
T = list(input())

g = fractions.gcd(N,M)

L = g * (N // g) * (M // g)

if S[0::N//g] == T[0::M//g]:
  print(L)
else:
  print(-1)





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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    int ans = 0;
    for (int i = 1; i < n - 1; i++){
        if (a[i] < a[i - 1] && a[i] > a[i + 1])
            ans += 1;
        else if (a[i] < a[i + 1] && a[i] > a[i - 1])
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int[] X = new int[3];

            for (int i = 0; i < 3; i++)
            {
                X[i] = int.Parse(s[i]);
            }

            Array.Sort(X);

            ans += X[1] - X[0];
            ans += X[2] - X[1];

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll min_x_occ = a / x - (a % x == 0);
  ll max_x_occ = b / x;
  ll ans = max_x_occ - min_x_occ;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<int> g[100005];
vector<int> res;

void dfs(int v, int d = 0, int p = -1) {
	res[v] = d;
	for (int c : g[v]) {
		if (c == p) continue;
		dfs(c, d + 1, v);
	}
}

vector<int> Distcalc(int v) {
	res = vector<int>(n);
	dfs(v);
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	auto distF = Distcalc(0);
	auto distS = Distcalc(n - 1);
	int f = 0, s = 0;
	rep(i, n) {
		if (distF[i] <= distS[i]) f++;
		else s++;
	}
	if (f > s) printf("%s\n", "Fennec");
	else printf("%s\n", "Snuke");
	return 0;
}


Measured memory_bytes: 11648
object Main extends App {
  import scala.math.abs
  
  val n = readInt
  val Array(t,a) = readLine split(' ') map{_.toInt}
  val h = readLine split(' ') map{_.toInt}
  val dif = h map {case x => abs(a - (t - x*0.006))}
  println(dif.indexOf(dif.min)+1)
}

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

int main()
{
	int m, f, r, gra;

	while (1) {
		cin >> m >> f >> r;

		gra = m + f;

		if (m == -1 || f == -1) {
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
			else {
				cout << "F" << endl;
			}
		}
		else {
			if (80 <= gra) {
				cout << "A" << endl;
			}
			else if (65 <= gra && gra < 80) {
				cout << "B" << endl;
			}
			else if (50 <= gra && gra < 65) {
				cout << "C" << endl;
			}
			else if (30 <= gra && gra < 50) {
				if (50 <= r) {
					cout << "C" << endl;
				}
				else {
					cout << "D" << endl;
				}
			}
			else if (0 <= gra && gra < 30) {
				cout << "F" << endl;
			}
		}
	}
    return 0;
}




Measured memory_bytes: 3100
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	char op;
	for(;;){
		cin>>a>>op>>b;
		if(op=='+'){
			cout<<a+b;
		}else if(op=='-'){
			cout<<a-b;
		}else if(op=='*'){
			cout<<a*b;
		}else if(op=='/'){
			cout<<a/b;
		}else if(op=='?')break;
		cout<<endl;
	}
	
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
void solve();int main() {FastIO;solve();return 0;}
// ====================================================================================
void solve()
{
	int a;
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3);
}

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

int top=0;
int stack[100];

void push(int);                                               
int pop(void);

int main()
{
  int i=0,a,b,kazu=0;
  char ori[10000];
  
  while(scanf("%s",ori)!=EOF){
     if(ori[0]=='+' || ori[0]=='-' || ori[0] =='*'){
       a=pop();
       b=pop();
	 if(ori[0]=='+'){
	   push(b+a);
	 }    
	 else if(ori[0]=='-'){
	   push(b-a);		  
	 }
    else if (ori[0] =='*'){
      push(b*a);     
    }
     }
    else{
      push(atoi(ori));                    
    }
      
  }
  printf("%d\n",pop());
  return 0;
}


void push(int x)
{
  stack[top]=x;
    top++;
    
}

int pop(void)
{
    top--;
    return stack[top];
    
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    LCIN(N);
    int k = -1;V<I> ans;
    for(LL a = 1;a <= 2*N;a++){
        if(a*(a-1) == 2*N){
            k = a;
        }
    }
    if(k == -1){
        COUT("No");
        rt 0;
    }
    LL ins = 1;
    for(LL a = 0;a < k;a++){
        I vec;
        for(int b = 0;b < ans.size();b++){
            vec.push_back(ans.at(b).at(a-1));
        }
        while((vec.size() < k-1)){
            vec.push_back(ins);
            ins++;
        }
        ans.push_back(vec);
    }
    COUT("Yes");
    COUT(ans.size());
    REP(a,ans.size()){
        cout<<ans.at(a).size()<<" ";
        REP(b,ans.at(a).size()){
            cout<<ans.at(a).at(b)<<" ";
        }
        ENDL;
    }
    rt 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    int sum = 0,tmp = n;
    while(tmp){
        sum += tmp % 10;
        tmp /= 10;
    }
    cout << (n%sum == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int ans[200006];
signed main()
{
	int n;
	cin>>n;
	int x=n;
	n--;
	while (n--){
		int y;
		cin>>y;
		ans[y]++;
	}
	for (int i=1;i<=x;i++){
		cout<<ans[i]<<endl;
	}
	re 0;
}

Measured memory_bytes: 5156
# B
def zeros(n): return [0 for i in range(n)]
W, H, N = [int(x) for x in input().split()]
white = [[0,0],[W,H]]
#x, y, a = zeros(N), zeros(N), zeros(N)
for i in range(N):
    #x[i], y[i], a[i] = [int(x) for x in input().split()]
    x, y, a = [int(x) for x in input().split()]
    #print(x,y,a)#
    if a==1: white[0][0] = max(white[0][0], x)
    elif a==2: white[1][0] = min(white[1][0], x)
    elif a==3: white[0][1] = max(white[0][1], y)
    elif a==4: white[1][1] = min(white[1][1], y)
    else: print('error')
    #print(white)#
    
print(max(white[1][0]-white[0][0], 0)*max(white[1][1]-white[0][1], 0))



Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a,b,i,j,m=0,c[100][100];
    cin>>a>>b;
    char s[100][100];
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cin>>s[i][j];
        }
    }
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            c[i][j]=0;
        }
    }
    for(i=0;i<a;i++){
        m=0;
        for(j=0;j<b;j++){
            if(s[i][j]!='.'){
                m=1;
                break;
            }
        }
        if(m==0){
            for(j=0;j<b;j++){
                c[i][j]=1;
            }
        }
    }
    for(i=0;i<b;i++){
        m=0;
        for(j=0;j<a;j++){
            if(s[j][i]!='.'){
                m=1;
                break;
            }
        }
        if(m==0){
            for(j=0;j<a;j++){
                c[j][i]=1;
            }
        }
    }
    m=0;
    for(i=0;i<a;i++){
        m=0;
        for(j=0;j<b;j++){
            if(c[i][j]!=1){
                m=1;
                cout<<s[i][j];
            }
        }
        if(m==1){
            cout<<endl;
        }
    }
}

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

int main(){
    long long n,d,x,y;
    cin>>n>>d;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3652
N,M = map(int,input().split())
light = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

cnt = 0
for i in range(2**N):
    b = [0]*N
    for j in range(N):
        if ((i >> j) & 1):
            b[j] = 1
    
    for k in range(M):
        num = 0
        for l in range(len(light[k])-1):
            num += b[light[k][l+1]-1] 
        if num%2 != p[k]:
            break
    else: cnt += 1
print(cnt)

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    vector<long long> list;
    long long num,no,adder,fin=0;
    cin >> num >> no >> adder;
    long long sum=adder;
    for (long long i=0; i<no; i++){
      long long a;
      cin >> a;
      list.push_back(a);}
    for (long long t=0; t<num; t++) {
      sum=adder;
      for (long long i=0; i<no; i++){
        long long a;
        cin >> a;
        sum+=a*list[i];}
      if (sum>0){fin++;}}
      cout << fin;}

Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  int ans = 0;
  string n;
  cin >> n;
  for(int i=0;i<n.size();i++){
    int tmp = n[i] - '0';
    ans = (ans + tmp) %9;
  }
  if(ans == 0) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}
vector<int> p;
signed main(){
  LOOP(i,1,1000006)if(Is_Prime(i))p.PB(i);
  int n;
  while(cin>>n,n){
    int ans=0;
    REP(i,n)ans+=p[i];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3728
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int modpow(int a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		int halfP = p / 2;
		int half = modpow(a, halfP);
		return half * half%mod;
	}
	else {
		return a * modpow(a, p-1) % mod;
	}
}

int calcComb(int a, int b) {
	if (b > a - b)return calcComb(a, a-b);
	int ansMul = 1;
	int ansDiv = 1;
	rep(i, b) {
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	int ans = ansMul * modpow(ansDiv, mod - 2)%mod;
	return ans;
}

signed main(void) {
	int n,m;
	cin >> n >> m;
	int Mnokori = m;
	int ans = 1;
	for (int i = 2; i*i <= Mnokori;i++) {
		if (Mnokori%i == 0) {
			int cnt = 0;
			while (Mnokori%i==0)
			{
				Mnokori /= i;
				cnt++;
			}
			ans *= calcComb(n + cnt - 1, n-1);
			ans %= mod;
		}
	}
	if (Mnokori != 1) {
		ans *= calcComb(n , n - 1);
		ans %= mod;
	}
	print(ans);
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

adif,bdif=0,0
for i in range(N):
    if a[i]<b[i]:
        adif+=(b[i]-a[i])//2
    elif a[i]>b[i]:
        bdif+=a[i]-b[i]
if bdif<=adif:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4596
using System;


public class A{
	
	public static void Main(){
	
		string str = Console.ReadLine();
		for(int i = 0; i < 3; i++){
			switch(str[i]){
				case '1':
					Console.Write(9);
					break;
				case '9':
					Console.Write(1);
					break;
				default:
					Console.Write(str[i]);
					break;
			}
		}
		Console.WriteLine();
		
	}
	
}

Measured memory_bytes: 11092
from collections import deque
S=input()
d=deque()
for i in S:
    d.append(i)
Q=int(input())
Flag=True
for i in range(Q):
    L=input().split()
    if L[0]=="1":
        Flag=not Flag
    else:
        if L[1]=="1" and Flag or L[1]=="2" and not Flag:
            d.appendleft(L[2])
        else:
            d.append(L[2])
ans=""
for i in d:
    ans+=i
if not Flag:
    ans=ans[::-1]
print(ans)
            


    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 12576
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		char s='#',p='.',n='\n';
		while(true){
			String in=br.readLine();
			if(in.equals("0 0")) break;
			String[] a=in.split(" ");
			int H=Integer.parseInt(a[0]);
	        int W=Integer.parseInt(a[1]);
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i%2==0){
						if(j%2==0){
							sb.append(s);
						}else{
							sb.append(p);
						}
					}else{
						if(j%2==0){
							sb.append(p);
						}else{
							sb.append(s);
						}
					}
				}
				sb.append(n);
			}
			sb.append(n);
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 20852
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
count =[0,0,0]

for p in P:
  if p <= A:
    count[0] += 1
  elif A < p and p <= B:
    count[1] += 1
  else:
    count[2] += 1

min = 100    
for i in count:
  if min > i:
    min = i
print(min)


Measured memory_bytes: 9140
//14
#include<iostream>

using namespace std;

int main(){
  int m,n,k;
  cin>>m>>n>>k;
  typedef int G[1001][1001];
  static G i,o,j;
  for(int y=0;y<m;y++){
    for(int x=0;x<n;x++){
      char c;
      cin>>c;
      i[y+1][x+1]=i[y][x+1]+i[y+1][x]-i[y][x]+(c=='I');
      o[y+1][x+1]=o[y][x+1]+o[y+1][x]-o[y][x]+(c=='O');
      j[y+1][x+1]=j[y][x+1]+j[y+1][x]-j[y][x]+(c=='J');
    }
  }
  while(k--){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int k=0;k<3;k++){
      int (*p[])[1001]={j,o,i};
      cout<<p[k][c][d]-p[k][a-1][d]-p[k][c][b-1]+p[k][a-1][b-1]<<((k==2)?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 12860
from operator import itemgetter
N = int(input())
A = []
for i in range(N):
  a = input().split()
  a = [a[0], int(a[1])]
  a.append(i+1)
  A.append(a)

A.sort(key=itemgetter(1), reverse = True)
A.sort(key=itemgetter(0))

for i in range(N):
  print(A[i][2])




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

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

const int MAX_FACT = 200000;
const int mod = 1000000000 + 7;
ll fact[MAX_FACT];

ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}

// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(a<b)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}


int B, W;
ll dp_b[200010]; // dp_b[i] -> iの要素の時点でbを使い切っている確率(wしか選べない確率)
ll dp_w[200010]; // dp_w[i] -> iの要素の時点でwを使い切っている確率(bしか選べない確率)

int main(){
    calcFact();
    cin >> B >> W;
    for(int i = 1; i < B + W; i++){
        if(i >= B){
            // comb(i - 1, B - 1) * 2^i
            (dp_b[i + 1] += comb(i - 1, B - 1) * pow_mod(div_mod(2), i)) %= mod;
            // cout << i<<","<<dp_b[i+1] << endl;
        }
        if(i >= W){
            (dp_w[i + 1] += comb(i - 1, W - 1) * pow_mod(div_mod(2), i)) %= mod;
        }
    }
    for(int i = 0; i < B + W; i++){
        (dp_b[i + 1] += dp_b[i]) %= mod;
        (dp_w[i + 1] += dp_w[i]) %= mod;
    }
    
    for(int i = 1; i < B + W; i++){
        cout << (dp_w[i] + (1 - (dp_w[i] + dp_b[i]) % mod + mod) * div_mod(2)) % mod << endl;
    }
    cout << dp_w[B+W] << endl;

    return 0;
}


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

int main(){

    string N;
    cin >> N;

    int S = 0;
    for( int i = 0; i < N.size(); i++ ) S += N[i] - '0';

    if( atoi(N.c_str())%S == 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a=0,b=0,c=0,d,e=0,f=0;
	
	scanf("%d%d%d",&a,&b,&c);
	for(d=a;d<=b;d++){
		e=0;
		e=c%d;	
	if(e==0){
		f++;
	}
	}
	printf("%d\n",f);
	
	return 0;
}


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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    bool ans = 0;
    for(int i = a;i <= b;i++){
        if(i%k == 0){
            ans = 1;
            break;
        }
    }

    if(ans){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main()
{
	int k, a, b;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	int i = 0;
	while(k * ++i <= b)
	{
		if (k * i >= a && k * i <= b) 
		{
			printf("OK\n");
			break;
		}
	}
	if (i * k > b) printf("NG");
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
ll a[5];

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s[0]=='M'){
			a[0]++;
		}
		else if(s[0]=='A'){
			a[1]++;
		}
		else if(s[0]=='R'){
			a[2]++;
		}
		else if(s[0]=='C'){
			a[3]++;
		}		
		else if(s[0]=='H'){
			a[4]++;
		}		
	}
	ll ans=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=a[i]*a[j]*a[k];
			}
		}
	}
	cout <<ans;
	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++)
#define ff first
#define ss second
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, q; cin>>n>>q;

    vector<iii> eventos;
    //.ff eje x .ss.ff tipo .ss.ff altura o persona
    //types -> 0 abrir, 1 persona, 2 cerrar
    rep(i,n){
        ll h, si, ti;
        cin>>si>>ti>>h;
        eventos.push_back(iii(2*si-1-2*h, ii(0, h)));
        eventos.push_back(iii(2*ti-1-2*h, ii(2, h)));
    }

    rep(i,q){
        ll h;
        cin>>h;
        eventos.push_back(iii(2*h,ii(1,i)));
    }

    sort(eventos.begin(),eventos.end(),[&](iii &a, iii &b){
        if(a.ff==b.ff) return a.ss.ff < b.ss.ff;
        return a.ff < b.ff;
    });

    ll ans[q];

    multiset<int> xd;
    for(auto& x: eventos){
        
        if(x.ss.ff==0){
            xd.insert(x.ss.ss);
        }
        if(x.ss.ff==1){
            if(xd.size()==0){
                ans[x.ss.ss]=-1;
            }
            else{
                ans[x.ss.ss] = *xd.begin();
            }
        }

        if(x.ss.ff==2){
            xd.erase(xd.find(x.ss.ss));
        }
    }

    rep(i,q) cout<<ans[i]<<endl;



    return 0;
}

Measured memory_bytes: 28096
#include<iostream>
using namespace std;
typedef struct
{
    char suit;
    int value;
}poker;
void bubbleSort(poker arr[],int n)
{
    bool flag = 1;
    for(int i = 0;flag;i++)
    {
        flag = 0;
        for(int j = n-1;j>=i+1;j--)
        {
            if(arr[j].value<arr[j-1].value)
            {
                swap(arr[j],arr[j-1]);
                flag = 1;
            }
        }
    }
}
void insertSort(poker arr[],int n)
{
    int j;
    poker v;
    for(int i = 1;i<n;i++)
    {
        v = arr[i];
        j = i-1;
        while(j >= 0 && arr[j].value > v.value)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
    }
}
void selectionSort(poker arr[],int n)
{
    for(int i = 0;i<n-1;i++)
    {
        int key = i;
        bool flag = 0;
        for(int j =i+1;j<n;j++)
            if(arr[j].value<arr[key].value)
            {
                key = j;
                flag = 1;
            }
        if(flag)
            swap(arr[i],arr[key]);
    }
}
bool ifstable(poker arr_stable[],poker arr_unknow[],int n)
{
    for(int i = 0;i<n;i++)
    {
        if(arr_stable[i].suit != arr_unknow[i].suit)
            return false;
    }
    return true;
}
void print(poker arr[],int n)
{
    for(int i = 0;i<n;i++)
    {
        if(i>0)
            cout<<" ";
        cout<<arr[i].suit<<arr[i].value;
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    poker *arrb = new poker[n];
    poker *arri = new poker[n];
    for(int i = 0;i<n;i++)
    {
        cin>>arrb[i].suit>>arrb[i].value;
    }
    for(int i = 0;i<n;i++)
    {
        arri[i].suit = arrb[i].suit;
        arri[i].value = arrb[i].value;
    }
    bubbleSort(arrb,n);
    selectionSort(arri,n);
    print(arrb,n);
    cout<<"Stable"<<endl;
    print(arri,n);
    if(ifstable(arrb,arri,n))
        cout<<"Stable"<<endl;
        else
            cout<<"Not stable"<<endl;
    return 0;
}



Measured memory_bytes: 3104
import string

S = input()
V = set(S)

for s in string.ascii_lowercase:
    if not s in V:
        print(S + s)
        exit()

for s, t in zip(S[:: -1], string.ascii_lowercase):
    if s != t:
        break
else:
    print(-1)
    exit()

for i in range(len(S))[:: -1]:
    A = []
    for j in range(i + 1, len(S)):
        if S[i] < S[j]:
            A.append(S[j])
    if A:
        A.sort()
        print(S[: i] + A[0])
        break

Measured memory_bytes: 3892
import numpy as np
from sys import stdin

N,D=[int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(N)]

ret=0
for i in range(N-1):
    a=[ int(x) for x in data[i]]
    for j in range(i+1,N,1):
        b=[ int(x) for x in data[j]]
        u = np.array(b) - np.array(a)
        c = np.linalg.norm(u)
        de,inte=np.modf(c)
        if de == 0:
            ret+=1
            # print(a,end=" ")
            # print(b)

print(ret,flush=True)

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

int main() {
    int n,m;
    cin >> n >> m;
    string ans;

    if (n == m) ans = "Yes";
    else ans = "No";

    cout<<ans<<endl;
}


Measured memory_bytes: 256
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
char a[8][8],b[8][8];
ll n,m,k;
ll ans=0;
ll solve()
{
    ll i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            b[i][j]=a[i][j];
        }
    }
    return 0;

}
void color(ll i,ll j)
{
    for(ll l=0;l<n;l++)
    {
        if(i&(1<<l))
        {
            for(ll y=0;y<m;y++)
            {
                b[l][y]='k';
            }
        }
    }
    for(ll l=0;l<m;l++)
    {
        if(j&(1<<l))
        {
            for(ll y=0;y<n;y++)
            {
                b[y][l]='k';
            }
        }
    }
    return ;
}
bool check()
{
    ll i,j,c=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(b[i][j]=='#')
                c++;
        }
    }
    if(c==k)
        return true ;
    else return false;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll i,j,t;
    cin>>n>>m>>k;
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0; i<(1<<n); i++)
    {
        for(j=0; j<(1<<m); j++)
        {
            solve();
            color(i,j);
            if(check())
                ans++;

        }
    }
    cout<<ans<<endl;

    return 0;
}




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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	int l[2000];
	int L[2001] = {};
	rep(i, n) { cin >> l[i]; L[l[i]]++; }
	for (int i = 1; i <= 1000; i++) { L[i] = L[i - 1] + L[i]; }

	long long A = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int a = l[i], b = l[j];
			int M = min(a + b - 1, 1000), m = abs(a - b);
			long long C = L[M] - L[m];
			if (m < l[i] && l[i] <= M) C--;
			if (m < l[j] && l[j] <= M) C--;

			A += C;
		}
	}

	cout << A / 3 << endl;
}

int main() {

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {

	int n, c;
	cin >> n >> c;
	vvi d(c, vi(c));
	rep(i, c)rep(j, c)cin >> d[i][j];
	vvi cc(n, vi(n));
	rep(i, n)rep(j, n) { cin >> cc[i][j]; cc[i][j]--; }

	vi dis0(c, 0), dis1(c, 0), dis2(c, 0);

	rep(k, c)rep(i, n)rep(j, n)if ((i + j) % 3 == 0)dis0[k] += d[cc[i][j]][k];
	rep(k, c)rep(i, n)rep(j, n)if ((i + j) % 3 == 1)dis1[k] += d[cc[i][j]][k];
	rep(k, c)rep(i, n)rep(j, n)if ((i + j) % 3 == 2)dis2[k] += d[cc[i][j]][k];

	int ans = INF;

	rep(i, c)rep(j, c)rep(k, c) {
		if (i == j || j == k || k == i)continue;
		ans = min(ans, dis0[i] + dis1[j] + dis2[k]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

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

const int inf = 999999999;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	cin.tie(0);
	char c[2][3];
	REP(i, 2) REP(j, 3) cin >> c[i][j];
	
	bool ans = true;
	
	if (c[0][0] != c[1][2]) ans = false;
	else if (c[0][1] != c[1][1]) ans = false;
	else if (c[0][2] != c[1][0]) ans = false;

	if (ans) cout << "YES";
	else cout << "NO";

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] += 'a' - 'A';
    cout << s << "\n";
}

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

int main(){
int n,l,s;
l=-10000000000;
s=100000000000;
long long sum=0;
cin>>n;
int a[10000];
int i;

for(i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
l=max(l,a[i]);
s=min(s,a[i]);
}

cout<<s<<" "<<l<<" "<<sum<<endl;
return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if(b == 0){
    cout << a;
    return 0;
  }
  set<int> S;
  rep(i,b){
    int c;
    cin >> c;
    S.insert(c);
  }
  if(!S.count(a)){
    cout << a;
    return 0;
  }
  int p, q, r, s;
  p = 0;
  q = 0;
  for(int i = a; i <= 100 ; i++){
    if(!S.count(i) && i != a){
      p = i - a;
      r = i;
      break;
    }
  }
  if(p == 0){
    p = 101 - a;
    r = 101;
  }
  for(int i = a; i >= 1 ; i--){
    if(!S.count(i) && i != a){
      q = a - i;
      s = i;
      break;
    }
  }
  if(q == 0){
    q = a;
    s = 0;
  }
  if(p < q){
    cout << r;
  }
  else{
    cout << s;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
using namespace std;

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

int main() {
    int n;
    cin >> n;
    double v[n];
    REP(i, n) {
        cin >> v[i];
    }
    sort(v, v+n);
    double sum = 0;
    // int i = 0;
    // while(i+1 == n-1) {
    //     cout << v[i] << " " << v[i+1] << " " << (v[i]+v[i+1])/2 << endl;
    //     v[i+1] = (v[i]+v[i+1])/2;
    //     i++;
    // }
    for(int i = 0; i < n; i++) {
        v[i+1] = (v[i]+v[i+1])/2;
        if(i+1 == n-1) break;
    }
    // cout << v[i] << endl;
    printf("%.8lf", v[n-1]);

    return 0;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n1 = o.a();
  var n2 = o.a();
  var n3 = o.a();
  var n4 = o.a();
  var N = "NO";
  if(n1 !== 1&&n2 !== 1&&n3 !== 1&&n4 !== 1)return N;
  if(n1 !== 9&&n2 !== 9&&n3 !== 9&&n4 !== 9)return N;
  if(n1 !== 7&&n2 !== 7&&n3 !== 7&&n4 !== 7)return N;
  if(n1 !== 4&&n2 !== 4&&n3 !== 4&&n4 !== 4)return N;
  return "YES";
}

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

typedef pair<int,string> P;

bool pairCom(const P& f, const P& s){
    return f.first < s.first;
}

int main(){
    int wa=0, ac=0, tmp=0;
    int n, m; cin >> n >> m;
    vector<P> p(m);
    for(int i = 0; i < m; i++){
        cin >> p.at(i).first >> p.at(i).second;
    }

    stable_sort(p.begin(),p.end(),pairCom);

    for(int i = 0, flag = 0; i < m; i++){
        if(i > 0){
            if(p.at(i).first != p.at(i-1).first){
                tmp = 0;
            }
        }
        if(flag == 1){
            if(p.at(i).first != p.at(i-1).first){
                flag = 0;
            }else{
                continue;
            }
        }
        if(p.at(i).second == "AC"){
            ac++;
            flag = 1;
            wa += tmp;
            tmp = 0;
        }else{
            tmp++;
        }
        
    }

    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 8064
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	io_init;
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<string> p;
	for (int r = 0, l = 0; r < S.size(); r++) {
		if (S[l] != S[r]) {
			p.push_back( S.substr(l, r - l));
			l = r;
		}
		if (r == N - 1) {
			p.push_back(S.substr(l, r - l + 1));
			break;
		}
	}
	int ans = 0;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == 'R' && S[i] == S[i + 1])ans++;
	}
	for (int i = S.size() - 1; i > 0; i--) {
		if (S[i] == 'L' && S[i] == S[i - 1])ans++;
	}
	for (int i = 0; i < (int)p.size() - 2; i++) {
		if (K != 0) {
			K--;
			ans += 2;
		}
	}
	if (K >= 0) {
		ans += min(K, 2);
	}
	cout << min(ans, N - 1) << endl;
}

Measured memory_bytes: 5828
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long i,sum=0,leaf=1;
    long long l[n+1],a[n+1],ai[n+1];
    for(i=0;i<=n;i++){
        cin >> a[i];
    }
    ai[n]=a[n];
    for(i=n-1;i>=0;i--){
        ai[i]=a[i]+ai[i+1];
    }
    for(i=0;i<=n;i++){
        l[i]=leaf;
        sum += leaf;
        leaf-=a[i];
        if(leaf<0){
            cout << -1 << endl;
            return 0;
        }
        if(i<n){
            leaf*=2;
            if(leaf>ai[i+1])leaf=ai[i+1];
        }
    }
    long long am = 0;
    for(i=n;i>0;i--){
        if(l[i]<=am+a[i])break;

        am+=a[i];
        sum -= l[i]-am;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
typedef pair<int, int> p;
//drken氏のコード参考にさせていただきました

int main(){
  string s;
  cin >> s;
  int n=s.size();
  ll ans=0;
  for(int bit=0;bit<(1<<(n-1));++bit){
    ll tmp=0;
    for(int i =0; i<n-1;++i){
      tmp*=10;
      tmp+=s[i]-'0';
      if(bit&(1<<i)){
        ans+=tmp;
        tmp=0;  
      }
    }
    tmp*=10;
    tmp+=s.back()-'0';
    ans+=tmp;
  }
  cout<<ans<<endl;
  }

Measured memory_bytes: 3616
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
using namespace std;

ll n,m;

ll p(int x) {
	ll ret=1;
	for (int i=2;i<=x;i++) ret=(ret*i)%MOD;
	return ret;
}

int main() {
	scanf("%lld%lld",&n,&m);
	if (abs(n-m)>1) {
		printf("0\n");
	} else if (n==m) {
		ll tmp=p(n);
		ll ans=(tmp*tmp)%MOD;
		ans=(ans*2)%MOD;
		printf("%lld\n",ans);
	} else {
		ll tmp=p(min(n,m));
		ll ans=(tmp*tmp)%MOD;
		ans=(ans*max(n,m))%MOD;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 100005
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[M];
int n, D[M];

void print(int a){
  int i, c;
  printf("node %d: ",a);
  printf("parent = %d, ",T[a].p);
  printf("depth = %d, ",D[a]);

  if(T[a].p==NIL)printf("root, ");
  else if(T[a].l == NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i = 0,c = T[a].l;c != NIL; i++,c = T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int a,int b)
{
  D[a]=b;
  if(T[a].r != NIL)rec(T[a].r, b);
  if(T[a].l != NIL)rec(T[a].l, b+1);
}

int main()
{
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].p = T[i].l = T[i].r = NIL;
    }
  for(i = 0; i < n;i++)
    {
      scanf("%d %d", &v,&d);
      for(j=0; j < d; j++)
	{
	  scanf("%d",&c);
	  if(j==0)T[v].l =c;
	  else T[l].r = c;
	  l=c;
	  T[c].p = v;
	}
    }
  for(i = 0;i < n; i++)
    {
      if(T[i].p == NIL) r = i;
    }

  rec(r,0);

  for(i = 0; i<n;i++) print(i);
  return 0;
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
typedef long long ll;
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<"\n";
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main() {
	cr7
	ll r;
	cin >> r;
	double d = 6.28318530717958623200/2;
	cout.precision(23);
	cout << 2*(d)*r<<"\n";
}

Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  3 10:58:30 2018

@author: ashida
"""
N=int(input())

S1=list(input())
S2=list(input())

if len(S1)>1:
    if S1[0]==S1[1]:
        st=2
        ans=6
        flag=1
    else:
        st=1
        ans=3
        flag=-1
else:
    st=1
    ans=3
    flag=-1

while st<N:
    if st+1<N:
        if S1[st]==S1[st+1]:
            if flag<0:
                ans*=2
            else:
                ans*=3
            st+=2
            flag=1
        else:
            if flag<0:
                ans*=2
            else:
                ans*=1
            st+=1
            flag=-1
    else:
        if flag<0:
            ans*=2
        else:
            ans*=1
        st+=1
        
ans=ans%1000000007
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int x,a,b; cin >> x >> a >> b;
    if(b<=a)cout << "delicious" << endl;
    else if(b-a<=x)cout << "safe" << endl;
    else cout << "dangerous" <<endl; 
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
char a[2][3];
int main(void)
{
     int i,j,k,n,m;
     for(i=0;i<2;i++)
     {
          for(j=0;j<3;j++)
               scanf("%c",&a[i][j]);
          getchar();
     }
     if(a[0][0]==a[1][2]&&a[0][1]==a[1][1]&&a[0][2]==a[1][0])
          printf("YES\n");
     else
          printf("NO\n");
     return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3636
/**
 * author: said_v15
 * created with web_programmer
**/
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int H , W ; cin >> H >> W ;
int h , w ; cin >> h >> w ;
int ans = ( H - h ) * ( W - w );
cout << ans << endl ;
return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

m = len(s)

for i in range(m):
	if ord(s[i])+n-65<26:
		s[i]=chr(ord(s[i])+n)
	else:
		s[i]=chr(ord(s[i])+n-26)
"".join(s)
print("".join(s))

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
import java.lang.*;

class Output extends PrintWriter {

    public Output(PrintStream io) {
        super(io);
    }

    public void printArray(int[] array, String space, String end) {
        int N = array.length;
        for(int n=0; n<N-1; n++){
            super.print(array[n]);
            super.print(space);
        }
        super.print(array[N-1]);
        super.print(end);
        super.flush();
    }
    public void printArray(int[] array){
        this.printArray(array, " ", "\n");
    }
    public void printArray(long[] array, String space, String end) {
        int N = array.length;
        for(int n=0; n<N-1; n++){
            super.print(array[n]);
            super.print(space);
        }
        super.print(array[N-1]);
        super.print(end);
        super.flush();
    }
    public void printArray(long[] array){
        this.printArray(array, " ", "\n");
    }
    public void printArray(double[] array, String space, String end) {
        int N = array.length;
        for(int n=0; n<N-1; n++){
            super.print(array[n]);
            super.print(space);
        }
        super.print(array[N-1]);
        super.print(end);
        super.flush();
    }
    public void printArray(double[] array){
        this.printArray(array, " ", "\n");
    }
    public void printArray(char[] array, String space, String end) {
        int N = array.length;
        for(int n=0; n<N-1; n++){
            super.print(array[n]);
            super.print(space);
        }
        super.print(array[N-1]);
        super.print(end);
        super.flush();
    }
    public void printArray(char[] array){
        this.printArray(array, " ", "\n");
    }
    public void printArray(Object[] array, String space, String end) {
        int N = array.length;
        for(int n=0; n<N-1; n++){
            super.print(array[n]);
            super.print(space);
        }
        super.print(array[N-1]);
        super.print(end);
        super.flush();
    }
    public void printArray(Object[] array){
        this.printArray(array, " ", "\n");
    }

}

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long S = sc.nextLong();
        long[] A = new long[N];

        if(S==1000000000L){
            for(int n=0; n<K; n++) A[n] = S;
            for(int n=K; n<N; n++) A[n] = 1;
        }else{
            for(int n=0; n<K; n++) A[n] = S;
            for(int n=K; n<N; n++) A[n] = 1000000000L;
        }

        new Output(System.out).printArray(A);

    }


}


Measured memory_bytes: 31564