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


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

  int one = 0;
  rep(i,S.size()){
    if(S[i] == '1') one++;
    else break;
  }

  if(K <= one){
    cout << 1 << endl;
  }else{
    cout << S[one] << endl;
  }
  
  return 0;
}



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

using namespace std;

#define to first
#define ind second

const int N = 55;
vector<pair<int , int> > adj[N];

bool find_path (int node , int par , int target , vector<int> &path) {
    if (node == target)
        return 1;

    for (auto &e : adj[node]) {
        if (e.to == par) continue;
        path.push_back(e.ind);
        if (find_path(e.to , node , target , path))
            return 1;
        path.pop_back();
    }

    return 0;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v;
        cin >> u >> v;
        adj[u].push_back({v , i});
        adj[v].push_back({u , i});
    }

    int m;
    cin >> m;

    vector<vector<int> > edges(m);
    for (int i = 0 ;i < m ;i++) {
        int a , b;
        cin >> a >> b;
        find_path(a , a , b , edges[i]);
    }


    vector<long long> p(n);
    p[0] = 1;
    for (int i = 1 ;i < n ;i++)
        p[i] = p[i - 1] * 2;

    long long bad = 0;
    for (int msk = 1 ;msk < (1 << m) ; msk++) {
        set<int> uni;
        int ones = 0;
        for (int i = 0 ;i < m ;i++) {
            if (msk & (1 << i)) {
                ones++;
                for (int x : edges[i])
                    uni.insert(x);
            }
        }

        if (ones&1)
            bad += p[n - 1 - uni.size()];
        else
            bad -= p[n - 1 - uni.size()];
    }

    cout << p[n - 1] - bad;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  ll K,A,B; cin >> K >> A >> B;
  ll ans = 1;
  if(B - A < 2){
    ans = K + 1;
  }
  else{
    while(K > 0){
      if(ans >= A && K >= 2){
        ans += B -A;
        K -= 2;
      }
      else{
        ans += 1;
        K--;
      }
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d",&k);
  printf("%d",a[k-1]);
}

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

int main() {
  int X, i=1, j=1, k=1, l=1;
  cin >> X;
  while(1){
    if(i*i>X) break;
    i++;
  }
  while(1){
    if(j*j*j>X) break;
    j++;
  }
  while(1){
    if(k*k*k*k*k>X) break;
    k++;
  }
  while(1){
    if(l*l*l*l*l*l*l>X) break;
    l++;
  }
  cout << max((i-1)*(i-1),max((j-1)*(j-1)*(j-1),max((k-1)*(k-1)*(k-1)*(k-1)*(k-1),(l-1)*(l-1)*(l-1)*(l-1)*(l-1)*(l-1)*(l-1)))) << endl;
}

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

const int NMAX = 200000;

int main()
{
	int N;
	char s[NMAX+1];
	scanf("%d %s", &N, s);
	int a[NMAX+1];
	a[0] = 0;
	for (int i = 0; i < N; ++i)
		a[i+1] = a[i] + (s[i] == 'W');

	int ans = NMAX;
	for (int i = 0; i <= N; ++i) {
		int left_w = a[i];
		int right_r = (N - i) - (a[N] - a[i]);

		ans = min(ans, max(left_w, right_r));
	}

	printf("%d\n", ans);
	return 0;
}


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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      (rinv*=inverse(k))%=MOD;
      if(k%2) (res+=MOD-rinv)%=MOD;
      else (res+=rinv)%=MOD;
    }
    for(Int i=1;i<=n;i++)
      (res*=i)%=MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<mod.C(k,n)<<endl;
  return 0;
}



Measured memory_bytes: 7464
#include <stdio.h>
void enumeration(int result[],int used[],int n,int d){
    int i;
    if(d>=n){
        for(i=0;i<n;i++){
            if(i==0)printf("%d",result[i]);
            else printf(" %d",result[i]);
        }
        printf("\n");
        return;
    }
    
    int used2[n-d-1];
    int j,k;
    for(i=0;i<n-d;i++){
        result[d]=used[i];
        for(j=0,k=0;j<n-d;j++)if(j!=i)used2[k++]=used[j];
        enumeration(result,used2,n,d+1);
    }
    
    return;
}
int main(void){
    int i;
    
    int n;
    scanf("%d\n",&n);
    
    int used[n];
    for(i=0;i<n;i++)used[i]=i+1;
    
    int result[n];
    
    enumeration(result,used,n,0);
    
    return 0;
}


Measured memory_bytes: 2100
import Data.Bits
import Data.List
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Generic as G

modulo :: Int
modulo = 1000000007

(+~) :: Int -> Int -> Int
a +~ b = (a + b) `mod` modulo

(*~) :: Int -> Int -> Int
a *~ b = (a * b) `mod` modulo

powMod :: Int -> Int -> Int
powMod a b = foldl' step 1 [63, 62 .. 0]
  where step x n = let pow2 = x *~ x in
                    if b `testBit` n then pow2 *~ a else pow2

invMod :: Int -> Int
invMod a = powMod (a `mod` modulo) (modulo - 2)

facts :: U.Vector Int
facts = 1 `G.cons` G.scanl1 (*~) (G.enumFromTo 1 200001)

factMod :: Int -> Int
factMod n = facts G.! n

combMod :: Int -> Int -> Int
combMod n r = factMod n *~ invMod (factMod r *~ factMod (n - r))

patterns :: Int -> Int -> Int
patterns h w = combMod (h + w) h

main :: IO ()
main = do
  [h, w, a, b] <- mapM readIO . words =<< getLine
  print $ foldl' (+~) 0 [ patterns row (b - 1) *~ patterns (h - row - 1) (w - b - 1)
                        | row <- [0 .. h - a - 1]
                        ]


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

int main() {
  int N;
  cin >> N;
  vector<int> button(N);
  int count=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    button.at(i) =a;
      }
      //cout << button[0] << endl;
      //cout << button[N-1] << endl;
    int next=1;
    for(int i =0;i<N+2;i++){
      next = button.at(next-1);
      //cout << next << endl;
      count++;
      if(next==2) break;

    }
    if(count>N+1){
      cout << -1 << endl;
    }
  else{
    cout << count << endl;
  }

  }


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

int n,a[200001],dp[3][200100];

signed main() {
    rep(i,3) rep(j,200004) dp[i][j] = -INF/10;
    cin >> n;
    rep1(i,n) cin >> a[i];
    dp[0][0] = dp[1][0] = dp[2][0] = dp[1][1] = dp[2][1] = dp[2][2] = 0;
    dp[0][1] = a[1];
    dp[0][2] = a[2];

    repo(i,3,n+1) {
        dp[0][i] = max(dp[0][i], dp[0][i-2] + a[i]);
        dp[1][i] = max(dp[1][i], dp[1][i-2] + a[i]);
        dp[2][i] = max(dp[2][i], dp[2][i-2] + a[i]);
        dp[1][i] = max(dp[1][i], dp[0][i-3] + a[i]);
        dp[2][i] = max(dp[2][i], dp[1][i-3] + a[i]);
        if (i >= 4) dp[2][i] = max(dp[2][i], dp[0][i-4] + a[i]);

    }
    int ans = -INF;
    if (n%2 == 1) {
        ans = max(ans, dp[0][n-2]);
        ans = max(ans, dp[0][n-1]);
        ans = max(ans, dp[0][n]);
        ans = max(ans, dp[1][n-1]);
        ans = max(ans, dp[1][n]);
        ans = max(ans, dp[2][n]);
    }
    else {
        ans = max(ans, dp[0][n-1]);
        ans = max(ans, dp[0][n]);
        ans = max(ans, dp[1][n]);
    }
    cout << ans << endl;
}





Measured memory_bytes: 9900
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	ll n;
	cin>>n;
	ll arr[n];
	ll val=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		val^=arr[i];
	}
	vector<ll> vec;
	ll k;
	k=val^arr[0];
	val=k;
	vec.pb(k);
	for(int i=1;i<n;i++)
	{
		val^=arr[i-1];
		val^=arr[i];
		vec.pb(val);
	}
	for(int i=0;i<n;i++)
	cout<<vec[i]<<" ";
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   string s,v;
   cin>>s>>v;
   cout<<v<<s<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int list[50000];
  int i,j,c;
  for(i=2;i<50002;i++)list[i-2]=i;
  for(j=2;j*j<50003;j++)
    if(list[j-2]!=0)
      for(i=1;j-2+list[j-2]*i<50001;i++)
	list[j-2+list[j-2]*i]=0;

  while(1){
    cin>>i,c=0;
    if(i==0)break;
    for(j=2;j<=(i/2);j++)
      if((list[j-2]!=0)&&(list[i-j-2]!=0))c++;
    cout<<c<<endl;
  }
}

Measured memory_bytes: 1060
S = raw_input()

if S == "SUN":
  print "7"
elif S == "MON":
  print "6"
elif S == "TUE":
  print "5"
elif S == "WED":
  print "4"
elif S == "THU":
  print "3"
elif S == "FRI":
  print "2"
elif S == "SAT":
  print "1"


Measured memory_bytes: 2568
N=int(input())
tmp=0
if N<10:
  print(N)  
elif N<1000:
  if 9+N-99<0:
    print(9)
  else:
    print(9+N-99)
elif N<100000:
  if 9+900+N-9999<0:
    print(909)
  else:
    print(9+900+N-9999)
elif N==100000:
  print(90909)

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int A, B, M;
	cin >>A >>B >>M;
	vector<int> a(A+1);
	vector<int> b(B+1);
	vector<vector<int>> x(M+1, vector<int> (3, 0));
	Rep1(i, A)
		cin >>a.at(i);
	Rep1(i, B)
		cin >>b.at(i);
	Rep1(i, M)
		Rep0(j, 3)
			cin >> x.at(i).at(j);
	int AA=INF;
	int BB=INF;
	Rep1(i, A)
		AA=min(AA, a.at(i));
	Rep1(i, B)
		BB=min(BB, b.at(i));
	int SS=INF;
	Rep1(i, M)
		SS=min(SS, a.at(x.at(i).at(0))+b.at(x.at(i).at(1))-x.at(i).at(2));
	SS=min(SS, AA+BB);
	cout <<SS <<endl;
	return 0;
}



Measured memory_bytes: 6528
# Atcoder Problem Solving
# Shock

# Code Fesitival Team Relay


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
N, M = map(int, input().split())

graph = []
G = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    G.union(a, b)

A = G.size(1)
B = G.size(2)
C = N-A-B
ans = 0
for i in range(C+1):
    ans = max(ans, (A+i)*(A+i-1)//2 + (B+C-i)*(B+C-i-1)//2-M)
print(ans)

Measured memory_bytes: 5364
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007

ll solve(ll n,ll k,vector<ll> &v)
{
    ll dp[n+1][k+1];
    
    for(ll i=0;i<=k;i++)
    {
        dp[1][i]=(i<=v.at(1)?(1):(0));
    }
    
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=k;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=((( (dp[i][j-1])%p+ (dp[i-1][j])%p - ( (j-1-v[i]>=0)?(dp[i-1][j-1-v[i]]):0)%p )%p)+p)%p;
            }
        }
    }
    return dp[n][k];
}

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(n,k,v);
    return 0;
}

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

int main()
{
    int h, w;
    cin>>h>>w;
    while(!(h==0 && w==0))
    {
        for(int i=0; i<h; i++)
        {
            for(int j=0; j<w; j++)
            {
                if((i+j)%2==0) cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
        cin>>h>>w;
    }
}


Measured memory_bytes: 3096
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"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var ans;

function main(){
  var n = o.a();
  var q = o.a();
  var graph = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var a = o.a()-1, b = o.a()-1;
    graph[a].push(b);
    graph[b].push(a);
  }
  ans = xArray(0,n);
  for(var i = 0; i < q; i++){
    var p = o.a()-1, x = o.a();
    ans[p] += x;
  }
  dfs(graph,0,-1,0);
  return ans.join(" ");
}

function dfs(g,v,p,c){
  ans[v] += c;
  c = ans[v];
  for(var V of g[v]){
    V = +V;
    if(V === p)continue;
    dfs(g,V,v,c);
  }
}

if (process.argv.length <= 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=240000"] });
else {
  console.log(main());
}

Measured memory_bytes: 256056
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=LI()
    CB=[[0,0]for _ in range(M)]
    A.sort()
    for i in range(M):
        CB[i][1],CB[i][0]=MI()
        
    CB.sort(reverse=True)
    now=0
    
    for i in range(N):
        if CB[now][1]<=0:
            now+=1
        
        if now>=M:
            break    
        
        ch=CB[now][0]
        if A[i]<ch:
            A[i]=ch
            CB[now][1]-=1
        else:
            break
        
    print(sum(A))
    

main()


Measured memory_bytes: 68588
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')


a = ns()
b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
if a in b:
    print('A')
else:
    print('a')

Measured memory_bytes: 9060
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;


int main()
{
    int n, m, x, right = 0, left = 0;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m)
    {
        cin >> a[i];
        if (a[i] < x) left++;
        if (a[i] > x) right++;
    }

    if (left > right) cout << right << endl;
    else cout << left << endl;
    return 0;
}

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

int ai(int i){//十進数の合計を求める関数
    int j = i;//iのコピー
    int l = 0;
    int m = 0;// 十進数の合計 int n = 0;
    int n = 0;
    int k = 0;//桁数
    int b = 0;
    while(j != 0){
        j = j / 10;
        k++;
    }
    for(int a = 10;b < k;a *= 10){
        b++;
        if(a == 10){
        l = i % a;
        m += l;
        continue;
        }
        l = i % a;
        n = (l - (l % (a / 10))) / (a / 10);
        m += n;
    }
    return m;
}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int l = 0;
  vector<int> a = {};//総和を求めるやつ
  for(int i = 1;i <= N;i++){
      int b = ai(i);
      if(A <= b){
          if(b <= B){
            a.push_back(i);
          }
      }
    }
    for(int i = 0;i < a.size();i++){
        l += a.at(i);
    }
    cout<<l<<endl;
}

Measured memory_bytes: 3704
def luka(n):
  global lk
  if n==0:
    return 2
  if n==1:
    return 1
  if lk[n] != -1:
    return lk[n]
  lk[n] = luka(n-1)+luka(n-2)
  return lk[n]

lk = [-1]*100
n = int(input())
print(luka(n))


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

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a <= c && c <= b) || (b <= c && c <= a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M;
    cin >> N >> M;

    vector<size_t> cnt(M + 1);
    set<size_t> S;
    for (size_t i = 0; i < N; ++i) {
        size_t K; cin >> K;
        for (size_t i = 0; i < K; ++i) {
            size_t a; cin >> a;
            cnt[a]++;
            S.insert(a);
        }
    }

    size_t res = 0;
    for (auto &si: S) {
        if (cnt[si] == N) {
            res++;
        }
    }

    cout << res << "\n";

    return 0;
}


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

int main(){
  ll n,l,r,s=0;
  cin>>n;
  fr(i,n){cin>>l>>r;s+=r-l+1;}
  cout<<s<<endl;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s;
    cin >> s;
    
    ll sum = 0;
    irep(i, s.size()) {
        sum += s[i]-'0';
    }

    if(sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
} /*atcoder*/


Measured memory_bytes: 3748
from math import sqrt
n=10**4
an=[0 for i in range(n+1)]
for i in range(1,int(sqrt(n))+1):
    for j in range(i,int(sqrt(n))+1):
        for k in range(j,int(sqrt(n))+1):
            a=i*i+j*j+k*k+i*j+i*k+j*k
            if a<=n:
                if i==j and j==k:
                    an[a]+=1
                elif i==j or j==k or i==k:
                    an[a]+=3
                else: an[a]+=6
n=int(input())
for i in range(1,n+1):
    print(an[i])


Measured memory_bytes: 73936
#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>;

const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(M);
    for(int x : a){
        if(cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for(int i = x; i<M; i+=x) cnt[i]++;
    }
    int ans = 0;
    for(int x : a){
        if(cnt[x] == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if (s.size() <= k) cout << s << endl;
  else {
    for (int i = 0; i < k; i++)
      cout << s.at(i);
    cout << "..." << endl;
  }
}




Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }

    let strw = s.as_str();
    if strw == "SSS" {
        println!("0");
    } else if strw == "SSR" || strw == "SRS" || strw == "RSS" || strw == "RSR" {
        println!("1");
    } else if strw == "RRS" || strw == "SRR" {
        println!("2");
    } else {
        println!("3");
    }
}


Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N){
        int a;cin >> a;
        p[--a]=i;
    }
    vector<int> a(N),b(N);
    int M = 30000;
    rep(i,N){
        a[i]=M*i+1+p[i];
        b[i]=M*(N-i)+1;
    }

    rep(i,N)cout << a[i] <<" ";
    cout << endl;
    rep(i,N)cout << b[i] <<" ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>

unsigned int gcd(int x, int y){
    int k = x%y;
    if(!k) return y;
    return gcd(y, k);
}

int main(void){
    unsigned int a, b;
    std::cin >> a >> b;
    unsigned int max = a > b ? a : b;
    unsigned int min = a > b ? b : a;
    std::cout << gcd(max, min) << "\n";
    return 0;
}


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

const int maxn = 1e5 + 10;

int n;
int a[maxn];
string ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
}

void solve(){
    ans = "APPROVED";
    for(int i = 0; i < n; i++)
        if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0)
            ans = "DENIED";
}

void out(){
    cout << ans;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << ((a + b) % 24) << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())


"""
"""

#solution:
#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans

#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))


#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
        
#input
def resolve():
    N=int(input())
    S=([input()[0] for i in range(N)])
    MARCH=[0]*5
    c="MARCH"
    for item in S:
        for char in range(5):
            if item==c[char]:
                MARCH[char]+=1
    j=0
    for t in range(5):
        if MARCH[t]!=0:
            j+=1
    ans=0
    for x in range(5):
        for y in range(x+1,5):
            for z in range(y+1,5):
                if MARCH[x]*MARCH[y]*MARCH[z]!=0:
                    ans+=MARCH[x]*MARCH[y]*MARCH[z]
    print(ans)
    #print(["No","Yes"][cond])
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
ZZ
ZZZ
Z
ZZZZZZZZZZ"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO"""
        output = """7"""
        self.assertIO(input, output)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 98004
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {            //ソートが安定するから（以下）
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if (N <= K)
			System.out.println(N * X);
		else
			System.out.println(K * X + ((N - K) * Y));
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;cin >> r;
  cout << r*r << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string board[50];
  for(int i = 0; i < H; i++) cin >> board[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(board[i][j] == '#') continue;
      
      int num = 0;
      for(int d = 0; d < 8; d++) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        if(ni < 0 or H <= ni) continue;
        if(nj < 0 or W <= nj) continue;
        if(board[ni][nj] =='#') num++;
      }
      board[i][j] = char(num + '0');
    }
  }
  for(int i = 0; i < H; i++) cout << board[i] << endl;
}

Measured memory_bytes: 256
from collections import Counter

n,p = list(map(int, input().split()))

# 因数分解
i=2
fact = []
while i * i <= p:
    while p % i == 0:
        fact.append(i)
        p //= i
    i += 1

if p >= 1:
    fact.append(p)

# N個以上そろっている共通因数を掛け合わせる
cf = Counter(fact)
ans = 1
for num, cnt in cf.items():
    if cnt >= n:
        ans *= (num ** (cnt//n))

print(ans)

Measured memory_bytes: 9396
#include <iostream>
#include <algorithm>

using namespace std;

const int DIM = 2010;

int i,j,k,n,sum, v[DIM];

int main(){
    long count = 0 ;
    cin >> n;
    for (i = 1; i <= n; ++i) {
        cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    for (i = 1; i<= n - 2; i++){
        for (j = i + 1; j <= n-1 ; j++){
            sum = v[i] + v [j]; 
            for(k = j + 1 ; k <= n; k++){
                if (v[k] < sum){
                    count ++; 
                }   
            }
        }   
    }       
    cout << count << "\n";
    return 0; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a<3200)
  {
    cout << "red" << endl;
  }
  else
  {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  Int L = lin();
  vector<int> res;
  stack<Int> len;
  stack<int> rig;

  for (int i = 0; i < N; ++i) {
    int a = in();
    len.push(a);
    rig.push(i);
    while (len.size() >= 2) {
      Int rlen = len.top(); len.pop();
      int rrig = rig.top(); rig.pop();
      if (len.top() + rlen >= L) {
        Int llen = len.top(); len.pop();
        int lrig = rig.top(); rig.pop();
        res.push_back(lrig + 1);
        len.push(llen + rlen);
        rig.push(rrig);
      } else {
        len.push(rlen);
        rig.push(rrig);
        break;
      }
    }
  }

  if (len.size() == 1) {
    puts("Possible");
    reverse(res.begin(), res.end());
    for (const int u : res) {
      printf("%d\n", u);
    }
  } else {
    puts("Impossible");
  }

  return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll r=0,g=0,b=0,sum=0;
    ll n,i;
    string s;
    cin>>n>>s;
    for (i=0;i<n;i++){
        if (s[i]=='R')r++;
        else if (s[i]=='G')g++;
        else b++;
    }
    sum=r*g*b;
    for (i=0;i<s.size();i++){
        for (ll i1=1;i1+i<s.size()&&i-i1>=0;i1++){
            if (s[i-i1]!=s[i]&&s[i+i1]!=s[i]&&s[i+i1]!=s[i-i1])sum--;
        }
    }
    cout<<sum<<'\n';
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

    char prev = S.front();
    for (int i = 1; i < S.length(); i++) {
        if (prev == S[i]) {
            cout << "Bad";
            break;
        } else if (i == S.length() - 1) {
            cout << "Good";
        }
        prev = S[i];
    }

    return 0;
}



Measured memory_bytes: 256
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

property = Array.new(4).map{Array.new(3).map{Array.new(10, 0)}}
n = STDIN.gets
n = n.to_i

1.upto(n) {|i|
	b, f, r, v = array_integer(STDIN.gets.split(" "))
	b -= 1
	f -= 1
	r -= 1
	property[b][f][r] += v
}

0.upto(3) {|b|
	0.upto(2) {|f|
		0.upto(9) {|r|
			print " ", property[b][f][r]
		}
		print "\n"
	}
	print "####################\n" if b != 3
}


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

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<std::string> a(h);

  for (int i = 0; i < h; i++) {
    std::cin >> a[i];
  }

  const auto end_itr = std::remove_if(a.begin(), a.end(),
    [](const auto &i){
      return std::all_of(i.cbegin(), i.cend(),
        [](const auto c){return c == '.';});});
  std::set<int> remove;
  for (size_t i = 0; i < a[0].size(); i++) {
    bool flag = true;
      for (auto itr = a.begin(); itr != end_itr; itr++) {
      if (itr->at(i) != '.') {
        flag = false;
      }
    }
    if (flag) {
      remove.insert(i);
    }
  }

  for (auto itr = a.begin(); itr != end_itr; itr++) {
    for (int j = 0; j < a[0].size(); j++) {
      if (remove.find(j) == remove.cend()) {
        std::cout << itr->at(j);
      }
    }
    std::cout <<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
K, S = [int(i) for i in input().split()]
cnt = 0 
for x in range(0,K+1):
  if 0 <= S - x <= K:
    cnt += S - x + 1
  elif 0 <= S - x <= 2*K:
    cnt += 2*K - S + x + 1
print(cnt)

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

int main() {
 int n,m; cin >> n >> m;
  int dh[]={0,1,0,-1};
  int dw[]={1,0,-1,0};
  string map[60];
  for(int i=0;i<n;i++)cin >> map[i];

  bool ok=true;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(map[i][j]=='#'){
        bool flag=false;
        for(int k=0;k<4;k++){
        int H=i+dh[k];
        int W=j+dw[k];
          if(H>=0 && W>=0 && H<n && W<m && map[H][W]=='#')flag=true;
        }
        if(!flag)ok=false;
      }
    }
  }

  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
    string W, T;
    int count = 0;
    int n = 'a' - 'A';
    cin >> W >> T;
    while(T != "END_OF_TEXT")
    {
        for (int i = 0; i < T.length(); i++)
        {
            if(T[i] >='A' && T[i] <= 'Z')
            {
                T[i] += n;
            }
        }
        if (T == W)
        {
            count++;
        }
        cin >> T;
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3188
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int Mod=1e9+7,N=110;
int ans,n,dp[N][5][5][5],sum[N];
int qpow(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1ll*ret*a%Mod;
		b>>=1;a=1ll*a*a%Mod;
	}
	return ret;
}
int main()
{
	n=gi();
	dp[0][0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int a=0;a<5;a++)
			for(int b=0;b<5;b++)
				for(int c=0;c<5;c++)
				{
					for(int d=1;d<=4;d++)
						{
							if(b==1 && c==3 && d==2)continue;
							if(a==1 && c==3 && d==2)continue;
							if(b==3 && c==1 && d==2)continue;
							if(b==1 && c==2 && d==3)continue;
							if(a==1 && b==3 && d==2)continue;
							dp[i+1][b][c][d]=(dp[i+1][b][c][d]+dp[i][a][b][c])%Mod;
						}
				}
	for(int a=0;a<5;a++)
		for(int b=0;b<5;b++)
			for(int c=0;c<5;c++)
				ans=(ans+dp[n][a][b][c])%Mod; 
	printf("%d\n",ans%Mod);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  string s, t;
  cin >> s >> t;
  ll n = s.size(), m = t.size();

  vector<vector<ll>> spos(n+2, vector<ll>(2, n)), tpos(m+2, vector<ll>(2, m));
  for(int i=n-1; i>=0; --i) {
    if(s[i]=='0') spos[i][0] = i, spos[i][1] = spos[i+1][1];
    else spos[i][1] = i, spos[i][0] = spos[i+1][0];
  }
  for(int i=m-1; i>=0; --i) {
    if(t[i]=='0') tpos[i][0] = i, tpos[i][1] = tpos[i+1][1];
    else tpos[i][1] = i, tpos[i][0] = tpos[i+1][0];
  }

  auto dp = make_v<int>(n+2, m+2); fill_v(dp, INF); dp[n+1][m+1] = 0;
  auto use = make_v<int>(n+2, m+2);
  auto nxt = make_v<PII>(n+2, m+2);
  for(int i=n+1; i>=0; --i) {
    for(int j=m+1; j>=0; --j) {
      if(i==n+1 && j==m+1) continue;
      REP(k, 2) {
        if(dp[i][j] > dp[spos[i][k]+1][tpos[j][k]+1]+1) {
          dp[i][j] = dp[spos[i][k]+1][tpos[j][k]+1]+1;
          use[i][j] = k;
          nxt[i][j] = {spos[i][k]+1, tpos[j][k]+1};
        }
      }
    }
  }

  string ans = "";
  PII now({0, 0});
  while(now.first != n+1 || now.second != m+1) {
    ans += use[now.first][now.second]+'0';
    now = nxt[now.first][now.second];
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 253768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int maxm = maxn*2;
const int inf = 0x3f3f3f3f;

char s[100005];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>(s+1);
    int n = strlen(s+1);
    for(int i = 2;i<=n;i++) {
        if(s[i]==s[i-1]) {
            cout<<i-1<<' '<<i<<'\n'; return 0;
        }
        if(i>=3 && s[i]==s[i-2]) {
            cout<<i-2<<' '<<i<<'\n'; return 0;
        }
    }
    cout<<-1<<' '<<-1<<'\n'; return 0;
}


Measured memory_bytes: 384
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

Y = [int(i + A[i - 1]) for i in range(1, N + 1)]
Y = Counter(Y)

cnt = 0
for i in range(1, N+1):
    X = i - A[i - 1]
    if X in Y.keys():
        cnt += Y[X]
print(cnt)


Measured memory_bytes: 42936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();

		int ans=0;

		for (int i=1;i<=N;i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			if ((H<=A) && (W<=B)) {
					ans++;
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 27796