akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, N-1)
		for j := 0; j < N-1; j++ {
			A[i][j] = sc.nextInt() - 1
		}
	}
	next := make([]int, N)
	que := &Queue{}
	for i := 0; i < N; i++ {
		que.push(Node{i})
	}
	ans := 0
	for !que.isEmpty() {
		que2 := &Queue{}
		done := make([]bool, N)
		ok := false
		for !que.isEmpty() {
			node := que.pop()
			i := node.n
			if done[i] {
				continue
			}
			pair := A[i][next[i]]
			if done[pair] {
				continue
			}
			if i == A[pair][next[pair]] {
				ok = true
				next[i]++
				next[pair]++
				done[i] = true
				done[pair] = true
				if next[i] < N-1 {
					que2.push(Node{i})
				}
				if next[pair] < N-1 {
					que2.push(Node{pair})
				}
			}
		}
		if ok {
			ans++
		}
		que = que2
	}
	ok := true
	for i := 0; i < N; i++ {
		if next[i] < N-1 {
			ok = false
		}
	}

	if ok {
		fmt.Fprintln(wtr, ans)
	} else {
		fmt.Fprintln(wtr, -1)
	}
}

type Node struct {
	n int
}

type Queue struct {
	arr []Node
}

func (q *Queue) push(v Node) {
	q.arr = append(q.arr, v)
}

func (q *Queue) pop() Node {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long pow_modp(long long a, long long n, long long p){
    // a^n mod p
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long p){
    // a^{-1} = 1/a mod p (拡張Euclidの互除法)
    long long b = p, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}

long long div_modp(long long a, long long b, long long p){
    // a/b mod p
    return mul_modp(a, modinv(b, p), p);
}

vector<pair<long long, int>> factorize(long long n){
    vector<pair<long long, int>> res;
    
    if(n%2 == 0){
        res.emplace_back(2,0);
        while(n%2 == 0){
            n /= 2;
            res.back().second++;
        }
    }
    
    for(int i=3; i*i<=n; i+=2){
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(void){
    ll N; cin >> N;
    ll mx = 0;
    vector<ll> A(N); REP(i,N){cin >> A[i]; chmax(mx, A[i]);}
    vector<int> fa(mx, 0);
    
    REP(i,N){
        auto lcm = factorize(A[i]);
        REP(j,lcm.size()){
            if(fa[lcm[j].first-1] < lcm[j].second) fa[lcm[j].first-1] = lcm[j].second;
        }
    }

    ll all = 1;
    REP(i,mx){
        all = mul_modp(all, pow_modp(i+1, fa[i], INF), INF);
    }
    
    ll B;
    ll ans = 0;
    REP(i,N){
        B = div_modp(all, A[i], INF);
        ans = (ans%INF + B%INF)%INF;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    cout.tie(0);
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int h,w;
char a[10][10];
int f;

void dfs(int x=0,int y=0){
  //cout<<x<<" "<<y<<endl;
  a[x][y]='.';
  if(x==h-1&&y==w-1)return;
  if(x==h-1){
    if(a[x][y+1]=='.'){
      f=1;
      return;
    }
    dfs(x,y+1);
    return;
  }
  if(y==w-1){
    if(a[x+1][y]=='.'){
      f=1;
      return;
    }
    dfs(x+1,y);
    return;
  }
  if(a[x+1][y]=='#'){
    dfs(x+1,y);
    return;
  }
  if(a[x][y+1]=='#'){
    dfs(x,y+1);
    return;
  }
  f=1;
  return;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>a[i][j];

  dfs();

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(a[i][j]=='#')f=1;

  if(f)cout<<"Impossible"<<endl;
  else cout<<"Possible"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
}

Measured memory_bytes: 3688
#include <iostream>

using namespace std;

int N;
long long a[10000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    int c = 0;
    for(int i=0;i<N;i++){
        while(a[i] > 0){
            if(a[i] % 2 == 0){
                c++;
            }else{
                break;
            }
            a[i] /= 2;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

bool solve(vector<int> in){
  rep(i,9){
    int cnt = 0;
    while(in[i]){
      cnt++;
      if(in[i]>=3)in[i]-=3;
      else if(i<7 && in[i]&&in[i+1]&&in[i+2]){
	      in[i]--;in[i+1]--;in[i+2]--;
      }
      if(cnt==6)break;
    }
  }
  bool h = true;
  rep(i,9){
    if(in[i])h=false;
  }
  return h;
}

int main(void){
  string s;
  while(cin>>s){
    vector<int> in(9);
    vector<int>out;
    rep(i,s.size())in[s[i]-'1']++;
    rep(i,9){
      if(in[i]==4)continue;
      in[i]++;
      rep(j,9){
        if(in[j]<2)continue;
        in[j]-=2;bool h=false;
        if(solve(in)){h=true;out.push_back(i+1);}
        in[j]+=2;
        if(h)break;
      }
      in[i]--;
    }
    if(out.size()){
      rep(i,out.size()-1)cout<<out[i]<<" ";
      cout<<out[out.size()-1]<<endl;
    }else cout<<0<<endl;
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
int N,M;
const int mod=1000000007;
int dp[100001];
int main(){
	cin >> N >> M;
	dp[0]=1;
	dp[1]=1;
	for(int i=1;i<=M;i++){
		int a;
		cin >> a;
		dp[a]=-1;
	}
		
	for(int i=2;i<=N;i++){
		if(dp[i]!=-1){
			if(dp[i-1]!=-1)dp[i]+=dp[i-1];
			if(dp[i-2]!=-1)dp[i]+=dp[i-2];
		}
		dp[i]%=mod;
	}
	printf("%d\n",dp[N]%mod);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
signed main(){
    int h,w,m;
    cin>>h>>w>>m;
    map<pair<int,int>,int>mp;
    map<int,int>row;
    map<int,int>col;
    int x,y;
    for(int i=0;i<m;i++){
      scanf("%lld %lld",&x,&y);
      row[x]++;
      col[y]++;
      mp[{x,y}]++;
    }
    int maxr=-1;
    int indr=-1;
    int maxc=-1;
    int indc=-1;
    vector<int>rowi;
    vector<int>coli;
    for(auto it=row.begin();it!=row.end();it++)if(it->second>maxr){
      maxr=it->second;
      indr=it->first;
    }for(auto it=row.begin();it!=row.end();it++)if(it->second==maxr){
      rowi.push_back(it->first);
    }
    for(auto it=col.begin();it!=col.end();it++)if(it->second>maxc){
      maxc=it->second;
      indc=it->first;
    }
    for(auto it=col.begin();it!=col.end();it++)if(it->second==maxc){
      coli.push_back(it->first);
    }
    int ans;
    for(int i=0;i<rowi.size();i++){
      for(int j=0;j<coli.size();j++){
        if(mp[{rowi[i],coli[j]}]==0){
          ans=maxr+maxc;
          cout<<ans;
          return 0;
        }
        else{
          ans=maxr+maxc-1;
        }
      }
    }
    cout<<ans;
    
    

}

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


int bsort(int n,int a[]){
    bool flag=1;
    int count=0;
    for(int j=0;flag;j++){
        flag=0;
        for(int i=n-1;i>j;i--){
            if(a[i]<a[i-1]){
            swap(a[i],a[i-1]);
            flag=1;
            count++;
            }
        }
        
    }
    return count;
}

int main(void){
    
    int n;
    cin>>n;
    int array[100];
    int count;
    
    for(int i=0;i<n;i++)
    cin>>array[i];
    
    count=bsort(n,array);
    
    for(int j=0;j<n;j++){
        if(j)cout<<" ";
        cout<<array[j];
    }
    cout<<endl;
    
    cout<<count<<endl;
    
    return 0;
    
}



Measured memory_bytes: 3100
q, h, s, d = map(int, input().split())
n = int(input())
n *= 4

lst = [[1, q, q*4], [2, h, h*2], [4, s, s], [8, d, d/2]]
lst.sort(key=lambda x: x[2])

ans = 0
for i in range(4):
    volume = lst[i][0]
    price = lst[i][1]
    ans += price * (n//volume)
    n = n % volume

print(ans)

Measured memory_bytes: 38256
#include <stdio.h>
int main()
{
	int A, B, i, n;

	do{
		scanf("%d%d", &A, &B);
	}while(A < 2 || B < 1 || A > 20 || B > 20);

	if(B != 1){
		n = A;

		for(i = 1; n < B; i++){
			n += (A - 1);
		}

		printf("%d", i);
	}

	else
		printf("%d", 0);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #define ll  long long int
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    const int M = 200005;
    using namespace std;
    clock_t time_p=clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int N =  100 ;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
    int main (){
   int n ;
cin >> n ;
map<int, int> m ;
for ( int i =  1 ; i <= n ; ++i ){
    int x ;
    cin >> x ;
    m[x] = i ;
}
for ( int i = 1 ; i <= n ; ++ i ){
 cout << m[i]<<" " ;
}





    return 0 ;
    }


Measured memory_bytes: 5504
N,K = map(int,input().split())
V = list(map(int,input().split()))
rV = V[::-1]
R = min(N,K)

ans = 0
for a in range(R):
    for b in range(R):
        if a+b > R: break
        tmpV = sorted(V[:a]+rV[:b])
        if R == 1: tmpV = [max(V[0],rV[0])]
        t = sum(tmpV)
        for i in range(min(len(tmpV),K-(a+b))):
            if tmpV[i] >= 0: break
            else: t -= tmpV[i]
        if ans < t: ans = t
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B= int.Parse(input[1]);
        int C= int.Parse(input[2]);
        if (Math.Min(A, B) < C && Math.Max(A, B) > C) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
        
    }
}

Measured memory_bytes: 13140
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll power1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}

ll h[100005];
int main()
{
   SPEED
   ll n,i;
   cin>>n;
   for(i=0;i<n;i++)
    cin>>h[i];
   ll dp[n+1];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   if(n==2)
   {
       cout<<dp[1];
       return 0;
   }
   for(i=2;i<n;i++)
   {
       dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
   }
   cout<<dp[n-1];
}







Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

ll ans=LINF;
vector<ll> h;
ll n,a,b;
void solve(ll l,ll r){
    if(l>r) return;
    //m回魔法
    ll m=(l+r)/2;
    ll dame=m*b;
    ll tmp=0;
    for(ll i=n-1;i>=0;i--){
        if(h[i]>dame){
            tmp+=(h[i]-dame+a-b-1)/(a-b);
        }
        if(tmp>m){solve(m+1,r);return;}
    }
    ans=min(ans,m);
    solve(l,m-1);
}

int main(){
    
    cin>>n;
    cin>>a>>b;
    h.resize(n);
    ll hmax=-1;
    rep(i,n){cin>>h[i];hmax=max(hmax,h[i]);}

    sort(ALL(h),greater<ll>());
    solve(0ll,(hmax+b)/b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(void){

  int A, B, H, M;
  double r, rH, rM, ans;
  double pi = 3.141592653589793;

  cin >> A >> B >> H >> M;

  rH = 2 * pi / 12 / 60 * (H * 60 + M);
  rM = 2 * pi / 60 * M;

  if(rH>rM){
    r = rH - rM;
  } else if(rH<rM){
    r = rM - rH;
  } else r = 0;

  if(r>pi) r = 2 * pi - r;

  if(r==0){
    if(A>=B) ans = A - B;
    else if(A<B) ans = B - A;
  }
  else if(r==pi) ans = A + B;
  else{
    ans = sqrt(A*A+B*B-2*A*B*cos(r));
  }

  cout << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 4188
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N = INT()
	A = [LIST() for _ in range(N)]

	match_id = [[0]*N for _ in range(N)]

	def toid(i, j):  # 選手から試合IDに変換
		if i > j: i, j = j, i
		return match_id[i][j]

	cnt = 0
	for i in range(N):
		for j in range(N):
			if i < j:
				match_id[i][j] = cnt
				cnt += 1

	V = N*(N-1)//2
	gout = [[] for _ in range(V)]
	deg = [0]*(V)
	for i in range(N):
		for j in range(N-2):
			gout[toid(i, A[i][j]-1)].append(toid(i, A[i][j+1]-1))
			deg[toid(i, A[i][j+1]-1)] += 1
			
	topo = [v for v in range(V) if deg[v]==0]
	day = [0]*V
	deq = deque(topo)
	ans = 0
	while deq:
	    v = deq.popleft()
	    for t in gout[v]:
	        deg[t] -= 1
	        if deg[t]==0:
	            deq.append(t)
	            day[t] = day[v] + 1
	            ans = day[t]
	if any(deg):  # 閉路あり
		print(-1)
		exit()
	print(ans+1)
	

if __name__ == '__main__':
	main()


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll now = 0;
    REP(i, N){
        ll d1, d2;
        cin >> d1 >> d2;

        if(d1 == d2) now++;
        else now = 0;

        if(now == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main () {
    int n, k, x=0;
    std::cin >> n >> k;
    int a, check[200000] ={0};
    for(int i = 0; i < n; i++){
        std::cin >> a;
        check[a] += 1;
    }
    for(int i = 0; i < 200000; ++i){
        if(check[i] != 0) ++x;
    }
    std::sort(check, check + 200000);
    int ans = 0;
    for(int i = 0; i < x - k; ++i){
        if(check[i] == 0){
            ++x;
            continue;
        }
        ans += check[i];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 4364
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main()
{_
    int a, p;
    cin >> a >> p;
    cout << ((3*a+p)/2);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0;i < N;i++){
        cin >> v[i];
    }

    vector<int> ans(N, INT_MAX);
    ans[0] = 0;

    for(int i = 0;i < N;i++){
        for(int j = 1;(j <= K) && (i + j < N);j++){
            ans[i+j] = min(ans[i+j], ans[i] + abs(v[i] - v[i+j]));
        }
        /* for(int temp : ans){
            cout << temp << " ";
        }
        cout << endl; */
    }

    /* for(int i : ans){
        cout << i << endl;
    } */

    cout << ans.back() << endl;
}

Measured memory_bytes: 3580
B = $<.read.split
A = B.shift 9
H = {}
B[1..-1].each {|b| H[b]=1}
puts %w"012 345 678 036 147 258 048 246".any? {|l|
  l.chars.all? {|c| H[A[c.to_i]]}
} ? :Yes : :No

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

int main(){
	vector<char> S(4);
	for( int  i = 0; i < 4; i++){
		cin >> S.at(i);
	}
	 bool j = true;
	for(int i = 0; i < 3; i++ ){
		if(S.at(i) ==  S.at(i + 1)){
			j = false;
		}
	}
	
	if(j){
		cout << "Good" << endl;
	} else {
		cout << "Bad" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
int main()
{
	int n;scanf("%d",&n);
	if(n<1200) puts("ABC");
	else if(n<2800) puts("ARC");
	else puts("AGC");
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10000;
int n, m, a, b, c, ans, A[MAXN];
string str1, str2;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	cin >> str1 >> str2;
	for (int i = 0; i < n; i++)
	{
		cout << str1[i] << str2[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) cin >> A[i];
  
  ll money=1000,stock=0;
  rep(i,N-1) {
    if(A[i]<A[i+1]&&stock==0) {
      stock=money/A[i];
      money%=A[i];
    }
    else if(A[i]>A[i+1]&&stock>0) {
      money+=stock*A[i];
      stock=0;
    }
  }
  money+=stock*A[N-1];
  
  cout << money << endl;
}

Measured memory_bytes: 3612
a = input()
s = map(int, raw_input().split())

l1 = []
l2 = []

if a % 2 == 0:
	for i in range(a):
		if i % 2 == 1:
			l2.append(s[i])
		else:
			l1.append(s[i])
else:
	for i in range(a):
		if i % 2 == 0:
			l2.append(s[i])
		else:
			l1.append(s[i])

for i in reversed(l2):
	print i,

for i in l1:
	print i,

Measured memory_bytes: 19956
days = gets.to_i
c = gets.split(" ").map(&:to_i).slice(0,26)
s = Array.new(days).map{|d| gets.split(" ").map(&:to_i).slice(0,26)}
t = Array.new(days).map{|d| gets.to_i }
last = Array.new(26,0)


score = 0


for d in 1..days
    i = t[d-1] - 1   #イベント種別
    score += s[d-1][i]
    last[i] = d
    c.each_with_index do |rate, index|
        score = score - rate * (d - last[index])
    end
    puts score
end


Measured memory_bytes: 14192
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)
 
 
int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n+1][2];//1始まり 転送先/カウンタ
    rep(i,1,n+1){
        cin >> a[i][0];
        a[i][1] = -1;
    }
    long long pos = 1;
    long long loopT = 200000001;
    a[1][1] = 0;
    rep(i,1,n+5){
        if(i == k){
            cout << a[pos][0] << endl;
            return 0;
        }
        pos = a[pos][0];
        if(a[pos][1] < 0){
            a[pos][1] = i;
            continue;
        }else{
            loopT = i - a[pos][1];
            break;
        }
    }
    long long modTurn = (k - a[pos][1])%loopT;
    //cout << loopT << ":" << modTurn << endl;
    rep(i,0,modTurn){
        pos = a[pos][0];
    }
    cout << pos << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 6800
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 200005;

char str[MAXN];
int cnt[256];
int main(){
	lint ret = 1;
	cin >> str;
	for(int i=0; str[i]; i++){
		cnt[str[i]]++;
	}
	int n = strlen(str);
	ret += 1ll * n * (n-1)/2;
	for(int i='a'; i<='z'; i++){
		ret -= 1ll * cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << ret << endl;
}


Measured memory_bytes: 384
# n = int(sys.stdin.readline())
# a, b = map(int, sys.stdin.readline().split())
# c = list(map(int, sys.stdin.readline().split()))
# s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a = 100
# b = 0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
# 000100-0.987654

import math
import sys
import itertools
import queue

mod = 1000000007

if __name__ == "__main__":
    c = list(input())
    prev = c[0]
    for e in c[1::]:
        if e == prev:
            print("Bad")
            exit()
        prev = e
    print("Good")

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

typedef long long int ll;

const ll maxs = 1e4+1;
const ll MAX = 1e3+1;
ll dp[MAX][maxs];
ll n;
pair<ll,ll> a[maxs];
ll oo =  1e10;
#define ff first
#define ss second

ll go(ll pos,ll c)
{
    if(pos < 0 and c<=0)
        return 0;
    if(pos < 0 and c > 0)
        return oo;
    if(pos < 0 )
        return oo;
    if(c <= 0)
        return 0;
    
    if(dp[pos][c]!=-1)
        return dp[pos][c];
        
    return dp[pos][c] =  min( a[pos].ss + go(pos,c-a[pos].ff) , go(pos-1,c));
}

int main()
{
    for(ll i=0;i<MAX;i++)
        for(ll  j=0;j<maxs;j++)
            dp[i][j] = -1;
    ll c;
    cin>>c;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].ff>>a[i].ss;
    }
    
    ll ANS = go(n-1,c);
    std::cout << ANS << std::endl;
}

Measured memory_bytes: 79104
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int k,s,check1;
	cin >> k >> s;
	LL ans = 0;
	for(int i = 0 ; i <= k ; i++)
		for(int j = 0 ; j <= k ; j++)
			{
			check1 = s - i - j;
			if(check1 <= k && check1 >= 0)ans++;
			}
				cout << ans << endl;
	return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int dp1[1000001];
int dp2[1000001];

set<int> por;
vector<int> porv;
set<int> pork;
vector<int> porkv;

int rec1(int n) {
	cout<<n<<endl;
	if(n < 0) return INF;
	if(dp1[n] != INF) return dp1[n];
	if(por.count(n) != 0) return 1;
	int res = INF;
	REP(i, porv.size()) {
		res = min(res, rec1(n - porv[i] ) + 1);
	}
	return dp1[n] = res;
}

int rec2(int n) {
	cout<<n<<endl;
	if(n < 0) return INF;
	if(dp2[n] != INF) return dp2[n];
	if(pork.count(n) != 0) return 1;
	int res = INF;
	REP(i, porkv.size()) {
		res = min(res, rec2(n - porkv[i]) + 1);
	}
	return dp2[n] = res;
}

int main() {
	REP(i, 1000001) dp1[i] = dp2[i] = INF;
	dp1[0] = 0;
	dp2[0] = 0;
	int buf = 1;
	while(buf * (buf + 1) * (buf + 2) / 6 <= pow(10, 6)) {
		por.insert(buf * (buf + 1) * (buf + 2) / 6);
		porv.pb(buf * (buf + 1) * (buf + 2) / 6);
		if((buf * (buf + 1) * (buf + 2) / 6) % 2 == 1) {
			pork.insert(buf * (buf + 1) * (buf + 2) / 6);
			porkv.pb(buf * (buf + 1) * (buf + 2) / 6);
		}
		++buf;
	}
	sort(ALL(porv));
	sort(ALL(porkv));
	REP(i, 1000001) {
		if(i == 0) dp1[i] = 0;
		else if(por.count(i) != 0) dp1[i] = 1;
		else {
			int roc = 0;
			int res = INF;
			while(roc < porv.size() && i - porv[roc] >= 0) {
				res = min(res, dp1[i - porv[roc]] + 1);
				++roc;
			}
			dp1[i] = res;
		}
	}
	REP(i, 1000001) {
		if(i == 0) dp2[i] = 0;
		else if(pork.count(i) != 0) dp2[i] = 1;
		else {
			int roc = 0;
			int res = INF;
			while(roc < porkv.size() && i - porkv[roc] >= 0) {
				res = min(res, dp2[i - porkv[roc]] + 1);
				++roc;
			}
			dp2[i] = res;
		}
	}
	while(1) {
		int n;
		cin>>n;
		if(n == 0) break;
		cout<<dp1[n]<<" "<<dp2[n]<<endl;
	}
}

Measured memory_bytes: 10820
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

constexpr ll MOD = 998244353;

vector<ll> fact, inv_fact;

ll combination(ll n, ll m) {
    return fact[n] * inv_fact[n - m] % MOD * inv_fact[m] % MOD;
}

ll POW(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m & 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }
    return result;
}

int main() {
    ll N, A, B, K;
    cin >> N >> A >> B >> K;

    //緑→紫として紫は赤と青が同時に塗られている場所とすると
    //N個のブロックから赤をi個,青をj個それぞれ独立に選んで色
    //を塗ることとして良い

    //fact, inv_factの準備
    fact.resize(N + 1, 1);
    inv_fact.resize(N + 1, 1);
    for (ll i = 2; i <= N; i++) {
        fact[i] = i * fact[i - 1] % MOD;
        inv_fact[i] = POW(fact[i], MOD - 2);
        assert(fact[i] * inv_fact[i] % MOD == 1);
    }

    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if (i * A > K) {
            continue;
        }

        if ((K - i * A) % B == 0) {
            ll j = (K - i * A) / B;
            if (j > N) {
                continue;
            }
            ans += combination(N, i) * combination(N, j) % MOD;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  vector<int>v,w;
  int now=0;
  char c=s[0];
  for(int i=0;i<s.size();i++){
    if(s[i]==c){
      now++;
    }
    else{
      if(c=='0'){
        v.push_back(now);
        c='1';
      }
      else{
        w.push_back(now);
        c='0';
      }
      now=1;
    }
  }
  if(c=='0'){
    v.push_back(now);
    c='1';
  }
  else{
    w.push_back(now);
    c='0';
  }
  int sv[v.size()+1],sw[w.size()+1];
  sv[0]=0;
  sw[0]=0;
  for(int i=0;i<v.size();i++){
    sv[i+1]=sv[i]+v[i];
  }
  for(int i=0;i<w.size();i++){
    sw[i+1]=sw[i]+w[i];
  }
  if(k>=v.size()){
    cout<<n<<endl;
    return 0;
  }
  if(s[0]=='0'){
    int ans=0;
    ans=sv[k]-sv[0]+sw[k]-sw[0];
    for(int i=1;i<v.size()-k;i++){
      ans=max(ans,sv[i+k]-sv[i]+sw[i+k]-sw[i-1]);
    }
    if(s[n-1]=='0'){
      ans=max(ans,sv[v.size()]-sv[v.size()-k]+sw[w.size()]-sw[w.size()-k]);
    }
    else{
      ans=max(ans,sv[v.size()]-sv[v.size()-k]+sw[w.size()]-sw[w.size()-k-1]);
    }
    cout<<ans<<endl;
  }
  else{
    int ans=0;
    for(int i=0;i<v.size()-k;i++){
      ans=max(ans,sv[i+k]-sv[i]+sw[i+k+1]-sw[i]);
    }
    if(s[n-1]=='0'){
      ans=max(ans,sv[v.size()]-sv[v.size()-k]+sw[w.size()]-sw[w.size()-k]);
    }
    else{
      ans=max(ans,sv[v.size()]-sv[v.size()-k]+sw[w.size()]-sw[w.size()-k-1]);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1404
/**
 *      ABC 103 C
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    cout << accumulate(v.begin(), v.end(), 0) - n << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <iostream>
using namespace std;
long long int n, a[100010], b[100010], cnt = 0;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = n; i > 0; i--) {
		if ((cnt + a[i]) % b[i]) {
			cnt += b[i] - ((cnt + a[i]) % b[i]);
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main(void){
    char s[11], t[11];
    scanf("%s", s);
    scanf("%s", t);
    int a, b;
    scanf("%d%d", &a, &b);
    char u[11];
    scanf("%s", u);

    int flag = 1;
    for (int i = 0; i < strlen(u); i++){
        if (u[i] != s[i]){
            flag = 0;
        }
    }
    if (flag){
        printf("%d %d\n", a - 1, b);
    }
    else {
        printf("%d %d\n", a, b - 1);
    }

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define ll long long
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
struct node{
	ll x,y,id;
}p[110];
bool cmp(const node & a,const node & b){
	if((a.y-p[1].y)*(b.x-p[1].x)==(b.y-p[1].y)*(a.x-p[1].x))return a.x<b.x;
	return (a.y-p[1].y)*(b.x-p[1].x)<(b.y-p[1].y)*(a.x-p[1].x);
}
int stk[110],tail=0;
bool check(int a,int b,int c){// 1 2(top) 3(top-1)
	return (p[a].x-p[c].x)*(p[b].y-p[c].y)-(p[a].y-p[c].y)*(p[b].x-p[c].x)>=0;
}
int get(int x){
	return (x+tail)%tail;
}
double d(int a,int b){
	return sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y));
}
double cal(int l,int m,int r){
	double Cos=(p[l].x-p[m].x)*(p[r].x-p[m].x)+(p[l].y-p[m].y)*(p[r].y-p[m].y);
	Cos/=d(l,m)*d(m,r);
	//dbg(acos(Cos));
	return (acos(-1)-acos(Cos))/2/acos(-1);
}
double res[110];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&p[i].x,&p[i].y);
		p[i].id=i;
	}
	for(int i=2;i<=n;i++){
		if(p[i].x<p[1].x)swap(p[i],p[1]);
		if(p[i].x==p[1].x && p[i].y<p[1].y)swap(p[i],p[1]);
	}
	sort(p+2,p+1+n,cmp);
	stk[tail++]=1;
	for(int i=2;i<=n;i++){
		while(tail>=2 && check(i,stk[tail-1],stk[tail-2]))tail--;
		stk[tail++]=i;
	}
	if(tail==1){
		res[1]=1;
	}else if(tail==2){
		res[p[stk[0]].id]=0.5;
		res[p[stk[1]].id]=0.5;
	}else{
		for(int i=0;i<tail;i++){
			res[p[stk[i]].id]=cal(stk[get(i-1)],stk[get(i)],stk[get(i+1)]);
			//dbg(p[stk[i]].res);
		}
	}
	for(int i=1;i<=n;i++){
		printf("%.20f\n",res[i]);
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var n, d int

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	bingoCard := make([][]int, 3)
	bingoOpened := make([][]bool, 3)
	for i := 0; i < 3; i++ {
		bingoCard[i] = make([]int, 3)
		bingoOpened[i] = []bool{false, false, false}
	}
	sc.Split(bufio.ScanWords)
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			bingoCard[i][j] = nextInt()
		}
	}

	bingoFlag := false
	n := nextInt()
	for k := 0; k < n; k++ {
		tmp := nextInt()
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if bingoCard[i][j] == tmp {
					bingoOpened[i][j] = true
					if checkBingo(bingoOpened, i, j) {
						fmt.Println("Yes")
						bingoFlag = true
					}
				}
				if bingoFlag {
					break
				}
			}
			if bingoFlag {
				break
			}
		}
		if bingoFlag {
			break
		}
	}
	if !bingoFlag {
		fmt.Println("No")
	}
}

func checkBingo(bingoOpened [][]bool, x, y int) bool {
	if (bingoOpened[x][0] == true &&
		bingoOpened[x][1] == true &&
		bingoOpened[x][2] == true) ||
		(bingoOpened[0][y] == true &&
			bingoOpened[1][y] == true &&
			bingoOpened[2][y] == true) {
		return true
	}
	if (x == 0 && y == 2) || (x == 2 && y == 0) || (x == 1 && y == 1) {
		if bingoOpened[0][2] == true &&
			bingoOpened[1][1] == true &&
			bingoOpened[2][0] == true {
			return true
		}
	}
	if (x == 0 && y == 0) || (x == 2 && y == 2) || (x == 1 && y == 1) {
		if bingoOpened[0][0] == true &&
			bingoOpened[1][1] == true &&
			bingoOpened[2][2] == true {
			return true
		}
	}

	return false
}


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

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

  vector<string> p(n);
  rep(i,n){
    cin >> p.at(i);
  }

  vector<int> ans(4,0);
  rep(i,n){
    if(p.at(i) == "AC")       ans.at(0)++;
    else if(p.at(i) == "WA")  ans.at(1)++;
    else if(p.at(i) == "TLE") ans.at(2)++;
    else                      ans.at(3)++;
  }
  
  cout << "AC x " << ans.at(0) << endl;
  cout << "WA x " << ans.at(1) << endl;
  cout << "TLE x " << ans.at(2) << endl;
  cout << "RE x " << ans.at(3) << endl;

}

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

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
const ll INF = 1e18;
const ll MAX_X   = 55555;
const ll MAX_NUM = MAX_X * 10;
bool is_prime[MAX_NUM+1];

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  for (ll i = 0; i < MAX_NUM; i++) {
    is_prime[i] = true;
  }

  is_prime[0] = false;
  is_prime[1] = false;
  for (ll i = 2; i < MAX_NUM; i++) {
    if (is_prime[i] == true) {
      for (ll j = i * 2; j < MAX_NUM; j+=i) {
	is_prime[j] = false;
      }
    }
  }

  std::vector< ll > vans;
  for (ll i = 2; i < MAX_X; i++) {
    if (is_prime[i] && i % 5 == 4) {
      vans.push_back(i);
    }
  }

  for (ll i = 0; i < N; i++) {
    std::cout << vans[i] << " ";
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<tuple>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 110000

int n, k, a, q, query, x;
string key, y;
map<string,int> se;

int main(){
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>query>>key;
		if(!query){
			cin>>x;
			se[key] = x;
		} else if(query == 1){
			cout<<se[key]<<endl;
		} else if(query == 2){
			se.erase(key);
		} else if(query == 3){
			cin>>y;
			decltype(se)::iterator it = se.lower_bound(key), it2 = se.upper_bound(y);
			for(int i = 0; it != it2; i++,it++) if((*it).second)cout<<(*it).first<<" "<<(*it).second<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 27784
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;

ll cnt = 0;
vector<int> list753;

void check(ll x) {
	string s = to_string(x);
	int size = s.size();
	bool is7_exist = false;
	bool is5_exist = false;
	bool is3_exist = false;
	rep(i, size) {
		if (s[i] == '3' ) {
			is3_exist = true;
		}
		if (s[i] == '7') {
			is7_exist = true;
		}
		if (s[i] == '5') {
			is5_exist = true;
		}
	}
	if (is7_exist && is5_exist && is3_exist) list753.push_back(x);
	return;
}

void dfs(ll x) {
	check(x);
	if (x <= 100000000) {
		dfs(10 * x + 3);
		dfs(10 * x + 5);
		dfs(10 * x + 7);
	}
}

int main() {
	ll n;
	cin >> n;
	dfs(0);
	rep(i, list753.size()) {
		if (list753[i] <= n) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC125A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = ReadInt;
            var B = ReadInt;
            var T = ReadInt;

            //test
            int[,] dp = new int[12, 12];
            DrawMapforDebug(dp);

            Console.WriteLine(T / A * B);


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void DrawMapforDebug(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void DrawArrayforDebug(int[] array, int mode = 0)
        {
            Console.WriteLine(string.Join(" ", array));
        }
    }
}


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

typedef long long ll;

ll N;
ll A[500010];
ll mod = 1000000007;
ll dp[1 << 21][2];
int mem[1 << 21];
int cnt;

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

    int now = 0;
    ll ans = 1;
    for(int i = 0; i < N; i++)
    {
        now ^= A[i];
        if(i == N - 1)
        {
            if(now == 0)
            {
                for(int j = 0; j < (1 << 20); j++)
                {
                    dp[j][0] += (cnt - mem[j]) * dp[j][1];
                    dp[j][0] %= mod;
                    mem[j] = cnt;
                    ans += dp[j][1];
                    ans %= mod;
                }
                ans += dp[now][0];
                ans %= mod;
                cout << ans << endl;
            }
            else
            {
                dp[now][0] += (cnt - mem[now]) * dp[now][1];
                dp[now][0] %= mod;
                mem[now] = cnt;
                cout << (1 + dp[now][0]) % mod << endl;
            }
        }
        if(now == 0)
        {
            cnt++;
            mem[0] = cnt;
            ll tmp0 = dp[now][0];
            ll tmp1 = dp[now][1];
            dp[now][0] += tmp1;
            dp[now][0] %= mod;
            dp[now][1] += tmp0;
            dp[now][1] %= mod;
        }
        else
        {
            dp[now][0] += (cnt - mem[now]) * dp[now][1];
            dp[now][0] %= mod;
            mem[now] = cnt;
            dp[now][1] += dp[now][0];
            dp[now][1] %= mod;
        }
        dp[now][0] += (cnt - mem[now]) * dp[now][1];
        dp[now][0] %= mod;
        mem[now] = cnt;
        dp[now][1]++;
        dp[now][1] %= mod;
    }
    return 0;
}





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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A.at(i);

    int ans = 0;

    for(int i=0; i<N; ++i){
        while(A[i] % 2 == 0){
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
h = list(map(int, input().split()))+[0]
ans = 0

while True:
    for i in range(N):
        if h[i]>0 and h[i+1]==0:
            ans += 1
            
    flag = True
    
    for j in range(N):
        if h[j]>0:
            h[j] -= 1
            flag = False
    
    if flag:
        break

print(ans)

Measured memory_bytes: 39408
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



Measured memory_bytes: 3064