akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
vi conne[100];
vb is_visited(100,false);
int n;
int t=1;;
int f[100];
int d[100];
void dfs(int i){
    if(!is_visited[i]){
        d[i]=t++;
        is_visited[i]=true;
    }
    for(int itr:conne[i]){
       if(is_visited[itr])continue;
       dfs(itr);
    }
    f[i]=t++;
}
int main( ){
    cin>>n;
    rep(i,0,n){
        int id;
        cin>>id;
        id--;
        int num; cin>>num;
        rep(j,0,num){
            int in; cin>>in;
            in--;
            conne[id].push_back(in);
        }
        sort(conne[id].begin(),conne[id].end());
    }
    rep(i,0,n){
        if(is_visited[i]==false)dfs(i);
    }
    rep(i,0,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return 0;
}





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

a=[]
b=[]

for i in range(4):
  a.append(int(input()))
  a.sort(reverse=True)

for j in range(4,6):
  b.append(int(input()))
  b.sort(reverse=True)
  
print(sum(a[:3])+b[0])


Measured memory_bytes: 5604
H,W=map(int,input().split())

A = [list(input()) for i in range(H)]

l=[False]*H
c=[False]*W

for i in range(H):
  for j in range(W):
    if A[i][j]=='#':
      l[i]=True
      c[j]=True

ans=['' for i in range(H)]
for i in range(H):
  for j in range(W):
    if l[i] and c[j]:
      ans[i]+=A[i][j]
for i in range(H):
  if str(ans[i])!='':
    print(str(ans[i]))

Measured memory_bytes: 3188
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x,vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout <<#x<<" "<< x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a,b,c) min(a,min(b,c))
#define max(a,b,c) max(a,max(b,c))
#define mod  998244353
ll power(ll x, unsigned ll y, ll p) 
{ 
    ll res = 1;
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
    ll count[100000+1]={0};
    ll a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        count[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    if(count[i-1]==0 && count[i]>0)
    {cout<<0;return 0;}
    if(a[1]!=0)
    {cout<<0;return 0;}
    if(count[0]!=1)
    {cout<<0;return 0;}
    ll ans=1;
    for(int i=2;i<=n;i++)
    {
        if(count[i]==0)
        break;
        ans=((ans%mod)*(power(count[i-1],count[i],mod)))%mod;
        ans=ans%mod;
        //deb(ans);
    }
    cout<<ans%mod;
}
	

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    for (int i = 0; i < a; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < q; ++i) {
        cin >> x[i];
    }

    s.insert(s.begin(), -infl);
    t.insert(t.begin(), -infl);
    s.insert(s.end(), infl);
    t.insert(t.end(), infl);

    for (ll query : x) {
        ll ans = infl;
        auto slb = lower_bound(s.begin(), s.end(), query);
        auto tlb = lower_bound(t.begin(), t.end(), query);
        auto sub = lower_bound(s.rbegin(), s.rend(), query, greater<ll>());
        auto tub = lower_bound(t.rbegin(), t.rend(), query, greater<ll>());

        ans = min({abs(*slb - query) + min(abs(*tlb - *slb), abs(*tub - *slb)),
                   abs(*sub - query) + min(abs(*tlb - *sub), abs(*tub - *sub)),
                   abs(*tlb - query) + min(abs(*slb - *tlb), abs(*sub - *tlb)),
                   abs(*tub - query) + min(abs(*slb - *tub), abs(*sub - *tub))});

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

Measured memory_bytes: 3680
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[] = new int[n];

		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}

		long up = 0;
		long down = 0;
		long diffMin = 0;
		for (int i=0; i<n-1; i++){
			if (i==0){
				up = a[0];
				for (int j=1; j<n; j++){
					down += a[j];
				}
				diffMin = Math.abs(up - down);
			} else {
				up += a[i];
				down -= a[i];
				diffMin = Math.min(diffMin, Math.abs(up - down));
			}
		}
		System.out.println(diffMin);
	}

}


Measured memory_bytes: 65932
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
int n,a,b,i,j,str[100005];
int main()
{

    scanf("%d%d",&n,&a);
    for(i=0;i<n;i++)
        scanf("%d",&str[i]);
    b=0;
    for(i=0;i<n;i++)
    {
        if(str[i]>=a)
            b++;
    }
    printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 640
X, N = map( int, input().split() )
ret = X
if N > 0:
  P = sorted( list( map( int, input().split() ) ))
  dis = 10 ** 18
  for i in range( 110, -1, -1 ):
    if not i in P:
      if dis - abs( i - X ) >= 0:
        ret = i
        dis = abs( i - X )
  
print( ret )

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
class UnionFind{
private:
	vl data;
public:
	UnionFind(int size):data(size,-1){}
	bool unite(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x])swap(x,y);
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool find(int x,int y){
		return root(x)==root(y);
	}
	ll root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	ll size(int x){
		return -data[root(x)];
	}
};

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    vp w(m);
    cin>>w;
    REP(i,m){w[i].F--;w[i].S--;}
    UnionFind uf(n);
    vl res(m);
    res[m-1]=((ll)n)*(n-1)/2;

    for(int i=m-2;i>=0;i--){
        cerr<<i<<':';
        if(uf.find(w[i+1].F,w[i+1].S)){
            res[i]=res[i+1];
            //cerr<<"no changes"<<endl;
        }else{
            ll a=uf.size(w[i+1].F);
            ll b=uf.size(w[i+1].S);
            res[i]=res[i+1]-(a*b);
            //cerr<<a*b<<"decreased"<<endl;
            uf.unite(w[i+1].F,w[i+1].S);
        }
    }
    REP(i,m){
        cout<<res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = list( map( int, input().split()))
    ans = 0
    for i in range(N):
        if B[i] > A[i]:
            B[i] -= A[i]
            ans += A[i]
        else:
            ans += B[i]
            B[i] = 0
        if B[i] > A[i+1]:
            ans += A[i+1]
            A[i+1] = 0
        else:
            A[i+1] -= B[i]
            ans += B[i]
    print(ans)
if __name__ == '__main__':
    main()



Measured memory_bytes: 82020
#include<bits/stdc++.h>
using namespace std;
string side[4],Longitudinal[5];
void righ(int x,int y);
void lef(int x,int y);
void up(int x,int y);
void down(int x,int y);
void serch(int x,int y,int then);
int main()
{
    for(int i=0;i<4;i++)cin>>Longitudinal[i]>>side[i];
    cin>>Longitudinal[4];
    cout<<"R";
    serch(1,0,0);
}
void righ(int x,int y)
{
    if(x+1<5&&Longitudinal[y][x]=='1'){
        cout<<"R";
        serch(x+1,y,0);
    }
}
void lef(int x,int y)
{
    if(x-1>-1){
        if(Longitudinal[y][x-1]=='1'){
            cout<<"L";
            serch(x-1,y,2);
        }
    }
}
void up(int x,int y)
{
    if(y-1>-1){
        if(side[y-1][x]=='1'){
            cout<<"U";
            serch(x,y-1,3);
        }
    }
}
void down(int x,int y)
{
    if(y+1<5&&side[y][x]=='1'){
            cout<<"D";
            serch(x,y+1,1);
        }
}
int mox[2][4]={{0,1,0,-1},{0,0,0,-1}},moy[2][4]={{-1,0,1,0},{-1,0,0,0}};
char str[5]="URDL";
void serch(int x,int y,int then)
{
    if(then==-1)then=3;
    if(x==0&&y==0){
        cout<<endl;
        exit(0);
    }
    for(int i=0;i<4;i++){
        int now=(then+i)%4;
        if(now%2==0){
            if(y+moy[0][now]<5&&y+moy[0][now]>-1&&side[y+moy[1][now]][x]=='1'){
                cout<<str[now];
                serch(x,y+moy[0][now],now-1);
            }
        }
        else{
            if(x+mox[0][now]<5&&x+mox[0][now]>-1&&Longitudinal[y][x+mox[1][now]]=='1'){
                cout<<str[now];
                serch(x+mox[0][now],y,now-1);
            }
        }
    }
}

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

typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int MID = 1e5 + 3;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main(){
    speed;
    int n;
    cin >> n;
    str s;
    cin >> s;
    int cnt = 0;
    int m = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == '('){
            cnt++;
        }
        else{
            if(cnt){
                cnt--;
            }
            else{
                m++;
            }
        }
    }
    while(m--){
        cout << '(';
    }
    cout << s;
    while(cnt--){
        cout << ')';
    }
}

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

int main()
{
    int n; cin >> n;
    repd(i, 7){
        if (1<<i <= n) {
            cout << (1<<i) << endl;
            break;
        }
    }
}

Measured memory_bytes: 3568
#include <algorithm>
#include <iostream>
#include <tuple>

using namespace std;

int main() {
    int N;
    cin >> N;

    pair<int, int> x[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i].first;
        x[i].second = i + 1;
    }
    sort(x, x + N);

    int a[N * N + 1], now = 0;
    fill(a, a + N * N + 1, -1);
    // aは1-indexed 埋まってなければ-1
    // 今a[now]まで埋まっている

    for (int i = 0; i < N; ++i) {
        int idx, n;
        tie(idx, n) = x[i];
        a[idx] = n;

        for (int j = 0; j < n - 1; ++j) {
            while (true) {
                if (a[++now] < 0) {
                    a[now] = n;
                    break;
                }
            }
        }

        if (now > idx) {
            cout << "No" << endl;
            return 0;
        }
    }

    now = N * N + 1;
    for (int i = N - 1; i >= 0; --i) {
        int idx, n;
        tie(idx, n) = x[i];

        for (int j = n; j < N; ++j) {
            while (true) {
                if (a[--now] < 0) {
                    a[now] = n;
                    break;
                }
            }
        }

        if (now < idx) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i <= N * N; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	long long n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n + 1);
	vector<long long> b(m + 1);
	vector<long long> ans;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	for(int i = 1; i <= m; i++){
		cin >> b[i];
	}
	long long sm = 0, cntb = 0, cnta = 0;
	for(int i = 1; i <= m; i++){
		if(sm + b[i] > k) break;
		sm += b[i];
		cntb++;
	}
	ans.push_back(cntb);
	for(int i = 1; i <= n; i++){
		//cout << sm << endl;
		while(sm + a[i] > k && cntb > 0){
			sm -= b[cntb];
			cntb--;
		}
		//cout << cntb << endl;
		if(cntb <= 0 && sm + a[i] > k) break;
		cnta++;
		sm += a[i];
		ans.push_back(cnta + max(cntb, 0ll));
	}
	cout << *max_element(ans.begin(), ans.end()) << '\n';
}

Measured memory_bytes: 8372
import java.util.*;

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

    if(B/A>C){
		System.out.println(C);	    
    }else{
		System.out.println(B/A);	    
	}
}
}


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

const int N = 300, MOD = 1e9 + 7;

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

int n, m, f[N + 2][N + 2][N + 2];
vector<pair<int, int>> lim[N + 5];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, l, r, x; i <= m; ++i) {
		scanf("%d%d%d", &l, &r, &x);
		lim[r].push_back(make_pair(l, x));
	}
	f[1][0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (const auto &p : lim[i]) {
			int l = p.first, x = p.second;
			for (int j = 0; j < i; ++j) {
				for (int k = 0; k <= max(j - 1, 0); ++k) {
					if (x == 1 && j >= l) f[i][j][k] = 0;
					if (x == 2 && (k >= l || j < l)) f[i][j][k] = 0;
					if (x == 3 && k < l) f[i][j][k] = 0;
				}
			}
		}
		for (int j = 0; j < i; ++j) {
			for (int k = 0; k <= max(j - 1, 0); ++k) {
				Add(f[i + 1][j][k], f[i][j][k]);
				Add(f[i + 1][i][k], f[i][j][k]);
				Add(f[i + 1][i][j], f[i][j][k]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= max(i - 1, 0); ++j) {
			Add(ans, f[n][i][j]);
		}
	}
	printf("%lld\n", 3LL * ans % MOD);
	return 0;
}

Measured memory_bytes: 105856
#include <cstdio>
    #include <cmath>
     
    int main(void){
      long long a, b, c;
      scanf("%ld %ld %ld", &a, &b, &c);
      
      if(sqrtl(4*a*b) < c-a-b){
        printf("Yes");
      }else{
        printf("No");
      }
      
      
      return 0;
    }

Measured memory_bytes: 128
C = [list(map(int,input().split())) for i in range(3)]
p=C[0][1]-C[0][0]
q=C[0][2]-C[0][1]
b1,b2,b3 = 0,0,0

for i in range(-200,201):
  b2=i
  b3=q-b2
  b1=b2-p
  if C[0][0]-b1==C[0][1]-b2 and  C[0][0]-b1==C[0][2]-b3:
    if C[1][0]-b1==C[1][1]-b2 and  C[1][0]-b1==C[1][2]-b3:
      if C[2][0]-b1==C[2][1]-b2 and  C[2][0]-b1==C[2][2]-b3:
        print("Yes");exit()
  
print("No")

Measured memory_bytes: 38408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
    1.cpp
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    if(s[2]==s[3]&& s[4]==s[5]){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static string[] a;
	static bool[,] h;
	static long ans=0,b=0,c=0;
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		a=new string[s[0]+2];
		for(int i=1;i<=s[0];i++){a[i]="0"+Console.ReadLine()+"0";}
		a[0]=new string('0',s[1]+2);
		a[s[0]+1]=new string('0',s[1]+2);
		h=new bool[s[0]+2,s[1]+2];
		for(int i=1;i<=s[0];i++){
			for(int j=1;j<=s[1];j++){
				if(!h[i,j]){
					fu(i,j);
					ans+=b*c;
					b=0;c=0;
				}
			}
		}

		Console.WriteLine("{0}",ans);
	}
	static void fu(int y,int x){
		h[y,x]=true;
		if(a[y][x]=='#'){b++;}
		else{c++;}
		if((!h[y-1,x])&&a[y-1][x]!=a[y][x]&&a[y-1][x]!='0'){fu(y-1,x);}
		if((!h[y+1,x])&&a[y+1][x]!=a[y][x]&&a[y+1][x]!='0'){fu(y+1,x);}
		if((!h[y,x-1])&&a[y][x-1]!=a[y][x]&&a[y][x-1]!='0'){fu(y,x-1);}
		if((!h[y,x+1])&&a[y][x+1]!=a[y][x]&&a[y][x+1]!='0'){fu(y,x+1);}
	}
}

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

using namespace std;

int main()
{
  string s;

  cin >> s;

  for (int i = 0; i < 5; i++)
  {
    cout << s[i];
  }

  cout << " ";

  for (int i = 0; i < 7; i++)
  {
    cout << s[6 + i];
  }
  cout << " ";
  for (int i = 0; i < 5; i++)
  {
    cout << s[14 + i];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int sumOfDigits(int data){
  string s = to_string(data);
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    ans += s.at(i) - '0';
  }
  return ans;
}

int main(int argc, const char * argv[]) {
    
  // input from txt （提出時にこの箇所は削除すること）
  std::ifstream in("input.txt");
  std::cin.rdbuf(in.rdbuf());
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
 
  cin >> n;

  cout << (n%(sumOfDigits(n))==0 ? "Yes" : "No") << endl;
  return 0;
}


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

long long arr[100010];
int main()
{
    long long n;
    scanf("%lld", &n);
    for(long long i = 1;i <= n;++i)
        scanf("%lld", &arr[i]);
    long long ans = 0;
    long long cur = 1;
    for(long long i = 1;i <= n;++i)
    {
        if(arr[i] > cur)
        {
            if(arr[i] == cur)
                ++cur;
            else
            {
                ans += (arr[i] - 1) / cur;
                arr[i] = 1;
            }
        }
        cur = max(cur, arr[i] + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long X, Y;
  scanf("%ld %ld", &X, &Y);

  // solve
  if (abs(X - Y) <= 1) {
    printf("Brown\n");
  } else {
    printf("Alice\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

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

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(ALL(a),greater<ll>());
    ll m=a[0];
    vector<ll>dp(m+1,0);
    for(ll i:a){
        ++dp[i];
        for(ll j=2;i*j<=m;++j){
            ++dp[i*j];
        }
    }
    ll ans=0;
    for(ll i:a){
        if(dp[i]==1){
            ++ans;
        }
    }
    cout<<ans;
}
/*

*/


Measured memory_bytes: 12748
import numpy as np
import collections

n = int(input())
s = np.array([[str(i) for i in input().split()] for i in range(n)])
s = np.ravel(s)
ans = 0
sorted_list = [''.join(sorted(e)) for e in s]
# dict
c = collections.Counter(sorted_list)
for i in c.values():
  for j in range(0, i):
    ans += j

print(ans)

Measured memory_bytes: 38792
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;


int main() {
  int n, m;
  int a,b;
  scanf("%d %d", &n, &m);

  vector<vector<int> > neigh(n);

  for (int i=0;i<m;++i) {
    scanf("%d %d", &a, &b);
    --a;
    --b;
    
    neigh[a].push_back(b);
    neigh[b].push_back(a);
  }

  queue<int> q;
  vector<bool> vis(n);
  vector<int> parent(n, -1);
  parent[0] = 0;
  q.push(0);
  

  while (!q.empty()) {
    int next = q.front();
    q.pop();

    for (auto& it : neigh[next]) {
      if (!vis[it]) {
       vis[it] = true;
       q.push(it); 
       parent[it] = next;
      }
    }
  }

  bool exist = true;
  
  for (auto& it : parent) 
    exist = exist && (it != -1);

  if (!exist) {
    printf("No\n");
  } else {
    printf("Yes\n");
    for (int i=1;i<n;++i)
      printf("%d\n", parent[i] + 1);
  }

  return 0;
}


Measured memory_bytes: 9556
from collections import defaultdict
from bisect import bisect_left
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] -= 1
for i in range(n):
    a[i + 1] += a[i]
    a[i] %= k
a[i + 1] %= k
c = defaultdict(list)
for i in range(n + 1):
    c[a[i]].append(i)
ans = 0
for v in c.values():
    for i in range(len(v)):
        ans += bisect_left(v, v[i] + k) - i - 1
print(ans)


Measured memory_bytes: 137280
from bisect import bisect_right
x = int(input())
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
ass = primes(x+10000)
# ass = [-1*i for i in primes(x+1000)]
# ass.reverse()
i = bisect_right(ass, x)
if ass[i-1] == x:
    print(x)
else:
    print(ass[i])


Measured memory_bytes: 39536
n,m = map(int,input().split())
a = list(map(int,input().split()))
count = 0
judge = 0
for i in range(n):
  judge = judge + a[i]

judge = judge/(4*m)

for i in range(n):
  if a[i] >= judge:
    count = count+1

if count >= m:
  print('Yes')
elif count < m:
  print('No')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
  ifstream fIn("input.txt");
  if (fIn.is_open())
    cin.rdbuf(fIn.rdbuf());

  string S;
  cin >> S;
  map<string,int> week;
  week["SUN"] = 7;
  week["MON"] = 6;
  week["TUE"] = 5;
  week["WED"] = 4;
  week["THU"] = 3;
  week["FRI"] = 2;
  week["SAT"] = 1;

  cout << week[S] << endl;
}


Measured memory_bytes: 256
#g = []
g = gets.to_s.split(" ")

N = g[0].to_i
A = g[1].to_i
B = g[2].to_i

#S = []
S = gets.to_s.split("")

yosen1 = 0
yosen2 = 0
pass = []

for i in 0..N-1 do
	if S[i] == "a" && yosen1 < A + B then
		yosen1 = yosen1 + 1
		pass[i] = "Yes"
	elsif S[i] == "b" && yosen1 < A + B && yosen2 < B then
		yosen1 = yosen1 + 1
		yosen2 = yosen2 + 1
		pass[i] = "Yes"
	else
		pass[i] = "No"
	end
end

puts pass.join("\n")


Measured memory_bytes: 16764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;

  cin>>a>>b;

  c=a*b;
  
  if(c%2 == 1) 
  cout << "Odd" << endl;

  
  else 
  cout << "Even" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, a, b = map(int, input().split())

if a == 0:
    print(a)
    exit()

# 整数除算
m = n // (a+b)

# あまり
amari = n % (a+b)

# まずはあまりを除いた青の数
blue_num = m * a

if a > amari:
    blue_num += amari
elif a <= amari:
    blue_num += a

print(blue_num)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
using namespace std;

struct block
{
	const int num, count;
	block() : num(0), count(0) { }
	block(int n, int c) : num(n), count(c) { }
};

class integer
{
	stack<block> blocks;
	stack<int> sum;
	const int P;
	block pop()
	{
		auto x = blocks.top(); blocks.pop();
		sum.pop();
		return x;
	}
	void push(const block& b)
	{
		if (b.count == 0) return;
		auto p = length() > 0 && blocks.top().num == b.num ? block(b.num, b.count + pop().count) : b;
		blocks.emplace(p);
		sum.emplace(length() + p.count);
	}
public:
	integer(int n, int p) : P(p) { blocks.emplace(0, n); sum.emplace(0); sum.emplace(n); }
	void add(int c) { push(block(0, c)); }
	int length() const { return sum.top(); }
	void take(int c)
	{
		auto last = -1;
		while (length() > c) last = pop().num;
		if (length() < c) push(block(last, c - length()));
	}
	bool incr()
	{
		auto b = pop();
		auto x = b.num;
		auto n = b.count;
		if (x == P - 1 && length() == 0) return false;
		// y*m x*n => y*(m-1) (y+1)*1 0*n
		if (x == P - 1)
		{
			auto c = pop();
			auto y = c.num;
			auto m = c.count;
			push(block(y, m - 1));
			push(block(y + 1, 1));
			push(block(0, n));
		}
		// x*n => x*(n-1) (x+1)*1
		else
		{
			push(block(x, n - 1));
			push(block(x + 1, 1));
		}
		return true;
	}
};

int N;
vector<int> A;

bool check(int p)
{
	integer S(A[0], p);
	for (size_t i = 1; i < N; i++)
	{
		auto a = A[i];
		if (a > S.length()) S.add(a - S.length());
		else
		{
			S.take(a);
			if (!S.incr()) return false;
		}
	}
	return true;
}

int first_binary(int min, int max, function<bool(int)> pred)
{
	while (min < max)
	{
		auto mid = (min + max) / 2;
		if (pred(mid)) max = mid;
		else min = mid + 1;
	}
	return min;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		int x; cin >> x;
		A.push_back(x);
	}
	cout << first_binary(1, N, check) << endl;
    return 0;
}


Measured memory_bytes: 1400
// Lec08-B Sum of numbers
#include<iostream>
#include<string>
int main(){
  std::string str;
  int cnt;
  while(1){
    cnt = 0;
    std::cin >> str;
    if(str[0] == '0') break;
    for(int i=0; i<str.length(); i++) cnt += str[i] - '0';
    std::cout << cnt << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3164
n,a,b=map(int,input().split())
mod=10**9+7
c,d=1,1
for i in range(n-a+1,n+1):
    c=i*c%mod
for i in range(1,a+1):
    c=c*pow(i,mod-2,mod)%mod
for i in range(n-b+1,n+1):
    d=i*d%mod
for i in range(1,b+1):
    d=d*pow(i,mod-2,mod)%mod
print((pow(2,n,mod)-c-d-1)%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m, p[10];
vector<int> s[10];

int main() {
    cin >> n >> m;
    rep(i, m) {
        int k;
        cin >> k;
        s[i].resize(k);
        rep(j, k) cin >> s[i][j];
    }
    rep(i, m) { cin >> p[i]; }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int flag = true;
        rep(i, m) {
            int sum = 0;
            for (int j : s[i]) {
                if (bit >> (j - 1) & 1) {
                    sum++;
                }
            }
            if (sum % 2 != p[i]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

LL pow(LL a, LL b, LL MOD) {
    LL ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}

#define INF (int)1e9
#define EPS (1.0e-8)
// ------------------


int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int N, H[101010], dp[101010];
int main() {
    cin >> N;
    rep(i,N) cin >> H[i];
    rep(i,N) dp[i] = INF;
    dp[0] = 0;
    dp[1] = abs(H[0]-H[1]);
    REP(i,2,N){
        dp[i] = min(dp[i-2] + abs(H[i-2]-H[i]),dp[i-1] + abs(H[i-1]-H[i]));
    }
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    if (m == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void)
{
    long long num;
    long long product;
    int p_count;

    cin >> num >> product;

    if(num == 1){
        cout << product << endl;
        return 0;
    }

    long long common_divisor = 1;

    for(long long p = 2; p <= pow(product, (double)1 / num) + 0.9; p++){
        p_count = 0;
        while(product % p == 0){
            product /= p;
            p_count = p_count + 1;
            if(p_count >= num){
                common_divisor *= p;
                p_count = 0;
            }
        }

    }

    cout << common_divisor << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000

int int_sort(const void *a, const void *b) {
  if(*(int*)a < *(int*)b){
    return -1;
  }else if(*(int*)a == *(int*)b){
    return 0;
  }
  return 1;
}

int main(void){
	int N, M;
	int i, j;
	int a, b;
	int *result;
	int first[MAX_NUM] = {0};
	int second[MAX_NUM] = {0};
	int first_index, second_index;

	scanf("%d %d", &N, &M);
	first_index = 0; second_index = 0;
	for(i=0; i<M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1)
			first[first_index++] = b;
		if(b == N)
			second[second_index++] = a;
	}

	qsort((void*)first, first_index, sizeof(first[0]), int_sort);
	qsort((void*)second, second_index, sizeof(second[0]), int_sort);


	for(i=0; i<first_index; i++){
		result = (int *)bsearch(&first[i], second, second_index, sizeof(int), int_sort);
		if(result != NULL){
			printf("POSSIBLE");
			return 0;
		}
	}

	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 2172
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

sol :: Int -> [Int] -> Int
sol m (x:[]) = if m >= x then 1 else 0
sol m (x:xs) = if m >= x then 1 + sol x xs else sol m xs

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInt <$> BS8.getLine
    p <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

    print $ sol n p


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i=1;i<N-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int h,w;
  cin >> h >> w;
  vector<string> c(h);
  rep(i,h) cin >> c.at(i);
  rep(i,h){
    cout << c.at(i) << endl;
    cout << c.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n],s=0;
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++)
  {
    for(int j=n-1;j>i;j--)
    {
      s=s+a[i]*a[j];
    }
  }
  cout<<s;
  return 0;
}  
  

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int y, m = 0, d = 0;
	while(scan(y, m, d)) {
		int t = 10000 * y + 100 * m + d;
		if (t < 18680908) {
			outl("pre-meiji");
			continue;
		} else if (t < 19120730)
			out("meiji ",  y - 1867);
		else if (t < 19261225)
			out("taisho ", y - 1911);
		else if (t < 19890108)
			out("showa ",  y - 1925);
		else
			out("heisei ", y - 1988);
		outl(' ', m, ' ', d);
	}
}


Measured memory_bytes: 2412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };

signed main() {
	int n; cin >> n;
	int cnt = 0;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2 == 0)cnt++;
	}
	if (cnt !=n)puts("first");
	else puts("second");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int cnt[n+1]={0};
    for(int i=1;i<=k;i++)
    {
        int d;
        cin>>d;
        for(int j=1;j<=d;j++)
        {
            int x;
            cin>>x;
            cnt[x]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(cnt[i]==0)
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
vector<string> v;

void permute(string s, int start, int end){
	if(start == end) {
		v.push_back(s);
		return;
	}

	for(int i = start; i < end; i++){
		swap(s[start], s[i]);
		permute(s, start+1, end);
		swap(s[start], s[i]);
	}
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	string s;
	int n, x, y;
	cin >> n;
	for(int i = 1; i <= n; i++) s.push_back('0'+i);

	permute(s, 0, s.length());
	
	string a, b;
	for(int i = 0; i < n; i++){
		cin >> x;
		a.push_back('0'+x);
	}
	for(int i = 0; i < n; i++){
		cin >> x;
		b.push_back('0'+x);
	}
	sort(v.begin(), v.end());

	for(int i = 0; i < (int)v.size(); i++){
		if(a == v[i]) x = i;
		if(b == v[i]) y = i;
	}

	cout << abs(x - y);
}

Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    long long int X;
    long long int ans = 0;
    long long int n = 100;
    cin >> X;
    while(X > n) {
        ans += 1;
        n *= 1.01;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
S = input()

length =  len(S)

if (length == 1):
    print('0')
    exit()

if ((length % 2) == 1):
    rev = S[(length//2 + 1):][::-1]
    count = 0
    for i in range(len(rev)):
        if (S[i] != rev[i]):
            count += 1

if ((length % 2) == 0):
    rev = S[(length//2):][::-1]
    count = 0
    for i in range(len(rev)):
        if (S[i] != rev[i]):
            count += 1
print(count)

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line = read_as_vec::<u64>();
    let (n, mut h) = (line[0], line[1]);
    let isb = 0;
    let isa = 1;
    let mut katanas = vec![];

    for _ in 0..n{
        let line = read_as_vec::<u64>();
        katanas.push((line[0], isa));
        katanas.push((line[1], isb));
    }

    katanas.sort();
    katanas.reverse();

    let mut ans = 0;

    for &(damage, way) in &katanas{
        //throwing is more harmful than cutting
        if way == isb{
            ans += 1;
            if h > damage{
                h -= damage;
            }else{
                break;
            }
        //cutting is better;
        }else{
            ans += (h + (damage-1))/damage;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 9284
#include <stdio.h>
#include <string.h>
int main(){
    int a[100],b[100],i,ix;
    char op[100];
    i=0;
    while(1){
        scanf("%d",&a[i]);
        scanf("%s",&op[i]);
        scanf("%d",&b[i]);
        if(op[i]=='?'){
            ix=i;
            break;
        }
        i++;
    }
    for(i=0;i<ix;i++){
        if(op[i]=='+'){
            printf("%d\n",a[i]+b[i]);
        }else if(op[i]=='-'){
            printf("%d\n",a[i]-b[i]);
        }else if(op[i]=='*'){
            printf("%d\n",a[i]*b[i]);
        }else if(op[i]=='/'){
            printf("%d\n",a[i]/b[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 1852
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
ns = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    ns[a].append(b)
    ns[b].append(a)
    
def is_bip(ns):
    start = 0
    q = [start]
    cs = [None]*n
    cs[start] = 1
    while q:
        u = q.pop()
        c = cs[u]
        cc = int(not c)
        for v in ns[u]:
            if cs[v] is None:
                cs[v] = cc
                q.append(v)
            elif cs[v]==c:
                return False, None
    return True, cs

res, cs = is_bip(ns)
if res:
    n1 = sum(cs)
    n2 = n - n1
    ans = n1*n2 - m
else:
    ans = n*(n-1)//2 - m
print(ans)

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

int A, list[200001] = { 0 };

int main() {
	int N,  i;
	cin >> N;
	for (i = 0; i < N-1; i++) {
		cin >> A;
		A--;
		list[A]++;
	}
	for (i = 0; i < N; i++) cout << list[i] << endl;
}

Measured memory_bytes: 4372
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()
    last = 7 % n
    if last == 0:
        return 1

    m = {last: True}
    cnt = 1
    while True:
        nxt = (10 * last + 7) % n
        cnt += 1

        if nxt == 0:
            return cnt

        if m.get(nxt, False):
            return -1

        m[nxt] = True
        last = nxt


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 157652
import Control.Monad
import Control.Applicative
import Data.List

main = do
    s <- getLine
    
    putStrLn (f [] s)
    


f xs [] = xs
--f xs ('0':ss) = f (xs : "0") ss
--f xs ('1':ss) = f (xs : "1") ss
f xs (x:ss) = if (x == 'B') then
                             if (xs == [])
                             then f xs ss
                             else f (init xs) ss
              else f (xs ++ [x]) ss

Measured memory_bytes: 380