akhauriyash/Code-Regression huggingface dataset:
ii = lambda:int(input())
li = lambda:list(map(int,input().split()))
lix = lambda x:list(li() for _ in range(x))
##########
def main(n,a):
    res = 0
    ran = 2**n
    for tar in range(1,ran):
        check = True
        for i in range(n):
            if tar>>i & 1 and not isHonest(tar, a[i]):
                check = False
                break
        if check : res = max(res, count(tar,n))
    return res                

def count(tar, n):
    res = 0
    for i in range(n):
        if tar>>i & 1 : res += 1
    return res

def isHonest(tar, a):
    res = True
    for i in range(len(a)):
        x,y = a[i]
        if tar>>(x-1) & 1 != y : return False
    return True

n = ii()
a = []
for i in range(n):
    c = ii()
    a.append(lix(c))
print(main(n,a))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; 
typedef long long ll;
struct graph
{
	int lst[100005], to[100005], pre[100005], tot; 
	graph()
	{
		memset(lst, -1, sizeof(lst)); 
		tot = 0; 
	}
	inline void add_edge(int u, int v)
	{
		to[tot] = v; 
		pre[tot] = lst[u]; 
		lst[u] = tot++; 
	}
} g, rg; 
bool f, vis[100005]; 
int fa[100005], sz[100005], orig[100005], cnt[5], col[100005]; 
int getfa(int u)
{
	if (u == fa[u])
		return u; 
	return fa[u] = getfa(fa[u]); 
}
inline void unite(int u, int v)
{
	u = getfa(u); 
	v = getfa(v); 
	if (u == v)
		return; 
	fa[u] = v; 
	sz[v] += sz[u]; 
	orig[v] += orig[u]; 
}
void dfs(int u, int c)
{
	vis[u] = true; 
	col[u] = c; 
	cnt[c]++; 
	for (int i = g.lst[u]; ~i; i = g.pre[i])
	{
		int v = g.to[i]; 
		if (!vis[v])
			dfs(v, (c + 1) % 3); 
		else if ((c + 1) % 3 != col[v])
			f = true; 
	}
	for (int i = rg.lst[u]; ~i; i = rg.pre[i])
	{
		int v = rg.to[i]; 
		if (!vis[v])
			dfs(v, (c + 2) % 3); 
		else if ((c + 2) % 3 != col[v])
			f = true; 
	}
}
int main()
{
	// freopen("AGC006-F.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < n; i++)
	{
		fa[i] = i; 
		sz[i] = 1; 
	}
	for (int i = 0; i < m; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		g.add_edge(--u, --v); 
		rg.add_edge(v, u); 
		unite(u, v); 
		orig[getfa(u)]++;
	}
	ll ans = 0; 
	for (int i = 0; i < n; i++)
	{
		if (i != getfa(i))
			continue; 
		memset(cnt, 0, sizeof(cnt)); 
		f = false; 
		dfs(i, 0); 
		if (f)
			ans += (ll)sz[i] * sz[i]; 
		else if (cnt[0] && cnt[1] && cnt[2])
			ans += (ll)cnt[0] * cnt[1] + (ll)cnt[0] * cnt[2] + (ll)cnt[1] * cnt[2]; 
		else
			ans += orig[i]; 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    string s; cin>>s;
    map<ll,ll> one, two, three;
    rep(i,n){
        ll tmp=s[i]-'0';
        for(ll j=0; j<100; j++){
            if(two[j]>0) three[j*10+tmp]=1;
        }
        for(ll j=0; j<10; j++){
            if(one[j]>0) two[j*10+tmp]=1;
        }
        one[tmp]=1;
    }
    ll res=0;
    for(ll i=0; i<1000; i++){
        if(three[i]>0) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 1024;
const ll inf = 1LL << 50;

ll n, i, j;
ll a[maxN], sum[maxN];
vector<int> moves;

pair<ll, ll> dp[maxN][maxN];
pair<ll, pair<ll, ll> > best;

void rm_back(int cnt) {
    while (cnt-- > 0) {
        moves.pb(n);
        n--;
    }
}

void rm_front(int cnt) {
    while (cnt-- > 0) {
        moves.pb(1);
    }
}

void compute_dp() {
    int i, j, k;
    best = mp(-inf, mp(-1, -1));

    for (i = n; i > 0; i--) {
        dp[i][i] = mp(a[i], 0);
        best = max(best, mp(a[i], mp(1LL * i, 1LL * i)));

        for (j = i + 1; j <= n; j++) {
            if (i % 2 == j % 2) {
                //! full group
                dp[i][j] = mp(-inf, -1);
                for (k = 1; j - k >= i + 1; k += 2)
                    dp[i][j] = max(dp[i][j], mp(dp[i][j - k].first + dp[j - k + 1][j].first, 1LL * j - k));

                best = max(best, mp(dp[i][j].first, mp(1LL * i, 1LL * j)));
            } else {
                //! partial group
                dp[i][j] = mp(dp[i][j - 1].first, j - 1);
                if (j - 2 >= i) dp[i][j] = max(dp[i][j], dp[i][j - 2]);
            }
        }
    }

}

void rev(int l, int r) {
    if (l == r) return;

    if (l % 2 == r % 2) {
        //! full group
        rev(dp[l][r].second + 1, r);
        rev(l, dp[l][r].second);
    } else {
        //! partial group
        rev(dp[l][r].second + 1, r);
        rev(l, dp[l][r].second);
        moves.pb(l + 1);
    }
}

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = a[i];

        if (i >= 3) sum[i] += sum[i - 2];
    }

    compute_dp();
    rm_back(n - best.second.second);
    rev(best.second.first, best.second.second);
    rm_front(best.second.first - 1);


    cout << best.first << '\n';
    cout << moves.size() << '\n';
    for (auto e : moves) cout << e << '\n';



    return 0;
}


Measured memory_bytes: 16640
if __name__ == "__main__":
    t0 = int(raw_input())
    h = t0 / 60 / 60
    t1 = t0 - ( h * 60 * 60 )
    m = t1  / 60
    s = t1 - ( m * 60 )
    print "{0}:{1}:{2}".format(h,m,s)

Measured memory_bytes: 4196
package main

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

const N = 100

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var M [N][N]int
	for i := 0; i < n; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		u--
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			v--
			M[u][v] = 1
		}
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			out.WriteString(fmt.Sprintf("%d", M[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 1388
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int a=tx-sx,b=ty-sy;
    cout<<string(b,'U')<<string(a,'R');
    cout<<string(b,'D')<<string(a,'L');
    cout<<'L'<<string(b+1,'U')<<string(a+1,'R')<<'D';
    cout<<'R'<<string(b+1,'D')<<string(a+1,'L')<<'U';
    cout<<endl;
}

Measured memory_bytes: 256
s = list(input())

if s.count('R') == 3:
    print(3)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 0:
    print(0)
else:
    if s[1] == 'R':
        print(2)
    else:
        print(1)

Measured memory_bytes: 61788
import numpy as np


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])

class PracticalSkillTest():

    def __init__(self):
        self.H, self.W, self.D = get_next_ints()
        self.field = []
        for _ in range(self.H):
            self.field.append(get_next_ints())
        self.Q = get_next_int()
        self.places = []
        for _ in range(self.Q):
            self.places.append(get_next_ints())
        self.mapping()
        self.dp = np.zeros(self.H * self.W+1, dtype=np.int)
        self.calc_cumulative_sum()

    def mapping(self):
        self.mapping_dic = {}
        for y in range(self.H):
            for x in range(self.W):
                self.mapping_dic[self.field[y][x]] = (x, y)


    def calc_cumulative_sum(self):
        for i in range(self.D+1, self.H*self.W+1):
            pos = self.mapping_dic[i]
            pre_pos = self.mapping_dic[i-self.D]
            self.dp[i] = self.dp[i-self.D] + abs(pos[0] - pre_pos[0]) + abs(pos[1] - pre_pos[1])
        # print(self.dp)



    def practice_solve(self):
        self.calc_cumulative_sum()
        for i in range(self.Q):
            cost = self.dp[self.places[i][1]] - self.dp[self.places[i][0]]
            print(cost)
    
def solve():
    p = PracticalSkillTest()
    p.practice_solve()

solve()

Measured memory_bytes: 45544
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

ll dp[maxn][2];

vector<ll>g[maxn];
bool used[maxn];

void dfs(ll u) {
	used[u] = 1;
	dp[u][1] = 1;
	dp[u][0] = 1;
	for (ll v : g[u]) {
		if (used[v]) continue;
		dfs(v);
		dp[u][1] = mul(dp[u][1], dp[v][0]);
		dp[u][0] = mul(dp[u][0], (dp[v][0] + dp[v][1]) % mod);
	}
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	for (ll i = 0; i < n - 1; i++) {
		ll u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % mod << endl;



	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 20352
s=input()
t=input()
ns=len(s)
nt=len(t)
li=[]
for i in range(ns-nt+1):
    for j in range(nt):
        if s[i]==t[j] or s[i]=='?':
            i+=1
            continue
        else:
            break
    else:
        li.append(s[:i-nt]+t+s[i:])

li2=[]
for i in li:
    li2.append(i.replace('?','a'))
li2.sort()
print(li2[0] if li2 else 'UNRESTORABLE')
        

Measured memory_bytes: 3064
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n%1000==0) {
            System.out.print(0);
        } else {
            System.out.print(1000-n%1000);
        }
    }

}

Measured memory_bytes: 35648
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(j);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = 1e9 + 7;
const int max_n = 3 * 1e5 + 1;
const int max_m = 83 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

//_________template______________
inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
int n;
vi mod;
void input(){
  IN(n);
  mod.resize(n+1);
  rep(i,n){
    int a;IN(a);
    mod[i+1] = a;
  }
}

void solve(){
  input();
  vi ans(n+1, 0);
  for(int i=n;i>0;i--){
    for(int j = i;j<=n;j+=i){
       mod[i] ^= ans[j];
    }
    ans[i] = mod[i];
    //dump(ans[i]);dump(i);
  }

  vi res;
  rep(i,n+1)if(ans[i] == 1)res.pb(i);
  OUT(res.size());
  for(auto c : res)cout << c << " ";
}

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





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

const int MOD = (int)1e9+7;

int main(){
	int A,B;
	cin >> A >> B;

	if(A==B){
		cout << 2*A << endl;
		return 0;
	}
	int x=max(A,B);
	cout << x+x-1 << endl;
	
	return 0;
}


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

using namespace std;

using ll = long long;

const int INF = 1e9 + 5;

template<typename T>
void min_self(T& a, T b)
{
    a = min(a,b);
}

template<typename T>
void max_self(T& a, T b)
{
    a = max(a,b);
}

const int Nax=1e5 + 5;

vector<int> edges[Nax];
bool visited[Nax];
int dist[Nax];
int in[Nax];

void dfs(int a)
{
    visited[a] = true;
    
    for(int b: edges[a])
    {
        dist[b] = max(dist[b],1+dist[a]);
        
        if(--in[b] == 0)
        {
            dfs(b);
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    
    int a, b;

    while(M--)
    {
        cin >> a >> b;
        edges[a].push_back(b);
        
        ++in[b];
    }
    
    for(int i=1; i<=N; ++i)
    {
        if(!visited[i] && in[i] == 0)
        {
            dfs(i);
        }
    }
    
    cout << *max_element(dist+1,dist+N+1);
    
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define INF ll(2e18)

inline ll mult(ll a, ll b) {
	if (a && INF / a < b) {
		return INF;
	}
	return a * b;
}

inline void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	if (b > d) {
		puts("No");
		return;
	}
	ll t = __gcd(b, d);
	ll l = 0, r = ll(1e18);
	while(l + 1 < r) {
		ll m = (l + r) / 2;
		if (a - mult(m, t) <= c)
			r = m;
		else
			l = m;
	}
	puts(a - mult(l, t) < b ? "No" : "Yes");
}

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	int tt;
	scanf("%d", &tt);
	for (int t = 0; t < tt; ++t)
		solve();

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        final int N = sc.nextInt();
        int[] A = new int[N];
        int flag = 0;

        for (int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            if(A[i] % 2 == 0){
                if(A[i] % 3 != 0 && A[i] % 5 != 0){
                    flag = 1;
                }
            }
        }

        if(flag == 0){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
        
        
    }
}

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

int main()
{
	int a, b;
	int ans;

	cin >> a >> b;

	ans = ( a + b ) / 2;
	if( ( a + b ) % 2 ) {
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
 
#define ll long long
#define endl "\n"
#define mod 1000000007
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    bool hasZero = false;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        if(a[i] == 0)
            hasZero = true;
    }
    if(hasZero)
    {
        cout<<0<<endl;
        return 0;
    }
    ll sum = 1;
    for(int i = 0; i < n; i++)
    {
        if(a[i] <= 1000000000000000000/sum)
        {
            sum *= a[i];
        }
        else
        {
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 4420
import math
gcd1 = 0
gcd3 = 0
gcd6 = 0
N = int(input())
for a in range(1, N + 1):
  for b in range(1, N + 1):
    for c in range(1, N + 1):
      if a < b < c:
        gcd6 += math.gcd(a,math.gcd(b, c))
      elif a == b < c or a < b == c:
        gcd3 += math.gcd(a,math.gcd(b, c))
      elif a == b == c:
        gcd1 += math.gcd(a,math.gcd(b, c))
print(6 * gcd6 + 3 * gcd3 + gcd1)

Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[200005],b[200005],c[200005],d[200005],B,ans;
bool cmp(int a,int b){
	return (a&B)>(b&B);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int t=0;t<=29;t++){
		B=(1<<t)-1;int g=1<<t,totl=0,totr=0;
		for(int i=1;i<=n;i++){
			if(b[i]&g) c[++totl]=b[i]&B;
			else d[++totr]=b[i]&B;
		}
		sort(c+1,c+totl+1);
		sort(d+1,d+totr+1);
		sort(a+1,a+n+1,cmp);
		int sum=0;
		for(int i=1,posl=0,posr=0;i<=n;i++){
			int w=a[i]&B;
			while(c[posl+1]+w<g&&posl<totl) posl++;
			while(d[posr+1]+w<g&&posr<totr) posr++;
			if(a[i]&g){
				sum^=(totl-posl+posr);
			}else{
				sum^=(totr-posr+posl);
			}
		}
		if(sum&1) ans|=g;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main ()
{
	int n,k;
	int m=1,i;
	cin>>n;
	cin>>k;
	for(i=0;i<n;i++)
	{
		if(k<=1)
		m+= k;
		else{
			if(m*2>m+k)
			{
				m+=k;
			 } 
			 else
			 {
			 	m*=2;
			 }
		} 
	}
	cout<<m<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

int n, a, b;
int dp[110][110][2];
int calc(int a, int b, int t) {
	int &ret = dp[a][b][t];
	if(~ret)
		return ret;
	ret = 0;
	if(!t) {
		vector<int>can;
		if(b > 1 && b - 1 != a)
			can.push_back(b - 1);
		if(b + 1 < n && b + 1 != a)
			can.push_back(b + 1);
		if(!can.size())
			ret = 1;
		for(int i = 0; i < can.size() && !ret; ++i)
			ret |= calc(a, can[i], !t);
	}
	else {
		vector<int>can;
		if(a > 1 && a - 1 != b)
			can.push_back(a - 1);
		if(a + 1 < n && a + 1 != b)
			can.push_back(a + 1);
		for(int i = 0; i < can.size() && !ret; ++i)
			ret |= calc(can[i], b, !t);
	}
	return ret;
}

int main() {


	scanf("%d%d%d", &n, &a, &b);
	memset(dp, -1, sizeof dp);
	puts(calc(a, b, 1) ? "Alice" : "Borys");
	

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;

int main() {
	int n;
	scanf("%d", &n);
	int arr[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	int ans = 1;
	sort(arr, arr + n);
	if (arr[n - 1] - arr[0] <= 2) {
		return printf("%d\n", n), 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (arr[j] - arr[i] > 2) {
				ans = max(ans, j - i);
				break;
			}
		}
	}

	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

const int N = 2e5 + 100;
const int Mod = 998244353;

int n, k;
int Dp[N];
int Seg[N << 2];
vector <pair<int, int>> ranges;

void update(int idx, int val, int Node = 1, int L = 1, int R = n) {
	if (idx > R || idx < L)
		return;
	if (L == R) {
		Seg[Node] = (Seg[Node] + val) % Mod;
		return;
	}

	int mid = L + R >> 1;
	update(idx, val, Node << 1, L, mid);
	update(idx, val, Node << 1 | 1, mid + 1, R);

	Seg[Node] = (Seg[Node << 1] + Seg[Node << 1 | 1]) % Mod;
}

int query(int i, int j, int Node = 1, int L = 1, int R = n) {
	if (j < L || i > R || i > j)
		return 0;
	if (L >= i && R <= j)
		return Seg[Node];

	int mid = L + R >> 1;
	int Q1 = query(i, j, Node << 1, L, mid);
	int Q2 = query(i, j, Node << 1 | 1, mid + 1, R);

	return (Q1 + Q2) % Mod;	
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; i++) {
		int L, R;	scanf("%d%d", &L, &R);
		ranges.emplace_back(L, R);
	}

	Dp[n] = 1;
	update(n, Dp[n]);
	for (int cell = n - 1; cell >= 1; cell--) {
		for (auto [L, R] : ranges) 
			Dp[cell] = (Dp[cell] + query(cell + L, min(n, cell + R))) % Mod;
		
		update(cell, Dp[cell]);
	}

	printf("%d\n", Dp[1]);
	return 0;
}


Measured memory_bytes: 6524
#include <iostream>

using namespace std;

int n,m,p;
int mem[101];

int main(){
  while(cin >> n >> m >> p, n || m || p){
    int sum = 0;
    for(int i = 1; i <= n ; i++){
      cin >> mem[i];
      sum += mem[i];
    }
    sum *= 100;
    if(mem[m]==0)cout << 0 << endl;
    else {
      sum = sum * (100-p)/100;
      cout << (int)(sum / mem[m]) << endl;
    }
  }
  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int L,N;
int sum[100];
int mx;

int main(){
  cin>>L>>N;
  rep(i,N){
    int a,b;
    cin>>a>>b;
    sum[a+L]+=b;
  }
  repl(x,-L,L+1){
    maxch(mx,sum[x+L]);
  }
  vector<P> res;
  repl(x,-L,L+1){
    if(mx-sum[x+L]>0)res.push_back(P(x,mx-sum[x+L]));
  }
  cout<<res.size()<<endl;
  rep(i,res.size())cout<<res[i].fi<<" "<<res[i].se<<endl;
  return 0;
}



Measured memory_bytes: 3104
n,k,q = map(int,input().split())
lista = [int(input())-1 for _ in range(q)]
plist = [k]*n
for i in lista:
    plist[i] += 1
for i in range(n):
    if plist[i] - q > 0:
        print("Yes")
    else:
        print("No")


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

const int mxN = 2e5 + 2;
int n, k, nums[mxN];
bool dp[mxN];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> nums[i];
    
    for (int i = 0; i <= k; i++)
    {
        bool ans = false;
        for (int j = 0; j < n; j++)
        {
            if (i - nums[j] >= 0)
            {
                ans = ans | (!dp[i - nums[j]]);
            }
        }
        dp[i] = ans;
    }

    if (dp[k] == 1)
    {
        cout << "First\n";
    }
    else
    {
        cout << "Second\n";
    }
    
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int A,B,C; cin >> A >> B >> C;
    FOR(i,1,B){
        if(A*i % B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e18;
const int MB = 20;
const int MOD = 1e9 + 7;

bool check(int n, int k, int m, vector<int>& minus, vector<int>& plus, int zeroes) {
    int res = 0;
    if (m >= 0) {
        res += zeroes * (minus.size() + plus.size());
        res += zeroes * (zeroes - 1) / 2;
    }
    int id = (int) plus.size() - 1;
    for(int i = (int) minus.size() - 1;i>=0;i--){
        while (id >= 0 && plus[id] * minus[i] <= m) id--;
        res += ((int) plus.size() - id - 1);
    }

    id = 0;
    int pls = 0;
    for (int i = (int) minus.size() - 1; i >= 0; i--) {
        while (id < minus.size() && minus[id] * minus[i] > m) id++;
        pls += (minus.size() - id);
        if (id <= i) pls--;
    }
    res += pls / 2;

    id = (int)plus.size() - 1;
    pls = 0;
    for (int i = 0; i < plus.size(); i++) {
        while (id >= 0 && plus[i] * plus[id] > m) id--;
        pls += id + 1;
        if (id >= i) pls--;
    }
    res += pls / 2;
    return res >= k;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> minus, plus;
    int zeroes = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0) minus.push_back(x);
        else if (x > 0) plus.push_back(x);
        else zeroes++;
    }
    
    sort(all(minus));
    sort(all(plus));

    check(n, k, 6, minus, plus, zeroes);

    int l = -INF;
    int r = INF;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (check(n, k, m, minus, plus, zeroes)) r = m;
        else l = m;
    }
    cout << r;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 2420
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<double> p(N);
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
	}
	vector<double> dp(N + 1);
	dp[0] = 1.0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j >= 0; --j) {
			dp[j] = p[i] * (j >= 1 ? dp[j - 1] : 0.0) + (1 - p[i]) * dp[j];
		}
	}
	double ans = 0.0;
	for (int i = N; i * 2 > N; --i) {
		ans += dp[i];
	}
	cout.precision(10);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i, n;
  double x[11], s;

  scanf("%d",&n);
  s = 0;
  for(i=0;i<n;i++) {
        scanf("%lf",&x[i]);
        char u[3] = {};
        scanf("%s",u);

        if(u[0]=='B') s=s+x[i]*380000.0;
        if(u[0]=='J') s = s + x[i];
        }
  printf("%lf\n",s);
  return 0;
}


Measured memory_bytes: 128
from collections import deque
# coding: UTF-8

n,m = map(int,input().split())
p = list(map(int,input().split()))
links = {}
checked = set()
for i in range(n):
    links[i] = set()
for i in range(m):
    x,y = map(int,input().split())
    v=x-1
    w=y-1
    links[v].add(w)
    links[w].add(v)
queue = deque()
ans = 0

for start in range(n):
    if start in checked:
        continue

    v = start
    queue.appendleft(v)
    checked.add(v)

    cluster = set()
    cluster.add(v)
    values = set()
    values.add(p[v]-1)

    while queue:
        v = queue.pop()
        neighbors = links[v]
        for w in neighbors:
            if w in checked:
                continue
            else:
                queue.appendleft(w)
                checked.add(w)
                cluster.add(w)
                values.add(p[w]-1)

    common = len (cluster & values)
    ans += common

print(ans)

Measured memory_bytes: 70108
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int sums[100010],sumt[100010];
int main(){
    string s,t;cin>>s>>t;
    for(int i=0;i<s.length();i++){
        sums[i+1]=sums[i];
        if(s[i]=='A')sums[i+1]++;
        if(s[i]=='B')sums[i+1]+=2;
    }
    for(int i=0;i<t.length();i++){
        sumt[i+1]=sumt[i];
        if(t[i]=='A')sumt[i+1]++;
        if(t[i]=='B')sumt[i+1]+=2;
    }
    int q;cin>>q;
    while(q--){
        int a,b,c,d;cin>>a>>b>>c>>d;
        int s1=sums[b]-sums[a-1];
        int s2=sumt[d]-sumt[c-1];
        if((s1-s2)%3==0){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var num = Input.num;
        var mod = 'z' - 'a' + 1;
        var bul = new StringBuilder();
        for (var i = 0; i < str.Length; i++)
            if ('z' - str[i] + 1 <= num)
            {
                num -= ('z' - str[i] + 1) % mod;
                bul.Append("a");
            }
            else bul.Append(str[i]);
        num %= 26;
        str = bul.ToString();
        str = str.Substring(0, str.Length - 1) + C(str[str.Length-1].ToString(), num);
        WriteLine(str);
    }
    private static string C(string c,int num)
    {
        var ind = Input.Alfa.IndexOf(c);
        return Input.Alfa.Substring((ind + num) % 26, 1);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 14944
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main(){
console.log(Math.pow(input[0],3));
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n;
    string s;
    cin >> n >> s;

    vector<bool> pass(1005,false);

    vector<vector<bool>> before(n, vector<bool>(10,false));
    for (ll i = 1; i < n; i++){
        before[i] = before[i-1];
        before[i][s[i-1] - '0'] = true;
    }

    vector<vector<bool>> after(n, vector<bool>(10,false));
    for (ll i = n-2; i >= 0; i--){
        after[i] = after[i+1];
        after[i][s[i+1] - '0'] = true;
    }

    /*for (ll i = 0; i < n; i++){
        for (ll j = 0; j < 10; j++){
            if (before[i][j]){
                cout << j << " ";
            }
        }
        cout << endl;
    }*/

    /*for (ll i = 0; i < n-1; i++){
        for (ll j = i+1; j < n; j++){
            for (ll k = 0;k < 10;k++){
                if (x[j][k]){
                    ll a = 100*(s[i] - '0') + 10*(s[j] - '0') + k;
                    pass[a] = true;
                }
            }
        }
    }*/

    for (ll i = 1; i < n-1; i++){
        for (ll j = 0; j < 10; j++){
            if (before[i][j]){
                for (ll k = 0; k < 10; k++){
                    if (after[i][k]){
                        ll x = 100*j + 10*(s[i] - '0') + k;
                        pass[x] = true;
                    }
                }
            }
        }
    }

    ll ans = 0;

    for (auto p : pass){
        if (p){
            ans++;
        }
    }

    /*for (ll i = 0; i < 1005; i++){
        if (pass[i]){
            cout << i << endl;
        }
    }*/

    cout << ans << endl;
}

Measured memory_bytes: 7404
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 
template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}
typedef pair<int, int> pii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int N = 1005;
int n, m;
vector<string>ar;
queue<pii>q;
int cost[N + 2][N + 2];
bool valid(int x, int y){
  if (x >= 0 && x < n && y >= 0 && y < m){
    if (cost[x][y] == -1){
      return true;
    }
  }
  return false;
}
void F(){
  while (!q.empty()){
    int ux = q.front().first;
    int uy = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++){
      int vx = ux + dx[i];
      int vy = uy + dy[i];
      if (valid(vx, vy)){
        cost[vx][vy] = cost[ux][uy] + 1;
        q.push({vx, vy});
      }
    }
  }
}
int main(){
  FASTER;
  memset(cost, -1, sizeof cost);
  cin >> n >> m;
  ar.resize(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      if (ar[i][j] == '#'){
        q.push({i, j});
        cost[i][j] = 0;
      }
    }
  }
  F();
  int mx = 0;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      //cout << cost[i][j] << ' ';
      mx = max(mx, cost[i][j]);      
    }
    //cout << '\n';
  }
  //cout << '\n';
  cout << mx << '\n';
  return 0;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt=0,ans=0,a,b=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		if(a>b)cnt=0;
		else cnt++;
		ans=max(ans,cnt);
		b=a;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
#define MAX 2000

int main(){
  int N,b[200],a[200],count=0,flag=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  for(int i=N-1;i>=0;i--,count=0){
    for(int k=N-1;k>=0;k--){
      if(b[k]!=-1) count++;
      if(b[k]==i-count+2){
        a[i]=b[k];
        b[k]=-1;
        break;
      }
      if(k==0){
        flag=1;
        break;
      }
    }
  }
  if(flag) cout<<-1<<endl;
  else{
    for(int i=0;i<N;i++){
      cout<<a[i]<<endl;
    }
  }
}


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

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
		cin>>n;
	cin>>str;
	int l=str.length();
	for(int i=0;i<l;i++)
	{
	    temp=str[i];
	    if((temp+n)<=90)
	    str[i]=str[i]+n;
	    else
	    str[i]=65+(temp+n)%91;
	}
	cout<<str;
}

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

int main(){
    int m,f,r,p;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if((m==-1)&&(f==-1)&&(r==-1))break;
        p = m+f;
        if((m==-1)||(f==-1)){
            printf("F\n");
        }else if(p>=80){
            printf("A\n");
        }else if((p>=65)&&(p<80)){
            printf("B\n");
        }else if(((p>=50)&&(p<65))||(r>=50)){
            printf("C\n");
        }else if((p>=30)&&(p<50)&&(r<50)){
            printf("D\n");
        }else{
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m;
    cin >> n >> m;
    vi a(n, -1);
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if (a[s] != -1 && a[s] != c) {
            cout << -1 << endl;
            return 0;
        }
        a[s] = c;
    }
    int s = 0;
    bool first = true;
    rep(i, n) {
        int b;
        if (a[i] == -1) {
           b = first ? 1 :  0;
        } else {
           b = a[i];
        }
       first = false;
        s += b * pow(10, n - i - 1);
    }
    if (n == 1 && m == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (s == 0 && n == 1) {
        cout << s << endl;
        return 0;
    }
    int t = s, d = 0;
    while (t) {
        t /= 10;
        d++;
    }
    if (d != n)
        cout << -1 << endl;
    else
        cout << s << endl;
    return 0;
}


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

int main(){
    int N;
    cin>>N;
    long long A=-1,B=-1,C=-1;
    int a=0,b=0,c=0;
    bool ans=true, ans1=true;
    for(int i=0;i<N;i++){
        long long x;
        cin>>x;
        if(A==-1 || A==x) {A=x; a++;}
        else if(B==-1 || B==x) {B=x; b++;}
        else if(C==-1 || C==x) {C=x; c++;}
        else {ans1=false; break;}
    }

    if(ans1){
        if(A==0 && B==-1 && C==-1) ans=true;
        else if(C==-1){
            if(A==0 && b==2*a) ans=true;
            else if(B==0 && a==2*b) ans=true;
            else ans=false;
        }
        else if (a!=b || a!=c) ans=false;
        else if ((A^B)==C) ans=true;
        else ans=false;
    }

    if(ans && ans1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int cnt = 0, ans = 0;
  while( C > 0 ) {
    ++cnt;
    C -= A;
    if( cnt && cnt % 7 == 0 ) C -= B;
    ++ans;
  }
  cout << ans << endl;
  compute();
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstring>
#include <array>

using namespace std;

int main() {
  int n;
  cin >> n;
  int _t = 0, _x = 0, _y = 0;

  for (int i = 0; i < n; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int dt = t - _t, d = (x - _x) + (y - _y);

    if (d > dt || (d - dt) % 2 != 0) {
      cout << "No";
      return 0;
    }
    _t = t, _x = x, _y = y;
  }

  cout << "Yes";
  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph =  vector< vector<Edge> >;

void add_edge(Graph& graph, int u, int v, int cost = 0){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}

void lowlink(int u, int p, int& num, const Graph& G, VI& ord, VI& low,
			 VI& art, vector<pair<int,int>>& brd){
  ord[u] = low[u] = num++;
  int chd_num = 0, chd_low_mx = -1;

  for(unsigned int i=0;i<G[u].size();++i){
	auto& e =  G[u][i];
	int to = e.to;
	if(to == p) continue;
	if(ord[to] < 0){
	  lowlink(to, u, num, G, ord, low, art, brd);
	  low[u] = min(low[u], low[to]);
	  if(ord[u] < low[to]){
		brd.push_back(MP(u, i));
	  }
	  ++chd_num;
	  chd_low_mx = max(chd_low_mx, low[to]);
	}
	else{
	  low[u] = min(low[u], ord[to]);
	}
  }

  if(p == -1){
	if(chd_num > 1)
	  art.push_back(u);
  }
  else{
	if(ord[u] <= chd_low_mx)
	  art.push_back(u);
  }
}

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

  int V, E;
  cin >> V >> E;
  Graph G(V);
  REP(i,E){
	int u, v;
	cin >> u >> v;
	add_edge(G, u, v);
  }

  int num = 0;
  VI ord(V, -1);
  VI low(V, -1);
  vector<PII> brd;
  VI art;
  lowlink(0, -1, num, G, ord, low, art, brd);

  vector<PII> ans;
  for(auto& p: brd){
	int u = p.FF;
	int v = G[u][p.SS].to;
	if(u > v) swap(u, v);
	ans.EB(u, v);
  }
  SORT(ans);
  for(auto e: ans) cout << e << endl;

  return 0;
}



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

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, n, m;

  int a[110][110], b[110];
  cin >> n >> m;
  rep(i, n) rep(j, m) cin >> a[i][j];
  rep(k, m) cin >> b[k];
  rep(i, n) {
    k = 0;
    rep(j, m) k += a[i][j] * b[j];
    cout << k << endl;
  }
  
  
  return 0;
}
  

Measured memory_bytes: 1208
#include <cstdio>
int gcd(int a,int b)
{
    return b? gcd(b,a%b):a;
}
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b) != EOF)
    {
        int g = gcd(a,b);
        int l = a/g*b;
        printf("%d %d\n",g,l);
    }
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e5+5;
const double EPS = 1e-6;
using namespace std;
int main()
{
	string s;
	cin>>s;
	int fg=0;
	rep(i,0,sz(s)-1){
		if(s[i]=='A'&&s[i+1]=='C') fg=1;
	}
	puts(fg?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256