akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, K;
	cin >> N >> K;
	vl Ap, Am;
	int cp = 0, cz = 0, cm = 0;
	rep(i, N) {
		int A;
		cin >> A;
		if (A > 0) {
			Ap.push_back(A);
			cp++;
		}
		if (A < 0) {
			Am.push_back(A);
			cm++;
		}
		if (A == 0) {
			cz++;
		}
	}
	ll ans;
	bool p_can = false;
	rep(i, N) {
		int Cm = i * 2;
		int Cp = K - Cm;
		if (Cm <= cm && Cp <= cp && Cp >= 0)
			p_can = true;
	}
	if (p_can) {
		sort(Ap.begin(), Ap.end(), greater<ll>());
		sort(Am.begin(), Am.end(), less<ll>());
		int Cm = min(K - (K % 2), cm - (cm % 2));
		int Cp = K - Cm;
		while (1) {
			if (Cm == 0)
				break;
			if (Cp + 2 > cp)
				break;
			ll scprev = Am[Cm - 1] * Am[Cm - 2];
			ll scnext = Ap[Cp] * Ap[Cp + 1];
			if (scnext <= scprev)
				break;
			Cm -= 2;
			Cp += 2;
		}
		ans = 1;
		rep(i, Cm) {
			ans *= abs(Am[i]);
			ans %= mod;
		}
		rep(i, Cp) {
			ans *= Ap[i];
			ans %= mod;
		}
	}
	else if (cz > 0) {
		ans = 0;
	}
	else {
		sort(Ap.begin(), Ap.end(), less<ll>());
		sort(Am.begin(), Am.end(), greater<ll>());
		int Cm = min(K - ((int)(!(K % 2))), cm - ((int)(!(cm % 2))));
		int Cp = K - Cm;
		while (1) {
			if (Cm == 0)
				break;
			if (Cp + 2 > cp)
				break;
			ll scprev = Am[Cm - 1] * Am[Cm - 2];
			ll scnext = Ap[Cp] * Ap[Cp + 1];
			if (scnext >= scprev)
				break;
			Cm -= 2;
			Cp += 2;
		}
		ans = 1;
		rep(i, Cm) {
			ans *= abs(Am[i]);
			ans %= mod;
		}
		rep(i, Cp) {
			ans *= Ap[i];
			ans %= mod;
		}
		ans *= -1;
		ans += mod;
		ans %= mod;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += s[i];
  }
  if (sum % 10 != 0){
    cout << sum << endl;
  } else {
    bool flg = false;
    for (int i = 0; i < N; i++){
      if (s[i] % 10 != 0){
        flg = true;
        cout << sum - s[i] << endl;
        break;
      }
    }
    if (!flg){
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i <= N ; i++)
            A[i] = in.nextInt();

        out.println(nodes(N, A));
        out.flush();
    }

    private static long nodes(int N, int[] A) {
        if (A.length <= N)
            throw new IllegalArgumentException();
        long nextNodes = 1;
        long ans = 1;
        long maxNodes = 0;
        for (int i : A)
            maxNodes += i;
        for (int i = 0; i <= N; i++) {
            nextNodes -= A[i];
            if (nextNodes < 0)
                return -1;
            maxNodes -= A[i];
            nextNodes = Math.min(maxNodes, nextNodes * 2);
            ans += nextNodes;
        }
        return ans;
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 45784
//from PKU1125
main(){
	int i,n,f,k,t,dist[101][101];
	scanf("%d",&n);
		/*initialize*/
		memset(dist,11,sizeof(dist));
		for(i=1;i<=n;i++){
			dist[i][i]=0;
			scanf("%d%d",&f,&k);
			for(;k;k--){
				scanf("%d",&t);
				dist[f][t]=1;
			}
		}

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++)
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j];
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d%d",&f,&t,&n);
				printf(dist[f][t]<n?"%d\n":"NA\n",dist[f][t]+1);
			}
		}
	exit(0);
}

Measured memory_bytes: 648
N = input()
A = list(map(int, input().split()))

import sys
if 0 in A:
  print(0)
  sys.exit()
prod = 1
lim = 10 ** 18
for elem in A:
  prod *= elem
  if prod > lim:
    print(-1)
    sys.exit()
print(prod)

Measured memory_bytes: 21564
#include <bits/stdc++.h>
using namespace std;
int main (void)
{
	set<string> k;
	string s;
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		k.insert(s);
	}
	cout<<k.size();
	return 0;
}

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


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

    int arr[3][3];
    for(int i=0; i<3; i++)
        for(int j=0; j<3; j++)
            cin >> arr[i][j];

    int n;
    cin >> n;
    for(int t=0; t<n; t++) {
        int x;
        cin >> x;
        for(int i=0; i<3; i++)
            for(int j=0; j<3; j++)
                if(arr[i][j]==x)
                    arr[i][j]=0;
    }

    for(int i=0; i<3; i++) {
        if(!arr[i][0] && !arr[i][1] && !arr[i][2]) {
            cout << "Yes";
            return 0;
        }
    }
    for(int i=0; i<3; i++) {
        if(!arr[0][i] && !arr[1][i] && !arr[2][i]) {
            cout << "Yes";
            return 0;
        }
    }
    if(!arr[0][0] && !arr[1][1] && !arr[2][2])
    {
        cout << "Yes";
        return 0;
    }
    if(!arr[0][2] && !arr[1][1] && !arr[2][0]) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/


int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       ll n;
       cin>>n;
       ll ans=1e14;
       for(ll i=1;i*i<=n;i++){
         if(n%i==0){
           ll x=(i-1)+(n/i - 1);
           ans=min(ans,x);
         }
       }
       if(ans==1e14)ans=n-1;
       cout<<ans<<endl;
    }
}












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

typedef long long ll;

int main() {
  ll H, W;
  cin >> H >> W;
  // 1つ目の長方形の縦の長さを全探索して、その値によって2つ目、3つ目の長方形を定める
  ll mini = 1e18;
  ll area_min, area_max;
  ll tmp, h2, h3, w2, w3;
  for (int j = 0; j < 2; j++) {
    for (int i = 1; i < H; i++) {
      ll area1, area2, area3;
      area1 = i * W;
      // 2つ目、3つ目を縦に分割する
      tmp = H - i;
      h2 = tmp / 2;
      area2 = h2 * W;
      h3 = tmp - h2;
      area3 = h3 * W;
      area_min = min(area1, min(area2, area3));
      area_max = max(area1, max(area2, area3));
      mini = min(mini, area_max - area_min);
      // 2つ目、3つ目を横に分割する
      w2 = W / 2;
      area2 = w2 * tmp;
      w3 = W - w2;
      area3 = w3 * tmp;
      area_min = min(area1, min(area2, area3));
      area_max = max(area1, max(area2, area3));
      mini = min(mini, area_max - area_min);
    }
    swap(H, W);
  }
  // 解答
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-26 21:01:15
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];
    if (sum >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
 
int h[100005] = { 0 };
int main()
{
	char c,d;
	int n, q;
	cin >> n >> q;
	cin >> d;
	for (int i = 2; i <= n;i++) {
		cin >> c;
		if (c == 'C'&&d == 'A')h[i]++;
		h[i] += h[i - 1];
		d = c;
	}
	int a, b;
	for (int i = 1; i <= q; i++) {
		cin >> a >> b;
		cout << h[b]-h[a] << endl;
	}
    return 0;
}

Measured memory_bytes: 1280
A=input()
n=[int(a) for a in A]
if n[0]+n[1]+n[2]+n[3]==7:
    print(str(n[0])+'+'+str(n[1])+'+'+str(n[2])+'+'+str(n[3])+'=7')
elif n[0]+n[1]+n[2]-n[3]==7:
    print(str(n[0]) + '+' + str(n[1]) + '+' + str(n[2]) + '-' + str(n[3]) + '=7')
elif n[0] + n[1] - n[2] + n[3] == 7:
    print(str(n[0]) + '+' + str(n[1]) + '-' + str(n[2]) + '+' + str(n[3]) + '=7')
elif n[0] + n[1] - n[2] - n[3] == 7:
    print(str(n[0]) + '+' + str(n[1]) + '-' + str(n[2]) + '-' + str(n[3]) + '=7')
elif n[0] - n[1] + n[2] + n[3] == 7:
    print(str(n[0]) + '-' + str(n[1]) + '+' + str(n[2]) + '+' + str(n[3]) + '=7')
elif n[0] - n[1] + n[2] - n[3] == 7:
    print(str(n[0]) + '-' + str(n[1]) + '+' + str(n[2]) + '-' + str(n[3]) + '=7')
elif n[0] - n[1] - n[2] + n[3] == 7:
    print(str(n[0]) + '-' + str(n[1]) + '-' + str(n[2]) + '+' + str(n[3]) + '=7')
elif n[0] - n[1] - n[2] - n[3] == 7:
    print(str(n[0]) + '-' + str(n[1]) + '-' + str(n[2]) + '-' + str(n[3]) + '=7')
    

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

const int MAX = 1e5;

bool ng1 = false, ng2 = false;
int used[MAX];
vector<pii> G[MAX];

ll a[MAX];
ll b[MAX];

ll mi = 1, ma = 1e9;

ll val = -1;

void dfs(int v) {
	used[v] = true;
	for (auto e : G[v]) {
		int to = e.first;
		if (used[to]) {
			if (a[to] == a[v]) {
				ng1 = true;
				if ((e.second - (b[v] + b[to])) % 2) {
					ng2 = true;
					continue;
				}
				int nv = (e.second - (b[v] + b[to])) / 2;
				if (a[v] < 0) {
					nv = -nv;
				}
				if (nv <= 0) {
					ng2 = true;
					continue;
				}
				if (val != -1 && val != nv) {
					ng2 = true;
					continue;
				}
				val = nv;
			}
			else if (b[to] != e.second - b[v]) {
				ng1 = ng2 = true;
			}
			continue;
		}
		a[to] = -a[v];
		b[to] = e.second - b[v];
		if (a[to] > 0) {
			mi = max(mi, 1 - b[to]);
		}
		else {
			ma = min(ma, b[to] - 1);
		}
		dfs(to);
	}
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, s;
		cin >> u >> v >> s; --u, --v;
		G[u].emplace_back(v, s);
		G[v].emplace_back(u, s);
	}
	a[0] = 1;
	b[0] = 0;
	dfs(0);
	cout << (ng1 ? ng2 ? 0 : (ll)(mi <= val && val <= ma) : max(ma - mi + 1, 0LL)) << endl;
	return 0;
}


Measured memory_bytes: 14464
using System;
class Program {
  static void Main(string[] args) {
    int N = int.Parse(Console.ReadLine());
    string[] vals = Console.ReadLine().Split();

    int[] A = new int[N * 3];
    for (int i = 0; i < N * 3; ++i) {
      A[i] = int.Parse(vals[i]);
    }

    Array.Sort(A, (x,y) => y - x);

    long ans = 0;
    for (int i = 0; i < N; ++i) {
      ans += A[2 * i + 1];
    }

    Console.WriteLine(ans);
  }
}


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

// @@ !! LIM(f:gcd)
// --> f:gcd
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B, C; cin >> A >> B >> C;
  ll g = gcd(A, B);
  if (C % g == 0) {
    cout << "YES\n";
  }else {
    cout << "NO\n";
  }

  return 0;
}



Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#include<unordered_map>
#include<set>
#define int long long
using namespace std;

signed main() {
	int MAX = 0;
	int a; cin >> a;
	unordered_map<int, int>U;
	U[0] = 1;
	int sum = 0;
	for (int b = 0; b < a; b++) {
		int c; scanf("%lld", &c);
		sum += c;
		if (U[sum] == 0) {
			U[sum] = b + 2;
		}
		else {
			MAX = max(MAX, b + 2 - U[sum]);
		}
	}
	cout << MAX << endl;
}

Measured memory_bytes: 11068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000
int main(){
	int n,m,ans=0;cin>>n>>m;
	
	vector<vector<int>> G(n);//隣接行列
	
	vector<pair<int,int>> P;
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		P.push_back(make_pair(a,b));//辺を記憶
	}

	for(int i=0;i<P.size();i++){//各辺について
		vector<int> visit(n,0);//各辺を訪れたかどうかの判定(visit:1  !visit:0  切り離し:-1)
		
		//dfs
		stack<int> st;
		st.push(P[i].first);
		visit[P[i].first]=visit[P[i].second]=-1;//辺を一つ切り離す(-1が切り離されたところ)
		
		while(st.size()!=0){
	
			int now=st.top();
			st.pop();
			visit[now]=1;//visit

			visit[now]=1;//visitしたならば1
			for(auto next:G[now]){
				if(now==P[i].first && next==P[i].second) continue;//切り離し
				if(visit[next]==1) continue;//already visit

				st.push(next);
			}
		}

		bool bridge=false;
		for(int j=0;j<n;j++){
			if(visit[j]==0 || visit[j]==-1){bridge=true;}//切り離して訪れていないところがあれば橋
		}
		if(bridge){ans++;}
	}


	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs'

const getInput = (): string => {
  const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
  return input
}

export const solveAbc075b = () => {
  const input = getInput()

  const arr = input.trim().split('\n').map(v => v.trim())
  // console.log(arr)

  const numbers = arr[0].trim().split(' ').map(Number)
  const H = numbers[0]
  const W = numbers[1]

  const grid = arr.slice(1).map(v => v.split(''))
  // console.log(grid)

  let extendedGrid = grid.slice()
  const dummy = [...Array(W)].map(_ => '.')
  extendedGrid = [dummy].concat(extendedGrid).concat([dummy])
  extendedGrid = extendedGrid.map(v => ['.'].concat(v).concat('.'))
  // console.log(extendedGrid)

  const result = []
  for (let i = 1; i <= H; i += 1) {
    const row = []
    for (let j = 1; j <= W; j += 1) {
      if (extendedGrid[i][j] === '#') {
        row.push('#')
        continue
      }

      let count = 0
      if (extendedGrid[i - 1][j - 1] === '#') count += 1
      if (extendedGrid[i - 1][j] === '#') count += 1
      if (extendedGrid[i - 1][j + 1] === '#') count += 1
      if (extendedGrid[i][j - 1] === '#') count += 1
      if (extendedGrid[i][j + 1] === '#') count += 1
      if (extendedGrid[i + 1][j - 1] === '#') count += 1
      if (extendedGrid[i + 1][j] === '#') count += 1
      if (extendedGrid[i + 1][j + 1] === '#') count += 1
      // console.log(count)
      row.push(count.toString())
    }
    result.push(row)
  }
  // console.log(result)
  const out = result.map(v => v.join('')).join('\n')
  console.log(out)
}

solveAbc075b()


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

typedef long long ll;

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

    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    double sum = 0.0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    double uku = sum / (4*m);
    int cnt = 0;
    bool ok = false;
    for(int i=0;i<n;i++){
        if(a[i]>=uku) cnt++;
        if(cnt==m){
            ok = true;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int top,S[200];

void push(int x){
    S[++top]=x;
}
int pop(){
    top--;
    return S[top+1];
}

int main() {
    int a, b; char s[10];
    while(cin>>s){
      if(s[0]=='+'){
        b=pop(); a=pop();
        push(a+b);
      }
      else if(s[0]=='-'){
        b=pop(); a=pop();
        push(a-b);
      }
      else if(s[0]=='*'){
        b=pop(); a=pop();
        push(a*b);
      }
      else{
        push(atoi(s));
      }
    }
    cout << pop() << endl;
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (n & 1)
    puts("No");
  else
  {
    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
      puts("Yes");
    else
    {
      puts("No");
    }
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	for i, _ := range x {
		fmt.Scan(&x[i])
	}

	sorted := make([]int, n)
	copy(sorted, x)
	sort.Ints(sorted)

	mid := n/2

	for i := 0; i < n; i++ {
		if x[i] < sorted[mid] {
			fmt.Println(sorted[mid])
		} else {
			fmt.Println(sorted[mid-1])
		}
	}

}


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

using namespace std;

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

int main(){
  int h,a;
  cin>>h>>a;
  if(h%a>0)
    cout<<h/a+1<<endl;
  else
    cout<<h/a<<endl;

  return 0;
}

Measured memory_bytes: 256
<?php
list($N,$M)=sscanf(trim(fgets(STDIN)),"%d %d");
//N 偶数
//M 奇数
$cnt = 0;
for($i=0;$i<$M+$N;$i++){
    for($j=$i+1;$j<$M+$N;$j++){
        $a=1;
        $b=1;
        if($i < $N){
            $a=0;
        }
        if($j < $N){
            $b=0;
        }
        if(($a + $b)%2 == 0){
            $cnt++;
        }
        
    }
}
printf($cnt);

Measured memory_bytes: 4856
#include<iostream>

using namespace std;

int main(){
  long long n;
  cin>>n;
  long long x[5];
  long long mi =1e16;
  for(int i=0;i<5;i++){
    cin>>x[i];
    mi=min(x[i],mi);
  }
  cout<<4+(n/mi+(n%mi!=0))<<endl;

}


Measured memory_bytes: 256
//BECAUSE ONE TRUTH PREVAILS
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
// function to construct new array 
void constructXOR(LL A[], LL n) 
{ 
    LL XOR = 0; 
    for (LL i = 0; i < n; i++) 
        XOR ^= A[i];
    for (LL i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 
int main() {

    LL N;
    cin>>N;
    LL arr[N];
    for(LL i=0;i<N;i++)
    {
        cin>>arr[i];
    }
    constructXOR(arr,N);
    for(auto it:arr)
        cout<<it<<" ";

}


Measured memory_bytes: 5088
N, K = (int(i) for i in input().split())  
lis = [0] * N 

for _ in range(K):
  d = int(input())
  A = [int(i) for i in input().split()] 
  for a in A:
    if lis[a-1] == 0:
      lis[a-1] = 1
      
print(N - sum(lis))

Measured memory_bytes: 9192
import java.util.*;

public class Main {


    public static long lcm(long m, long n){
        return m*n/gcd(m,n);
    }

    public static long gcd(long c, long d){
        if (c<d){return gcd(d,c);}
        if(d==0){return c;}
        return gcd(d, c%d);
    }


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

//        long num[] = new long[b-a+1];
//        for (long i=0; i<b-a+1; i++){
//            num[i] = a+i;
//        }

        long count=0;

        long total = b-a+1;


        b = b-(b/c)-(b/d)+b/lcm(c,d);
        a = a-1-((a-1)/c)-((a-1)/d)+(a-1)/lcm(c,d);

        count = b-a;

//        long c_count=0;
//        long d_count=0;
//        long cd_count=0;
//
//
//        c_count = b/c - (a-1)/c;
//        d_count = b/d - (a-1)/d;
//        cd_count = b/lcm(c,d)-(a-1)/lcm(c,d);
//
//        if (((c-(a%c))+b%c)>c){
//            c_count += (b-a+1)/c-1;
//        }else{
//            c_count += (b-a+1)/c;
//        }
//
//
//        if (((d-(a%d))+b%d)>d){
//            d_count += (b-a+1)/d-1;
//        }else{
//            d_count += (b-a+1)/d;
//        }
//
//
//
//
//        if (((lcm(c,d)-(a%lcm(c,d))+b%lcm(c,d))>lcm(c,d))){
//            cd_count += (b-a+1)/lcm(c,d)-1;
//        }else{
//            cd_count += (b-a+1)/lcm(c,d);
//        }

//        count = (b-a+1)-c_count-d_count+cd_count;

        System.out.println(count);

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> C(N);
    for (int i = 0; i < N; ++i)
        cin >> C[i];
    sort(C.begin(), C.end(), greater<int>());

    ll ans = 0, p = 1, po = 0;
    for (int i = 0; i < N; ++i) {
        (ans <<= 1) %= MOD;
        ll tmp = (p + i * po) % MOD;
        ans += tmp * C[i] % MOD;
        po = p;
        (p <<= 1) %= MOD;
    }
    (ans *= (po << 1)) %= MOD;

    cout << ans << endl;

    return 0;
}


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

int main() {
	int m, f, r;
	char c;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;
		if (m == -1 || f == -1)
			c = 'F';
		else if ((m + f) >= 80)
			c = 'A';
		else if ((m + f) >= 65)
			c = 'B';
		else if ((m + f) >= 50)
			c = 'C';
		else if ((m + f) >= 30) {
			if (r >= 50)
				c = 'C';
			else
				c = 'D';
			} else
			c = 'F';
		cout << c << endl;
	}
	return 0;
}

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

const double EPS = 1e-9;

struct Node{
    int num, v, before;
    double cost;
    bool operator<(const Node& obj)const{
        return cost > obj.cost + EPS;
    }
};

struct Edge{
    int to, from, v, distance;
};

double mini[33][33][33];

int main(){
    int n, m;
    while(cin >> n >> m, n != 0){
        int s, g;
        cin >> s >> g;
        vector<Edge> graph[33];
        for(int i=0;i<m;++i){
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            graph[x].push_back((Edge){y, x, c, d});
            graph[y].push_back((Edge){x, y, c, d});
        }

        for(int i=0;i<=30;++i){
            for(int j=0;j<=30;++j){
                for(int k=0;k<=30;++k){
                    mini[i][j][k] = 1e9;
                }
            }
        }

        priority_queue<Node> que;
        que.push((Node){s, 1, -1, 0});
        bool ok = false;
        while(!que.empty()){
            Node curr = que.top(); que.pop();
            if(curr.num == g && curr.v == 0){
                printf("%.10f\n", curr.cost);
                ok = true;
                break;
            }
            for(Edge e : graph[curr.num]){
                if(curr.v > e.v)continue;
                if(curr.before != -1 && curr.before == e.to)continue;
                double newcost = curr.cost + e.distance / (double)(curr.v);
                for(int i=1;i>=-1;--i){
                    if(e.to != g && curr.v + i <= 0 || e.to == g && curr.v + i < 0)continue;
                    if(newcost + EPS < mini[curr.num][e.to][curr.v+i]){
                        mini[curr.num][e.to][curr.v+i] = newcost;
                        que.push((Node){e.to, curr.v+i, curr.num, newcost});
                    }
                }
            }
        }
        if(!ok)cout << "unreachable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3940
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        int d;
        cin >> d;
        v[i] = d;
    }
    // sort(ALL(v));
    int answer = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            answer += v[i] * v[j];
        }
    }
    cout << answer << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  bool a = true;
  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) == vec.at(i+1)) {
      a = false;
      break;
    }
  }
  
  if (a) {
    cout << "YES" <<endl;
  }
  else {
    cout << "NO" <<endl;
  }
  
}


Measured memory_bytes: 1024
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

INF = 10**9
cost = [[INF]*N for _ in range(N)]
for _ in range(M):
  A, B, C = map(int, input().split())
  A -= 1
  B -= 1
  cost[A][B] = C
  cost[B][A] = C

for k in range(N):
  for i in range(N):
    for j in range(N):
      cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])

ans = INF

for route in permutations(r):
  temp = 0
  for i in range(R-1):
    temp += cost[route[i]][route[i+1]]
  ans = min(ans, temp)

print(ans)

Measured memory_bytes: 74888
#include<bits/stdc++.h>
#define IO cin.tie(0),ios::sync_with_stdio(0);
#define ff first
#define ss second
#define eb emplace_back
#define iter(v) v.begin() ,v.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define print(v) for(auto x: v) cout<<x<<' ';
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vec;
int a[100001];
int main()
{
    int h,n;
    cin>>h>>n;
    rep(i,n)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int tmp=h;
    rep(i,n)
    {
        tmp-=a[i];
        if(tmp<=0)
            break;
    }
    if(tmp<=0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int a, b;
    cin >> a >> b;
    if (b == 1) {
        dump(0);
        return 0;
    }
    Int res = 0;
    Int cur = 1;
    while (cur < b) {
        res++;
        cur--;
        cur += a;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
    int n,m;cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for(auto v:G){
        cout<<sz(v)<<endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;
ll N;
vector<ll> A;
vector<vector<ll>> sum(410, vector<ll>(410, 0));
vector<vector<ll>> memo(410, vector<ll>(410, INF));

void set_sum(){
    for(ll l = 0; l < N; l++){
        sum[l][l + 1] = A[l];
        for(ll r = l + 2; r <= N; r++){
            sum[l][r] = sum[l][r - 1] + A[r - 1];
        }
    }
}

ll search(ll l, ll r){
    if(memo[l][r] != INF) return memo[l][r];
    if(r - l <= 1) return memo[l][r] = 0;
    ll v = INF;
    for(ll s = l + 1; s <= r - 1; s++) v = min(v, search(l, s) + search(s, r) + sum[l][s] + sum[s][r]);
    //cout << "memo[" << l << "][" << r << "] = " << v << endl;
    return memo[l][r] = v;
}

int main(){
    cin >> N;
    A.resize(N);
    for(ll &a : A) cin >> a;
    set_sum();
    cout << search(0, N) << endl;
    return 0;
}


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

int main(){
  string s,ans;
  int num,cnt;
  char prv;

  cin >> s;
  cnt = 0; num = 0; prv = 'a';

  for(int i=0;i<(int)s.size();i++){
    if(prv != s[i]){
      cnt++; prv = s[i];
    }else{
      if(num < cnt){
	num = cnt;
	ans = (prv=='c')?"chicken":"egg";
      }
      cnt = 1;
    }
    if(s[i] == 'e')i += 2;
    else i += 6;
  }
  if(num < cnt)ans = (prv=='c')?"chicken":"egg";

  cout << ans << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b);
    return 0;
}


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

int main(){
  string s;
  cin >>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  if(a+b+c+d==7)cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b+c-d==7)cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a+b-c+d==7)cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b-c-d==7)cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b+c+d==7)cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b+c-d==7)cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b-c+d==7)cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b-c-d==7)cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
using namespace std;
const int INF = 1e9 + 7;
int i;

int main(){
    ///preprocessing
    #ifndef ONLINE_JUDGE
    freopen("test.inp", "r", stdin);
    #endif // ONLINE_JUDGE
    fio;
    ///code below
    cin >> i;
    cout << ((i)? 0 : 1);
}


Measured memory_bytes: 3580
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = Integer.parseInt(sc.next());
			int n = Integer.parseInt(sc.next());
			if (m == 0 && n == 0) break;
			int w = (m + n) * 20;
			int f[] = new int[w + 1];
			for (int i = m; i <= w; i++) {
				f[i] = i;
			}
			for (int i = m; i <= w; i++) {
				for (int j = i + i; j <= w; j += i) {
					f[j] = 0;
				}
			}
			int[] a = new int[n];
			int index = m;
			for (int i = 0; i < n; i++) {
				while (f[index] == 0)
					index++;
				a[i] = index;
				index++;
			}
			int ans[] = new int[w + 1];
			for (int i = 0; i < n; i++) {
				int b = 1;
				while (a[i] * b <= w) {
					ans[a[i] * b] = 1;
					b++;
				}
			}
			for (int i = m; i <= w; i++) {
				if (ans[i] == 0) {
					System.out.println(i);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 721384
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin >> n >> k;
	set<int> have;
	forl(i, 0, n) {
		int d; cin >> d;
		forl(j, 0, d) {
			int a; cin >> a;
			have.insert(a);
		}
	}
	println(n-have.size());
}


Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}


int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    ans = max(a*d, ans);
    ans = max(b*d, ans);
    ans = max(c*b, ans);

    cout << ans <<endl;
}





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

#define N 100

void push(int);
int pop(void);

int top;
int A[N];

int main()
{
  char c[N];
  int x,y;

  while(scanf("%s",c)!=EOF)
    {
      if(c[0]=='+')
	{
	  x=pop();
	  y=pop();
	  push(x+y);
	}
      else if(c[0]=='-')
	{
	  x=pop();
	  y=pop();
	  push(y-x);
	}
      else if(c[0]=='*')
	{
	  x=pop();
	  y=pop();
	  push(x*y);
	}
      else push(atoi(c));
    }

  printf("%d\n",A[top]);
  
  return 0;
}


void push(int x)
{
  top++;
  A[top]=x;
}

int pop(void)
{
  top--;
  return A[top+1];
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    string ans = "No";
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (i * j + (n - i) * (m - j) == k)ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n; scanf("%d", &n);
	char s[n], t[n]; scanf("%s", &s); scanf("%s", &t);
	
	int i = 0;
	for(;i<n;i++){
		bool f = true;
		reg(j, i, n-1){
			if(s[j] != t[j-i]){
				f = false;
				break;
			}
		}
		if(f) break;
	}
	
	cout << 2*n - (n-i) << endl;	
	
	return 0;
}

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

int paper[10][10];

bool onPaper(int x,int y){
	return 0<=x&&x<10&&0<=y&&y<10;
}
void small(int x,int y){
	for(int i=-1;i<=1;i++)
		for(int j=-1;j<=1;j++)
			if(onPaper(x+i,y+j) && abs(i)+abs(j) <= 1)
				paper[x+i][y+j]++;
}
void medium(int x,int y){
	for(int i=-1;i<=1;i++)
		for(int j=-1;j<=1;j++)
			if(onPaper(x+i,y+j) && abs(i)<=1 && abs(j)<=1)
				paper[x+i][y+j]++;
}
void large(int x,int y){
	for(int i=-2;i<=2;i++)
		for(int j=-2;j<=2;j++)
			if(onPaper(x+i,y+j) && abs(i)+abs(j) <= 2)
				paper[x+i][y+j]++;
}
int main(){
	int x,y,size;
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		if(size==1)small(x,y);
		else if(size==2)medium(x,y);
		else large(x,y);
	}
	int n=0,depth=0;
	for(x=0;x<10;x++){
		for(y=0;y<10;y++){
			if(paper[x][y]==0)n++;
			depth = max(depth,paper[x][y]);
		}
	}
	cout<<n<<endl;
	cout<<depth<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    if (N == 0) {
        cout << "0" << endl;
        return 0;
    }

    string ans = "";
    for (ll i = 0; true; ++i) {
        if (N == 0) {
            break;
        }
        if (N % 2 == 0) {
            ans = "0" + ans;
            N = N / 2;
        } else {
            ans = "1" + ans;
            if (i % 2 == 0) {
                N = (N - 1) / 2;
            } else {
                N = (N + 1) / 2;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
	// your code goes here
	string s;
	cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
    cout<<"Yes";
    else
    cout<<"No";
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int dx[8]={1,1,1,0,0,-1,-1,-1};
	int dy[8]={1,0,-1,1,-1,1,0,-1};
	int h,w,i,j,x,y,cnt,k;
	char s[50][51];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)	scanf("%s",s[i]);
	for(i=0;i<h;i++)	{
		for(j=0;j<w;j++)	{
			if(s[i][j]!='#')	{
				cnt=0;
				for(k=0;k<8;k++)	{
					x=j+dx[k];	y=i+dy[k];
					if(x>=0 && y>=0 && x<w && y<h && s[y][x]=='#')	cnt++;
				}
				s[i][j]=cnt+'0';
			}
		}
	}
	for(i=0;i<h;i++)	printf("%s\n",s[i]);
	return 0;
}

Measured memory_bytes: 128
import sys
num = list(input())
op1 = "+"
for x in range(2):
  op2 = "+"
  for y in range(2):
    op3 = "+"
    for z in range(2):
      fml = (num[0]+op1+num[1]+op2+num[2]+op3+num[3])
      if eval(fml) == 7:
        print(num[0]+op1+num[1]+op2+num[2]+op3+num[3]+"=7")
        sys.exit()
      op3 = "-"
    op2 = "-"
  op1 = "-"

Measured memory_bytes: 9044
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveD();
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] t = new int[N];
		int sum_t = 0;
		for (int i = 0; i < N; i++) {
			t[i] = sc.nextInt() * 2;
			sum_t += t[i];
		}
		int[] v = new int[N];
		for (int i = 0; i < N; i++) {
			v[i] = sc.nextInt() * 2;
		}
		int tmp_v = 0;
		int tmp_t = 0;
		int[] max_v = new int[sum_t + 1];
		for (int i = 0; i < N; i++) {
			max_v[tmp_t] = v[i] < tmp_v ? v[i] : tmp_v;
			tmp_v = max_v[tmp_t];
			for (int t_ind = 0; t_ind < t[i]; t_ind++) {
				max_v[++tmp_t] = v[i] < tmp_v + 1 ? v[i] : tmp_v + 1;
				tmp_v = max_v[tmp_t];
			}
		}
		tmp_v = 0;
		for (int i = N - 1; i >= 0; i--) {
			max_v[tmp_t] = v[i] < tmp_v ? v[i] : tmp_v;
			tmp_v = max_v[tmp_t];
			for (int t_ind = 0; t_ind < t[i]; t_ind++) {
				int back_v = v[i] < tmp_v + 1 ? v[i] : tmp_v + 1;
				--tmp_t;
				max_v[tmp_t] = max_v[tmp_t] < back_v ? max_v[tmp_t] : back_v;
				tmp_v = max_v[tmp_t];
			}
		}
		double answer = 0;
		for (int i = 0; i < sum_t; i++) {
			answer += (max_v[i] + max_v[i + 1]);
		}
		System.out.println(answer * 0.125);
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,d;
    cin >> m >> d;
    ll c = 0;
    for (int z=1;z<=m;z++){
        for (int x=10;x<=d;x++){
            if (((x%10) * (x/10) == z) && x%10 >=2  && x/10 >= 2) {
                c++;
            }
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int i;
    int n;
 
    scanf("%d %d %d", &a, &b, &c);
    n = 0;
    for (i=a; i<=b; i++) {
        if (c%i == 0) n++;
    }
    printf("%d\n", n);
    
    return 0;
}


Measured memory_bytes: 2108