akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>                                                                                               

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
//#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;

signed main(){
    string s,t;
    queue <char> a,b;
    cin >> s >> t;
    int n = s.size();
    rep(i,n){
        a.push(s[n-1-i]);
        b.push(t[n-1-i]);
    }   
    bool flg = false;
    bool flgx = true;
    for(int i=0;i<n ;++i){
        bool flgy = true;
        for(int j=0;j<n;++j){
            if(a.front() != b.front()){
                flgy = false;
                break;
            }
            else{
                a.push(a.front());
                b.push(b.front());
                a.pop();
                b.pop();
            }
        }
        if(flgy){
            flg = true;
            break;
        }
        a.push(a.front());
        a.pop();
    }   
    if(flg) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


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

using namespace std;


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

  vector<int> A(N);

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



  int L1 = 0, L2 = 0;
  int id1 = 0, id2 = 1;

  for(int i = 0; i < N; i++){
    int temp;
    if(L2 < A[i]){
      L2 = A[i];
      id2 = i;
    }
    if(L1 < L2){
      temp = L1;
      L1 = L2;
      L2 = temp;
      id2 = id1;
      id1 = i;
    }
  }

  for(int i = 0; i < N; i++){
    if(i != id1){
      cout << L1 << endl;
    }
    else{
      cout << L2 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2432
#include<string.h>
#include<stdio.h>
int main()
{
  int n,ans=0;
  char s[10]={};
  scanf("%s",s);
  for(n=0;n<3;n++){
   if(s[n]=='1'){
     ans++;
   }
  }
  printf("%d",ans);            
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long hoge1 = n / (a + b);
        long hoge2 = n % (a + b);
        long count = 0;

        count = hoge1 * a;
        if(hoge2 >= a){
            count += a;
        }else{
            count += hoge2;
        }
        System.out.println(count);
        
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
int main(){
	int A;
	int B;
	
	scanf("%d %d", &A,&B);
	
	if(B%A==0){
		printf("%d\n", A+B);
	}else{
		printf("%d\n", B-A);
	}
	
	
	return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<bool> S(N,false);
  for(int i=0; i<K; i++){
    int p;
    cin>>p;
    for(int j=0; j<p;j++){
      int t;
      cin>>t;
      S.at(t-1)=true;
    }
  }
  int count=0;
  for(int i=0; i<N; i++){
    if(S.at(i)==false) count++;
  }
  cout<< count;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;


int main(){
 int h,w,n; cin>>h>>w>>n;
 int a[n];
 REP(i,n)cin>>a[i];
 
 int v[h][w];
  REP(i,h)REP(j,w)v[i][j]=0;
 int x=0;
 int y=0;
 
 REP(i,n){
    REP(j,a[i]){
       v[y][x]=i+1;  
      
     // cout<<"("<<y<<","<<x<<")"<<v[y][x]<<endl;
       if(x==w-1&&v[y][x-1]!=0)y++;
       else if(x==w-1&&v[y][x-1]==0) x--;
       else if(x==0&&v[y][x+1]!=0) y++;
       else if(x==0&&v[y][x+1]==0) x++;
       else if(v[y][x-1]==0) x--;
       else if(v[y][x+1]==0) x++;
   
       }
    }
 
   REP(i,h){
      REP(j,w)cout<<v[i][j]<<" ";
      cout<<endl;
   }

} 


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    long n;
    cin >> n;
    long long v[n],c[n];
    for(long i=0;i<n;i++){
        cin>>v[i];
    }
    for(long i=0;i<n;i++){
        cin>>c[i];
    }
    long sum = 0;
    for(long i=0;i<n;i++){
        if( c[i] < v[i]  ){
            sum += v[i] - c[i];
        }
    }
    
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){

	int h,a;
	cin>>h>>a;

	int ans = h/a;
	if(h%a!=0)
		ans++;

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
S = str(input())
months = ['01','02','03','04','05','06',
          '07','08','09','10','11','12']
front = S[:2]
back = S[2:]

if front in months and back in months:
    print("AMBIGUOUS")
elif (front not in months) and (back in months):
    print("YYMM")
elif (front in months) and (back not in months):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int n;
	
	while(cin>>n){
		
		int m=0;
		
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==n)m+=1;
					}
				}
			}
		}
		cout<<m<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b){
        puts("a < b");
    }else if (a > b){
        puts("a > b");
    }else{
        puts("a == b");
    }
    return 0;
    
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; ++i){cin >> x[i];}
    int res = INT32_MAX;
    for(int p=1; p<=100; ++p){
        int sum = 0;
        for(int i=0; i<n; ++i){
            sum += (p-x[i])*(p-x[i]);
        }
        res = min(res, sum);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int d[100100];
int n;
int main(){
	cin >> n;
	rep(i,n)cin >> d[i];
	sort(d,d+n);
	cout << d[n/2]-d[n/2-1] << endl;
	return 0;
}

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

int main() {
  int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  ll pn[a+1];rep(i,a)cin>>pn[i];
  ll qn[b+1];rep(i,b)cin>>qn[i];
  ll rn[c];rep(i,c)cin>>rn[i];
  pn[a]=1e9+7;
  qn[b]=1e9+7;
  
  sort(pn,pn+a);
  sort(qn,qn+b);
  sort(rn,rn+c);
  
  int red=a-x,green=b-y,non=c;
  while (non>0) {    
    if (rn[non-1] < pn[red] && rn[non-1] < qn[green]) break;
    
    if (red < a && pn[red] <= qn[green]) {
      red++;non--;
    } else if (green < b && qn[green] <= pn[red]) {
      green++;non--;
    } else break;
    
  }
  
  ll total=0;
  for(int i=red;i<a;i++) total+=pn[i];
  for(int i=green;i<b;i++) total+=qn[i];
  for(int i=non;i<c;i++) total+=rn[i];
  cout<<total;
}


Measured memory_bytes: 2560
N, K, Q = [int(_) for _ in input().split()]

A = []
for _ in range(Q):
  A.append(int(input()) - 1)

score = [K - Q] * N

for i in range(len(A)):
  score[A[i]] += 1

for i in range(len(score)):
  if score[i] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 56024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
    	static int cnt = Integer.MAX_VALUE;
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	
        		String S = in.next();
        		String T = in.next();
        		
        		
        		int min = Integer.MAX_VALUE; 
        		
        		for(int i = 0; i <= S.length() - T.length(); i++){
        			String str = S.substring(i, i+T.length());
        			int cnt = 0;
        			for(int j = 0; j < str.length(); j++){
        				if(str.charAt(j) != T.charAt(j))
        					cnt++;
        			}
        			min = Math.min(cnt, min);
        		}
        		
        		out.print(min);
        }
        
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 33252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if (max(A, B) == A) {
      ans += A;
      A--;
    }
    else if (max(A, B) == B) {
      ans += B;
      B--;
    }
  }
  cout << ans << endl;
}

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

const int INF = 1e9;
const int N = 3e5 + 5;

struct node_t {
  int lo, hi, add_tag = 0, max_val = 0;
  
  void add(int tag) {
    add_tag += tag;
    max_val += tag;
  }
  
  void pushdown(node_t &lhs, node_t &rhs) {
    if (add_tag == 0) return;
    lhs.add(add_tag);
    rhs.add(add_tag);
    add_tag = 0;
  }

  void maintain(node_t &lhs, node_t &rhs) {
    max_val = max(lhs.max_val, rhs.max_val);
  }
};

struct seg_t {
  vector<node_t> seg;
  seg_t(int n) : seg(n + n) {
    int k = 1;
    while (k < n) k = k + k;
    int m = n + n - k, s = k - n;
    for (int i = 0; i < m; i++) seg[i + k] = {i, i + 1, 0};
    for (int i = m; i < n; i++) seg[i + s] = {i, i + 1, 0};
    for (int i = n - 1; i; i--) seg[i] = {seg[i + i].lo, seg[i + i + 1].hi, 0};
  }
  template <class Fn> void run(int l, int r, Fn &&fun, int i = 1) {
    if (r <= seg[i].lo || seg[i].hi <= l) return;
    if (l <= seg[i].lo && seg[i].hi <= r) return fun(seg[i]);
    seg[i].pushdown(seg[i + i], seg[i + i + 1]);
    run(l, r, fun, i + i);
    run(l, r, fun, i + i + 1);
    seg[i].maintain(seg[i + i], seg[i + i + 1]);
  }
  
  int query_max(int l, int r) {
    node_t res;
    res.max_val = -INF;
    run(l, r, [&](node_t &node) { res.maintain(res, node); });
    return res.max_val;
  }
  
  void add(int i, int val) { run(i, i + 1, [&](node_t &node) { node.add(val); }); }
  
  void update(int i, int val) { 
    int original = query_max(i, i + 1);
    // cout << original << endl;
    if (val > original) add(i, val - original);
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  seg_t seg(N);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int new_ans = seg.query_max(max(0, a - k), a + k + 1) + 1;
    // cout << new_ans << endl; 
    seg.update(a, new_ans);
    ans = max(ans, new_ans);

    // for (int j = 0; j < 15; j++) {
    //     cout << seg.query_max(j, j + 1) << " ";
    // }
    // cout << endl;
  }
  cout << ans;
//   cin >> n;
}

Measured memory_bytes: 12748
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
map<int,int> my;
int A[N+5];
int main()
{
  finp;
  cin>>n;
  afor(i,1,n)
  {
    cin>>A[i];
    my[A[i]]=i;
  }
  sort(A+1,A+n+1);

  int ans=0;

  for(int i=1;i<=n;i+=2)
  {
    if(my[A[i]]%2 == 0)++ans;
  }

  cout<<ans;
  
return 0;
}

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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 


from collections import deque
def bfs(g,root,memo,backtrack):
    q = deque()
#    """初期化、キューに入れて訪問済みにする"""
    memo[root] = 0
    q.append(root)
    """BFS"""
    while q: #キューが空になるまで
        v = q.popleft() #キューから情報を取り出す
        for c in g[v]:
            if memo[c] > 0: continue #訪問済みならスキップ
            # 訪問済みにしてキューに入れる
            memo[c] = memo[v] + 1
            backtrack[c] = v
            q.append(c)

##############################            

n,m = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]

for _ in range(m):
    a,b = [int(i)-1 for i in readline().split()]
    g[a].append(b)

res = 1000000
v0 = -1
b0 = None

for v in range(n):
    memo = [-1]*n
    backtrack = [-1]*n
    bfs(g,v,memo,backtrack)
    if 1 < memo[v] < res:
        v0 = v
        b0 = backtrack
        res = memo[v]

#print(res,v0,b0)

if res == 1000000: print(-1)
else:
    i = b0[v0]
    ans = [i+1]
    while i != v0:
        i = b0[i]
        ans.append(i+1)
    ans.reverse()
    
    print(res)
    print(*ans,sep="\n")



Measured memory_bytes: 44252
h,w = map(int,input().split())
num = []
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] =='#':
            num.append(j+1)
            
for i in range(len(num)-1):
    if num[i] == num[i+1] or num[i]+1 == num[i+1]:
        continue
    else:
        print('Impossible')
        exit()
print('Possible')


Measured memory_bytes: 3060
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int x = int.Parse(Console.ReadLine());
        bool flag;
        while (true)
        {
            flag = true;
            for (int i = 2; i < x / 2; i++)
            {
                if (x % i == 0)
                {
                    flag = false;
                }
            }
            if (flag)
                break;
            else
                x++;
        }
        Console.WriteLine(x);
    }
}

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

int main()
{
     int T,n,i;
     
     cin>>n;
     long long int arr[n],sum;

     for(i=0;i<n;i++)
     {
          cin>>arr[i];
     }

     sort(arr,arr+n,greater<int>());

     //cout<<"\n";
     int y=0,x=0;
     sum=0;
     for(i=1;i<n;i++)
     {
          //cout<<arr[i]<<"  ";
          if(i==1)
               sum+=arr[x];
          else
          {
               if(y==0)
               {
                    x++;
                    sum+=arr[x];
                    y++;
               }
               else
               {
                    sum+=arr[x];
                    y=0;
               }
          }
     }   
     cout<<sum<<"\n";  

     return 0;
}

Measured memory_bytes: 5180
a;b;main(t){
    scanf("%d%d",&a,&b);
    t=b;
    while(t)t/=10,a*=10;
    a+=b;    
    
    /*if(pow((int)sqrt((float)a),2)==(float)a)
        printf("Yes");
    else
        printf("No");
        */
    printf((pow((int)sqrt((float)a),2)==(float)a)?"Yes":"No");
}

Measured memory_bytes: 2128
def main() -> None:
    a, b, c, d = map(int, input().split())
    if abs(a - b) <= d and abs(b - c) <= d:
        print("Yes")
    elif abs(a - c) <= d:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

x,k,d = nm()

if abs(x) > d*k:
  print(abs(x)-d*k)
  exit()

import math


if (abs(x)//d)%2==0:
  if k%2==0:
    print(abs(x)%d)
  else:
    print(d-abs(x)%d)
else:
  if k%2==0:
    print(d-abs(x)%d)
  else:
    print(abs(x)%d)
  
    
  
  

Measured memory_bytes: 9044
#include <stdio.h>

int main(){
  int N,P,min,ans=1;
  scanf("%d",&N);
  scanf("%d",&min);
  for(int i=1;i<N;i++){
    scanf("%d",&P);
    if(P<min){
      min=P;
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 605;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int dp[MAXN][MAXN][MAXN];
int n, a[MAXN], t, p, brak;
int chk[MAXN];
pi stk[MAXN];

lint f(int pos, int h, int count_up){
	if(pos == 0) return h == 0 && count_up == 0;
	if(~dp[pos][h][count_up]) return dp[pos][h][count_up];
	lint ret = 0;
	if(stk[pos-1].second == 1){
		// we use up stack
		if(count_up > 0) ret += f(pos - 1, h, count_up - 1) * count_up;
		// we don't. this is wasted.
		ret += f(pos - 1, h + 1, count_up); // and need debt
	}
	else{
		ret += f(pos - 1, h + 1, count_up); // we show now. (one surplus needed)
		if(h > 0) ret += f(pos - 1, h - 1, count_up); // we waste, and pay off debt.
		ret += f(pos - 1, h, count_up + 1); // we MUST show in stack.
	}
	return dp[pos][h][count_up] = ret % mod;
}

int main(){
	cin >> n;
	for(int i=0; i<2*n; i++){
		cin >> a[i];
		if(~a[i]) chk[a[i]] = 1;
	}
	for(int i=1; i<=2*n; i++){
		if(!chk[i]) stk[p++] = pi(i, 0); 
	}
	for(int i=0; i<2*n; i+=2){
		if(a[i] > a[i+1]) swap(a[i], a[i+1]);
		if(a[i+1] < 0){
			brak++;
		}
		else if(a[i] < 0){
			t++;
			stk[p++] = pi(a[i+1], 1);
		}
	}
	sort(stk, stk + p);
	memset(dp, -1, sizeof(dp));
	reverse(stk, stk + p);
	lint ret = f(p, 0, 0);
	for(int i=1; i<=brak; i++) ret = ret * i % mod;
	cout << ret << endl;
}



Measured memory_bytes: 865280
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[] W = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        
        int S1 = Arrays.stream(W).sum();
        int S2 = 0;

        int min = Math.abs(S1 -S2);
        for(int i = 0; i < N; i++){
            S1 -= W[i];
            S2 += W[i];
            min = Math.min(min, Math.abs(S1 - S2));
        }
        
        System.out.println(min);
    }
}


Measured memory_bytes: 26580
#include <cstdio>

using namespace std;

int a[100000];
int f[100000];

int main() {
    int n, m, ans = 0, i;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n; i++) a[i] = 1;
    f[0] = 1;
    
    for (i = 0; i < m; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        a[x]--;
        a[y]++;
        
        if (f[x] == 1) f[y] = 1;
        if (a[x] == 0) f[x] = 0;
    }
    
    for (i = 0; i < n; i++) ans += f[i];
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 896
//A - Rainy Season
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  char x[3];
  scanf("%s", x);
  x[3]='\0';

  if(x[0]=='S' && x[1]=='S' && x[2]=='S' ){
    printf("0\n");
  }
  else if(x[0]=='S' && x[1]=='S' && x[2]=='R' ){
    printf("1\n");
  }
  else if(x[0]=='S' && x[1]=='R' && x[2]=='S' ){
    printf("1\n");
  }
  else if(x[0]=='S' && x[1]=='R' && x[2]=='R' ){
    printf("2\n");
  }
  else if(x[0]=='R' && x[1]=='S' && x[2]=='S' ){
    printf("1\n");
  }
  else if(x[0]=='R' && x[1]=='S' && x[2]=='R' ){
    printf("1\n");
  }
  else if(x[0]=='R' && x[1]=='R' && x[2]=='S' ){
    printf("2\n");
  }
  else if(x[0]=='R' && x[1]=='R' && x[2]=='R' ){
    printf("3\n");
  }

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstring>

using namespace std;

int map[21][21];

int main(){
	int n, x, y, ans, m, sx, sy;
	char d;
	while(cin >> n, n){
		ans = 0;
		memset(map, 0, sizeof(map));
		for(int i = 0;i < n;++i){
			cin >> x >> y;
			map[y][x]++;
		}
		cin >> m;
		sx = sy = 10;
		for(int i = 0;i < m;++i){
			cin >> d >> x;
			for(int j = 0;j < x;++j){
				switch (d) {
					case 'N':
						++sy;
						break;
					case 'E':
						++sx;
						break;
					case 'S':
						--sy;
						break;
					case 'W':
						--sx;
						break;
					default:
						break;
				}
				if(map[sy][sx]){
					ans += map[sy][sx];
					map[sy][sx] = 0;
				}
			}
		}
		cout << (ans == n ? "Yes" : "No") << endl;
	}
	return 0;
}



Measured memory_bytes: 3052
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.next().split("");
    String[] T = sc.next().split("");
    int count = 0;
    for (int i = 0; i < S.length; i++) {
      if (!S[i].equals(T[i])) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 57388
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int i;
  for(i=1;i<s.length();i++)
  {
    if(s[i]!=s[i-1])
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

int main()
{
    int p,k,a[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
    int b[10];
    char n[10];
    scanf("%s%d",&n,&k);

    int l=strlen(n);
    int mx=-1;
    for(int i=0; i<l; i++)
    {
        int temp=n[i]-48;
        if(temp>=mx)
            mx=temp;
    }


    for(int i=0; i<k; i++)
    {
        scanf("%d",&p);
        a[p]=5;
    }
    int t=0;
    for(int i=0; i<10; i++)
    {
        if(a[i] == -1)
            b[t++]=i;

    }

    if(mx>b[t-1])
    {
        if(b[0]==0)
        {
            printf("%d",b[1]);
            for(int i=1; i<=l; i++)
                printf("0");
            printf("\n");
        }
        else
        {
            for(int i=1; i<=l+1; i++)
                printf("%d",b[0]);
            printf("\n");
        }

    }
    else
    {
        int countt=0,ctt=0;
        for(int i=0; i<l; i++)
        {
            int q=n[i]-48;
            for(int j=0; j<t; j++)
            {
                if(b[j]==q)
                {
                    printf("%d",q);
                    countt++;
                    break;
                }
                else if(b[j]>q)
                {
                    printf("%d",b[j]);
                    for(i=1; i<=(l-countt-1); i++)
                        printf("%d",b[0]);
                    printf("\n");
                    ctt=1;
                    break;
                }


            }
            if(ctt==1)
                break;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> in(n);
    int i;
    rep(i, n) {
        cin >> in[i];
    }
    int cnt(0);
    rep(i, n) {
        if (i % 2 == 0 && in[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int):
    if A <= 8 and B <= 8:
        print("Yay!")
    else:
        print(":(")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int num=0,n,a[200004];
int main(){
	cin>>n;for(int i=0;i<n;i++)cin>>a[i],num^=a[i];
	for(int i=0;i<n;i++)cout<<(num^a[i])<<" ";
}

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

//降順
int s_dsort(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(void) {

	int  N,K;
	unsigned long cnt=0;
	int  i;

//入力
    scanf("%d %d",&N,&K);
    if(N<=K)
    {printf("\n 0 \n");return 0;}

    int  H[N];
    for(i=0;i<N;i++)
	    scanf("%d",&H[i]);

//降順に並べる
    if(K)
	  qsort((void*)H,N,sizeof(int),s_dsort);

//やっつける！
	for(i=K;i<N;i++)
		cnt+=(unsigned long)H[i];
	printf("%lu\n",cnt);
	return 0;
}



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

typedef struct{
  int root,left,right;
} Node;
Node T[25];

int getHeight(int id){
  int l=-1,r=-1;
  if(T[id].left!=-1)l=getHeight(T[id].left);
  if(T[id].right!=-1)r=getHeight(T[id].right);
  return 1+max(l,r);
}

int getParent(int id){
  return T[id].root;
}

int getSibling(int id){
  int r=T[id].root;
  if (r==-1)return -1;
  if (T[r].left==id)return T[r].right;
  return T[r].left;
}

int getDegree(int id){
  int c=0;
  if (T[id].left!=-1) c++;
  if (T[id].right!=-1) c++;
  return c;
}

int getDepth(int id){
  int i=id,count=0;
  while(T[i].root!=-1){
    i=T[i].root;
    count++;
  }
  return count;
}
int getType(int id){
  if (T[id].root==-1)return 0;
  if (T[id].left==-1&&T[id].right==-1)return 2;
  return 1;
}

int main(){
  int n,id,cl,cr;
  char *types[]={(char*)"root",(char*)"internal node",(char*)"leaf"};
  
  for (int i=0;i<25;i++){
    T[i].root=-1;
    T[i].left=-1;
    T[i].right=-1;
  }

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> id >> cl >> cr;
    T[id].left=cl;
    T[id].right=cr;
    if(cl!=-1)T[cl].root=id;
    if(cr!=-1)T[cr].root=id;
  }
  for(int i=0;i<n;i++){
    cout << "node "<< i << ": ";
    cout << "parent = "<< getParent(i) <<", ";
    cout << "sibling = " << getSibling(i) << ", ";
    cout << "degree = " << getDegree(i) << ", ";
    cout << "depth = " << getDepth(i) << ", ";
    cout << "height = " << getHeight(i) << ", ";
    cout << types[getType(i)] <<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import copy
 
n, t = map(int, input().split())
L = [int(i) for i in input().split()]

LL = [[0] for i in range(n)]
tmax = L[-1]
for i in range(n):
  if tmax <= L[-i-1]:
    tmax = L[-i-1]
  LL[-i-1] = tmax
 
minvalue = L[0]
maxvalue = LL[0]
subt = 0
count = 1
flag = 0
flagg = 0
j = 0
for i in range(n-1):
  if minvalue > L[i]:
    minvalue = L[i]
    flag = 1
  
  maxvalue = LL[i]
 
  #if maxvalue == L[i]:
    #LL = LL[i-j+1:]
    #maxvalue = max(LL)
    #j = i+1
 
  tsubt = maxvalue - minvalue
  if tsubt > subt:
    subt = tsubt
    count = 1
  elif tsubt == subt and flag == 1:
    count += 1
  flag = 0
  #print("L[i]:{0}, min:{1}, max:{2}, subt:{3}, count:{4}".format(L[i], minvalue, maxvalue, subt, count))
 
print(count)

Measured memory_bytes: 18140
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;


int main(int argc, char* argv[]){
	long long A;
	double B;


	long long pows[7]={1000000000000000,
									100000000000000,
									10000000000000,
									1000000000000,
									100000000000,
									10000000000,
									1000000000};

	scanf("%lld %lf", &A, &B);

	long long A_n[5];
	long long A_digit = A;
	for(int i=0; i<5;i++){
		A_n[i] = A_digit/pows[i];
		A_digit -= A_n[i]*pows[i];
	}
	long long A_left = A;
	for(int i=0; i<5;i++){
		A_left -= A_n[i]*pows[i];
	}
	long long B_100 = (long long)(B*100.0+0.1);

	long long B_n[5];
	for(int i=0; i<5;i++){
		B_n[i] = A_n[i] * B_100 * pows[i+2];
	}

	double B_left_d = (double)A_left*B;
	long long B_left_ll = (long long)B_left_d;

	long long ans = B_left_ll;
	for(int i=0; i<5;i++){
		ans += B_n[i];
	}
//	printf("%lld, %lld\n", B_100, A_left);
//	for(int i=0; i<5;i++){
//		printf("%lld %lld\n", A_n[i], B_n[i]);
//	}
//	printf("%lf\n", B_left_d);
	printf("%lld\n", ans);




	return 0;
}







Measured memory_bytes: 3828
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in A:
    if i<=399:
        B.append(1)
    elif i<=799:
        B.append(2)
    elif i<=1199:
        B.append(3)
    elif i<=1599:
        B.append(4)
    elif i<=1999:
        B.append(5)
    elif i<=2399:
        B.append(6)
    elif i<=2799:
        B.append(7)
    elif i<=3199:
        B.append(8)
    else:
        C.append(1)

D=set(B)
minans=len(D)
if C:
    maxans=len(C)+minans
else:
    maxans=minans
    
print(max(minans,1), maxans)
    

Measured memory_bytes: 3064
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 t = sc.nextInt();
		
		// ビスケットの合計枚数
		int number = ((t-(t%a))/a)*b;
		
		// 出力
		System.out.println(number);
	}
}


Measured memory_bytes: 21460
import sys
import math
import numpy as np
import copy
import heapq
import queue

# Pythonのheapqはmin-heapを提供する
# max-heapを利用するにはどうすればよいか？→数値であれば、マイナスを入れればよい。
def main():
    n, m = [int(t) for t in input().split()]
    a = [int(t) for t in input().split()]
    b = [-x for x in a]
    heapq.heapify(b)
    for i in range(m):
        x = heapq.heappop(b) * -1
        heapq.heappush(b, (x // 2) * -1)
    print(-1 * sum(b))
    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
typedef pair<ll, ll> Pair;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define FIND(x,key) x.find(key) != x.end()
#define IN_RANGE_V2(v,k,x,y) (0<=x+dx[k]&&x+dx[k]<v[y].size()&&0<=y+dy[k]&&y+dy[k]<v.size())
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(a) REPALL(__i,a) {cout<<a[__i]<<(__i != a.size()-1 ? " " : "");} newline;
#define PRINT_ARRAY_V(a) REPALL(__i,a) {cout<<a[__i]<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};
//const VI dx = {1, 1, 0, -1, -1, -1, 0, 1};
//const VI dy = {0, 1, 1, 1, 0, -1, -1, -1};

VLL dp, a, b;
ll n;

void solve()
{
    cin>>n;
    a.resize(n); dp.resize(n+1);
    REP(i,n) cin>>a[i];
    b.push_back(0);
    RFOR(i,n,0) {
        if (b.size() % 2 == 1) {
            if (b[b.size()-1] < a[i])
                b.push_back(a[i]);
            else if (b[b.size()-1] > a[i]) {
                b[b.size()-1] = a[i];
            }
        } else if (b.size() % 2 == 0) {
            if (b[b.size()-1] > a[i])
                b.push_back(a[i]);
            else if (b[b.size()-1] < a[i])
                b[b.size()-1] = a[i];
        }
    }
    if (b.size() % 2 == 0) b.pop_back();
    //PRINT_ARRAY_H(b);
    if (b.size() < 3) {
        cout<<1000<<endl;
        return;
    }
    ll m = 1000ll, k = 0ll;
    RFOR(i,b.size(),b.size()%2) {
        if ((b.size()-i) % 2 == 1) {
            k += m / b[i];
            m = m % b[i];
        } else {
            m += k * b[i];
            k = 0;
        }
    }
    cout<<m<<endl;
}

int main()
{
    cout<<fixed<<setprecision(20);
    int __t = 1;
    //cin>>__t;
    REP(i,__t) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define read(n) scanf("%d",&n);
#define readll(n) scanf("%lld",&n);
#define readdb(n) scanf("%lf",&n);
#define readch(n) scanf("%c",&n);
#define readstr(n) scanf("%s",n);
#define test printf("test\n");
#define init(n , i) memset(n,i,sizeof(n));

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
bool cmp (int a , int b){
	return a>b;
}

int main(){
	string a;
	cin >> a;
	for(int i = 1 ; i <= 9 ; i ++){
		string t = "";
		for(int j = 0 ; j < 3 ; j ++){
			t+=('0'+i);
		}
		if(t >= a){
			cout << t << endl;
			return 0;
		}
	}
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 return 0; 
}












Measured memory_bytes: 256
//#pragma GCC optimize "O3"

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
const long long TEN16 = 10000000000000000;

int main() {
  long long k;
  cin >> k;
  long long n = 50;
  cout << n << endl;
  vector<long long> ans(n);

  long long shou = k / n;
  long long amari = k % n;

  for (int i = 0; i < n; i++) {
    ans[i] = i + shou;
  }

  for (int i = 0; i < amari; i++) {
    ans[i] += n+1;
    for (int j = 0; j < n; j++) {
      ans[j] -= 1;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 16;
const int N = 1 << maxn;
const int mod = 1e9 + 7;
typedef long long ll;
inline void reduce(int & x) { x += x >> 31 & mod; }
int t[N], dp[N], fac[N | 1], ifac[N | 1], inv[N | 1];
std::vector<int> v;
inline int A(int n,int m) { return n >= m ? (ll) fac[n] * ifac[n - m] % mod : 0; }
int n, m;
int main() {
	std::cin >> n >> m;
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for(int i = 2;i <= N;++i) {
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (ll) fac[i - 1] * i % mod;
		ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
	}
	for(int i = 0,x;i < m;++i) std::cin >> x, v.push_back(x - 1);
	const int o = 1 << n;
	std::reverse(v.begin(), v.end());
	dp[0] = 1;
	for(int x : v) for(int i = o - 1;i >= 0;--i) for(int j = 0;j < n;++j) if(!(i >> j & 1)) {
		dp[i | 1 << j] = (dp[i | 1 << j] + ((ll) dp[i] * A(o - x - i - 1,(1 << j) - 1) % mod << j)) % mod;
	}
	ll ans = 0;
	for(int i = 1;i < o;++i) {
		int sum = 0;
		for(int j = 0;j < n;++j) if(!(i >> j & 1)) sum += 1 << j;
		dp[i] = (ll) dp[i] * fac[sum] % mod;
		ans += __builtin_popcount(i) & 1 ? dp[i] : -dp[i];
	}
	std::cout << (fac[1 << n] - (ans << n) % mod + mod) % mod << '\n';
}


Measured memory_bytes: 1280
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,t,p,k;
    cin>>a>>b;
    c=0;
    for(i=0;i<a+1;i++){
        if(i+a*2<b)
        continue;
        for(j=0;j<a+1;j++){
            if(b<=i+j+a&&i+j<=b)
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

string S;

void solve() {
	cin >> S;
	bool ok = true;
	rep(i, 0, 3) {
		if(S[i] == S[i + 1]) ok = false;
	}
	if(ok) cout << "Good\n";
	else cout << "Bad\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=202202;
int a[N];
int n;
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	for (int i=1; i<=n; i++)
		if (a[i]%2==0){
			if (a[i]%3!=0&&a[i]%5!=0){
				printf("DENIED\n");	
				return 0;
			}
		}
	printf("APPROVED\n");
	return 0;
}

Measured memory_bytes: 128
//ABC110 A-train
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;cin >> N >> K;
    if(N == K | N % K == 0){
        cout << 0 << endl;
        }
    else{
        cout << 1 << endl;
    }
    return 0;
}

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	string s;
	cin>>s;

	vector<int> red(n+1);
	vector<int> white(n+2);

	for(int i=0; i<n; i++)
	{
		if(s[i]=='R') red[i+1]++;
		else white[i+1]++;
	}

	for(int i=2; i<=n; i++)
	{
		red[i]+=red[i-1];
	}

	for(int i=n-1; i>=1; i--)
	{
		white[i]+=white[i+1];
	}

	int ans=1e9;

	for(int i=0; i<=n; i++)
	{
		// make the first i red

		int val1=i-red[i];
		int val2=(n-i)-white[i+1];

		ans = min(ans, max(val1,val2));
	}

	cout << ans << endl;
}

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

using namespace std;

long long dp[1000][1000];

const int mod = 1e9 + 7;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++)
		cin >> a[i];
	dp[0][0] = 1;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			if (i + 1 != h && a[i + 1][j] == '.')
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
			if (j + 1 != w && a[i][j + 1] == '.')
				dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
		}
	cout << dp[h - 1][w - 1] % mod << endl;

	return 0;
}


Measured memory_bytes: 9088
s=int(input())
mod=10**9+7
n=(s+2)//3

dp=[[0]*(s+1) for _ in range(n+1)]
ans=0
dp[0][0]=1

for i in range(n):
    for j in range(3,s+1):
        dp[i+1][j]=dp[i][j-3]+dp[i+1][j-1]
        dp[i+1][j]%=mod
    
    ans+=dp[i+1][s]
    ans%=mod

print(ans)

Measured memory_bytes: 71300
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if max(A, B) > 8:
        ret = ':('
    else:
        ret = 'Yay!'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main(void){
	int n, k, i;
	scanf("%d%d", &n, &k);
	double ans;
	for(i=1; i<=n; i++){
		int j=i;
		int f=1;
		while(j<k){j<<=1; f<<=1;}
		ans += 1/((double)f);
	}
	printf("%.9lf\n", ans/n);
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program{
    public static int[] array;
    public static int[] rank;
    public static void Main(){
        var reader = Console.In;
        var nq = reader.ReadLine().Split().Select(int.Parse).ToArray();
        int N = nq[0], Q = nq[1];
        array = Enumerable.Range(0, N).ToArray();
        rank = Enumerable.Repeat(1, N).ToArray();
        for(int i=0; i<Q; i++){
            var info = reader.ReadLine().Split().Select(int.Parse).ToArray();
            int query = info[0], a = info[1], b = info[2];
            if(query==0) Union(a, b);
            else{
                if(Same(a, b))Console.WriteLine("1");
                else Console.WriteLine("0");
            }
        }
    }

    //return the parrent of the group(array[target])
    public static int Find(int target){
        /*
        not root compression version
        while(target!=array[target]){
            target = array[target];
        }
        */
        //root compression version
        if(target!=array[target]){
            array[target] = Find(array[target]);
        }
        return array[target];
    }

    //if differ parrent of b from parrent of a
    public static void Union(int a, int b){
        var parent_a = Find(a);
        var parent_b = Find(b);
        if(parent_a!=parent_b){
            //join lower rank side to heigher
            if(rank[parent_a]<rank[parent_b]){
                array[parent_a] = parent_b;
            }else{
                array[parent_b] = parent_a;
                //update rank of lower side
                rank[parent_a]++;
            }
        }
    }

    //parrent of a and thats b is same?
    public static bool Same(int a, int b){
        if(Find(a)!=Find(b))return false;
        return true;
    }
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    ll ans = 0;
    UnionFind u(h*w);
    vector<vector<int>> id(h, vector<int>(w));
    int index = 0;
    rep(i, h) rep(j, w) {
        id[i][j] = index++;
    }

    rep(i, h) rep(j, w) {
        int x = id[i][j];
        rep(k, 4) {
            int ii = i + dx[k];
            int jj = j + dy[k];
            if (ii<0 || ii>=h || jj<0 || jj>=w) continue;
            int y = id[ii][jj];
            if (s[i][j]!=s[ii][jj]) {
                u.unite(x, y);
            }
        }
    }
    vector<pair<ll, ll>> p(h*w);
    rep(i, h) rep(j, w) {
        int x = id[i][j];
        int z = u.find(x);
        if (s[i][j]=='#') p[z].first++;
        else p[z].second++;
    }
    rep(i, h*w) {
        ans += p[i].first * p[i].second;
    }
    
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 7160