akhauriyash/Code-Regression huggingface dataset:
process.stdin.resume();
process.stdin.setEncoding('utf8');

function tansaku(N, Y) {
    for (var i = 0; i <= N; i++) {
        for (var j = 0; j + i <= N; j++) {
            var total = 10000 * i + 5000 * j + 1000 * (N - (i + j));
            if (total === Y) {
                return i + " " + j + " " + (N - (i + j));
            }
        
        }
    }
    return "-1 -1 -1";
}

function Main(input) {
    var inputs = input.split(" ");
    
    var N = parseInt(inputs[0]),
        Y = parseInt(inputs[1]);

    console.log(tansaku(N, Y));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
using System;

namespace B_007_54
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();//

        }


        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var A = Convert.ToInt32(str[0]);
                var B = Convert.ToInt32(str[1]);

                if (A == B)
                {
                    Console.WriteLine("Draw");
                    return;
                }

                if (A == 1 && B != 1)
                {
                    Console.WriteLine("Alice");
                }
                else if (A != 1 && B == 1)
                {
                    Console.WriteLine("Bob");
                }
                else
                {
                    Console.WriteLine(A > B ? "Alice" : "Bob");
                }
            }
        }
    }
}

Measured memory_bytes: 13268
if __name__ == '__main__':
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    c = [list(map(int, input().split())) for _ in range(N)]
    # D = [[0 for _ in range(C)] for __ in range(C)]
    # c = [[0 for _ in range(N)] for __ in range(N)]
    gr = [[0 for __ in range(C + 1)] for _ in range(3)]
    # for i in range(C):
    #     tmp = input().split()

    for i in range(N):
        for j in range(N):
            gr[(i + j) % 3][c[i][j]] += 1

    ans = 500000000000000000000000
    for g1 in range(1, C + 1):
        for g2 in range(1, C + 1):
            for g3 in range(1, C + 1):
                if g1 != g2 and g1 != g3 and g2 != g3:
                    tmp = 0
                    for i in range(1, C + 1):
                        tmp += gr[0][i] * D[i - 1][g1 - 1]
                        tmp += gr[1][i] * D[i - 1][g2 - 1]
                        tmp += gr[2][i] * D[i - 1][g3 - 1]
                    ans = min(tmp, ans)

    print(ans)


Measured memory_bytes: 45916
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int N;
  cin >> N;
  VI A(N);
  cin >> A;
  while(1) {
    VSORT(A);
    // cout << A << endl;
    bool last = true;
    int f;
    for (size_t i = 0; i < N; i++) {
      if (A[i] != 0) {
        if (i == N - 1 && last) {
          cout << A[i] << endl;
          return 0;
        } else if (last) {
          f = A[i];
        } else {
          A[i] %= f;
        }
        last = false;
      }
    }
  }
  return 0;
}


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

int main() {
  
  int N;
  string colour;
  cin >> N;
  int y = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> colour;
    
    if (colour == "Y")
      y++;
  }
  
  if (y == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

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

const int MX = 200005;

int a[MX];
ll SS[MX];
ll S(int L, int R) {
	if (L > R) return 0;
	return SS[R] - SS[L - 1];
}

ll L[MX];
ll R[MX];

ll ans;

void Get(int l, int r)
{
	if (l > r) return;
	
	int m = (l + r) / 2;
	
	ll tmpL = L[m - 1];
	ll tmpR = R[m + 1];
	
	for (int i = m - 1, x = 0; i >= l; i--) {
		x += (a[i] % 2 == 1 ? 0 : 1);
		tmpL = min(tmpL, x + L[i - 1]);
	}
	
	for (int i = m + 1, x = 0; i <= r; i++) {
		x += (a[i] % 2 == 1 ? 0 : 1);
		tmpR = min(tmpR, x + R[i + 1]);
	}
	
	ans = min(ans, tmpL + tmpR + (a[m] % 2 == 1 ? 0 : 1));
	
	Get(l, m - 1);
	Get(m + 1, r);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		SS[i] = SS[i - 1] + a[i];
	}
	
	for (int i = 1; i <= n; i++) {
		L[i] = min(S(1, i), (a[i] == 0 ? 2 : a[i] % 2) + L[i - 1]);
	}
	for (int i = n; i >= 1; i--) {
		R[i] = min(S(i, n), (a[i] == 0 ? 2 : a[i] % 2) + R[i + 1]);
	}
	
	ans = S(1, n);
	
	for (int i = 1; i <= n; i++) {
		ans = min(ans, L[i] + S(i + 1, n));
	}
	
	Get(1, n);
	
	cout << ans << "\n";
}


Measured memory_bytes: 5760
import java.util.HashMap;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String first = s.substring(0,n);
		String second = s.substring(n,n*2);

		HashMap<String, Integer> map = new HashMap<String, Integer>();
		for (int i=0;i<1<<n;i++) {
			String tmp1 = "";
			String tmp2 = "";
			for (int j=0;j<n;j++) {
				if ((i>>j)%2!=0) {
					tmp1+=second.charAt(j);
				}
			}
			for (int j=n-1;j>=0;j--) {
				if ((i>>j)%2==0) {
					tmp2+=second.charAt(j);
				}
			}
			String tmp = tmp2+"_"+tmp1;
			if(map.containsKey(tmp)) {
				int x = map.get(tmp);
				map.put(tmp, x+1);
			} else {
				map.put(tmp, 1);
			}
		}
		long ans = 0;

		for (int i=0;i<1<<n;i++) {
			String tmp1 = "";
			String tmp2 = "";
			for (int j=0;j<n;j++) {
				if ((i>>j)%2!=0) {
					tmp1+=first.charAt(j);
				}
			}
			for (int j=n-1;j>=0;j--) {
				if ((i>>j)%2==0) {
					tmp2+=first.charAt(j);
				}
			}
			String tmp = tmp1+"_"+tmp2;
			if (map.containsKey(tmp)) {
//				System.out.println(tmp+" "+map.get(tmp));
				ans+=map.get(tmp);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 358928
###modular exponentiation: a^n % M
#pow(a, n, M) 
### gcd: gcd(a, b)
#import fractions
#fractions.gcd(a, b)
### LCM (M, N)
#lcm = M*N/fractions.gcd(M, N)
INF = 1000000000+5

def get_res(N, L):
    DP = [INF]*N
    DP[0] = 0
    DP[1] = abs(L[1]-L[0])
    for i in range(2, N):
        DP[i] = min(DP[i-1] + abs(L[i]-L[i-1]), DP[i-2] + abs(L[i]-L[i-2]))
    return DP[N-1]

N = int(input())
L = [int(s) for s in input().split(" ")]
result = get_res(N, L)
print("{}".format(result))


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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

void print(){}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
//    IOS;
    SCIN(s);
    string check="ACGT";
    int ans=0,now=0;
    rep(i,s.size()){
        if(check.find(s[i])<check.size())now++;
        else now=0;
        ans=max(ans,now);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let k:i32 = procon_read()[0];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().to_string();
	if s.len() <= k as usize {
		println!("{}", s);
	}else{
		print!("{}", &s[..(k as usize)]);
		print!("...");
		println!("");
	}
}

Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <set>
#include <climits>
#define INF 1000000000000000
#define ll long long
using namespace std;
ll N;
struct edge{ ll to, cost;};
vector<edge> G[100005];
ll d[100005];
typedef pair<ll,ll> P;
ll dijkstra(int s){
    priority_queue<P, vector<P>,greater<P>> que;
    fill(d,d+N,INF);
    d[s] = 0;
    que.push(P(0,s));
 
    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.second;
        if(d[v] < p.first)continue;
 
        for(ll i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if( d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
    cin >> N;
    ll a,b,c;
    for(int i=0;i<N-1;i++){
        cin >> a >> b >> c;
        a--,b--;
        G[a].push_back(edge{b,c});
        G[b].push_back(edge{a,c});
    }
    ll Q,K;
    cin >> Q >> K;
    K--;
    dijkstra(K);
    ll x,y;
    for(int i=0;i<Q;i++){
        cin >> x >> y;
        x--; y--;
        cout << d[x]+d[y] << endl;
    }
}


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    map<char, int> h;
    for(auto c : s){
    	h[c]++;
    }
    int o = 0;
    for(auto x : h){
    	o += x.second == 2 ? 1 : 0;
    }
    cout << (o == 2? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
using namespace std;
#define rrep(i,m,n) for(int (i)=(int)(m);(i)>=(int)(n);(i)--)
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define M_PI 3.1415926535897932LL;
typedef pair<ll, ll> P;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
typedef vector<ll> Array;

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

struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));//最小カットの場合逆辺は0にする
}

//max and min
P dfs(Graph& g, ll v, ll par,Array& cnt,string& s) {
	if (s[v] == '1')cnt[v]++;

	vector<P> kids(g[v].size());
	ll sum = 0;
	REP(i, g[v].size()) {
		ll to = g[v][i].to;
		if (to == par)continue;
		kids[i] = dfs(g, to, v, cnt, s);
		kids[i].first += cnt[to];
		kids[i].second += cnt[to];
		sum += kids[i].first;
		cnt[v] += cnt[to];
	}

	ll mx = 0;
	REP(i, g[v].size()) {
		ll temp = kids[i].second + kids[i].first - sum;
		chmax(mx, temp);
	}
	if (sum % 2 == 1)chmax(mx, 1LL);
	P ret = { sum,mx };

	return ret;
}


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

	ll n;
	string s;
	cin >> n >> s;
	Graph g(n);
	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 1, true, 1);
	}
	ll ans = INF;
	REP(i, n) {
		Array cnt(n, 0);
		auto temp = dfs(g, i, -1, cnt, s);
		if (temp.second == 0)chmin(ans, temp.first / 2);
	}
	if (ans == INF)cout << -1 << "\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
map<int,int> m;
int a[100005];

int main() {
	int n;
	si(n);
	
	for(int i=0;i<n;i++) si(a[i]);
	
	int ans=0;
	for(int i=0;i<n;i++){
	    int f=++m[a[i]];
	    int s=++m[a[i]-1];
	    int t=++m[a[i]+1];
	    
	    ans=max(ans,max(f,max(s,t)));
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
int IsPrime(int x) {
    int i;
    if(x == 2) return 1;
    if(x < 2) return 0;
    for(i = 2; i*i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int main(void){
    int n, num, i, count=0;

    scanf("%d", &n); //個数入力
    
    for(i = 0; i < n; i++){
        scanf("%d", &num); //数の入力
        if(IsPrime(num)) count++;
    }
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll in[100050];
ll sum[100050];

map <ll, int> Mx;
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &in[i]);
		sum[i] = (sum[i - 1] + in[i]) % M;
	}

	ll ans = 0;
	Mx[0] = 1;
	for (i = 1; i <= N; i++) {
		ans += Mx[sum[i]];
		Mx[sum[i]]++;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        s = s.at(s.size()-1) + s.substr(0,s.size()-1);
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int x;
  cin >> x;
  if(x < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	L := readString()
	result := 1
	t := 1
	for i := len(L) - 1; i >= 0; i-- {
		if L[i] == '1' {
			result = result*2 + t
			result %= 1000000007
		}
		t *= 3
		t %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}


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

namespace TYC
{
	typedef pair<int, int> pii;
	const int N = 1e6 + 5, K = 3;

	int n;
	char S[N];
	struct data { int c, v; } V[5];
	struct null_tag { };
	struct node
	{
		static node *null;
		node *pre, *nxt;
		int c;
		node(null_tag) : pre(this), nxt(this), c(-1) { }
		node() : pre(null), nxt(null), c(-1) { } 
		node(node *_pre, const int _c) : pre(_pre), c(_c), nxt(null)
		{
			if (_pre)
				_pre->nxt = this;
		}
	} *node::null = new node(null_tag()), *head;

	void del(node *p)
	{
		if (p == head)
			head = p->nxt;
		p->pre->nxt = p->nxt;
		p->nxt->pre = p->pre;
	}

	void work()
	{
		scanf("%s", S);
		int len = int(strlen(S));
		for (int i = 0; i < K; i++)
			V[i].c = i;
		node *p = head = new node(node::null, S[0] - 'A');
		V[S[0] - 'A'].v++;
		for (int i = 1; i < len; i++)
			if (S[i] != S[i - 1])	
			{
				p = new node(p, S[i] - 'A');
				V[S[i] - 'A'].v++;
			}
		sort(V, V + K, [](const data &a, const data &b) { return a.v < b.v; });  

		for (p = head; p != node::null && V[2].v > V[1].v; p = p->nxt)
			if (p->c == V[2].c && p->pre->c != p->nxt->c)
				del(p), V[2].v--;

		for (p = head; p->nxt != node::null && V[2].v > V[1].v; p = p->nxt)
			if (p->c == V[0].c && p->nxt->c == V[2].c && p->nxt->nxt->c == V[0].c)
			{
				V[0].v--, V[2].v--;
				del(p);
				p = p->nxt;
				del(p);
			}	 

		for (p = head; p->nxt != node::null && V[1].v > V[0].v; p = p->nxt)
			if (((p->c == V[1].c && p->nxt->c == V[2].c) || (p->c == V[2].c && p->nxt->c == V[1].c)) && p->pre->c != p->nxt->nxt->c)
			{
				V[1].v--, V[2].v--;
				del(p);
				p = p->nxt;
				del(p);
			}
		
		if (V[0].v == V[1].v && V[0].v == V[2].v)
			for (p = head; p != node::null; p = p->nxt)
				printf("%c", p->c + 'A');
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int r,d,x;
    cin>>r>>d>>x;
    int val[11]={};
    val[0]=x;

    for(int i=1;i<=10;i++)
    {
        val[i] = r*val[i-1] - d;
        cout<<val[i],nl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                     
using namespace std;                                                    
                                                                        
int main(void) {                                                        
  int a, b, c;                                                          
  cin >> a >> b >> c;                                                   
  int ans=0;                                                            
  for (int i=a; i<=b; i++) {                                            
    if (c%i==0) {                                                       
      ans++;                                                            
    }                                                                   
  }                                                                     
  cout << ans << endl;                                                  
  return 0;                                                             
}                                                                       
                                            

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, k; cin>>n>>k;
  int c = 0;
  while(n>0) {
    n/=k;
    c++;
  }
  cout<<c<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, m;
    cin >> n >> m;
    int ac=0;
    vector<int> watemp(n,0);
    int wa=0;
    vector<int> isok(n,0);

    for(int i=0; i<m; i++){
        int p;
        string s;
        cin >> p >> s;
        //初めて正解した場合
        if(isok.at(p-1) == 0 && s == "AC"){
            ac ++;
            isok.at(p-1) = 1;
            //正解前にWAを出していたらペナルティを追加
            if(watemp.at(p-1) != 0){
                wa += watemp.at(p-1);
            }
        }
        //AC前の問題でWAを出した場合
        else if(isok.at(p-1) == 0 && s == "WA"){
            watemp.at(p-1) ++;
        }
        else continue;
    }
    cout << ac << " " << wa << endl;

}

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

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

    int total = 0;
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        total += a;
    }

    cout << max(-1, n - total) << endl;
    return 0;
}

Measured memory_bytes: 3592
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m,w;
	cin>>n>>m>>w;
	vs in(n);
	rep(i,n)cin>>in[i];
	int out=inf;
	rep(i,1<<(n-1)){
		int c=0,sum=0;
		rep(j,n-1)if(i&1<<j)c++;
		vi co(c+1);
		sum=c;
		bool H=false;
		rep(a,m){
			int C=0;
			bool h=true;
			rep(j,n){
				if(in[j][a]=='1'){
					co[C]++;
					if(co[C]>w)h=false;
				}
				if(i&1<<j)C++;
			}
			if(!h){
				if(H){
					sum=inf;
					break;
				}
				sum++;
				co=vi(c+1);
				a--;
				H=true;
			}else H=false;
		}
		cmin(out,sum);
	}
	cout<<out<<endl;
}






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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	static int n;
	static int c[200010];
	scanf("%d",&n);
	rep1(i,n)scanf("%d",&c[i]);
	
	static int pre[200010] = {};
	static int nex[200010] = {};
	rep1(i,n){
		if(pre[c[i]] != 0){
			nex[pre[c[i]]] = i;
		}
		pre[c[i]] = i;
	}
	
	static ll dp[200010];
	dp[1] = 1;
	rep1(i,n-1){
		dp[i] %= M;
		dp[i+1] += dp[i];
		if(nex[i] != 0 && nex[i] != i+1){
			dp[nex[i]] += dp[i];
		}
	}
	cout << dp[n]%M << endl;
}


Measured memory_bytes: 4096
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int gcd(int m, int n) {
    int r;
    while (0 != n) {
        r = m % n; 
        m = n; 
        n = r;
    }
    return m;
}

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

    vector<int>left(N);
    vector<int>right(N);
    left[0] = A[0];
    right[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) {
        left[i] = gcd(left[i - 1], A[i]);
    }
    for (int i = N - 2; i >= 0; i--) {
        right[i] = gcd(right[i + 1], A[i]);
    }

    int ans = 1;
    for (int i = 0; i < N; i++) {
        int x;
        if (i == 0)x = right[1];
        else if (i == N - 1)x = left[N - 2];
        else x = gcd(left[i - 1], right[i + 1]);
        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
typedef long long int ll;

int h,w,n; 

int culc(int x,int y){
	if(x==0)return y;
	if(y==w)return w+x;
	if(x==h)return h+w+(w-y);
	if(y==0)return w+h+w+(h-x);
	return -1;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> h >> w >> n;
	vector<pair<int,int> > v;
	for(int i=0;i<n;i++){
		int a,b,c,d; cin >> a >> b >> c >> d;
		int x=culc(a,b);
		int y=culc(c,d);
		if(x==-1||y==-1)continue;
		v.push_back(make_pair(x,i));
		v.push_back(make_pair(y,i));
	}
	sort(v.begin(),v.end());
	stack<int> s;
	for(auto p:v){
		if(s.size()&&s.top()==p.second){
			s.pop();
		}
		else{
			s.push(p.second);
		}
	}
	if(s.size()){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}
}

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



int main() {
	long long int N, M;
	cin >> N >> M;
	long long int ansmin = -1, ansmax = 100000000LL;
	for(size_t i = 0; i < M; i++) {
		long long int L, R;
		cin >> L >> R;
		ansmin = max(L, ansmin);
		ansmax = min(R, ansmax);
	}
	cout << max(0LL,ansmax - ansmin + 1) << endl;
}



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

using namespace std;
#define ll long long
#define endl '\n'
#define PB push_back
const ll modd=1e9+7;

int main(){

int a,b;
cin>>a>>b;
int ans=0,i,j;
int pl=0;
for(i=a;i<=b;++i){
        j=i;
        while(j){
            pl*=10;pl+=j%10;j/=10;
        }
if(i==pl)ans++;
pl=0;

}
cout<<ans<<endl;


return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll a, b;
    cin >> a >> b;
    if((a * b) % 2 == 0)
        cout << "Even";
    else
        cout << "Odd";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;
vector<int> vec[11];
int ans;

signed main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		vec[s[i] - '0'].push_back(i);
	}
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				int m = -1;
				if (!(int)vec[i].size())continue;
				m = vec[i][0];
				if (!(int)vec[j].size() || vec[j][(int)vec[j].size() - 1] <= m)continue;
				m = *upper_bound(all(vec[j]), m);
				if (!(int)vec[k].size() || vec[k][(int)vec[k].size() - 1] <= m)continue;
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
def gyakugen(x,p):
  binp = str(bin(p-2))[::-1]
  ruijou = x
  
  result = 1
  for i in range(len(binp)-2):
    if binp[i] == "1":
      result *= ruijou
      result %= p
    ruijou *= ruijou
    ruijou %= mod
  return result

N, M = [int(i) for i in input().split()]
mod = 10**9+7

if abs(N-M) > 1 :
  print(0)
  exit()
elif N == M:
  ans = 1
  for i in range(1,N+1):
    ans *= i
    ans %= mod
    ans *= i
    ans %= mod
  ans *= 2
  ans %= mod
  print(ans)
else:
  ans = 1
  m = min(N,M)
  for i in range(1,m+1):
    ans *= i
    ans %= mod
    ans *= i
    ans %= mod
  ans *= max(N,M)
  ans %= mod
  print(ans)

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

typedef pair<int, int> P;

const int inf = 1e9;
const int max_n = 10000;

struct edge {
  int to, dist, cost;
};

int main()
{
  int n, m;

  while (cin >> n >> m, n){
    vector<edge> G[max_n];

    for (int i = 0; i < m; i++){
      int u, v, t, c;
      cin >> u >> v >> t >> c;
      u--; v--;
      edge e1 = {v, t, c}, e2 = {u, t, c};
      G[u].push_back(e1);
      G[v].push_back(e2);
    }

    int d[max_n];
    fill(d, d + n, inf);

    d[0] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));

    while (!q.empty()){
      P p = q.top(); q.pop();
      int v = p.second;

      if (d[v] < p.first) continue;

      for (int i = 0; i < G[v].size(); i++){
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.dist) {
          d[e.to] = d[v] + e.dist;
          q.push(P(d[e.to], e.to));
        }
      }
    }

    int ans = 0;

    for (int v = 1; v < n; v++){
      int mini = inf;

      for (int i = 0; i < G[v].size(); i++){
        edge e = G[v][i];

        if (d[v] == d[e.to] + e.dist && e.cost < mini){
          mini = e.cost;
        }
      }

      ans += mini;
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 4332
import sys

import numpy as np

sys.setrecursionlimit(2 ** 31 - 1)
INF = float('inf')

N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

s1 = [1]
s2 = [N]
fennec = 0
snuke = 0
fixed = np.zeros(N + 1, dtype=bool)
while s1 or s2:
    u1 = []
    for v in s1:
        if fixed[v]:
            continue
        fixed[v] = True
        fennec += 1
        u1.extend(graph[v])
    s1 = u1

    u2 = []
    for v in s2:
        if fixed[v]:
            continue
        fixed[v] = True
        snuke += 1
        u2.extend(graph[v])
    s2 = u2

if fennec > snuke:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 43812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int a, b, c, d; cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
}

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

int main(){
    int a[5], b = 1;
    int k, sum = 0;
    int count = 0;

    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    cin >> k;

    for (int i = 0; i < 5; i++){
        for(int j = 0; j < 5; j++){
            if(a[i] - a[j] > k) count++;
        }
    }

    if (count > 0){
        cout << ":(" <<endl;
    }else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int line(double x1,double y1,double x2,double y2,double *a,double *b);

int main(){
	double ax,ay,bx,by,cx,cy,px,py;
	double aa,ab,ba,bb,ca,cb;
	int swch;
	
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&px,&py)!=EOF){
		swch=0;
		if (1== line(ax,ay,bx,by,&ca,&cb) ){	/*xÀWª¯¶¾Á½ê*/
			swch=( (ax<cx) == (ax<px) );
		}
		if ( ((cx*ca+cb)>cy) == ((px*ca+cb)>py) /*|| ((px*ca+cb)==px)*/ || swch){/*((px*ca+cb)>px)->((px*ca+cb)>py)*/
			swch=0;/*((px*ca+cb)==px)->Èµ*/
			if(1== line(bx,by,cx,cy,&aa,&ab) ){
				swch=( (bx>ax) == (bx>px) );
			}
			if(((ax*aa+ab)>ay) == ((px*aa+ab)>py) /*|| ((px*aa+ab)==py)*/ || swch){
				swch=0;
				if (1== line(cx,cy,ax,ay,&ba,&bb) ){
					swch=( (cx<bx) == (cx<px) );
				}
				if(((bx*ba+bb)>by) == (px*ba+bb)>py /*|| (px*ba+bb)==py*/ || swch){
					printf("YES\n");
					continue;
				}
			}
		}
		
		printf("NO\n");
	}
	
	
	return 0;
}



int line(double x1,double y1,double x2,double y2,double *a,double *b){
	if (x1==x2){
		return 1;
	}else{
		*a=(y1-y2)/(x1-x2);
		*b=y1-(*a*x1);
	}
	
	return 0;
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    string s, t;
    cin >> s >> t;
    for(char c = 'a'; c <= 'z'; c++) {
        if(t == s + c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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


Measured memory_bytes: 3624
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}


int main() {
	int a[3];
	cin >> a[0]>>a[1] >> a[2];
	int max = 0;
	max = a[0] * 10 + a[1]+a[2];
	if (max < a[0] + 10 * a[1] + a[2])max = a[0] + 10 * a[1] + a[2];
	if (max < a[2] * 10 + a[1] + a[0])max = a[2] * 10 + a[1] + a[0];
	cout << max;
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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


ll INF = 1000000000;
ll dp[1000000];

int main() {
    ll N;
    cin >> N;
    REP(i,N+1){
        dp[i]=INF;
    }
    dp[0]=0;
    REP(i,N+1){
        chmin(dp[i+1], dp[i]+1);
        ll c6=6,c9=9;
        while(c6<=N){
            chmin(dp[i+c6],dp[i]+1);
            c6*=6;
        }
        while(c9<=N){
            chmin(dp[i+c9],dp[i]+1);
            c9*=9;
        }
    }
    cout<<dp[N]<<endl;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  string ans = "APPROVED";
  rep(i,n){
    if((a[i]%2 == 0)&&!(a[i]%3 == 0 || a[i]%5 == 0)) ans = "DENIED";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  sort(s, s + a);
  sort(t, t + b);

  string ans;
  for(int i = 0; i < q; i++){
    ll tmp = INF_LONG;
    // ->
    auto j = lower_bound(s, s + a, x[i]);
    auto k = lower_bound(t, t + b, x[i]);
    if(j != s + a && k != t + b){
      tmp = min(tmp, max(*j, *k) - x[i]);
    }
    // <-
    j = upper_bound(s, s + a, x[i]);
    k = upper_bound(t, t + b, x[i]);
    if(j != s && k != t){
      tmp = min(tmp, x[i] - min(*(j - 1), *(k - 1)));
    }
    // -> <-
    j = lower_bound(s, s + a, x[i]);
    k = upper_bound(t, t + b, x[i]);
    if(j != s + a && k != t){
      ll d1 = abs(x[i] - *j);
      ll d2 = abs(x[i] - *(k - 1));
      tmp = min(tmp, 2l * min(d1, d2) + max(d1, d2));
    }
    // <- ->
    j = upper_bound(s, s + a, x[i]);
    k = lower_bound(t, t + b, x[i]);
    if(j != s && k != t + b){
      ll d1 = abs(x[i] - *k);
      ll d2 = abs(x[i] - *(j - 1));
      tmp = min(tmp, 2l * min(d1, d2) + max(d1, d2));
    }
    ans += to_string(tmp) + "\n";
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N; cin >> N;
VI a(N); rep(i, 0, N) cin >> a[i];

int cnt = 0;
rep(i, 0, N) 
    while(a[i] % 2 == 0){
        ++cnt;
        a[i] /= 2;
    }
cout << cnt << endl;

}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 384