akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;

void main()
{
  string s = chomp(readln());
  long sec = to!long(s);
  
  string hh = to!string(sec / 3600);
  string mm = to!string((sec % 3600) / 60);
  string ss = to!string(sec % 3600 % 60);

  write(hh);
  write(":");
  write(mm);
  write(":");
  writeln(ss);
}

Measured memory_bytes: 2492
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

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

    vector<ll> val;

    ll curv = 0;

    for(int i=1;i<=n;i++){
        curv = 0;
        for(int j=i;j>=1;j--){
            curv += (ll)A[j];
            val.push_back(curv);
        }
    }

    ll res = 0;


    for(int t=40;t>=0;t--){
        curv = res|(1LL<<t);

        cnt = 0;

        for(int i=0;i<val.size();i++){
            if((curv&val[i])==curv)cnt++;
        }

        if(cnt>=k){
            res|=(1LL<<t);
        }
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

ll pow(ll a, ll b, ll m)
{
    ll  ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

vector<int>v[100005];
bool vis[100005];
int l[100005];
int n;

int dfs(int index,int length,int parent){
    if(l[index]!=-1){
        return l[index];
    }
    vis[index]=true;
    if(v[index].size()==0){l[index]=1; return 1;}
    
    for(int i=0;i<v[index].size();i++){
        if(v[index][i]!=parent)
          l[index]=max(l[index],1+dfs(v[index][i],length,index));
    }
    return l[index];
}

int main()
{
	IOS;
	int t=1; //cin>>t;
	while(t--){
	  int m;
	  cin>>n>>m;
	  for(int i=1;i<=n;i++) l[i]=-1,vis[i]=false;
	  for(int i=0;i<m;i++){
	      int x,y;
	      cin>>x>>y;
	      v[x].push_back(y);
	  }
	  for(int i=1;i<=n;i++){
	      if(!vis[i]){
	          dfs(i,1,0);
	      }
	  }
	  int ans=0;
	  for(int i=1;i<=n;i++) ans=max(ans,l[i]);
	  cout<<ans-1;
	  cout<<"\n";
	}    

}

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

int main(){
	bool flag;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		if(c-b<=0){
			flag=true;
			break;
			
		}
		if(a-d<=0){
			flag=false;
			break;
		}
		c=c-b;
		a=a-d;
	}
	if(flag){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

}

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


int main(){
   int64_t N,A,B;
   cin>>N>>A>>B;
   int64_t amari;
   if(N%(A+B)<A){
       amari=N%(A+B);
   }
   else{
       amari=A;
   }
   cout<<(N/(A+B))*A+amari<<endl;
}


Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break

    data = []
    for _ in range(n):
        i, u, a, p = map(int, input().split())
        data.append([i, u, a, p])

    data = sorted(data, key=lambda x: (-x[2], x[3], x[0]))
    union = [0] * 1001

    cnt = 0
    for d in data:
        i, u, a, p = d
        if cnt < 10 and union[u] < 3:
            print(i)
            cnt += 1
            union[u] += 1
        elif cnt < 20 and union[u] < 2:
            print(i)
            cnt += 1
            union[u] += 1
        elif cnt < 26 and union[u] < 1:
            print(i)
            cnt += 1
            union[u] += 1



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

int main()
{
	int n;
	cin>>n;
	for(int a=1;a<=9;a++)
	{
		for(int b=1;b<=9;b++)
		{
			if(a*b==n)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> sum(N+1);
	vector<int> sum2(N + 1);
	sum[0] = 0;
	vector<char> dx;
	for (int i = 0; i < N; i++)
	{
		char temp;
		cin >> temp;
		dx.push_back(temp);
		sum[i + 1] = sum[i];
		sum2[i + 1] = sum2[i];
		if (temp == 'E')
		{
			sum[i + 1] = sum[i] + 1;
		}
		else if (temp == 'W')
		{
			sum2[i + 1] = sum2[i] + 1;
		}
	}
	int mini = 9999999;
	for (int i = 1; i < N + 1; i++)
	{
		mini = min(mini, sum2[i-1] + sum[N] - sum[i]);
	}
	cout << mini << endl;
    return 0;
}


Measured memory_bytes: 3196
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

type StringStack struct {
	container []string
}

func NewStringStack() *StringStack {
	return &StringStack{
		container: make([]string, 0),
	}
}

func (s *StringStack) Push(value string) {
	s.container = append(s.container, value)
}

func (s *StringStack) Pop() string {
	if s.Size() == 0 {
		panic("StringStack is empty")
	}
	x := s.container[len(s.container) - 1]
	s.container = s.container[:len(s.container) - 1]
	return x
}

func (s *StringStack) Size() int {
	return len(s.container)
}

func main() {
	io := NewIo()
	defer io.Flush()
	a := io.NextInt()
	b := io.NextInt()
	if a == 1 {
		a = 14
	}
	if b == 1 {
		b = 14
	}
	if a < b {
		io.PrintLn("Bob")
	} else if a > b {
		io.PrintLn("Alice")
	} else {
		io.PrintLn("Draw")
	}
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int ans = n-1+2*k;
    for (int i = 1; i < n; i++) if (s[i-1] != s[i]) ans--;
    cout << min(ans, n-1) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N],cnt,n,v,b[N],f[1<<18];
int c[19][N];
bool ans[N];
inline void Max(int &x,int y){if(y>x)x=y;}
int main(){
	scanf("%d%d",&n,&v);
	for(int i =1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	int last = 1,tot = 0;
	for(int i = 2;i<=n;i++){
		if(a[i]>a[i-1]+v) {
			for(int j = last;j<i;j++) c[0][j] =i-1;
			last = i;
			tot++;
		}
	} 
	tot++;
	for(int j=last;j<=n;j++) c[0][j]=  n;
	if(tot>18){
		for(int i =1;i<=n;i++) puts("Impossible");
		return 0;
	}
	
	for(int st=1,fi;st<=n;st=fi+1){
		fi = c[0][st];
		int tmp = v;
		cnt = 0;
		int m = 0;
		bool pd = false;
	
		for(int i =1;i<st;i++) b[++m] = a[i];
		for(int i =fi+1;i<=n;i++) b[++m] = a[i];
		do{
			cnt++;
			tmp>>=1;
			int last = 1;
			for(int i = 2;i<=m;i++){
				if(b[i]>b[i-1]+tmp) {
					for(int j = last;j<i;j++) c[cnt][j] =i-1;
					last = i;
				}
			} 
			for(int j=last;j<=m;j++) c[cnt][j]=  m;
		} while(tmp>0);
		//cout<<start<<' '<<*it<<endl;
		memset(f,0,sizeof(f));
		for(int k = 0;k<1<<cnt;k++){
			if(f[k] == m) {
				pd =true;
				continue;
			}
			for(int j = 1;j<=cnt;j++) if(!(k>>j-1&1)){
				Max(f[k+(1<<j-1)],c[j][f[k]+1]);
			}
		}
		for(int i =st;i<=fi;i++) ans[i] = pd;
	}
	for(int i=1;i<=n;i++) 
		if(ans[i]) puts("Possible");
		else puts("Impossible");
	return 0;
}

Measured memory_bytes: 19968
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
c = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ind = bisect.bisect_left(l, l[i]+l[j])
        c += ind-j-1               
print(c)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    size_t d, x;
    cin >> d >> x;
    unsigned long long sum = x;
    for (size_t i = 0; i < n; ++i) {
        size_t a;
        cin >> a;
        for (size_t j = 0; j < d; ++j) {
            if (j * a + 1 <= d) {
                ++sum;
            }
            else {
                break;
            }
        }
    }
    cout << sum << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int S=a*b;
  int l=2*a+2*b;
  System.out.println(S+" "+l);
 }
}
  

Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

template <typename T>
class SparseTable {
	int n;
	vector<vector<T>> t;
	T merge(const T& l, const T& r) {
		return min(l, r);
	}
public:
	SparseTable(const vector<T>& b) {
		n = b.size();
		t.push_back(b);
		for (int i = 2, j = 1; i <= n; i <<= 1, j++) {
			t.push_back(vector<T>());
			for (int k = 0; k + i <= n; k++) {
				t[j].push_back(merge(t[j - 1][k], t[j - 1][k + i / 2]));
			}
		}
	}
	T find(int l, int r) {
		r++;
		assert(0 <= l && l < r && r <= n);
		unsigned int w = r - l;
		int i = 31 - __builtin_clz(w);
		return merge(t[i][l], t[i][r - (1 << i)]);
	}
	T operator[](int id) {
		return t[0][id];
	}
};

class LCA {
	int V, rt;
	vector<vector<int>> G;
	vector<int> depth, used, id;
	vector<int> vs, de;
	SparseTable<pii> st;
	void dfs(int s, int d) {
		used[s] = 1;
		vs.push_back(s);
		de.push_back(d);
		for (int v : G[s]) {
			if (!used[v]) {
				dfs(v, d + 1);
				vs.push_back(s);
				de.push_back(d);
			}
		}
	}
	vector<pii> init() {
		dfs(rt, 0);
		for (int i = 0; i < (int)vs.size(); i++) {
			if (id[vs[i]] == -1) id[vs[i]] = i;
		}
		vector<pii> r((int)vs.size());
		for (int i = 0; i < (int)vs.size(); i++) {
			r[i] = pii(de[i], vs[i]);
		}
		return r;
	}
public:
	LCA(vector<vector<int>> G_, int rt_ = 0)
		: V(G_.size()), rt(rt_), G(G_), depth(V), used(V), id(V, -1), st(init()) {
		for (int i = 0; i < V; i++) depth[i] = st[id[i]].first;
	}
	int calc(int a, int b) {
		return st.find(min(id[a], id[b]), max(id[a], id[b])).second;
	}
	int dist(int a, int b) {
		return depth[a] + depth[b] - depth[calc(a, b)] * 2;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n;
	vector<vector<int>> G(n);
	for (int i = 0, k; i < n; i++) {
		cin >> k;
		for (int j = 0, c; j < k; j++) {
			cin >> c;
			if (c > i) {
				G[i].push_back(c);
				G[c].push_back(i);
			}
		}
	}
	LCA lca(G);
	cin >> q;
	for (int i = 0, u, v; i < q; i++) {
		cin >> u >> v;
		printf("%d\n", lca.calc(u, v));
	}
	return 0;
}

Measured memory_bytes: 54212
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;



int N;
int a[100010];
int A;
//---------------

int main(){
	cin>>N;
	REP(i,0,N) {
		cin>>A;
		a[A+2]++;
		a[A+1]++;
		a[A]++;
	}
	p(*max_element(a,a+100002));
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string i2s(int x){
  stringstream ss;
  ss<<x;return ss.str();
}
bool check(string s){
  for(int i=0;i<s.size()-1;i++) if(s[i+1]-s[i]!=1) return false;
  return true;
}
int main(){
  int n,i,j,k=-1;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(check(i2s(a[i]*a[j]))) k=max(k,a[i]*a[j]);
    }
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	string t;
	int a,b,c;
	cin>>a>>b;
	if(b==1){
		cout<<0<<endl;
		return 0;
	}else cout<<a-b<<endl;
}

	


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a=Integer.parseInt(scan.next());
		int b=Integer.parseInt(scan.next());
		System.out.print("a");
		if(a<b)System.out.println(" < b");
		else if(a>b)System.out.println(" > b");
		else System.out.println(" == b");
	}
}

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

int main()
{
	int A, B, C;

	scanf("%d %d %d",&A,&B,&C );
	if (A == B&&B == C) { printf("Yes\n" ); }
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
start = sum(A)
for i in range(N):
    A[i] = A[i] - B[i]
    if A[i] < 0:
        m = A[i] * (-1)
        A[i] = 0
        A[i+1] = max(A[i+1]-m,0)
end = sum(A)
print(start - end)


Measured memory_bytes: 18624
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <deque>

#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;



signed main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) {
		cout << "YES" NL;
	} else {
		cout << "NO" NL;
	}

	return 0;
}

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

using namespace std;

int sosu(int a){
  for (int i = 2; i <=  a; i++) {
        if (a % i == 0) return i;
    }
}

int main(){
  int n;
  int a[1000], arr[1000];
  int answer = 1;
  double mox = 0;
  
  scanf("%d", &n);
  
  for(int i = 0; i<n; i++){
    scanf("%d", &a[i]);
  	arr[i] = a[i];
  }
  
  for (int i = 0; i < n; i++) {
        while (arr[i] != 1) {
            int tp = sosu(arr[i]);
            answer = answer * tp;
            for (int j = 0; j < n; j++) {
                if (arr[j] % tp == 0) arr[j] = arr[j] / tp;
            }
        }
    }
  
  for (int i = 0; i<n; i++)
    mox = mox + answer/a[i];
  
  cout << answer/mox;
  
  return 0;
}
  


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 200005, mod = 1e9 + 7;
int F[N], sum[N], mn[N], mx[N];
struct Edge{ int v, l, r, x; } A[N];
bool cmp1(const Edge &A,const Edge &B) { return A.v > B.v; }
bool cmp2(const Edge &A,const Edge &B) { return A.l == B.l ? A.r < B.r : A.l < B.l; }

int main() {
	int n = read();
	for (int i = 1; i <= n; ++i) 
		A[i].x = read(), A[i].v = read();
	sort(A + 1, A + n + 1, cmp1);
		
	mn[1] = A[1].x;
	for (int i = 2; i <= n; ++i) mn[i] = min(mn[i - 1], A[i].x);
	for (int i = 1; i <= n; ++i) {
		int l = 1, r = i - 1, p = i;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (mn[mid] < A[i].x) p = mid, r = mid - 1;
			else l = mid + 1;
		}
		A[i].l = p;
	}
	mx[n] = A[n].x;
	for (int i = n - 1; i >= 1; --i) mx[i] = max(mx[i + 1], A[i].x);
	for (int i = n; i >= 1; --i) {
		int l = i + 1, r = n, p = i;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (mx[mid] > A[i].x) p = mid, l = mid + 1;
			else r = mid - 1;
		}
		A[i].r = p;
	}
	sort(A + 1, A + n + 1, cmp2);
	int p = 1, Ans = 0;
	for (int i = 1; i <= n; ++i) {
		while (A[p].r < A[i].l - 1) 
			p ++;
		F[i] = (sum[i - 1] - sum[p - 1] + mod) % mod;
		if (A[i].l == 1) F[i] = (F[i] + 1) % mod;
		sum[i] = (sum[i - 1] + F[i]) % mod;
		if (A[i].r == n) Ans = (Ans + F[i]) % mod;
	}
	cout << Ans;
	return 0;
}

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

int main()
{
    int c[5] = {0};
    for (int i = 0; i < 6; i++)
    {
        int ab;
        cin >> ab;
        c[ab]++;
    }
    
    int i;
    for (i = 1; i <= 4; i++)
    {
        if(c[i] >= 3)break;
    }
    
    if(i == 5)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn = int(1e6);
vector<bool> isprime(Maxn + 1,0);
int X;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> X;
    isprime[0] = isprime[1] = 1;
    for (int i = 2; i <= 1000; i++)
        if (!isprime[i])
            for (int j = i*i; j <= Maxn; j += i) isprime[j] = 1;
    
    while (X <= Maxn && isprime[X]) X++;
    cout << X;
    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
x=99999
s=[list(map(int,input().split())) for i in range(m)]
s=sorted(s)
for i in range(m):
    if s[i][0]==1 and s[i][1]==0 and n!=1:
        x=-1

for i in range(m):
    for j in range(m):
        if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:
            x=-1

a=[0]*n
ans=0
for i in range(m):
    a[s[i][0]-1]=s[i][1]

if a[0]==0 and n!=1:
    a[0]=1

for i in range(n):
    ans+=a[i]*(10**(n-i-1))


print(min(x,ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/5;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

int n;
string s;
int main(){
	cin>>n>>s;
	vector<int> t;
	int ans=0;
	for(int i=0;i<n;i++){
		t.clear();
		t=z_algorithm(s.substr(i,n-i));
		for(int j=1;j<t.size();j++){
			if(t[j]>j){
				ans=max(ans,j);
			}else{
				ans=max(ans,t[j]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

class Program
{
    public static void Main()
    {
        char c=Console.ReadLine()[0];
        switch (c)
        {
            case 'A':
                Console.WriteLine('T');
                break;
            case 'T':
                Console.WriteLine('A');
                break;
            case 'G':
                Console.WriteLine('C');
                break;
            case 'C':
                Console.WriteLine('G');
                break;
        }
    }
}

Measured memory_bytes: 13140
e1,e2,e3,e4 = map(int,input().split())
if e1==e2:
    if e3==e4:
        print("yes")
    else:
        print("no")
elif e1==e3:
    if e2==e4:
        print("yes")
    else:
        print("no")
elif e1==e4:
    if e2==e3:
        print("yes")
    else:
        print("no")
else:
    print("no")



Measured memory_bytes: 5596
import math

def main():
    a, b, x = map(int, input().split())
    if x < a * a * b / 2:
        tan = 2 * x / (b * b * a)
        print(90 - math.degrees(math.atan(tan)))
    else:
        tan = (2 / a) * (b - x / a**2)
        print(math.degrees(math.atan(tan)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62444
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

int main(){
  int a,b,c; cin >> a>> b>>c;
  bool r = (a<c && c<b) || (b<c && c<a);
  cout << ( r?Liney:Linen);
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut gifts: Vec<String> = vec![];

    for _ in 0..n{
        gifts.push(read_as_string());
    }

    gifts.sort();
    gifts.dedup();

    println!("{}", gifts.len());
}


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

int main() {
  int N;
  cin>>N;
  vector<int> ans(N, 0); // A1からAN
  int tensho=100;
  for(int i = 0; i < N; i++){
    int A;
    cin>>A;
    while(true){
      if(A % 2 == 1){
      break;
      }
      A = A / 2;
      ans[i]++;
    }
    tensho=min(ans[i],tensho);
  }
  /* for(int i = 0; i < N; i++){
    if(i == 0){
      tensho = min(vec[i], vec[i+1]);
    }
    else {
      tensho = min(tensho, vec[i]);
    }
  } */
  cout<<tensho<<endl;
}


Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())
s = input()
b = [0]
w = [0]
for i in range(n):
    bt = b[i]
    wt = w[i]
    if s[i] == "#":
        bt += 1
    else:
        wt +=1
    b.append(bt)
    w.append(wt)

cost = 1000000000000

for i in range(0,n+1):
    temp = 0
    temp += b[i]
    temp += w[-1]-w[i]

    # print(i)
    # print(b[i]-b[1])
    # print(w[-1]-w[i])

    if cost > temp:
        cost = temp
    #print(cost)
    # print("*********")


#print(b)
#print(w)

print(cost)











Measured memory_bytes: 12844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m[15] = {}, a[15][15] = {}, u, v, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> m[i];
        for (int j = 0; j < m[i]; j++) {
            cin >> u >> v;
            if (v == 1) a[i][u - 1] = 1;
            else a[i][u - 1] = -1;
        }
    }
    for (int i = 0; i < (1 << n); i++) {
        int b[15] = {};
        for (int j = 0; j < n; j++) if (i & (1 << j)) b[j] = 1;
        bool y = 0;
        for (int j = 0; j < n; j++) if (b[j]) {
            for (int k = 0; k < n; k++) {
                if (a[j][k] == 1 && !b[k]) {
                    y = 1;
                }
                if (a[j][k] == -1 && b[k]) {
                    y = 1;
                }
            }
        }
        if (!y) z = max(z, __builtin_popcount(i));
    }
    cout << z;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <cmath>

using std::cout;
using std::cin;
using std::endl;

int main(void){
  std::cout << std::fixed << std::setprecision(15);
  int r;
  cin >> r;
  cout << r * r;
}
  

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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll s,w;
    cin >> s >> w;
    if(w>=s)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long min2(long a,long b){
    return a>=b?b:a;
}

int compare(const void *a, const void *b){return *(long *)a - *(long *)b;}
int sqs(long a[],long n,long s){
    if(s==4){qsort(a,n,sizeof(long),compare);}
    return 0;
}

long mod(long a,long b){
    return a/b?mod(a%b,b):a;
}

long comb(long a,long b){
    if(a==1) return 1;
    if(b==0 || b==a) return 1;
    return comb(a-1,b-1)+comb(a-1,b);}

int main(void){
    long l,r,i,j/*c,ju*/;
    scanf("%ld%ld",&l,&r);
    //printf("%ld\n",l);
    if(r-l>=2019){
        printf("0\n");
        return 0;
    }
    if(l<=r/2019*2019){
        printf("0\n");
        return 0;
    }
    l=mod(l,2019);
    r=mod(r,2019);
    // long by[2019],k=0;
    // for(i=0;i<2019;i++){
    //     by[i]=10000;
    // }
    long min=10000;
    for(i=l;i<r;i++){
        for(j=i+1;j<r+1;j++){
            //ju=0;
            // if(k>0){
            //     for(c=0;c<k;c++){
            //         if(by[c]== mod(i*j,2019)){
            //             ju=1;
            //             break;
            //         }
            //     }
            // }
            // if(ju==1) continue;
            // by[k] = mod(i*j,2019);
            // k++;
            // if(k==2019) break;
            min = min2(min,mod(i*j,2019));
        }
    }
    printf("%ld\n",min);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int S_left = atoi(S.substr(0, 2).c_str());
    int S_right = atoi(S.substr(2, 2).c_str());
    bool left_judge_m = (1 <= S_left) and (S_left <= 12);
    bool left_judge_y = 0 <= S_left;
    bool right_judge_m = (1 <= S_right) and (S_right <= 12);
    bool right_judge_y = 0 <= S_right;
    bool mmyy = left_judge_m & right_judge_y;
    bool yymm = left_judge_y & right_judge_m;
    if (mmyy == true and yymm == true)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (mmyy == true and yymm == false)
    {
        cout << "MMYY" << endl;
    }
    else if (mmyy == false and yymm == true)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

struct FenwickTree {
  vector<int> bit;
  int siz;

  FenwickTree(int N) : bit(N) {
    siz = N;
    for ( int i = 0; i < siz; i++ ) { bit[i] = 0; }
  }

  void add(int i, int x) {
    for ( ; i < siz; i += i&-i ) { bit[i] += x; }
  }

  int sum(int i) {
    int sm = 0;
    for ( ; i > 0; i -= i&-i ) { sm += bit[i]; }
    return sm;
  }

  int range_sum(int l, int r) {
    return sum(r) - sum(l-1);
  }
};

struct query {
  int id;
  int l;
  int r;
};
bool operator < (const query &a, const query &b) { return a.r < b.r; }

int main() {
  int n, q;
  cin >> n >> q;
  int c[n+1];
  for ( int i = 1; i <= n; i++ ) { cin >> c[i]; }
  query qs[q];
  for ( int i = 0; i < q; i++ ) {
    int l, r;
    cin >> l >> r;
    qs[i] = {i, l, r};
  }
  sort(qs, qs+q);

  FenwickTree FT(n+1);
  int right_pos[n+1];
  for ( int i = 1; i <= n; i++ ) { right_pos[i] = 0; }
  int ans[q];
  int now_q = 0;
  for ( int i = 1; i <= n; i++ ) {
    if ( right_pos[c[i]] > 0 ) { FT.add(right_pos[c[i]], -1); }
    FT.add(i, 1);
    right_pos[c[i]] = i;
    while ( now_q < q && qs[now_q].r == i ) {
      ans[qs[now_q].id] = FT.range_sum(qs[now_q].l, qs[now_q].r);
      now_q++;
    }
  }

  for ( int i = 0; i < q; i++ ) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main(){
    long long n;
    cin >> n;
    //10で割れる回数...?
    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    long long cnt = 0;
    long long waru = 10;
    while(true){
        if(n/waru > 0){
            cnt += n / waru;
            waru *= 5;
        }else{
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3612
#取り去る順番は考えなくてもok、（０と１の数が少ない方）回だけ取り除く動作ができるので、取り除けるキューブ数は（０と１の数が少ない方）＊2個
S = input()
numofzero = 0
numofone = 0
N = len(S)
for i in range(N):
    if S[i] == "0":
        numofzero += 1
    else:
        numofone += 1
if numofone > numofzero:
    print(numofzero*2)
else:
    print(numofone*2)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
string divide[4]={"dream","dreamer","erase","eraser"};
int main()
{
  int n;cin>>n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(n==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	char s[110], t[110];
	cin >> s >> t;
	int tmp = 0;
	for (int i = n;i < 2 * n;i++) {
		for (int j = i - n;j <= i&&j < n;j++) {
			if (s[j] != t[j - i + n]) {
				tmp = 1;
				break;
			}
		}
		if (tmp == 0) {
			cout << i << endl;
			return 0;
		}
		tmp = 0;
	}
	cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n;
ll solve(ll n) {
	ll num = n;
	ll res = 0;
	while (num) {
		num /= 10;
		res++;
	}
	return res;
}

int main() {
	cin >> n;
	ll ans = INF;
	FOR(i, 1, 100000 + 1) {
		if (n%i == 0) {
			ll num = max(n / i, (ll)i);
			ans = min(ans, solve(num));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll costs [105][10];
ll p[100][11];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> costs[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }
    ll mx = -2e18;
    for (int i = 0; i < (1 << 10); i++) {
        bool can = false;
        int cnt[n];
        memset(cnt, 0, sizeof cnt);
        for (int j = 0; j < 10; j++) {
            if (i & (1 << j)) {
                for (int k = 0; k < n; k++) {
                    if (costs[k][j])
                        cnt[k]++;
                }
            }
        }
        ll currCost = 0;
        for (int j = 0; j < n; j++) {
            if (cnt[j])
                can = true;
            currCost += p[j][cnt[j]];
        }
        if (can)
            mx = max(mx, currCost);
    }
    cout << mx;
    return  0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void){
    int n, m;
    int a[100][100];
    int b[100];
    int c[100] = {0};
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)




int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a >= 3200)puts(s);
	else puts("red");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a : A) cin >> a;
    sort(all(A));
    A.erase(unique(all(A)), A.end());
    if (n == (int)A.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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


Measured memory_bytes: 3936
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

k = ni()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for k in range(1, k + 1):
            ans += gcd(i, gcd(j, k))

print(ans)

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

vector<int> g[15];
bool used[15]={};
int N;

int solve(int u,int pa=-1){
    bool all=true;
    for(int i=0;i<N;i++){
        if(used[i]==true) continue;
        all=false;
    }
    if(all) return 1;
    int ans=0;
    for(auto v:g[u]){
        if(v==pa||used[v]) continue;
        used[v]=true;
        ans+=solve(v,u);
        used[v]=false;
    }
    return ans;
}

int main(){
    int M; cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b; cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    used[0]=true;
    cout << solve(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  vector <int> vec;
  for (int i = 1; i <= n; i++) {
    if (arr[i] != i) {
      vec.push_back(i);
    }
  }
  if (vec.size() > 2) {
    cout << "NO" << endl;
    return 0;
  }
  if (vec.size() > 1) swap(arr[vec[0]], arr[vec[1]]);
  for (int i = 1; i <= n; i++) {
    if (arr[i] != i) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    istream_iterator<int> input(cin);
    int n = *input;
    vector< bitset<20> > a(n);
    bitset<20> bits(0);
    repi(i, a){
        (*i) = bitset<20>(*(++input));
    }
    
    int right = 0;
    ll res = 0;
    rep(left, n){
        while(right < n && (bits & a[right]).none()){
            bits |= a[right];
            ++right;
        }
        res += (right - left);
        if(left == right){
            ++right;
        }else
            bits &= ~a[left];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

const int N = 100 + 2;
int a[N];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
        
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    double val = sum / (4.0 * m);
    sort(a, a + n);
    for (int i = 0; i < n; i++){
        if (a[i] >= val)
            cnt++;
        if (cnt == m){
            return cout << "Yes", 0;
        }
    }
    cout << "No" << endl;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N, x;
    ll count = 0;
    vector<ll> a;
    cin >> N >> x;
    a.resize(N);
    for(ll i = 0;i < N;i++) cin >> a[i];
    if(a[0] > x) {
        count += a[0] - x;
        a[0] = x;
    }
    for(ll i = 1;i < N;i++) {
        ll sum = a[i] + a[i - 1];
        if(sum > x) {
            ll c = sum - x;
            count += c;
            a[i] -= c;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
n, m = list(map(int, input().split()))
condition = [list(map(int, input().split())) for _ in range(m)]

condition.sort(key=lambda a: (a[1], a[0]))

right_end = 0
ans = 0
for c in condition:
    if c[0] >= right_end:
        ans += 1
        right_end = c[1]
print(ans)


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

using namespace std;

const int kMaxN = 50 + 5;

int DP[kMaxN][kMaxN][kMaxN];

int& at(const array<int, 3>& v)
{
    return DP[v[0]][v[1]][v[2]];
}

int main()
{
    for (int i = 0; i < kMaxN; ++i) {
        for (int j = 0; j < kMaxN; ++j) {
            for (int k = 0; k < kMaxN; ++k) {
                DP[i][j][k] = -1;
            }
        }
    }

    array<int, 3> init;
    for (int i = 0; i < 3; ++i) {
        cin >> init[i];
    }

    queue<array<int, 3>> Q;
    auto add = [&] (array<int, 3> a, int cost)
    {
        sort(a.begin(), a.end());
        for (int i = 0; i < 3; ++i) {
            if (a[i] >= kMaxN) {
                return;
            }
        }

        if (at(a) == -1 || cost < at(a)) {
            at(a) = cost;
            Q.push(a);
        }
    };

    add(init, 0);

    while (!Q.empty()) {
        const auto v = Q.front();
        Q.pop();

        const int now_cost = at(v);
        assert (now_cost != -1);

        // Increase one by 2.
        for (int i = 0; i < 3; ++i) {
            auto now = v;
            now[i] += 2;
            add(now, now_cost + 1);
        }

        // Increase two of them by 1.
        for (int i = 0; i < 3; ++i) {
            for (int j = i + 1; j < 3; ++j) {
                auto now = v;
                now[i]++;
                now[j]++;

                add(now, now_cost + 1);
            }
        }
    };

    int best = -1;
    for (int i = 0; i < kMaxN; ++i) {
        int now = DP[i][i][i];

        if (now == -1) {
            continue;
        }

        if (best == -1 || now < best) {
            best = now;
        }
    }

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


Measured memory_bytes: 896
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const h = input[1].split(" ").map(n => Number(n));
  let result = 0;
  let height = 0;
  for (let i = 0; i < n; i++) {
    if (height <= h[i]) {
      result++;
      height = h[i];
    }
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n = int(input())
a = list(map(int, input().split()))
ans = 0
f = True


while f == True:
    for i in range(n):
        if a[i]%2 != 0:
            f = False
            break
        else:
            a[i] //= 2
    if f == True:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,Y;cin>>n>>Y;
    for(ll i=0;i<=n;i++){
        for(ll j=0;i+j<=n;j++){
            for(ll k=0;i+j+k<=n;k++){
                if(i+j+k!=n)continue;
                if(k*1000+j*5000+i*10000==Y){
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


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

int main() {
  int K, A, B; cin >> K >> A >> B;
  bool exist = false;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) exist = true;
  }
  if (exist) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3624
import Data.List
import Control.Monad
main = do
  n <- readLn
  w <- replicateM n getLine
  putStrLn $ if f w then "Yes" else "No"
f x
  | length x == 1 = True
  | length (nub x) < length x = False
  | last (head x) == head (head (tail x)) = f (tail x)
  | otherwise = False

Measured memory_bytes: 1020
h=int(input())
a=list(map(lambda x:int(x),input().split()))
for i in range(1,h+1):
   key=a[i-1]
   print("node {0}: key = {1}, ".format(i,key),end="")
   if i!=1:
       parentindex=i//2
       parentkey=a[parentindex-1]
       print("parent key = {0}, ".format(parentkey),end="")
   leftindex=2*i
   if leftindex<=h:
       leftkey=a[leftindex-1]
       print("left key = {0}, ".format(leftkey),end="")
   rightindex=2*i+1
   if rightindex<=h:
       rightkey=a[rightindex-1]
       print("right key = {0}, ".format(rightkey),end="")
   print()





Measured memory_bytes: 5684