akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int[] cnt = new int[n];
		Arrays.fill(cnt, 1);

		boolean[] can = new boolean[n];
		can[0] = true;

		for (int i = 0; i < m; i++) {
			int from = nextInt() - 1;
			int to = nextInt() - 1;

			if (can[from]) {
				can[to] = true;
				if (cnt[from] == 1) {
					can[from] = false;
				}
			}
			
			cnt[from]--;
			cnt[to]++;

		}
		
		int ret = 0;
		for (boolean x : can) {
			ret += x ? 1 : 0;
		}
		
		out.println(ret);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 20884
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}


//const int mod = 1000000007;
const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(1000000);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    ll k;
    cin >> n >> a >> b >> k;

    mint ans = 0;
    rep(i, n+1) {
        ll nb = k-a*i;
        if(nb%b == 0) {
            nb /= b;
            ans += c(n, i)*c(n, nb);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 18604
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> lines(H);
  for(int i = 0; i < H; ++i) {
    cin >> lines[i];
  }
  for(auto line : lines) {
    for(int i = 0; i < 2; ++i) {
      cout << line << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int a,b;
    cin >> a >> b;
    if(a <= b){
        REP(i,b) cout << a;
    }else{
        REP(i,a) cout << b;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,x,y;
    cin>>n>>m>>l;
    x=m/l;
    y=n/l;
    if(n%l==0)
    {
        y--;
    }
    cout<<(x-y)<<"\n";
    return 0;
}



Measured memory_bytes: 256
#line 2 "/home/toof/working/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "a.cpp"

int main() {
  ll k;
  cin >> k;
  rep(i, k) {
    cout << "ACL";
  }
  cout << el;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>

using namespace std;



int main(){
    int res = 0;
    int N;
    cin >> N;
    string S;
    cin >> S;

    for(int i=0;i<S.length()-1;i++){
        if(S[i] == S[i+1]){}
        else{
            res++;
        }
    }
    
    cout << res+1;

}

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

int main() {
	long long x;

	cin >> x;

	long long ans = x / (6 + 5) * 2;
	if( ( x % (6 + 5) ) == 0 ) {
	}
	else {
		if( ( x % (6 + 5) ) > 6 ) {
			ans += 2;
		}
		else {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A;

void chmin(ll &a,ll b){
    if(a>b) a=b;
}

void Gauss(vector<ll> &B){//binary
    int rank=0;
    for(int d=59;d>=0;d--){
        int pivot=-1;
        for(int i=rank;i<(int)B.size();i++){
            if(B[i]&(1ll<<d)){
                pivot=i;
                break;
            }
        }
        if(pivot==-1) continue;
        //swap(B[rank],B[pivot]);
        if(rank<pivot) B[rank]^=B[pivot];
        for(int j=0;j<(int)B.size();j++){
            if(j<=rank) continue;
            //if(!(B[j]&(1ll<<d))) continue;
            //B[j]^=B[rank];
            chmin(B[j],B[j]^B[rank]);
        }
        rank++;
    }
}

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  ll sum=0;
  for(int i=0;i<N;i++) sum^=A[i];

  vector<ll> B=A;
  for(int i=0;i<N;i++){
      B[i]&=(~sum);
  }

  Gauss(B);

  ll ans=0;
  for(int i=0;i<N;i++){
      ans=max(ans,ans^B[i]);
  }

  ans*=2;
  ans+=sum;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int field[101][101];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				cin>>field[i][j];
		int sum=0;
		bool no=false;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				int num=field[i][j];
				bool f=false;
				for(int k = 0; k < n; k++){
					if(k==j)
						continue;
					if(field[i][k]<num){
						f=true;
						break;
					}
				}
				if(f)
					continue;
				f=false;
				for(int k = 0; k < n; k++){
					if(k==i)
						continue;
					if(field[k][j]>num){
						f=true;
						break;
					}
				}
				if(f)
					continue;
				//sum+=field[i][j];
				//if(no)
				//	cout<<" ";
				cout<<field[i][j];
				no=true;
				break;
			}
			if(no)
				break;
		}
		if(!no)
			cout<<0;
		cout<<endl;
		//cout<<sum<<endl;
	}		


	return 0;
}

Measured memory_bytes: 0
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K, Q = list(map(int, sys.stdin.readline().split()))
A = [int(sys.stdin.readline()) for _ in range(Q)]

cnts = Counter(A)
for i in range(N):
    if Q - cnts[i + 1] >= K:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 22228
s = input()
pre = int(s[:2])
pos = int(s[2:])
if 1 <= pre <= 12:
    if 1 <= pos <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= pos <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int K,X;
    cin>>K>>X;
    for(int i=X-K+1;i<=X+K-1;i++){
        cout<<i<<endl;
    }
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int i,j;
	int anscount = 0;
	int count = 0;
	for (j = 1; j <= n; j += 2)
	{
		for (i = 1; i <= j; i += 2)
		{
			if (j % i == 0)
			{
				count++;
			}
		}
		if (count == 8)
		{
			anscount++;
		}
      count = 0;
	}
	cout << anscount << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N =  sc.nextInt();
        int M =  sc.nextInt();


        int[] v = new int[N];
        int tv = 0;
        for (int i = 0; i < N ; i++) {
            v[i] = sc.nextInt();
            tv += v[i];
        }


        int count = 0;
        for (int i = 0; i < N; i++) {
            int n = v[i];
            if(n*4*M>=tv){
                count++;
            }
        }


        System.out.println( count>=M?"Yes":"No");
    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N;
    map<string,ll> m;
    cin >> N;
    string S;
    for(int i=0;i<N;i++){
        cin >> S;
        vector<char> v;
        for(auto x:S) v.push_back(x);
        sort(v.begin(),v.end());
        string T = "";
        for(auto x:v) T += x;
        m[T]++;
    }
    ll ans = 0;
    for(auto x:m) ans += (x.second-1)*x.second/2;
    cout << ans << endl;
}

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

using namespace std;

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N) { r = vector<int>(N, -1); }

    int root(int x) {
        if(r[x] < 0)
            return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return false;
        if(r[x] > r[y])
            swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) { return -r[root(x)]; }
};
int main() {
    int N, M;
    cin >> N >> M;

    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A -= 1;
        B -= 1;
        uf.unite(A, B);
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3972
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long>hn(n);
    for(int i = 0; i < n; i++){
        cin >> hn.at(i);
    }
    sort(hn.begin(), hn.end());
    reverse(hn.begin(), hn.end());
    long long ans = 0;
    if(k >= n){
        cout << 0 << endl;
    }
    else{
        for(int i = k; i < n; i++){
            ans += hn.at(i);
        }
        cout << ans << endl;
    }
    solve();
    return 0;
}



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

int gcd(int x, int y) {
  int tmp;
  while (y != 0) {
    tmp = x;
    x = y;
    y = tmp % y;
  }
  return x;
}

int main(void) {
  int K;
  cin >> K;

  long long answer = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        answer += gcd(gcd(a, b), c);
      }
    }
  }

  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
A, B, C  = [int(x) for x in input().strip().split()]
if (A == B and A != C) or (A == C and A != B) or (B == C and A != B):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
// Template //
#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 sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

// End of Template //

int main() {

    int N;
    cin >> N;

    string s;
    cin >> s;

    rep(i, s.size()) {
        if (s[i] + N > 'Z') {
            cout << char(s[i] + N - ('Z' - 'A') - 1);
        }
        else {
            cout << char(s[i] + N);
        }
    }

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e5;

char s[30];

int main()
{
	int n = 700,vis;
	while(~scanf("%s",s))
	{
		vis =0;
		for(int i = 0;i < 3;i++) if(s[i] == 'o') vis++;
		printf("%d\n",vis*100 + n);
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = tuple(map(int, input().split()))

ans = 0
r = {}
l = {}

for i, a in enumerate(A):
    if i - a in l:
        l[i - a] += 1
    else:
        l[i - a] = 1

    if i + a in r:
        r[i + a] += 1
    else:
        r[i + a] = 1

for k in r:
    if k in l:
        ans += r[k] * l[k]

print(ans)


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    int n, a, b;
    cin >> n;
    if(n == 1) {
        cout << "Hello World" << endl;
    }
    else {
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        boolean isZ = false;
        for (int i = 0; i < n; i++) {
            int d1 = Integer.parseInt(sc.next());
            int d2 = Integer.parseInt(sc.next());
            if (d1 == d2) {
                cnt++;
                if (cnt == 3) {
                    isZ = true;
                }
            } else {
                cnt = 0;
            }
        }
        if (isZ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35576
#include<stdio.h>

#define UNION_FIND_MAX_N (100010)
int union_find_par[UNION_FIND_MAX_N];
int union_find_rank[UNION_FIND_MAX_N];

void init(int n)
{
  int i;
  for(i=0;i<n;i++)
    {
      union_find_par[i]=i;
      union_find_rank[i]=0;
    }
}

int find(int x)
{
  if(union_find_par[x]==x)
    return x;
  else
    return union_find_par[x]=find(union_find_par[x]);
}

void unite(int x,int y)
{
  x=find(x);
  y=find(y);
  if(x==y)
    return;
  if(union_find_rank[x]<union_find_rank[y])
    union_find_par[x]=y;
  else
    union_find_par[y]=x;
  if(union_find_rank[x]==union_find_rank[y])
    union_find_rank[x]++;
}

int same(int x,int y)
{
  return find(x)==find(y);
}

int main()
{
  int n,m;
  int i;
  int a,b;
  int q;
  int s,t;
  scanf("%d %d",&n,&m);
  init(n);
  for(i=0;i<m;i++)
    {
      scanf("%d %d",&a,&b);
      unite(a,b);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d %d",&s,&t);
      same(s,t)?puts("yes"):puts("no");
    }
  
  return 0;
}

Measured memory_bytes: 3364
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    vector<int> a(3);
    rep(i, 3)cin >> a[i];
    sort(ALL(a));
    if(a[0] == a[2])cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d", &a);
	b = a / 3600;
	c = (a - 3600 * b) / 60;
	d = (a - (3600 * b + 60 * c));
	printf("%d:%d:%d\n", b, c, d);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++ )
bool map[21][21];

int main(){
	int n, m;
	while( cin >> n, n ){
		rep(i,21) rep(j,21) map[i][j] = false;
		rep(i,n){
			int x,y;
			cin >> x >> y;
			map[x][y] = true;
		}
		int px=10, py=10;
		cin >> m;
		rep(i,m){
			char d;
			int r;
			cin >> d >> r;
			rep(j,r){
					 if(d=='N')	py++;
				else if(d=='E')	px++;
				else if(d=='S')	py--;
				else if(d=='W')	px--;
				map[px][py] = false;
			}
		}
		bool comp=true;
		rep(i,21) rep(j,21) if( map[i][j] ) comp=false;
		cout << (comp?"Yes":"No") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int b[200005];

int main() {
	int n;
	int cnt = 1;
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		if (b[i] == cnt) {
			cnt++;
		}
		else {
			ans++;
		}
	}
	if (cnt == 1) {
		cout << -1;
	}
	else {
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
int field[10][10][6] = {0};
int h,w,c;
void copyfield(int num);
void color(int draw, int x, int y, int fand, int num);
int colorval(int lot);
int color_c(int x, int y, int fand, int sum);
using namespace std;
int main(){
	while(cin >>h>>w>>c){
		if(!h && !w && !c){break;}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cin >>field[j][i][0];
			}
		}
		cout <<colorval(5)<<endl;
	}
	return 0;
}
void color(int draw, int x, int y, int fand, int num){
	field[x][y][num] = draw;
	if(x>0){if(field[x-1][y][num-1] == fand && field[x-1][y][num] != draw){color(draw,x-1,y,fand,num);}}
	if(y>0){if(field[x][y-1][num-1] == fand && field[x][y-1][num] != draw){color(draw,x,y-1,fand,num);}}
	if(x<w-1){if(field[x+1][y][num-1] == fand && field[x+1][y][num] != draw){color(draw,x+1,y,fand,num);}}
	if(y<h-1){if(field[x][y+1][num-1] == fand && field[x][y+1][num] != draw){color(draw,x,y+1,fand,num);}}
}
void copyfield(int num){
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			field[j][i][num] = field[j][i][num-1];
		}
	}
}
int colorval(int lot){
	int sum=0;
	if(lot>1){
		for(int i=1; i<7; i++){
			copyfield(6-lot);
			color(i,0,0,field[0][0][5-lot],6-lot);
			int r = colorval(lot-1);
			if(sum<r){sum = r;}
		}
	}
	if(lot == 1){
		copyfield(5);
		color(c,0,0,field[0][0][4],5);
		sum = color_c(0,0,field[0][0][5],0);
	}
	return sum;
}
int color_c(int x, int y, int fand, int sum){
	field[x][y][5] = 0;
	sum++;
	if(x>0){if(field[x-1][y][5] == fand){sum+=color_c(x-1,y,fand,0);}}
	if(y>0){if(field[x][y-1][5] == fand){sum+=color_c(x,y-1,fand,0);}}
	if(x<w-1){if(field[x+1][y][5] == fand){sum+=color_c(x+1,y,fand,0);}}
	if(y<h-1){if(field[x][y+1][5] == fand){sum+=color_c(x,y+1,fand,0);}}
	return sum;
}

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

int main() {
	int n;cin>>n;
	int a[n];
	int count[100001];
	for(int i=0;i<100001;i++)count[i]=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		count[a[i]]++;
		if(a[i]!=0)count[a[i]-1]++;
		if(a[i]!=100000)count[a[i]+1]++;
	}
	int ans=0;
	for(int i=0;i<100001;i++){
		if(ans<=count[i]){
			ans=count[i];
		}
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 1024
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	string S;
	cin >> S;
	ll A = stoi(S.substr(0,2));
	ll B = stoi(S.substr(2,2));
	if (0<A and A<=12 and 0<B and B<=12){
		printf("AMBIGUOUS\n");
	}
	else if (0<A and A<=12){
		printf("MMYY\n");
		
	}
	else if (0<B and B<=12){
		printf("YYMM\n");
		
	}
	else{
		printf("NA\n");
		
	}
	
}


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

int main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d; cin >> c >> d;
		if (c % 100 == 0 && d % 30 == 0) {
			cout << d / 6 + c / 100 << endl;
		}
		else if (c % 100 == 0) {
			int e = d / 30 * 30;
			cout << e / 6 + c / 100<<" "<< e / 6 + c / 100+5 << endl;
		}
		else if (d % 30 == 0) {
			cout << d / 6 + c / 100<<" "<< d / 6 + c / 100+1 << endl;
		}
		else {
			int e = d / 30 * 30, f = c / 100 * 100;
			printf("%d %d %d %d\n", e / 6 + f/100, e / 6 + f / 100 + 1, e /6+ f / 100 + 5, e /6+ f / 100 + 6);
		}
	}
}

Measured memory_bytes: 3184
"""
import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）
"""

import sys
readline = sys.stdin.buffer.readline
w,h,x,y=map(int,readline().rstrip().split())

if x==w/2 and y==h/2:print(w*h/2, 1)

else:print(w*h/2, 0)

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

int main() {
    int const MOD = 1e9 + 7;
    int n, m;
    cin >> n >> m;

    ll ans = 1;
    if (abs(n - m) == 0) {
        for (ll i = 1; i <= n; i++) ans = (ans * ((i * i) % MOD)) % MOD;
        ans = (ans * 2) % MOD;
    } else if (abs(n - m) == 1) {
        for (ll i = 1; i <= n; i++) ans = (ans * i) % MOD;
        for (ll i = 1; i <= m; i++) ans = (ans * i) % MOD;
    } else
        ans = 0;

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


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

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

    int ans = 0;
    for(int i = 1; i <= N; i++){
        string str = to_string(i);
        if(str.size() % 2 == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

template<typename T>
class Dijkstra {
 public:
  int n;
  T INF = numeric_limits<T>::max();
  vector< vector< pair<int,T> > > g;
  vector<T> dis;
  vector<int> prev;
  
  Dijkstra(int _n) : n(_n) {
    g.resize(n);
  }

  void add_edge(int u, int v, T w) {
    assert(0 <= u && u < n && 0 <= v && v < n);
    assert(w >= 0);
    g[u].emplace_back(v, w);
  }

  vector<T> short_path(int s) {
    dis = vector<T>(n, INF);
    prev = vector<int>(n, -1);

    set< tuple<T,int,int> > bag; // cost, vertex, prev
    bag.insert(make_tuple(0, s, -1));
    while (bag.size()) {
      int u, v, p;
      T w, cost;
      tie(cost, u, p) = *bag.begin();
      bag.erase(bag.begin());
      if (dis[u] > cost) {
        dis[u] = cost;
        prev[u] = p;
        for (auto i : g[u]) {
          tie(v, w) = i;
          bag.insert(make_tuple(w + cost, v, u));
        }
      }
    }
    return dis;
  }
};

int main() {
  ios_base::sync_with_stdio(false);

  int n, m, s, t;
  cin >> n >> m;
  Dijkstra<int> g(3 * n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g.add_edge(3 * u + 0, 3 * v + 1, 1);
    g.add_edge(3 * u + 1, 3 * v + 2, 1);
    g.add_edge(3 * u + 2, 3 * v + 0, 1);
  }
  cin >> s >> t;
  s--; t--;

  auto dis = g.short_path(3 * s);
  if (dis[3 * t] == g.INF) {
    cout << -1 << '\n';
  } else {
    assert(dis[3 * t] % 3 == 0);
    cout << dis[3 * t] / 3 << '\n';
  }

  return 0;
}
 


Measured memory_bytes: 23304
import Data.Int
import Data.Maybe

main = do
  line <- getLine 
  let t = read line :: Int64
  display $ listToMaybe [(x, y) | x <- [-500..500], y <- [-500..500], x^5 - y^5 == t]
    where 
      display Nothing = putStrLn "-1"
      display (Just (a, b)) = putStrLn (show a ++ " " ++ show b)

Measured memory_bytes: 3948
from collections import deque



# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from bisect import bisect_left as bl
def main():

    # n = int(input())
    # l = [int(j) for j in input().split()]
    
# 3 4 240
# 60 90 120
# 80 150 80 150

    # for t in range(int(input())):

    n,m,k = [int(j) for j in input().split()]
    l1 = [0]+[int(j) for j in input().split()]
    l2 = [0]+[int(j) for j in input().split()]

    # pre = [0]*n
    i = 0
    j = 0
    for i in range(1,n+1):
        l1[i] += l1[i-1]
    for i in range(1,m+1):
        l2[i] += l2[i-1]

    # print(l1, l2)
    ans =0 
    for i in range(n+1):
        if l1[i]>k: 
            break
        x = bl(l2, k-l1[i])
        if x<=m and x>0:
            if l2[x]>k-l1[i]:
                x = x-1
        if x==m+1:
            x = m
        # print(x,i)
        ans = max(ans, x+i)
    for i in range(m+1):
        if l2[i]>k: 
            break
        x = bl(l1, k-l2[i])
        if x<=n and x>0:
            if l1[x]>k-l2[i]:
                x = x-1
        if x==n+1:
            x = n
        # print(x,i)
        ans = max(ans, x+i)
    print(ans)






# endregion

if __name__ == "__main__":
    main()



Measured memory_bytes: 115680
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

int main(){
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  REP(i,N) cin >> a[i] >> b[i];

  int amax = 0;
  REP(i,N) amax = max(amax, a[i]);
  vector<int> btmp;
  REP(i,N) if(b[i] > amax) btmp.push_back(b[i]);
  sort(btmp.rbegin(), btmp.rend());

  int sum = 0;
  int ret = (H + amax - 1) / amax;
  REP(i, btmp.size()) {
    sum += btmp[i];
    if(sum >= H) {
      ret = min(ret, i + 1);
      break;
    }
    ret = min(ret, i + 1 + max(0, H - sum + amax - 1) / amax);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	long long n,ans=0;
	vector<char> buffer(10);
	map<vector<char>, long long> data;
	map<vector<char>, long long> ::iterator p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++) cin >> buffer.at(j);
		sort(buffer.begin(), buffer.end());
		p = data.find(buffer);
		if (p == data.end()) data.insert(pair<vector<char>, long long>(buffer, 0));
		else
		{
			p->second++;
			ans += p->second;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11136
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let a=(0..n).map(|_|read::<i32>()-1).collect::<Vec<i32>>();
    let mut s=0;
    let mut c=0;
    while c<n&&s!=1{
        s=a[s as usize];
        c+=1;
    }
    println!("{}",if c<n{c}else{-1})
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[300010],ans=0;
    cin>>n;
    rep(i,3*n){
        cin>>a[i];
    }
    sort(a,a+3*n);
    reverse(a,a+3*n);
    rep(i,n){
        ans+=a[i*2+1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i <= k; i++) {
        int tc = c;
        for (int j = 0; j < i; j++) tc *= 2;
        int tb = b;
        for (int j = 0; j < k - i; j++) tb *= 2;
        if (a < tb && tb < tc) {
            cout << "Yes" << newl;
            return 0;
        }
    }
    cout << "No" << newl;
}

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

using namespace std;
using LL = long long;

LL ans = 0;
map< char, vector<int> > m;

void getAns(char R, char G, char B) {

	for(int i : m[R]) {												// each i
		for(int j : m[G]) {											// each j, j > i
	
			if (j <= i)
				continue;

			auto itB = upper_bound(m[B].begin(), m[B].end(), j);		

			if (itB != m[B].end()) {

				int k =  itB - m[B].begin();						// find k > j
				
				ans += 1LL * 1LL * (m[B].size() - k); 				// R * G * B

				if (find(m[B].begin(), m[B].end(), 2 * j - i) != m[B].end())
					--ans;
	
			}
		}
	}
}

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

	int N; 
	string S;

	cin >> N >> S; 

	for(int i = 0; i < N; ++i) 
		m[S[i]].push_back(i);

	sort(m['R'].begin(), m['R'].end());
	sort(m['G'].begin(), m['G'].end());
	sort(m['B'].begin(), m['B'].end());
	
	getAns('R','G','B');
	getAns('R','B','G');
	
	getAns('G','R','B');
	getAns('G','B','R');
	
	getAns('B','R','G');
	getAns('B','G','R');
	
	cout << ans << '\n';

	return 0;	
}

Measured memory_bytes: 3680
N = int(input())

def makePrimes():
    primeList = []
    isPrime = [True for _ in range(55556)]
    isPrime[0] = False
    isPrime[1] = False

    for i in range(2, 55556):
        if not isPrime[i]:
            continue
        if i % 5 == 1:
            primeList.append(i)

        for j in range(i, 55556, i):
            isPrime[j] = False

    return primeList

primeList = makePrimes()
print(*primeList[:N])


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 01:35:41 2020

@author: shinba
"""

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

for i in range(1,1264):
    if int(i*(0.08)) == a and int(i*(0.1)) == b:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t H,W;
  cin >> H >> W;
  if (W==1 || H ==1){
  cout << 1 << endl;
  }
  else if (H%2==1 && W%2==1){
  cout << W*(H/2)+W/2+1 << endl;
  }
  else {
  cout << H*W/2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
	
		int m;
		int[] tall;
		tall = new int[3];
		
		for(int i = 0; i < 10; i++){
			m = scan.nextInt();
			if(tall[0] < m){
				tall[2] = tall[1];
				tall[1] = tall[0];
				tall[0] = m;
			}else if(tall[1] < m){
				tall[2] = tall[1];
				tall[1] = m;
			}else if(tall[2] < m){
				tall[2] = m;
			}
		}
		for(int i = 0; i < 3; i++){
			System.out.println(tall[i]);
		}
	}
}

Measured memory_bytes: 26128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}
struct list{
	int a;
	struct list *prev;
	struct list *next;
};
struct list *head,*tail;
struct list *make(int a){
	struct list *p;
	p=malloc(sizeof(struct list));
	p->a=a;
	p->prev=NULL;
	p->next=NULL;
	return p;
}

int main(void){
	int n=in(),i;
	long long a[100000],sum,t=0,ans=0;
	rep(i,n)a[i]=in();
	sum=0;
	// when i is even, sum is plus
	rep(i,n){
		sum+=a[i];
		if(i%2&&sum>=0){
			t+=sum+1;
			sum=-1;
		}
		else if(!(i%2)&&sum<=0){
			t+=1-sum;
			sum=1;
		}
	}
	ans=t;
	sum=0;
	t=0;
	// when i is odd, sum is plus
	rep(i,n){
		sum+=a[i];
		if(i%2&&sum<=0){
			t+=1-sum;
			sum=1;
		}
		else if(!(i%2)&&sum>=0){
			t+=sum+1;
			sum=-1;
		}
	}
	ans=min(ans,t);
	llprint(ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int n,m;
int dist[10][10];
bool used[10][10];
int max_len, curr_len;
vector<int> max_nodes, curr_nodes;

void dfs(int v){
    curr_nodes.push_back(v);
    bool end = true;
    for(int i=0; i<n; i++){
        if(dist[v][i]==0 or used[v][i]) continue;
        end = false;
        used[v][i] = used[i][v] = true;
        curr_len += dist[v][i];
        dfs(i);
        curr_len -= dist[v][i];
        used[v][i] = used[i][v] = false;
    }
    if(end){
        if(curr_len > max_len){
            max_len = curr_len;
            max_nodes = curr_nodes;
        }
    }
    curr_nodes.pop_back();
}

int main(){
    while(1){
        cin >> n >> m;
        if(n == 0) break;

        memset(dist, 0, sizeof(dist));
        max_len = 0;
        max_nodes.clear();
        for(int i=0; i<m; i++){
            int a,b,c;
            cin >> a >> b >> c;
            a--; b--;
            dist[a][b] = dist[b][a] = c;
        }
        for(int i=0; i<n; i++){
            dfs(i);
        }
        cout << max_len << endl;
        for(int i=0; i<(int)max_nodes.size()-1; i++){
            cout << max_nodes[i]+1 << " ";
        }
        cout << max_nodes.back()+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define mod 1000000007
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{  IOS
    ll n,k;cin>>n>>k;
    ll a[n];
    ll dp[k+1];
    dp[0]=0;
    for(int i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-a[j]<0)dp[i]=0;
            else if(dp[i-a[j]]==0){dp[i]=1;break;}
            else
                dp[i]=0;
        }
    }
    if(dp[k]==1)cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
string s,s1;
vector<ll> vec[100005];
ll arr[200005],vis[200005];
vector<pair<int,int> > store[200005];
priority_queue <ll> pq;
map<ll,ll> mp;
set<ll> st;
int f=0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	char a,b;
    ll i,j,k,c=0LL,t,z=0,x=0LL,y=0LL,cnt=0;
    
   	cin>>s>>k;
   	if(s.length()==1){
   		cout<<k/2;
   		return 0;
	   }
   	for(i=0;i<s.length();i++){
   		if(s[i]==s[0])
   		z++;
	}
	if(z==s.length()){
		cout<<(z*k)/2;
		return 0;
	}
   	for(i=0;i<s.length()-1;i++){
   			if(s[i]==s[i+1]){
   				c++;
				i++;	
			}	
		}
   	if(s[0]!=s[s.length()-1]){
   		cout<<c*k;
   		return 0;
	}
   	else{
   		for(i=s.length()-1;i>=0;i--)
		   {
		   	if(s[i]==s[0])
			   	x++;
		   	else
		   		break;
			}

			y=1;
			for(j=1;j<s.length();j++){
   			if(s[j]==s[0]){
   				y++;	
				}
				else 
				break;
					
			}
		//	cout<<x<<y<<endl;
			cout<<k*c - (k-1)*(x/2 + y/2 - (x+y)/2);
		}			
	
 	return 0;
}

Measured memory_bytes: 10368