akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll MAX_V = 2510;
const ll MAX_E = 5010;
ll n, m, p;
// 辺from    辺to      辺の距離   最短距離(!=INF:startから到達できる)
ll a[MAX_E], b[MAX_E], c[MAX_E], d[MAX_V];
// startから到達できる負閉路である
bool neg[MAX_V];

// ベルマンフォード法
// 有向グラフの単一始点最短経路を求める O(VE)
// 始点から到達可能な負閉路を検出する O(VE)
void BellmanFord(ll start){
    repr(i, 1, n+1){
        d[i] = INF;
        neg[i] = 0;
    }
    d[start] = 0;
    // 距離の緩和
    rep(i, n){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(d[u] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
            }
        }
    }
    // 負閉路検出
    rep(i, n){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            // startから到達できる、かつ距離を緩和できる
            if(d[v] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
                neg[v] = 1;
            }
            // negの伝播
            if(neg[u]) neg[v] = 1;
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m >> p;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i] + p;
    }
    BellmanFord(1);
    if(neg[n]){
        cout << -1 << endl;
    }else{
        cout << max(-d[n], 0ll) << endl;
    }
    return 0;
}

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

#define MAX_N 3000

using namespace std;

typedef long long lint;

const lint MOD = 998244353LL;

int n, s;
int v[MAX_N + 9];

lint ap[MAX_N + 9];

void modd(lint &a)
{
    if(a >= MOD)
        a -= MOD;

    if(a < 0)
        a += MOD;
}

void modd(int &a)
{
    if(a >= MOD)
        a -= MOD;

    if(a < 0)
        a += MOD;
}

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

    lint rez = 0;
   // ap[0] = 1;
    for(int i = 1; i <= n; i ++)
    {

        //cout << " SUNTME " << i <<  "ADUNAM " << (n - i + 1) << " RO " << ap[s] << "\n";

        if(v[i] < s)
            rez += 1LL * (n - i + 1) * ap[s - v[i]] % MOD;

        else if(v[i] == s)
            rez += 1LL * (n - i + 1) * i % MOD;

        modd(rez);

        for(int j = s; j > v[i]; j --)
        {
            ap[j] += ap[j - v[i]];
            modd(ap[j]);
        }

        ap[v[i]] += i;
        modd(ap[v[i]]);

    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 384
p_num = input()
p_loc = input()
num = int(p_num)
loc_list = [int(i) for i in p_loc.split()]
value_list = []
for i in range(min(loc_list), max(loc_list)+1):
  value = 0
  for loc in loc_list:
    value += (loc-i)**2
  value_list.append(value)
    
print(min(value_list))

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>pat[202020];
bool flag[202020];
int maxi = -1, rr;
void dfs(int node, int d)
{
	if (flag[node])return;
	flag[node] = true;
	if (maxi < d)maxi = d, rr = node;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i], d + 1);
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb), pat[zb].push_back(za);
	}
	dfs(0, 0);
	maxi = -1;
	fill(flag, flag + num, false);
	dfs(rr, 0);
	if (maxi % 3 == 1)printf("Second\n");
	else printf("First\n");
}

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll num = n/(a+b);
    ll ans = num*a;
    ll re = n%(a+b);
    if(a>=re) ans+=re;
    else ans+=a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, m, a = 1, b = 1, e = 0;
	cin >> n;
	int test[200001] = { 0 };
	if (n % 2 == 0) {
		for (int h = 1; h <= n; h++) {
			cin >> m;
			if (h % 2 == 0) {
				test[100001 - h / 2] = m;
			}
			else {
				test[100001 + h / 2] = m;
			}
		}
		for (int i = 100001 - n / 2; i <= 100001 + n / 2 - 1; i++) {
			cout << test[i] << ' ';
		}
	}
	else {
		for (int h = 1; h <= n; h++) {
			cin >> m;
			if (h % 2 == 0) {
				test[100001 + h / 2] = m;
			}
			else {
				test[100001 - h / 2] = m;
			}
		}
		for (int i = 100001 - n / 2; i <= 100001 + n / 2; i++) {
			cout << test[i] << ' ';
		}
	}
	cin >> e;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 2020;

int C[MAX][MAX];
int CS[MAX][MAX];

int DP[MAX][MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	FOR (i, 0, MAX)
	{
		C[i][0] = 1;
		FOR (j, 1, i+1)
		{
			C[i][j] = C[i-1][j] + C[i-1][j-1];
			if (C[i][j] >= MOD) C[i][j] -= MOD;
		}
	}

	FOR (i, 0, MAX)
	{
		FOR (j, 0, MAX)
		{
			CS[i][j] = C[i][j];
			if (j) CS[i][j] += CS[i][j-1];
			if (CS[i][j] >= MOD) CS[i][j] -= MOD;
		}
	}

	int a, b;
	cin>>a>>b;

	FOR (i, 0, a+1)
	{
		a -= i;
		b--;

		FOR (j, 0, min(b+1, a+1))
		{
			int na = a - j;
			int nb = b - (b - j);

			DP[na][nb] += C[b][j];
			if (DP[na][nb] >= MOD) DP[na][nb] -= MOD;
		}
		a += i;
		b++;

//		cout<<i<<":"<<endl;
//
//		FOR (i, 0, a+1)
//		{
//			FOR (j, 0, b+1)
//			{
//				cout<<DP[i][j]<<' ';
//			}
//			cout<<endl;
//		}
//		cout<<endl;

	}


	RFOR(i, a+1, 0)
	{
		FOR (j, 0, b)
		{
			if (i)
			{
				DP[i-1][j] += DP[i][j];
				if (DP[i-1][j] >= MOD) DP[i-1][j] -= MOD;
			}
		}
	}

//	FOR (i, 0, a+1)
//	{
//		FOR (j, 0, b+1)
//		{
//			cout<<DP[i][j]<<' ';
//		}
//		cout<<endl;
//	}
//	cout<<endl;
	LL res = DP[0][0];

	FOR (i, 0, a+1)
	{
		FOR (j, 1, b+1)
		{
			if (DP[i][j] == 0) continue;

			int cur = CS[j - 1][i];
//			cout<<i<<' '<<j<<": "<<cur<<' '<<DP[i][j]<<endl;

			res += cur * (LL)DP[i][j];
			res %= MOD;
		}
	}


	cout<<res<<endl;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , m;
bool bad[ N ];
LL dp[ N ];

LL solve( int idx ) {
        if( idx == n ) return 1;
        if( dp[idx] != -1 ) return dp[idx];
        LL ret = 0;
        if( idx + 1 <= n && !bad[idx+1] ) ret += solve( idx + 1 );
        ret %= MOD;
        if( idx + 2 <= n && !bad[idx+2] ) ret += solve( idx + 2 );
        ret %= MOD;
        return dp[idx] = ret;
}
int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n >> m;
        for( int i = 1; i <= m; i++ ) {
                int x;
                cin >> x;
                bad[x] = true;
        }
        memset( dp , -1 , sizeof(dp) );
        cout << solve( 0 ) << endl;
        return 0;
}










Measured memory_bytes: 5760
<?php

while(true) {
	$inputs = explode(' ', trim(fgets(STDIN)));

	if (!is_array($inputs) || count($inputs) < 2) {
		exit;
	}

	$a = $inputs[0];
	$b = $inputs[1];

	$d = numDigits($a + $b);

	echo $d . "\n";
}

function numDigits($n) {
	return (int)(log10($n) + 1);
}

Measured memory_bytes: 6696
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
a,b = LS()
c = int(a+b)
for i in range(1,1000):
    if i * i == c:
        print("Yes")
        quit()
print("No")
"""

#B
"""
a,b = LI()
if a*b <= 0:
    print("Zero")
else:
    if b < 0:
        if (a-b) %2 == 1:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Positive")
"""

#C
"""
n = II()
s = SR(n)
march = [[] for i in range(5)]
ch = list("MARCH")
for i in s:
    for j in range(5):
        if i[0] == ch[j]:
            march[j].append(i)
ans = 0
for i in range(5):
    for j in range(i):
        for k in range(j):
            if len(march[i])*len(march[j])*len(march[k]) == 0:
                break
            ans += len(march[i])*len(march[j])*len(march[k])
print(ans)
"""

#D
"""
n = II()
d = LIR(n)
q = II()
p = IIR(q)
d.insert(0,[0 for i in range(n+1)])
for i in range(n):
    d[i+1].insert(0,0)
for i in range(n):
    for j in range(n):
        d[i+1][j+1] += d[i+1][j]+d[i][j+1]-d[i][j]
ans = [0 for i in range(n**2+1)]

for a in range(n+1):
    for b in range(n+1):
        for c in range(a):
            for e in range(b):
                ans[(a-c)*(b-e)] = max(ans[(a-c)*(b-e)],d[a][b]-d[c][b]-d[a][e]+d[c][e])

for i in p:
    an = 0
    for a in range(i+1):
        an = max(an, ans[a])
    print(an)
"""
#E

"""
s = list(S())
ans = -1
s.insert(0,0)
d = 0
for i in range(1,len(s)):
    if s[i] != d:
        d = s[i]
        ans += 1
print(ans)
"""

#F
"""
n = II()
x,y = LI()
for _ in range(n-1):
    a,b = LI()
    if a == b:
        x = max(x,y)
        y = x
    else:
        i = max(x//a,y//b)
        while 1:
            if a*i >= x and b*i >= y:break
            i += 1
        x = a*i
        y = b*i
print(x+y)
"""
#G

s = list(S())
p = 0
g = 0
for i in s:
    if i == "g":
        g += 1
    else:
        p += 1
ans = (g-p)//2
print(ans)


#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 49392
#include <stdio.h>
#include <stdlib.h>
int main(){
    char n[200000+1]={0};
    int cnt=0, sum=0;
    do{
        scanf("%c", &n[cnt]);
        sum += atoi(&n[cnt]);
        cnt++;
    }
    while( n[cnt-1] >= '0' );

    if(sum%9 == 0){ printf("Yes\n"); }
    else          { printf("No\n");  }
    return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	
	int n,k,ai,bi,data;
	vector<int> res;

	cin >> n >> k;
		
	rep(i,k){
		cin >> ai >> bi;
		data  = min(min(ai-1, n-ai), min(bi-1, n-bi));
		res.push_back(data % 3 + 1);
	}
	rep(i,res.size()) cout << res[i] << endl;

	return 0;
}

Measured memory_bytes: 1224
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	res := 0
	loop := true
	for {
		for i := 0; i < len(a); i++ {
			if a[i] == 0 || a[i]%2 == 1 {
				loop = false
				break
			} else {
				a[i] = a[i] / 2
			}
		}
		if !loop {
			break
		}
		res++
	}
	fmt.Printf("%v", res)
}

Measured memory_bytes: 512
n, y = map(int, input().split())
for a in range(y // 10000 + 1):
  for b in range((y - a*10000) // 5000 + 1):
    c = (y - a*10000 - b*5000) // 1000
    if a + b + c == n:
      print("{} {} {}".format(a, b, c))
      break
  else:
    continue
  break
else:
  print("-1 -1 -1")

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

int main(){
    int h,w;
    cin >> h >> w;
    queue<int> qx,qy;
    vector<vector<int>> grid(h,vector<int>(w,-1));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char in;
            cin >> in;
            if(in == '#'){
                grid[i][j] = 0;
                qx.push(i);
                qy.push(j);
            }
        }
    }
    int last = 0;
    vector<int> nx = {1,-1,0,0};
    vector<int> ny = {0,0,1,-1};

    while(!qx.empty()){
        int x = qx.front();
        int y = qy.front();
        qx.pop();
        qy.pop();
        for(int i=0; i<4; i++){
            if(
                x+nx[i] < 0 || x+nx[i] >= h ||
                y+ny[i] < 0 || y+ny[i] >= w){
                    continue;
                }
            if(grid[x+nx[i]][y+ny[i]] < 0){
                grid[x+nx[i]][y+ny[i]] = grid[x][y]+1;
                qx.push(x+nx[i]);
                qy.push(y+ny[i]);
                last = grid[x][y] + 1;
            }
        }
    }
    cout << last << endl;
}

Measured memory_bytes: 12416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created by Aksenov239 on 23.10.2016.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

    public void solveA() throws IOException {
        String s = nextToken();
        String f = "CF";
        int p = 0;
        for (int i = 0; i < s.length() && p < f.length(); i++) {
            if (s.charAt(i) == f.charAt(p)) {
                p++;
            }
        }
        if (p == 2) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    public void solveB() throws IOException {
        int k = nextInt();
        int t = nextInt();
        int[] a = new int[t];
        int max = 0;
        for (int i = 0; i < t; i++) {
            a[i] = nextInt();
            max = Math.max(a[i], max);
        }

        if (2 * max > k) {
            out.println(max - 1 - (k - max));
        } else {
            out.println(0);
        }
    }

    public void solveC() throws IOException {
        int n = nextInt();
        int[] t = new int[n];
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            t[i] = nextInt();
        }

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

        int[] ready = new int[n];
        for (int i = 0; i < t.length; i++) {
            if (i == 0 || t[i] != t[i - 1]) {
                ready[i] = t[i];
            }
        }

        for (int i = a.length - 1; i >= 0; i--) {
            if (i == a.length - 1 || a[i] != a[i + 1]) {
                if (ready[i] != 0 && ready[i] != a[i]) {
                    out.println(0);
                    return;
                }
                ready[i] = a[i];
            }
        }

        long ans = 1;
        for (int i = 0; i < ready.length; i++) {
            if (ready[i] > t[i] || ready[i] > a[i]) {
                out.println(0);return;
            }
            if (ready[i] == 0) {
                ans = (ans * Math.min(t[i], a[i])) % 1000000007;
            }
        }
        out.println(ans);
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solveC();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 31700
#include <cstdio>

typedef long long LL;
const int MN = 100005;

int N, A[MN];
LL S;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), S += A[i];
	if (S % ((LL)N * (N + 1) / 2) != 0) return puts("NO"), 0;
	LL C = S / ((LL)N * (N + 1) / 2);
	for (int i = 1; i <= N; ++i) {
		LL k = C - (A[i % N + 1] - A[i]);
		if (k < 0 || k % N != 0) return puts("NO"), 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		String n = scan.nextLine();

		int ans = Integer.parseInt(n.substring(0, 1)) - 1;

		boolean flg = true;
		for (int i = 1; i < n.length(); i++) {
			if(!n.substring(i,i+1).equals("9")){
				flg = false;
			}
			ans = ans + 9;
		}
		if(flg) {
			ans = ans+1;
		}
		System.out.println(ans);
	}
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c, d ;
  cin >> a >> b >> c >> d ;
  int e, f ;
  
  e = min(a,b) ;
  f = min(c,d) ;
  
  cout << e+f <<endl ;
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;



int main() {
    string s; cin >> s;
    rep(i, s.size()){
        s[i] == '9' ? cout << 1: cout << 9;
    }
    cout << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var xs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(Gcd(Math.Max(xs[0], xs[1]), Math.Min(xs[0], xs[1])));
    }

    static int Gcd(int m, int n)
    {
        if (n == 0) return m;

        return Gcd(n, m % n);
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, x;
    cin >> x >> n;
    vector<int> p(n);
    vector<bool> cantake(200, 1);
    FOR(i, n) {
        cin >> p[i];
        cantake[p[i]] = 0;
    }
    sort(p.begin(), p.end());

    int sol = -100;
    int mdist = 100000;
    for(int y = -1; y <= 101; y++){
        if (y < 0 || cantake[y]) {
            int dist = abs(y - x);
            if (dist < mdist){
                mdist = dist;
                sol = y;
            }
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3656
/* 
 * Project: AtCoder Beginners Contest 143 B - Roller Coaste
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/17
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <vector>
using namespace std;

int32_t n;
int32_t k;
vector<int32_t> h;

void solve() {

    uint32_t cnt = 0;
    for (int32_t i : h) {
        if (i >= k) {
            cnt++;
        }
    }
    printf("%d\n", cnt);

}

int main() {

    scanf("%d", &n);
    scanf("%d", &k);
    for (int i=0;i<n;i++) {
        int32_t tmp;
        scanf("%d", &tmp);
        h.push_back(tmp);
    }

    solve();

}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char a[60][60], b[60][60];
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      cin >> a[i][j];
    }
  }
  for(int i=1; i<=m; i++){
    for(int j=1; j<=m; j++){
      cin >> b[i][j];
    }
  }
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      int cnt = 0;
      if(a[i][j]==b[1][1]){
        cnt++;
        for(int k=1; k<m; k++){
          if(a[i][j+k]!=b[1][k+1]){
            break;
          }
          cnt++;
        }
      }
      if(cnt==m){
        for(int s=1; s<m; s++){
          for(int t=0; t<m; t++){
            if(a[i+s][j+t]!=b[s+1][t+1]) break;
            cnt++;
          }
        }
      }
      if(cnt==m*m) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 998244353
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fact[1000010],ifact[1000010];
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int C(int n,int m){return n<m?0:1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),k=gi();if(n>k)return puts("0"),0;
	fact[0]=1;for(int i=1;i<=1000000;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[1000000]=pow(fact[1000000],mod-2);for(int i=1000000;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	int ans=0;
	for(int R=std::max(k+1>>1,n),B=k-R;R<=k;++R,--B){
		int s=R-n+1,K=k;
		if(s<=0)continue;
		if(R==B)--K;
		if(s<=B)ans=(0ll+ans+C(K,R)-C(K,R+s)+mod)%mod;
		else ans=(ans+C(K,R))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

complex<double> naive(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> total_sum(0);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                total_sum += polar(1., (angles[i]+angles[j])/2) + polar(1., (angles[j]+angles[k])/2) - polar(1., (angles[i]+angles[k])/2);
            }
        }
    }
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}

complex<double> smart(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> ij_sum;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ij_sum += polar(1., (angles[i]+angles[j])/2) * ((double) (n-j-1));
        }
    }
    complex<double> jk_sum;
    for (int j = 0; j < n; ++j) {
        for (int k = j + 1; k < n; ++k) {
            jk_sum += polar(1., (angles[j]+angles[k])/2) * ((double) j);
        }
    }
    complex<double> ik_sum;
    for (int i = 0; i < n; ++i) {
        for (int k = i + 1; k < n; ++k) {
            ik_sum += polar(1., (angles[i]+angles[k])/2) * ((double) k-i-1);
        }
    }
    complex<double> total_sum = ij_sum + jk_sum - ik_sum;
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}

complex<double> simpler(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> total_sum;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            total_sum += polar(1., (angles[i]+angles[j])/2) * ((double) n - 2*j + 2*i);
        }
    }
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, L;
    cin >> n >> L;
    double pi = atan(1)*4;
    vector<double> angles(n);
    for (auto& angle : angles) {
        cin >> angle;
        angle *= 2*pi/L;
    }
    complex<double> result = simpler(angles);
    cout << setprecision(20) << real(result) << " " << imag(result) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000000;
using namespace std;
vector<pair<long long,long long>>juice;
int main() {
	int a = 0, b = 0, c = 0, d = 0;
	long long counto = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		cin >> c >> d;
		juice.push_back(make_pair(c, d));
	}
	sort(juice.begin(), juice.end());
	for (int i = 0; b > 0; i++) {
		//cout << juice[i].first << endl;
		if(juice[i].second<=b){
			b -= juice[i].second;
			counto += (juice[i].first * juice[i].second);
		}
		else {
			counto += (juice[i].first * b);
			b -= juice[i].second;
		}
	}
	cout << counto<<endl;
	return 0;
}

Measured memory_bytes: 2420
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int n , m ;
vector<vector<int> > g ;
vector<bool> vis ;
void dfs(int x){
    vis[x] = true ;
    for(int &c : g[x]){
        if ( vis[c] ) continue ;
        dfs(c) ;
    }
}
signed main(){
    fastio
    cin >> n >> m ; 
    g = vector<vector<int> > (n) ;
    vis = vector<bool>(n) ;
    for(int i = 0; i < m; i++){
        int a , b ;
        cin >> a >> b ; 
        a--, b-- ;
        g[a].emplace_back(b) ;
        g[b].emplace_back(a) ;
    }
    int ans = 0  ;
    for(int i = 0; i < n; i++){
        if ( not vis[i] ) {
            ans++ ;
            dfs(i) ;
        }
    }
    cout << ans - 1 << endl;
    return 0; 
}

Measured memory_bytes: 9772
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int N;
	scanf("%d", &N);

	if (N % 2 == 0)printf("%d", N);
	else printf("%d", 2 * N);


}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    x: i32,
    y: i32,
  }
  let mut ans = 0;
  ans += match x {
    1 => 300000,
    2 => 200000,
    3 => 100000,
    _ => 0
  };
  ans += match y {
    1 => 300000,
    2 => 200000,
    3 => 100000,
    _ => 0
  };
  if x == 1 && y == 1 {
    ans += 400000;
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,x,y;
int a[100005];
struct bit{
	int f[100005],pos;
	bit(){
		memset(f,0,sizeof f);
		pos=0;
	}
	void add(int x,int v){
		x++;
		while(x<=1e5+3){
			f[x]+=v;f[x]%=mod;x+=x&-x;
		}
	}
	int sum(int x){
		x++;
		if(x<=0)return 0;
		int ret=0;
		while(x){
			ret+=f[x];ret%=mod;x-=x&-x;
		}
		return ret;
	}
	int query(int l,int r){
		return (sum(r)-sum(l-1)+mod)%mod;
	}
	void clear(int p){
		while(pos<=p){
			add(pos,mod-query(pos,pos));pos++;
		}
	}
}f,g;
int posx=1,posy=1;
signed main(){
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)cin>>a[i];
	f.add(0,1);g.add(0,1);
	for(int i=2;i<=n;i++){
		while(a[i]-a[posx]>=x)posx++;
		while(a[i]-a[posy]>=y)posy++;
		//f: last X is t,cur=y
		//g: last Y is t,cur=x
		int F=g.query(0,min(posy-1,i-2));
		int G=f.query(0,min(posx-1,i-2));
		if(a[i]-a[i-1]<x)g.clear(i-2);
		if(a[i]-a[i-1]<y)f.clear(i-2);
		f.add(i-1,F);
		g.add(i-1,G);
//		for(int j=0;j<i;j++)cerr<<f.query(j,j)<<" ";cerr<<endl;
//		for(int j=0;j<i;j++)cerr<<g.query(j,j)<<" ";cerr<<endl;
	}
//	cerr<<f.query(0,n)<<" "<<g.query(0,n)<<endl;
	cout<<(f.query(0,n)+g.query(0,n))%mod<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;
    if(s==u) cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
}

Measured memory_bytes: 256
S = input()
T = input()

s_t = {}
s = set()
t = set()
for i in range(len(S)):
    if S[i] not in s:
        if T[i] not in t:
            s.add(S[i])
            t.add(T[i])
            s_t[S[i]] = T[i]
        else:
            print("No")
            exit()
    else:
        if s_t[S[i]] != T[i]:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 73452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N, S; cin >> N >> S;
  vector<int> A(N); rep(i, N) cin >> A[i];
  vector<mint> f(S + 1);
  mint ans;
  rep(i, N) {
    f[0] += 1;
    for (int j = S - A[i]; j >= 0; j--) {
      f[j + A[i]] += f[j];
    }
    ans += f[S];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
using P = pair<int, int>;
typedef long long ll;

vector<int> to[1000005];

int main() {
    int X, N;
    bool flag = true;
    cin >> X >> N;

    int p[N];
    REP(i,N){
        cin >> p[i];
        if (p[i] == X){
            flag = false;
        }
    }

    if (flag){
        cout << X << endl;
    }

    else{
        sort(p, p+N);

        flag = false;
        int res = 10000;
        int num = 0;
        REP(i, N){
            res = p[i] - X;
            if (res == 0){
                num = i;
                break;
            }
        }

        int i = 1;
        while(1){
            if (p[num-i] != X-i){
                cout << X-i << endl;
                break;
            }
            if (p[num+i] != X+i){
                cout << X+i << endl;
                break;
            }
            i++;
        }
    }
    return 0;
}

Measured memory_bytes: 27068
n = int(input())
a = list(map(int, input().split()))
a.sort()
while len(a) >= 2 :
    k = a[1] % a[0]
    if k == 0 :
        a.pop(1)
    else :
        a[1] = k
        a[0], a[1] = a[1], a[0]
print(a[0])


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s,t;
	cin>>s>>t;
	
	int a,b;
	cin>>a>>b;
	
	map<string,int> mp;
	mp[s]=a;
	mp[t]=b;
	
	string u;
	cin>>u;
	
	mp[u]--;
	
	cout<<mp[s]<<' '<<mp[t]<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    N=int(input())
    R=[]
    for _ in range(N):
        R.append(list(map(int, input().split())))
    B=[]
    for _ in range(N):
        B.append(list(map(int, input().split())))
    B.sort(key=lambda x:x[0]) # 解説の通り。Bをxでソート
    ans = 0
    while B:
        b = B[0] # x が最小の b を順に処理
        cr = []
        for r in R:
            if r[0]<=b[0] and r[1]<=b[1]:
                cr.append(r) # ペア候補
        if cr:
            cr.sort(key=lambda x:x[1]) # 候補のうち、yが最大のもの
            R.remove(cr[-1])
            ans += 1
        B.remove(b)

    print(ans)

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;


void pre(){

}

void solve(){
  int h,w,k; cin>>h>>w>>k;
  string s[h],temp[h];

  rep(i,h){
    cin>>s[i];
    temp[i]=s[i];
  }

  int ans=0;

  for(int i=0;i<(1<<h);i++){
    rep(j,h){
      temp[j]=s[j];
    }
    for(int j=0;j<h;j++){
      if(i&(1<<j)){
        for(int x=0;x<w;x++){
          temp[j][x]='R';
        }
      }
    }

      string kemp[h];

      // rep(lol,h){
      //   rep(hol,w){
      //     cout<<temp[lol][hol]<<" ";
      //   }
      //   cout<<endl;
      // }

      for(int y=0;y<(1<<w);y++){
        rep(bhai,h){
          kemp[bhai]=temp[bhai];
        }
        for(int z=0;z<w;z++){
          if(y&(1<<z)){
            for(int x=0;x<h;x++){
              kemp[x][z]='R';
            }
          }
        }
        // rep(lol,h){
        //   rep(hol,w){
        //     cout<<kemp[lol][hol]<<" ";
        //   }
        //   cout<<endl;
        // }
        // cout<<endl;
        int sum=0;
        rep(lol,h){
          rep(hol,w){
            if(kemp[lol][hol]=='#'){
              sum++;
            }
          }
        }

        if(sum==k) ans++;
      }
    }

  cout<<ans<<"\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


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

int main(){
    int i,n;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    int maxindex=0;
    for(i=0;i<n;i++){
        if(arr[i]>arr[maxindex])
        maxindex=i;
    }
    int sum=0;
    for(i=0;i<n;i++){
        if(i!=maxindex)
        sum+=arr[i];
    }
    if(sum>arr[maxindex])
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

const long long limit = 1000000000000000000ll;

int main(int n,char**){
    long long *a;
    cin>>n;
    a = new long long[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!a[i]){
            cout<<0<<endl;
            return 0;    
        }
    }
    long long acc = 1;
    for(int i=0;i<n;i++){
        if(a[i]<=limit/acc){ 
            acc*=a[i];
        }else{
            cout<<-1<<endl;
            return 0;  
        }
    }
    cout<<acc<<endl;
}

Measured memory_bytes: 4392
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(512):
    for j in range(n):
        if a[j] % 2 != 0:
            break
    else:
        ans += 1
    a = list(map(lambda x: x / 2, a))
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

const int nmax = 40, abmax = 10;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main()
{
	int n, ma, mb;
	cin >> n >> ma >> mb;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				dp[i][ca][cb] = INF;
			}
		}
	}

	dp[0][0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				if (dp[i][ca][cb] == INF) continue;
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}

	int ans = INF;
	for (int ca = 1; ca <= nmax * abmax; ca++) {
		for (int cb = 1; cb <= nmax * abmax; cb++) {
			if (ca * mb == cb * ma) ans = min(ans, dp[n][ca][cb]);
		}
	}

	if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}

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

int main() {
    long l, r;
    cin>>l >>r;
    long ans=2019;
    for(long i=l+1;i<=r;i++){
        for(long k=l;k<i;k++){
            long a=(i*k)%2019;
            ans=min(ans,a);
            if(ans==0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;

int groups(int num) {
	if (num == 2)
		return 3;
	else if (num == 1 || num == 3 || num == 5 || num == 7 || num == 8 || num == 10 || num == 12)
		return 1;
	else
		return 2;
}

int main()
{
	int x, y;
	cin >> x >> y;
	int xgroup, ygroup;
	xgroup = groups(x);
	ygroup = groups(y);
	if (xgroup != ygroup)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int x = Integer.parseInt(scan.nextLine());
		int sum = 0;
		int time;
		ArrayList<Integer> jump = new ArrayList<Integer>();
		if(x > 0){
			for(time = 1; sum < x; time++){
				sum += time;
				jump.add(time);
			}
		}else{
			for(time = 1; sum > x; time++){
				sum -= time;
				jump.add(time);
			}
		}
		time--;
		System.out.println(time);
	}
}


Measured memory_bytes: 25556
import math
n = int(input())
init_n = n

dig_num = len(str(n))
s_n = 0
for i in range(dig_num):

    sub = math.floor(n/10**(dig_num-i-1))
    s_n = s_n + sub
    n = n - sub*10**(dig_num-i-1)

if init_n/s_n == math.floor(init_n/s_n):
    print('Yes')
else:
    print("No")


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    f(k){
        ll add;
        cin >> add;
        n -= add;
    }
    if(n <= 0){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
inline double add(double a, double b){
	return abs(a + b) <= 1e-8 ? 0 : a + b;
}
int main(){
	double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	double dist = sqrt(add(add(x2,-x1)*add(x2, -x1), add(y2, -y1)*add(y2, -y1)));
	cout << fixed << setprecision(8) << dist << '\n';
}

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

int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int i,n,g=0;
  n=s.size();
  rep(i,n){
    if(s[i]!=t[i])g=1;
  }
  if(g==0)cout<<"Yes";
  if(g==1)cout<<"No";
  
  return 0;
}

Measured memory_bytes: 3628
h,w = map(int, input().split())
n = int(input())
list_a = list(map(int, input().split()))
list_a_post = []
for i in range(n):
    for j in range(list_a[i]):
        list_a_post.append(i+1)
list_ans = []
p = 0
for i in range(h):
    memo_list = []
    for j in range(w):
        memo_list.append(list_a_post[p])
        p += 1
    if i % 2 == 1:
        memo_list.reverse()
    list_ans.append(memo_list)
for i in range(h):
    for j in range(w):
        list_ans[i][j] = str(list_ans[i][j])
for row in list_ans:
    print(" ".join(row))


Measured memory_bytes: 4212
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<cstdlib>
//#include<cmath>
//#include<algorithm>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
	int c=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		c+=(x!=i);
	}
	puts((c==0||c==2)?"YES":"NO");
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int x = stoi(s+t);
  for(int i = 1; i <=1000; i++){
    if(i*i == x){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int n, k, x, a[10];

bool f(int n) {
	while (n > 0) {
		if (a[n % 10]) return true;
		n /= 10;
	}
	return false;
}

int main() {
	cin >> n >> k;
	while (k--) {
		cin >> x;
		a[x] = true;
	}
	while (f(n)) n++;
	cout << n << endl;
}

Measured memory_bytes: 256