akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc098e {
public:
    void solve(istream& in, ostream& out) {
        int N, K, Q;
        in >> N >> K >> Q;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        int ans = 1'000'000'000;
        for (int i = 0; i < N; ++i) {
            vector<int> cur, res;
            for (int j = 0; j < N; ++j) {
                if (A[j] < A[i]) {
                    sort(begin(cur), end(cur));
                    for (int k = 0; k + K <= (int)cur.size(); ++k) {
                        res.push_back(cur[k]);
                    }
                    cur.clear();
                } else {
                    cur.push_back(A[j]);
                }
            }
            sort(begin(cur), end(cur));
            for (int k = 0; k + K <= (int)cur.size(); ++k) {
                res.push_back(cur[k]);
            }
            cur.clear();
            sort(begin(res), end(res));
            if ((int)res.size() >= Q) {
                ans = min(ans, res[Q - 1] - res[0]);
            }
        }
        out << ans << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc098e solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')
const input = stdin.split('\n')

const [N, M, C] = input[0].split(' ').map(Number)
const [...B] = input[1].split(' ').map(Number)
const [, , ...rawA] = input
const [...A] = rawA.filter((e, i) => i < N).map(el => el.split(' ').map(Number))

const res = A.filter(el => {
  const abArr = el.map((a,i)=>B[i]*a)
  const calc = abArr.reduce((pv,cv)=>pv+cv) + C
  return calc > 0
}).length

console.log(res)

Measured memory_bytes: 7500
#include <iostream>

using namespace std;

bool judge(int n)
{
    do { if (n % 4 == 0) return true; } while((n -= 7) >= 0);
    return false;
}


int main()
{
    int N;
    cin >> N;
    cout << (judge(N) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int N = NextInt();
        List<Tuple<int, int>>[] Data = new List<Tuple<int, int>>[N];
        for (int i = 0; i < N; i++)
        {
            int A = NextInt();
            Data[i] = new List<Tuple<int, int>>();
            for (int j = 0; j < A; j++)
            {
                int x = NextInt() - 1;
                int y = NextInt();
                Data[i].Add(new Tuple<int, int>(x, y));
            }
        }
        int ans = 0;
        int R = (int)Math.Pow(2, N);
        for (int bit = 0; bit < R; bit++)
        {
            List<List<Tuple<int, int>>> ok = new List<List<Tuple<int, int>>>();
            int[] f = Enumerable.Repeat(0, N).ToArray();
            int count = 0;
            for (int shift = 0; shift < N; shift++)
            {
                if ((1 & bit >> shift) == 1)
                {
                    //ここの人の証言全部信じてみる
                    count++;
                    f[shift] = 1;
                    ok.Add(Data[shift]);
                }
            }
            bool can = true;
            foreach (var d in ok)
            {
                foreach (var e in d)
                {
                    if (f[e.Item1] != e.Item2) { can = false; }
                }
            }
            if (can) ans = Math.Max(ans,count);
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

using namespace std;
typedef unsigned long long ull;

ull PickLargestMinimumPiece(const ull _total_size, const ull _piece1_s, const ull _piece1_l, const ull _piece3_s, const ull _piece3_l){
	ull tmp = min(_piece1_s, _piece3_s);
	
	ull piece2 = _total_size - _piece1_s - _piece3_l;
	tmp = max(tmp, min(_piece1_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_s;
	tmp = max(tmp, min(_piece3_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_l;
	tmp = max(tmp, piece2);

	return tmp;
}

void CalcPiece1(int *_i2, ull *_piece1_s, ull *_piece1_l, const int _i1, const int _N, const ull _one_third_size, const int *_A){
	for (; *_i2 < _i1 + _N - 2;){
		*_piece1_s = *_piece1_l;
		*_piece1_l += _A[(*_i2)%_N];
		(*_i2)++;
		if (*_piece1_l > _one_third_size) break;
	}
}

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

	int N;	//切れ込みの個数
	cin >> N;

	int *A = new int[N];	//各ピースの大きさを格納する配列
	ull total_size = 0;	//バームクーヘンの大きさ
	int i1_ini = 0;
	int A_max = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		total_size += A[i];
		if (A[i] > A_max){
			A_max = A[i];
			i1_ini = i;
		}
	}
	ull one_third_size = total_size / 3;
	ull answer = 0;
	if (A_max > one_third_size){
		ull half_size = (total_size - A_max) / 2;
		ull tmp = 0;
		ull piece2 = 0;
		for (int i3 = i1_ini + 1; i3 < i1_ini + N - 1; i3++){
			piece2 = tmp;
			tmp += A[i3%N];
			if (tmp > half_size) break;
		}
		ull piece3 = total_size - A_max - tmp;
		answer = max(piece2, piece3);
		cout << answer << endl;
		delete[] A;
		return 0;
	}

	int i2 = i1_ini;
	ull piece1_s = 0;
	ull piece1_l = 0;
	CalcPiece1(&i2, &piece1_s, &piece1_l, i1_ini, N, one_third_size, A);
	const int i1_fin = i2;

	int i3 = i2;
	ull piece3_s = total_size - piece1_l;
	ull piece3_l = 0;
	for (; i3 < i1_ini + N - 1;){
		piece3_l = piece3_s;
		piece3_s -= A[i3%N];
		i3++;
		if (piece3_s <= one_third_size) break;
	}

	answer = PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l);

	for (int i1 = i1_ini + 1; i1 < i1_fin; i1++){
		int A_tmp = A[(i1 - 1) % N];
		piece1_l -= A_tmp;
		if (piece1_l > one_third_size) piece1_s -= A_tmp;
		else{
			/*
			for (; i2 < i1 + N - 2;){
				piece1_s = piece1_l;
				piece1_l += A[i2%N];
				i2++;
				if (piece1_l > one_third_size) break;
			}//*/
			CalcPiece1(&i2, &piece1_s, &piece1_l, i1, N, one_third_size, A);
		}

		piece3_s += A_tmp;
		if (piece3_s <= one_third_size) piece3_l += A_tmp;
		else{
			for (; i3 < i1 + N - 1;){
				piece3_l = piece3_s;
				piece3_s -= A[i3%N];
				i3++;
				if (piece3_s <= one_third_size) break;
			}
		}

		answer = max(answer, PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l));
	}

	cout << answer << endl;

	delete[] A;

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
	using namespace std;
	typedef long long ll;
	ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
	ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

	int main() {
		string s;
		cin >> s;
		rep(i, 3) {
			if (s[i] == '1')s[i] = '9';
			else s[i] = '1';
		}
		cout << s << endl;
		return 0;
	}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std;

const int MAX=1e5+5;
const int INF=1e9;
int n,m;
int edge[20][20];
int total;
int cost[1<<16][16],dp[1<<16][16];//dp[s][x]记录达到某点集s,最后“末端”（继续连接其余点的唯一点）为x时余下权值和最大的边的情况
int inner[1<<16];//内部的边

inline int read() {
	int x = 0,f = 1;
	char ch = getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1; ch = getchar(); }
	while(ch>='0'&&ch<='9') { x = x *10+ch-48 ; ch = getchar(); }
	return x * f ;
}

int main() {
	n = read() ; m = read() ; 
	For(i,1,m) {
		int x,y,price ; 
		x=read();y=read();price=read();
		x--;y--;
		edge[x][y]=edge[y][x]=price ; 		
	}
	
	total = 1<<n;
	For(i,0,total-1) 
	  For(a,0,n-1) 
	    if(i&(1<<a))  
	      For(b,0,a-1) 
	        if (i&(1<<b)) 
				inner[i]+=edge[a][b] ;  
				
	For(i,0,total-1) 
	  For(a,0,n-1) 
	    if(!(i&(1<<a))) 
	      For(b,0,n-1) 
	        if(i&(1<<b)) 
	          cost[i][a]+=edge[a][b] ; 
	
	memset(dp,-1,sizeof dp) ; 
	dp[1][0]=0 ; 
	For(i,0,total-1) {
		For(a,0,n-1) 
		  if((i&(1<<a)) && dp[i][a]!=-1 ) {
		  	 For(b,0,n-1) 
		  	   if(!(i&(1<<b))) 
		  	    if(edge[a][b])
		  	     dp[i| (1<<b) ][b] = max( dp[i| (1<<b)][b],dp[i][a]+edge[a][b] ) ;  
		  	     
		  	int left = total-i-1 ; 
		  	for(int now=left;now!=0;now=(now-1)&left) {
		  		int num = inner[now]+cost[now][a] ; 
		  		dp[i| now][a] = max(dp[i| now][a],dp[i][a]+num) ;  
			}
		  }
	} 
	printf("%d\n",inner[total-1]-dp[total-1][n-1]) ; 
	
	return 0 ; 
}








Measured memory_bytes: 8576
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    long long a;
    long double b;
    cin >> a >> b;
    cout << static_cast < long long > (floor(a * b));

    return 0;
}


Measured memory_bytes: 3728
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		int p[] = fs.nextIntArray(n);
		
		double q[] = new double[n];
		
		for(int i=0;i<n;i++) {
			q[i] = ((double)p[i] + 1)/2;
		}
		
		
		
		double sum[] = new double[n+1];
		for(int i=0;i<n;i++) sum[i+1] = sum[i]+q[i];
		double ans = 0;
		for(int i=0;i<n;i++) {
			if(i+k>n)break;
			ans = Math.max(ans,sum[i+k]-sum[i]);
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 44372
import fileinput
import re

for line in fileinput.input():
    A = int(re.search("^[0-9]+", line).group())
    B = int(re.search("[0-9]+$", line).group())
    if(A < 10 and A >=1 and B < 10 and B >= 1):
        print(A*B)
    else:
        print(-1)
    exit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    int b[n];
    rep(i,n+1)cin >> a[i];
    rep(i,n)cin >> b[i];
    ll ans = 0;
    rep(i,n){
        int t = min(a[i],b[i]);
        ans += t;
        b[i]-=t;
        int k = min(a[i+1],b[i]);
        ans += k;
        a[i+1] -=k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;



public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String n = in.next();
        char [] a = n.toCharArray();
        if (n.length() < 4){
            System.out.println("No");
        }else  if (a[0]=='Y' && a[1]=='A' && a[2]=='K' && a[3]=='I'){
        System.out.println("Yes");}
        else {
            System.out.println("No");
        }
    }
}















Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int ch_string(char str[], char ch);

int n;
char str[55];
int ch[30];

int main()
{
	for (int i = 0; i < 30; i++) {
		ch[i] = 100000;
	}

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", str);

		for (int j = 'a'; j <= 'z'; j++) {
			ch[j - 'a'] = min(ch[j - 'a'], ch_string(str, j));
		}
	}

	for (int i = 'a'; i <= 'z'; i++) {

		if (ch[i - 'a'] < 100000) {
			for (int j = 0; j < ch[i - 'a']; j++) {
				putchar(i);
			}
		}
	}

	return 0;
}

int ch_string(char str[], char ch)
{
	int res = 0;

	while (*str != '\0') {
		if (*str == ch) {
			res++;
		}
		str++;
	}

	return res;
}


Measured memory_bytes: 128
def solve(m, a, n, i):
    if m == 0:
        return True
    if i >= n:
        return False
    return solve(m, a, n, i+1) or solve(m-a[i], a, n, i+1)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))
    for m in M:
        if m < min(a) or m > sum(a):
            print("no")
        elif solve(m, a, n, 0):
            print("yes")
        else:
            print("no")


if __name__ == '__main__':
    main()



Measured memory_bytes: 5624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string S;
	int a,b;
	cin>>S;
	a=S.find('A');
	b=S.rfind('Z');
	printf("%d\n",b-a+1);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

void dfs(int v, int p, int d, Graph &G, vector<int> &parents,
         vector<int> &depth) {
    depth[v] = d;
    parents[v] = p;
    for(auto nv : G[v]) {
        if(nv == p)
            continue;
        dfs(nv, v, d + 1, G, parents, depth);
    }
}

// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N;
    cin >> N;
    Graph G(N);
    vector<pair<int, int>> edge(N - 1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
        if(a > b)
            swap(a, b);
        edge[i] = MP(a, b);
    }
    vector<int> parents(N), depth(N);
    dfs(0, -1, 0, G, parents, depth);
    vector<int> path;
    int cur = N - 1;
    while(1) {
        path.pb(cur);
        if(parents[cur] == -1)
            break;
        cur = parents[cur];
    }
    reverse(All(path));
    int len = path.size();
    int x = path[(len - 1) / 2];
    int y = path[(len - 1) / 2 + 1];
    if(x > y)
        swap(x, y);
    UnionFind uf(N);
    rep(i, N - 1) {
        if(edge[i] != MP(x, y)) {
            uf.unite(edge[i].first, edge[i].second);
        }
    }
    int fen = uf.size(0), snu = uf.size(N - 1);
    if(fen > snu) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}

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

int main() {
  int N = 1;
  int A = 0;
  cin >> N >> A;
  int rem = N % 500;
  if (rem <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



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


int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  int sum_L = 0;
  for(auto& l : L){
    cin >> l;
    sum_L += l;
  }
  sort(L.begin(), L.end());
  int max_L = L.back();
  cout << ((max_L < sum_L - max_L) ? "Yes" : "No") << endl;
  return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int a, b;
  cin >> a >> b;
  if(b < a){
    cout << a - 1 <<endl;
  } else{
    cout << a <<endl;
  }
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	ini(x);
	ini(y);
	ini(apple1);
	ini(apple2);
	ini(apple3);
	vi apple1_;
	vi apple2_;
	vi apple3_;
	FOR(i,0,apple1){
		ini(x1);
		apple1_.push_back(x1);
	}
	FOR(i,0,apple2){
			ini(x1);
			apple2_.push_back(x1);
		}
	FOR(i,0,apple3){
				ini(x1);
				apple3_.push_back(x1);
			}

	sort(all(apple1_),greater<int>());
	sort(all(apple2_),greater<int>());
	FOR(i,0,x){
		apple3_.push_back(apple1_[i]);
	}
	FOR(i,0,y){
		apple3_.push_back(apple2_[i]);
	}
	sort(all(apple3_),greater<int>());
	ll total = 0;
	FOR(i,0,x+y){
		total+=apple3_[i];
	}
	out(total);
	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int I[]={1,0,-1,0};
int J[]={0,1,0,-1};
int H,W;
int ch,cw;
int dh,dw;
char S[1000][1000];
int cnt[1000][1000];

int main(){
    cin>>H>>W;
    cin>>ch>>cw>>dh>>dw;
    ch--, cw--, dh--, dw--;
    rep(i,H) rep(j,W) cin>>S[i][j];
    rep(i,H) rep(j,W) cnt[i][j]=INF;

    cnt[ch][cw]=0;
    queue<P> q1;
    queue<P> q2;
    q1.push(P(ch,cw));
    while(!q1.empty()){
        while(!q1.empty()){
            //cout<<"AAA"<<endl;
            P p=q1.front(); q1.pop();
            //cout<<p.first<<' '<<p.second<<endl;
            rep(k,4){
                int i=p.first+I[k];
                int j=p.second+J[k];
                if(0<=i && i<H && 0<=j && j<W && S[i][j]=='.' 
                && cnt[p.first][p.second]<cnt[i][j]){
                    //cout<<cnt[p.first][p.second]<<endl;
                    cnt[i][j]=cnt[p.first][p.second];
                    q1.push(P(i,j));
                }
            }
            q2.push(p);
        }

        while(!q2.empty()){
            P p=q2.front(); q2.pop();
            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    int x=i+p.first;
                    int y=j+p.second;
                    if(0<=x && x<H && 0<=y && y<W && S[x][y]=='.'
                    && cnt[p.first][p.second]+1<cnt[x][y]){
                        cnt[x][y]=cnt[p.first][p.second]+1;
                        q1.push(P(x,y));
                    }
                }
            }
        }
    }

    int ans=cnt[dh][dw];
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 8520
/************************************************************
	> File Name: d.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Fri 20 Dec 2019 03:02:31 AM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 3e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll n;
ll a[MAXN];
int bit[65];
int main(void){
	IOS;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		for(int j = 0;j < 62;j++)
			if(a[i]&(1ll<<j))
				bit[j]++;
	}
	ll ans = 0;
	for(int i = 0;i < 62;i++)
		ans = (ans+((bit[i]*(n-bit[i])%MOD)*((1ll<<i)%MOD))%MOD)%MOD;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

	int y,m,d;
	while(cin>>y>>m>>d){
		if(y<=1867){
			cout<<"pre-meiji"<<endl;
		}
		else if(y>=1869&&y<=1911){
			cout<<"meiji ";
			cout<<y-1867<<" "<<m<<" "<<d<<endl;
		}
		else if(y>=1913&&y<=1925){
			cout<<"taisho ";
			cout<<y-1911<<" "<<m<<" "<<d<<endl;
		}
		else if(y>=1927&&y<=1988){
			cout<<"showa ";
			cout<<y-1925<<" "<<m<<" "<<d<<endl;
		}
		else if(y>=1990){
			cout<<"heisei ";
			cout<<y-1988<<" "<<m<<" "<<d<<endl;
		}
		else{
			if(y==1868){
				if((m<=8)||(m==9&&d<=7)){
					cout<<"pre-meiji"<<endl;
				}
				else{
					cout<<"meiji ";
					cout<<y-1867<<" "<<m<<" "<<d<<endl;
				}
			}
			else if(y==1912){
				if((m<=6)||(m==7&&d<=29)){
					cout<<"meiji ";
					cout<<y-1867<<" "<<m<<" "<<d<<endl;
				}
				else{
					cout<<"taisho ";
					cout<<y-1911<<" "<<m<<" "<<d<<endl;
				}
			}
			else if(y==1926){
				if((m<=11)||(m==12&&d<=24)){
					cout<<"taisho ";
					cout<<y-1911<<" "<<m<<" "<<d<<endl;
				}
				else{
					cout<<"showa ";
					cout<<y-1925<<" "<<m<<" "<<d<<endl;
				}
			}
			else if(y==1989){
				if(m==1&&d<=7){
					cout<<"showa ";
					cout<<y-1925<<" "<<m<<" "<<d<<endl;
				}
				else{
					cout<<"heisei ";
					cout<<y-1988<<" "<<m<<" "<<d<<endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main() {
    ll n,ans=0;
    vector<int> a;
    cin >> n;
    for(int i=0;i<3*n;i++){
        int hoge;
        cin >> hoge;
        a.push_back(hoge);
    }
    sort(a.begin(),a.end());
    for(int i=3*n-2;i>n-1;i-=2){
        ans+=a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector< LL > satis( n );
		vector< vector<LL> > ss( n, vector<LL>() ), es( n, vector<LL>() );

		REP( i, 0, n )
		{
			int m, l;
			cin >> m >> l;

			satis[i] = l;

			ss[i].resize( m );
			es[i].resize( m );

			REP( j, 0, m )
			{
				int s, e;
				cin >> s >> e;

				ss[i][j] = s - 6;
				es[i][j] = e - 6;
			}
		}
		
		vector<LL> dp( 1U << 16, -1 );
		dp[0] = 0;

		REP( i, 0, 1 << 16 )
		{
			if ( dp[i] < 0 )
			{
				continue;
			}

			REP( j, 0, n )
			{
				int next = i;
				bool ok = true;

				for ( int k = 0; ok && k < ss[j].size(); k++ )
				{
					REP( l, ss[j][k], es[j][k] )
					{
						if ( ( next >> l ) & 1 )
						{
							ok = false;
							break;
						}

						next |= ( 1 << l );
					}
				}

				if ( !ok )
				{
					continue;
				}

				dp[ next ] = max( dp[ next ], dp[i] + satis[j] );
			}
		}

		cout << *max_element( ALL( dp ) ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1732
package main

import "fmt"

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	if (b-a)%2 == 0 {
		fmt.Println((b - a) / 2)
	} else {
		fmt.Println(min(a-1, n-b) + (b-a-1)/2 + 1)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%2){
        string s;
        cin>>s;
        cout<<"No"<<endl;
    }
    else {
        char x;
        int flag=0;
        map<char, int>mp;
        for(int i=0; i<n; i++) {
            cin>>x;
            mp[x]+=1;
        }
        for(auto i: mp) {
            if(i.second%2) {
                flag=1;
                break;
            }
        }
        if(flag) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

// Cð½·àÌªlb¤É èACð½·ÅålðßéÆ«BCð½·àÌª³¢Æ«ÌÉÓB
template<class T> T upper_search(T lb, T ub, bool (*C)(T)) {
  while(ub-lb>1) { // ±±ÍKÉB
    T mid = (lb+ub)/2;
    if (C(mid)) lb = mid;       // Å¬lðßéÈçlbÆubðüêÖ¦é
    else ub = mid;
  }
  return lb;
}

struct P {
  string name;
  int x;
  P(char *name, int x) : name(name), x(x) {}
  P() {}
};
bool operator<(const P &a, const P &b) {
  return a.x != b.x ? a.x > b.x : a.name < b.name;
}

int x[100000];
P fav[100000];
P v[100000];

int n, m, k, l;

bool C(int a) {
  if (a > k) return 0;
  P standard ;
  int c = 0;
  REP(i, n) {
    if (fav[c].name == v[i].name) c++;
    if (i == k-a+c) {
      standard = v[i];
      break;
    }
  }
  if (standard.name == "") return 1;
  // cout << "a = " << a << endl;
  // cout << standard.name << " " << standard.x << endl;
  int need = 0;
  REP(i, a) {
    if (standard < fav[i] ) {   // standardÌÙ¤ªÊªã
      if (standard.name < fav[i].name) { // standardª«Å¢
        need += standard.x - fav[i].x + 1;
      } else {
        need += standard.x - fav[i].x;
      }
    }
    if (need > l) return 0;
  }
  // cout << "need = " << need << endl;
  return 1;
}

int main() {
  while(scanf("%d%d%d%d",&n,&m,&k,&l), n) {
    map<string, int> id;
    REP(i, n) {
      char tmp[20];
      scanf("%s %d", tmp, x+i);
      id[string(tmp)] = i;
      v[i] = P(tmp, x[i]);
    }
    REP(i, m) {
      char tmp[20];
      scanf("%s", tmp);
      fav[i] = P(tmp, x[id[string(tmp)]]);
    }
    sort(v, v+n);
    sort(fav, fav+m);
    // REP(i,n) {
    //   cout << v[i].name << " " << v[i].x << endl;
    // }
    // cout << endl;
    // REP(i,m) {
    //   cout << fav[i].name << " " << fav[i].x << endl;
    // }
    cout<<upper_search<int>(0, m+1, C)<<endl;
  }
}

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

int main()
{
    string s;
    char AB[3] = "AB";

    cin >> s;

    int n_a = 0;
    int n_b = 0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == AB[0])
        {
            n_a++;
        }
        else
        {
            n_b++;
        }
    }

    if(n_a == 0 || n_b == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	double pi=3.14159;
	double r; cin>>r;
	cout<<2*pi*r;
}

Measured memory_bytes: 3800
import sys

n=int(input())
xyh=[[] for i in range(n)]
for i in range(n):
    x,y,h=map(int,input().split())
    xyh[i].append(x)
    xyh[i].append(y)
    xyh[i].append(h)
for i in range(101):
    for j in range(101):
        f=0
        dis=[[i] for i in range(205)]
        for q in range(n):
            x=xyh[q][0]
            y=xyh[q][1]
            h=xyh[q][2]
            d=abs(x-i)+abs(y-j)
            
            if len(dis[d])==1:
                dis[d].append(h)
            elif len(dis[d])!=1 and dis[d][1]!=h:
                f=1
        
        dis=[dis[e] for e in range(205) if len(dis[e])!=1]
        m=len(dis)
        if m==1 and f==0:
            print(i,j,dis[0][0]+dis[0][1])
            sys.exit()
            
        else:
            if all(dis[e][0]+dis[e][1]==dis[e+1][0]+dis[e+1][1] for e in range(m-1) if dis[e+1][1]!=0) and f==0:
                print(i,j,dis[0][0]+dis[0][1])
                sys.exit()



Measured memory_bytes: 9320
def sieve(N):#エラトステネスの篩
    prime = [0]*(N+1)
    isprime = [True]*(N+1)
    isprime[0]=isprime[1] = False
    num = 0
    for p in range(2,N+1):
        if isprime[p]:
            prime[num] = p
            num += 1
            for j in range(2*p,N+1,p):
                isprime[j] = False
    return prime

lis = sieve(10**5)
prime = set(lis)-{0}
for i in range(len(lis)):
    if lis[i] != 0:
        if (lis[i]+1)//2 in prime:continue
        else:lis[i] = 0
    else:continue
Q = int(input())
lis = set(lis)-{0}
c = [0]*(10**5+1)
for i in range(10**5):
    if i+1 in lis:
        c[i+1] = c[i]+1
    else:
        c[i+1] =c[i]
c = tuple(c)
for _ in range(Q):
    l,r = map(int,input().split())
    tmp = c[r]-c[l-1]
    print(tmp)



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  printf("%c%c%c", 'A', b[0], 'C');
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line = input.readLine();
        BigInteger A = new BigInteger(line);
        line = input.readLine();
        BigInteger B = new BigInteger(line);

        if (A.compareTo(B)==1) {
            System.out.println("GREATER");
        } else if (A.compareTo(B)==-1) {
            System.out.println("LESS");
        } else {
            System.out.println("EQUAL");
        }
    }
}


Measured memory_bytes: 23380
#include <iostream>
using namespace std;
int main(void){
   int ans,A,B,X,Y;
  cin>>A>>B;
  int memo=B*10;
  for(int i=0;i<9;i++){
    int ans=(memo+i)*0.08;
    if(ans==A){
      cout<<memo+i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int a, b;

int main() { 

  cin >> a >> b;

  if (a * b % 2 == 0) {
    puts("Even");
  } else {
    puts("Odd");
  }

  return 0;
}


Measured memory_bytes: 256
input = gets.to_s.split()

a = input[0].to_i
b = input[1].to_i
c = input[2].to_f

# s
puts 0.5 * a * b * Math.sin(c / 180.0 * Math::PI)

# l
puts a + b + Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(c / 180.0 * Math::PI))

# h
puts b * Math.sin(c / 180.0 * Math::PI)


Measured memory_bytes: 6916
N,L = [int(i) for i in input().split()]
list=[]
s=N*(L-1)
for i in range(1,N+1):
    s +=i
    list.append(abs(L+i-1))
a=0
if s<0:
    a=s+min(list)
else:
    a=s-min(list)

print(a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <x86intrin.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4,sse4.1,sse4.2,tune=native")

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int m1,d1, m2,d2;
	cin >>m1 >>d1 >>m2 >>d2;
	
	int mdy[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	
	if(m1==12 && m2==31 && m2==1 && d2==1){
		puts("1"); return 0;
	}
	if(m1 !=m2) puts("1");
	else puts("0");
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << "\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort();C.sort()
M = 0
for i in range(N):
    low = 0
    high = N - 1
    t = (low + high) // 2
    if A[N-1] < B[i]:
        t = N-1
    elif A[0] >= B[i]:
        t = -1
    else:
        while (low <= high):
            if A[t] < B[i] <= A[t+1]:
                break
            elif B[i] <= A[t]:
                high = t
            elif A[t+1] < B[i]:
                low = t+1
            t = (low + high) // 2
    low = 0
    high = N - 1
    s = (low + high) // 2
    if C[N-1] <= B[i]:
        s = N-1
    elif B[i] < C[0]:
        s = -1
    else:
        while (low <= high):
            if C[s] <= B[i] < C[s+1]:
                break
            elif B[i] < C[s]:
                high = s
            elif C[s+1] <= B[i]:
                low = s + 1
            s = (low + high) // 2
    M += (t+1)*(N-s-1)
print(M)


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

const int depth = 19;
class Segtree
{
	int sum[1 << (depth + 1)];

public:
	Segtree() {
		for (int i = 0; i < 1 << (depth + 1); i++) {
			sum[i] = 0;
		}
	}
	
	void update(int pos, int x) {	//x=0,1
		pos += (1 << depth) - 1;
		int plus = x - sum[pos];
		
		sum[pos] += plus;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			sum[pos] += plus;
		}
	}
	
	//??????[l, r)??????
	int getSum(int l, int r, int a = 0, int b = (1 << depth), int id = 0) {
		if (l >= b || r <= a) { return 0; }
		if (l <= a && b <= r) { return sum[id]; }
		int u = getSum(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int v = getSum(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return u + v;
	}
	
	//????????????(0????????????)??\?????§, ??????????????????0?????????
	int getZeroPos(int a = 0, int b = (1 << depth), int id = 0) {
		if (sum[id] == b - a || id == (1 << depth) - 1) { return (1 << depth); }
		if (b - a == 1) { return id - (1 << depth) + 1; }
		int u = getZeroPos(a, a + (b - a) / 2, id * 2 + 1);
		if (u != (1 << depth)) { return u; }
		return getZeroPos(a + (b - a) / 2, b , id * 2 + 2);
	}
};

int n;
int x[500000];
int s[500100];	//s[0].s[1]s[2]???
Segtree seg;

bool check(int digit) {
	if (s[0] == 1) { return false; }
	
	int pos = seg.getZeroPos();
	if (digit >= pos) { return true; }
	if (digit < pos - 1) { return false; }
	if (seg.getSum(pos, (1 << depth)) > 0) { return false; }
	return true;
}

void addBit(int digit) {
	if (digit > n + 90) { return; }
	
	s[digit]++;
	seg.update(digit, s[digit]);
	
	for (int i = digit; i > 0 && s[i] == 2; i--) {
		s[i - 1]++;
		seg.update(i - 1, s[i - 1]);
		s[i] = 0;
		seg.update(i, 0);
	}
}

void print() {
	cout << "s = " << s[0] << ".";
	for (int i = 1; i < 10; i++) {
		cout << s[i];
	}
	cout << endl;
}

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> x[i];
	
	for (i = 0; i < n; i++) {
		if (!check(x[i])) { cout << "No" << endl; }
		else { cout << "Yes" << endl; addBit(x[i]); }
	}
	return 0;
}

Measured memory_bytes: 10552
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_set>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

int len(ll k){
    int cnt=0;
    for(ll i=k;i;i/=10) cnt++;
    return cnt;
}

ll solve(){
    ll k,m=0,ans=1,cur=7;
    cin>>k;
    unordered_set<ll> s;
    while(1){
        while(cur < k) ans++,cur=cur*10+7;
        m=cur%k;
        if(s.count(m)) return -1;
        s.insert(m);
        if(m == 0) return ans;
        cur=m;
    }
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 39388
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;

		for (int i = 0; i + 1 < n; i++) {
			if (s[i] == 'A' && s[i + 1] == 'C') {
				pr.println("Yes");
				return;
			}
		}

		pr.println("No");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <sstream>

typedef long long ll;

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < n; i++){
        for(int j = i - 1; j >= 0; j--){
            if(v[j] > v[j + 1]) {
                int a = v[j + 1];
                v[j + 1] = v[j];
                v[j] = a;
            }
        }
        string s = "";
        for(int j = 0; j < n; j++){
            s += to_string(v[j]);
            if(j != n - 1) s += " ";
        }
        cout << s << endl;
    }
}




Measured memory_bytes: 3232
MOD = 10 ** 9 + 7
inv = [None, 1]
for i in range(2, 10 ** 5 * 2 + 1):
    inv.append(MOD - MOD // i * inv[MOD % i] % MOD)

fact = [1]
ifact = [1]
for i in range(1, 10 ** 5 * 2 + 1):
    fact.append((i * fact[-1]) % MOD)
    ifact.append((inv[i] * ifact[-1]) % MOD)


class Node:
    def __init__(self, ind):
        self.ind = ind
        self.val = 1
        self.ndesc = 1
        self.neighs = []


N = int(input())
nodes = [Node(i) for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].neighs.append(nodes[b - 1])
    nodes[b - 1].neighs.append(nodes[a - 1])

stack = [(-1, nodes[0])]
for i in range(N):
    fro, node = stack[i]
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh))

for i in range(N - 1, -1, -1):
    fro, node = stack[i]
    node.val = node.val * fact[node.ndesc - 1] % MOD
    if fro == -1:
        continue
    nodes[fro].ndesc += node.ndesc
    nodes[fro].val = nodes[fro].val * node.val * ifact[node.ndesc] % MOD

stack = [(-1, node, nodes[0].val * inv[N] % MOD)]
for i in range(N):
    fro, node, val = stack[i]
    node.val = val * node.ndesc * inv[max(1, N - node.ndesc)] % MOD
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh, node.val))

for i in range(N):
    print(nodes[i].val)


Measured memory_bytes: 130248
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li a,b,c,d,e; cin >>a >>b >>c >>d >>e;
  b+=a*60; d+=c*60;
  print(d-b-e);
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	int n,count=0;
	bool left = true, right = true, all = true;
	vector<string> v;
	for (;;) {
		cin >> n;
		if (n == 0)break;
		v.resize(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}

		for (int i = 0; i < n; i++) {
			if (v[i] == "lu") left = false;
			if (v[i] == "ru") right = false;
			if (v[i] == "ld") left = true;
			if (v[i] == "rd") right = true;

			if (all == true) {
				if (left == false && right == false) {
					count++;
					all = false;
				}
			}
			else {
				if (left == true && right == true) {
					count++;
					all = true;
				}
			}
			
		}
		cout << count << endl;
		count = 0;
		left = true; right = true; all = true;
	}
}

Measured memory_bytes: 3072
let tas = Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let x, y = Array.fold_left (fun (x, y) (t, a) -> let k = max ((x + t - 1) / t) ((y + a - 1) / a) in k * t, k * a) tas.(0) tas
let _ = Printf.printf "%d\n" @@ x + y

Measured memory_bytes: 1024
#include <iostream>
#include <set>

using namespace std;

int main(){

    int N;
    cin >> N;

    int i;
    set<int> st;
    for(i = 0; i < N; i++){
        int n;
        cin >> n;
        st.insert(n);
    }
    cout << st.size() << endl;

    return 0;
}

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

int main() {
   string s1, s2, s3;
   cin >> s1 >> s2 >>s3;
  cout << "A" << s2.at(0) << "C" <<endl;
  return 0;
}


Measured memory_bytes: 3636