akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int64_t MOD = 1000000007;
  int64_t ans = 1;
  for(int64_t i = 0;i < n;i++) ans = ans * (i+1) % MOD;
  cout << ans << endl;
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double c = a * a * b / 2;
  double ans;
  if (x <= c) {
    ans = atan(2*x/(a*b*b));
    ans *= 180/M_PI;
    ans = 90 - ans;
  }
  else {
    ans = atan(a*a*a/(2*(a*a*b - x)));
    ans *= 180/M_PI;
    ans = 90 - ans;
  }
  printf("%.10lf\n", ans);
}

Measured memory_bytes: 384
//atRto TLH
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ll long long
const ll MOD = 1e9 + 7;
#define ln '\n'
#define all(x) (x).begin(), (x).end()
#define rotate rotate(vec.begin(), vec.begin() + k, vec.end())
#define alloc(v) set<int> S(all(v))
#define bitset(n)  bitset<20>(n)
#define Min min({a, b, c, d})
 
      const ll INF=2*1e5;
      char tt[2003][2003];
    
     int vis[107];
     //vector<ll>v[107];
    int size=0;
 

 
 
 
  void lcs(string s,string t,ll a,ll b)
   {
      ll dp[a+1][b+1];
     for(ll i=0;i<=a;i++){
      for(ll j=0;j<=b;j++){
        if(i==0||j==0){
          dp[i][j]=0;
        }
        else{
          if(s[i-1]==t[j-1]){
            dp[i][j]=1+dp[i-1][j-1];
          }
          else{
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
          }
        }
      }
     }
     int index=dp[a][b];
    char lcs[index+1];
    lcs[index]='\0';
    
 ll i=a;
 ll j=b;
 while(i>0||j>0){
  if(s[i-1]==t[j-1]){
   lcs[index-1]=s[i-1];
    i--;j--;index--;
  }
  else if(dp[i-1][j]>dp[i][j-1]){
    i--;
  }
  else j--;
 }
 cout<<lcs<<ln;

   }
    
 
    int main() {
      IOS;
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
   
     string s,t;
     cin>>s>>t;

     ll a,b;
     a=s.length();b=t.length();

  lcs(s,t,a,b);
   return 0;
 }



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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int a[10];
bool ans;

void dfs(int idx, int l, int r) {
   if (idx == 10) {
      ans = true;
      return;
   }

   int val = a[idx];
   if (l < val) dfs(idx+1, val, r);
   if (r < val) dfs(idx+1, l, val);
}

int main() {
   int N;
   cin >> N;
   while (N--) {
      for (int i = 0; i < 10; i++) cin >> a[i];
      ans = false;
      dfs(0, -1, -1);
      puts(ans ? "YES" : "NO");
   }

   return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    vi x(3); REP(i, 3) cin >> x[i]; 
    sort(ALL(x), greater<>());
    int ans = x[0] * 10 + x[1] + x[2];
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
n,i,d=-1,m,a[1<<17];
main(){
	scanf("%d",&n);
	for(;~scanf("%d",a+i);i++)m<a[i]&&(m=a[i]);
	for(i=0;i<n;i++)m-a[i]&&abs(m-2*a[i])<abs(m-2*d)&&(d=a[i]);
	printf("%d %d",m,d);
}

Measured memory_bytes: 512
N,*uvws=$<.read.split.map(&:to_i)

h = {}
uvws.each_slice(3) do |u,v,w|
    h[u] ||= []
    h[u] << [u,v,w%2]
    h[v] ||= []
    h[v] << [v,u,w%2]
end

arr = Array.new(N+1,-1)
arr[1] = 0

q = h[1]
until q.empty?
    u,v,w = q.shift
    next if arr[v] != -1
    if w == 0
        arr[v] = arr[u]
    else
        arr[v] = 1-arr[u]
    end
    # q.push(*h[v]) # Array#+= だとTLEになるので.pushを使う
    q.concat(h[v])
end

puts arr[1..-1]

Measured memory_bytes: 55084
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll a,b;
ll ans=0;

void dfs(ll l,ll r,ll d,ll w){
    //[L,R)
    ll L=w,R=w+(1LL<<d);
    if(l>=R || r<=L){return;}
    if(l<=L && R<=r){
        if(d==0){ans^=w;}
        if(d==1){ans^=1;}
        return;
    }
    dfs(l,r,d-1,w);
    dfs(l,r,d-1,w+(1LL<<(d-1)));
}


int main(){
    cin>>a>>b;
    dfs(a,b+1,50,0);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys, bisect, math, itertools
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, k = inpl()
ans={i for i in range(1,n+1)}
for i in range(k):
    d = inp()
    a=set(map(int, input().split()))
    ans -= a
print(len(ans))

Measured memory_bytes: 74588
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
 int N;
 cin>>N;
int A[100001]={0,};
fx(N){
	int k;
cin>>k;
A[k]++;
}
int max=A[1]+A[0];
fyg(100000,1){
	int sum=0;
	sum+=A[y-1]+A[y+1]+A[y];
	if(sum>max){max=sum;}
}

if(A[100000]+A[99999]>max){max=A[100000];}
ce(max);

}

Measured memory_bytes: 640
#include <stdio.h>

int parent(int),left(int),right(int);

int main()
{
    
    int H, i;
    int N[250];
    
    scanf("%d", &H);
    
    for(i=1; i<=H; i++){
        scanf("%d", &N[i]);
    }
    
    for(i=1; i<=H; i++){
        printf("node %d: ", i);
        printf("key = %d, ", N[i]);
        if(parent(i) > 0 && parent(i) <= H) printf("parent key = %d, ", N[parent(i)]);
        if(left(i) > 0 && left(i) <= H) printf("left key = %d, ", N[left(i)]);
        if(right(i)> 0 && right(i) <= H) printf("right key = %d, ", N[right(i)]);
        printf("\n");
    }
    
    return 0;
}

int parent(int i){
    return i / 2;
}

int left(int i){
    return 2 * i;
}

int right(int i){
    return 2 * i + 1;
}




Measured memory_bytes: 2108
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll a, b, c;

  cin >> a >> b >> c;

  if ((10 * b + c) % 4 == 0)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }

  return 0;
}


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

using namespace std;

struct Graph {
    vector<vector<int>> G;
    vector<int> dp;

    Graph(int N) {
        G.assign(N+1, vector<int>{});
        dp.assign(N+1, -1);
    };

    void make_edge(int u, int v) {
        G[u].push_back(v);
    }

    void make_twoedge(int u, int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }

    // uを始点とする最長経路の長さf(u)
    int f(int u) {
        // dpの値が計算済みのときその値を返す
        if (dp[u] != -1) {
            return dp[u];
        }

        int tmp = 0;
        
        for (auto v : G[u]) {
            tmp = max(tmp, f(v)+1);
        }

        return dp[u] = tmp;
    }
};


int main() {
	int N,M;
    cin >> N >> M;

    int x,y;
    Graph G(N);

    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        G.make_edge(x, y);
    }

    int answer = 0;

    for (int i = 1; i <= N; i++) {
        answer = max(answer, G.f(i));
    }

    cout << answer << endl;
	return 0;
}

Measured memory_bytes: 11080
import numpy as np
N = int(input())
input_H = input().split()
H = np.empty(N, int)
for i in range(N):
    H[i] = int(input_H[i])

max = H[0]
num = 1
for i in range(1, N):
    if H[i] >= max:
        num += 1
        max = H[i]
print(int(num))

Measured memory_bytes: 12500
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
Ps = list(map(int, input().split()))

def ok(Qs):
    N = len(Qs)
    for i in range(N - 1):
        if Qs[i] > Qs[i + 1]:
            return False
    return True

if ok(Ps):
    print("YES")
else:
    flag = False
    for i in range(N - 1):
        for j in range(i + 1, N):
            Qs = Ps[:]
            Qs[i], Qs[j] = Qs[j], Qs[i]
            if ok(Qs):
                flag = True
    if flag:
        print("YES")
    else:
        print("NO")
                




Measured memory_bytes: 7968
import java.util.*

fun main(args: Array<String>){

    //var (K,T) = readLine()!!.split(" ").map{it.toInt()}
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{it.toInt()}
    var max = 0
    for(i in a.indices){
        max = Math.max(a[i],max)
    }

    var rMax = -1
    var rMaxIndex = 0
    for(i in a.indices){
        if(a[i] != max){
            var r = Math.min(a[i],max-a[i])

            if(r>rMax){
                rMaxIndex = i
                rMax = r
            }
        }
    }
    print("$max ${a[rMaxIndex]}")


}


Measured memory_bytes: 51800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const ll MOD = 1e9 + 9;
const int INF = 1e9;
const ll INFF = 1e18;
 
const int MAX_N = 60;
ll com[MAX_N][MAX_N];
void combination(void){ //com[i][j] := iCj
	com[0][0] = 1;
	for (int i = 1; i <= MAX_N - 1; ++i){
		for (int j = 0; j <= i; ++j){
			//パスカルの３角形
			if(j == 0) com[i][j] = com[i - 1][j];
			else com[i][j] = (com[i - 1][j] + com[i - 1][j - 1]);
		}
	}
}

int N, A, B;
map<ll, int> ma;
int main(void){
	cin >> N >> A >> B;
	vector<ll> v(N);
	rep(i, N) cin >> v[i];
	rep(i, N){
		ma[v[i]]++;
	}
	sort(all(v));
	reverse(all(v));
	long double sum = 0;
	int cnt = 0;
	rep(i, A){
		if(i == 0) cnt++;
		else{
			if(v[i - 1] == v[i])cnt++;
			else{
				cnt = 1;
			}
		}
		sum += v[i];
	}
	long double tsum = sum;
	int cntr = cnt;
	reps(i, A, B){
		ll tmp = sum + v[i];
		if(tmp * A == tsum * (i + 1)){
			cntr++, sum = tmp;
		}
		else break;
	}
	ll num = ma[v[A - 1]];
	ll ans = 0;
	combination();
	for (int i = cnt; i <= cntr; ++i){ // num C i
		// if(num < i) break;
		ans += com[num][i];
	}
	printf("%.7Lf\n", tsum / (double)A);
	// cout << (long double)tsum / (long double)A << endl;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  $map[$i] = trim(fgets(STDIN))."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j <= $W; $j++){
    if($map[$i][$j] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$i][$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j <= $H; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $max = max($max, $p[$j - 1 - $k][$i] + $h);
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
echo $max - 1;

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

bool judge(int x,int y,int r,int W,int H){
    
    int ans=1;
    
    if((r+x)<=W && (x-r)>=0 && (r+y)<=H && (y-r)>=0){
        return true;
    }
    else{
        return false;    
    }
    
}

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    int ans=judge(x,y,r,W,H);
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
    
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 2025
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

int cnt[maxn][maxn], n, k, red, blue, ans;
const int Mod = 1e9 + 7;

void pre_calc()
{

    cnt[0][0] = 1;
    for (int i = 1; i < maxn; i++) {
        for (int r = 0; r <= maxn; r++) {
            if (r == 0 || r == i) cnt[i][r] = 1;
            else cnt[i][r] = cnt[i - 1][r - 1] + cnt[i - 1][r];
            cnt[i][r] %= Mod;
            //cerr << cnt[i][r]<<endl;
        }
    }
}
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        pre_calc();
        cin >> n >> k;
        blue = k, red = n - k;
        for (int i = 1; i <= blue; i++) {
            ans = (1ll * cnt[red + 1][i] * cnt[blue - 1][i - 1]) % Mod;
            //cerr << cnt[red+1][i] <<" "<<cnt[blue - 1][i - 1]<<endl;
            cout << ans << endl;
        }
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>

int main(void)
{
  long long int X,A,B,Y;

  scanf("%lld %lld %lld",&X,&A,&B);
  Y = A - B;

  if(Y >= 0)
    printf("delicious\n");
  else if(-Y <= X)
    printf("safe\n");
  else
    printf("dangerous\n");

  return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	void main() {

		try(Scanner sc = new Scanner(System.in)) {
			for(;;) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				if(x == 0 && y == 0)
					break;
				if(x < y)
					System.out.println(x + " " + y);
				else
					System.out.println(y + " " + x);
			}
		}
	}

	public static void main(String[] args) {

		new Main().main();

	}

}



Measured memory_bytes: 36312
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1ll << 60;

ll Cmb(int n, int k)
{
    ll coef = 1;
    vector<ll> sieve(n + 1, 0);
    if (n < k)
    {
        coef = 0;
        return coef;
    }
    if (n == k || k == 0)
    {
        coef = 1;
        return coef;
    }
    k = min(k, n - k);
    for (ll p = 2; p <= n; p++)
    {
        if (sieve.at(p) == 0)
        {
            for (ll i = p * p; i <= n; i += p)
            {
                sieve.at(i) = 1;
            }
            for (ll prime = p; prime <= n; prime *= p)
            {
                ll cnt = n / prime - k / prime - (n - k) / prime;
                REP(j, cnt)
                {
                    coef *= p;
                    coef %= MOD;
                }
            }
        }
    }
    return coef;
}

int main()
{
    ll x,y;
    cin >> x >> y;
    if((x+y)%3!=0||x*2<y||x>y*2){
        cout << 0 << endl;
        return 0;
    }
    ll tmp=(x+y)/3;
    ll tmp1=x-tmp;
    cout << Cmb(tmp,tmp1) << endl;
}

Measured memory_bytes: 5504
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n)-1)
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int f(int a, LL b){
    if(b<a) return b;
    int ret=b%a +f(a,b/a);
    return ret;
}

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

    LL n,s;
    cin >>n >>s;
    LL sqr=sqrt(n);
    if(n==s){
        cout << n+1 <<endl;
        return 0;
    }
    REPN(i,2,sqr){
        //OUT(i)
        if(f(i,n)==s){
            cout << i << endl;
            return 0;
        }
    }

    for(LL i=sqr+1; i>=1;--i){
        LL tmp=s-i;
        //OUT(i)
        if(tmp<0) continue;
        if((n-tmp)%i==0){
            LL base=(n-tmp)/i;
            if(base!=0 && (n/base)+(n%base)==s&&base>i){
            cout << base <<endl;
            return 0;
        }
        }
    }
    cout << -1 <<endl;

    return 0;
}


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

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();

        int ans = 0;
        char cur = s[0];
        for (int i = 0; i < s.Length; i++)
        {
            if (cur != s[i])
            {
                ans++;
                cur = s[i];
            }
        }
        Console.WriteLine(ans);
    }
}

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


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vll a(n);
rep(i,0,n-1)cin>>a[i];
ll ans=1000,st=0;


rep(i,0,n-2)
{
	if(a[i]<a[i+1])
	{
		st+=ans/a[i];
		ans%=a[i];
	}
	else if(a[i]>a[i+1])
	{
		ans+=st*a[i];
		st=0;
	}
}
ans+=st*a[n-1];
ol(ans);
return 0;
}



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

def solve():
    H, W, M = map(int, input().split())
    numRs = [0] * H
    numCs = [0] * W
    hws = []
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        numRs[h] += 1
        numCs[w] += 1
        hws.append((h, w))

    maxR = max(numRs)
    maxC = max(numCs)

    hs = set()
    ws = set()
    for h in range(H):
        if numRs[h] == maxR:
            hs.add(h)
    for w in range(W):
        if numCs[w] == maxC:
            ws.add(w)
    numH = len(hs)
    numW = len(ws)

    num = 0
    for hb, wb in hws:
        if hb in hs and wb in ws:
            num += 1

    ans = maxR+maxC
    if num == numH*numW:
        ans -= 1

    print(ans)


solve()


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

int main(void)
{
    long long n, m;
    long long k;
    cin >> n >> m >> k;

    vector<long long> a{0}, b{0};
    long long tmp;
    for (long long i = 0; i < n; i++)
    {
        cin >> tmp;
        a.push_back (tmp + a.back());
    }
    for (long long i = 0; i < m; i++)
    {
        cin >> tmp;
        b.push_back (tmp + b.back());
    }
    long long i = 0, jmax = m, best = 0;
    while (a[i] <= k && i <= n)
    {
        for (long long j = jmax; j >= 0; j--)
        {
            jmax = j;
            if (a[i] + b[j] <= k)
            {
                if (i + j > best) best = i + j;
                break;
            }
        }
        i++;
    }
    cout << best << endl;
}


Measured memory_bytes: 7896
a = int(input())
ar = list(map(int,input().split(" ")))
ar.append(0)
ar.insert(0,0)
mx = 0
for i in range(1,len(ar)):
    mx += abs(ar[i] - ar[i-1])
for i in range(1,len(ar) - 1):
    mi = mx
    mi -= abs(ar[i-1] - ar[i])
    mi -= abs(ar[i] - ar[i+1])
    mi += abs(ar[i-1] - ar[i+1])
    print(mi)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b, tmp;
    int i, rep;
    cin >> a >> b;
    tmp=a;
    rep=stoi(b);
    for(i=1;i<rep;i++){
        a=a+tmp;
    }
    rep=stoi(tmp);
    tmp=b;
    for(i=1;i<rep;i++){
        b=b+tmp;
    }
    if(a>b) cout << b << endl;
    else cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,a,b; //1<=a<=b<=36
  int i,r,c,res;
  
  cin>>n>>a>>b;
  
  for(i=1;i<=n;i++){
    r=0;
    c=i;
    while(c!=0){
  	  r+=c%10;
      c/=10;
    }
    if(a<=r&&r<=b)
      res+=i;
  }
  cout<<res<<endl;  
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    if n==1:
        print(1)
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
    x=Counter(PQ).most_common(1)[0][1]
    print(n-x)

if __name__=='__main__':
    main()

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<string> s(n);
	int ans = 0;
	int AB = 0, BA = 0;
	int frontB = 0, endA = 0;
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
		
		int m = s[i].size();
		for(int j = 0; j < m - 1; ++j) {
			if( s[i][j] == 'A' && s[i][j + 1] == 'B' ) ans++;
		}	
		
		if( s[i][0] == 'B' && s[i][m - 1] == 'A' ) BA++;
		else if( s[i][0] == 'B' && s[i][m - 1] != 'A' ) frontB++;
		else if( s[i][0] != 'B' && s[i][m - 1] == 'A' ) endA++;		
	}
	
	if( BA == 0 ) {
		ans += min(frontB, endA);
	} else {
		if( frontB + endA > 0 ) {
			ans += (BA + min(frontB, endA));
		} else if( frontB + endA == 0 ) {
			ans += BA - 1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 768
use proconio::input;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

impl PartialEq for Wrapper {
  fn eq(&self, other: &Wrapper) -> bool {
    self.0 == other.0
  }
}
impl Eq for Wrapper {}

impl PartialOrd for Wrapper {
  fn partial_cmp(&self, other: &Wrapper) -> Option<Ordering> {
    let result = if self.0 < other.0 {
      Ordering::Less
    } else if self.0 == other.0 {
      Ordering::Equal
    } else {
      Ordering::Greater
    };
    Some(result)
  }
}

impl Ord for Wrapper {
  fn cmp(&self, other: &Wrapper) -> Ordering {
    if self.0 < other.0 {
      Ordering::Less
    } else if self.0 == other.0 {
      Ordering::Equal
    } else {
      Ordering::Greater
    }
  }
}

#[derive(Debug)] 
struct Wrapper(f64);

fn main() {
  input! {
    n: usize,
    m: usize,
    mut products: [f64;n] 
  }
  let mut heap = BinaryHeap::new();
  for v in products {
    heap.push(Wrapper(v));
  }

  for _ in 0..m {
    let mut v = heap.pop().unwrap();
    v.0 /= 2f64; 
    heap.push(v);
  }
  
  let mut sum = 0;
  for v in heap.into_iter() {
    sum += v.0.trunc() as usize;
  }
  
  println!("{}", sum);
}

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

using namespace std;

int N, L;

int main()
{
	priority_queue<string, vector<string>, greater<string>> Q;
	cin >> N >> L;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		Q.push(s);
	}
	while (!Q.empty())
	{
		cout << Q.top();
		Q.pop();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int a=1;
    int b=1;
    rep(i,n){
        while(a*b<n&&b<=a){
            if(a!=b) ans+=2;
            else ans++;
            b++;
            
        }
        a++;
        b=1;
    }
    cout << ans;
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count=0,s;

  cin >> s;
  
  
  if(s/100){
    count++;
    s-=100;
  }

  if(s/10){
    count++;
    s-=10;
  }

  if(s) {
  count++;
  }

  cout << count << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, L, R;
  cin >> a >> b >> c >> d;
  
  L = a + b;
  R = c + d;
  
  if (L < R){
    cout << "Right" << endl;
  }
  else if (R < L){
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define M 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"


int main() {
jaldi_chal
ll n,k;
cin>>n>>k;
ll a[n+1];
REW(i,1,n) 
{
    cin>>a[i];
}
ll dp[n+1];

dp[1]=0;

REW(i,2,n)
{
    ll val=INT_MAX;;
    
   
    for(ll m=i-1;m>=1&&m>=i-k;m--)
    {
        val=min(val,dp[m]+abs(a[i]-a[m]));
    }
    dp[i]=val;
    
    
}

cout<<dp[n];




	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e18;
int main()
{
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    ll dp[n];
    for(int i=1;i<n;i++) dp[i]=N;
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i-1>=0)dp[i]=min(dp[i],abs(arr[i-1]-arr[i])+dp[i-1]);
        if(i-2>=0)dp[i]=min(dp[i],abs(arr[i-2]-arr[i])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;

    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

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

void test(){freopen("test.txt", "r", stdin);}

int main(){
	int n;
	while(cin >> n, n){
		int in[30] = {};
		int out[30] = {};
		map<int, int> m;

		int all = 0;
		rep(i, n){
			string s;
			cin >> s;
			int f = s[0]-'a', l = s[s.size()-1]-'a';
			in[f]++;
			out[l]++;
			m[f] |= 1<<l;
			all |= 1<<l;
		}

		// 適当な開始点から行ける文字をすべて探す
		// 入力の全ての端の文字に行けて、in==outだったらOK
		int vis;
		for(int i = 0; i < 26; i++){
			if(in[i] != 0){
				vis = 1<<i;
				break;
			}
		}

		rep(j, 26){
			rep(i, 26){
				if( vis & 1<<i )vis |= m[i];
			}
		}

		//rep(i, 26){
		//	if(vis&1<<i) cout << char('a'+i);
		//}

		bool ok = true;
		for(int i = 0; i < 26; i++){
			if(in[i] != out[i]){
				ok = false;
				break;
			}
		}
		ok &= (vis==all);
		cout << (ok?"OK":"NG") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])
H.reverse()

for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] = H[i+1]-1
    if H[i] < H[i+1]:
        print('No')
        sys.exit() 
print('Yes')


Measured memory_bytes: 11152
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <bits/stdc++.h>
#define PI 3.141592653589793238462643383279
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int N;
    cin >> N;

    int Taka[N];
    int Aoki[N];
    int Ans[N];
    
    fill(Ans,Ans+N,0);

    REP(i,N){
        cin >> Taka[i];
    }
    REP(i,N){
        cin >> Aoki[i];
    }

    if(Taka[N-1] != Aoki[0]){
        cout << 0 << endl;
        return 0;
    }

    REP(i,N-1){
        if(Taka[i] < Taka[i+1]){
            Ans[i+1] = 1;
            if(Taka[i+1] > Aoki[i+1]){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    
    for(int i = N-1;i > 1;i--){
        if(Aoki[i] < Aoki[i-1]){
            Ans[i-1] = 1;
            if(Taka[i-1] < Aoki[i-1]){
                cout << 0 << endl;
                return 0;
            }
        }
        
    }
    Ans[0] = 1;
    Ans[N-1] = 1;

    REP(i,N){
        if(Ans[i] == 0){
            if(Taka[i] <= Aoki[i]){
                Ans[i] = Taka[i];
            }else{
                Ans[i]= Aoki[i];
            }
        }
    }
    long ans = 1;
    REP(i,N){
        ans *= Ans[i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int n=5;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		if (!a) {
			cout << i; return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
char buf[250000];sz;
char out[50505];outsz;
char tmp[10];tmpsz;
int d[5000];
main()
{
	read(0,buf,250000);
	int k=0,q=0;
	for(;;)
	{
		char c=buf[sz++];
		if(c<'0')break;
		k=k*10+c-'0';
	}
	for(;;)
	{
		char c=buf[sz++];
		if(c<'0')break;
		q=q*10+c-'0';
	}
	for(int i=0;i<k;i++)
	{
		int D=0;
		for(;;)
		{
			char c=buf[sz++];
			if(c<'0')break;
			D=D*10+c-'0';
		}
		d[i]=D;
	}
	for(;q--;)
	{
		int N=0,X=0,M=0;
		for(;;)
		{
			char c=buf[sz++];
			if(c<'0')break;
			N=N*10+c-'0';
		}
		for(;;)
		{
			char c=buf[sz++];
			if(c<'0')break;
			X=X*10+c-'0';
		}
		for(;;)
		{
			char c=buf[sz++];
			if(c<'0')break;
			M=M*10+c-'0';
		}
		long B=X;
		for(int i=0;i<k;i++)
		{
			long y=d[i]%M;
			y+=!y*M;
			B+=(N-i-2+k)/k*y;
		}
		long ans=N-1-B/M+X/M;
		tmpsz=10;
		do{
			tmp[--tmpsz]=ans%10+'0';
		}while(ans/=10);
		for(;tmpsz<10;)out[outsz++]=tmp[tmpsz++];
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
static const int N = 1000;
void lcs(string x, string y)
{
    int m = x.length(), n = y.length();
    int c[1001][1001]; //c[0][0] = 0;
    int maxv = 0;
    x = ' ' + x;
    y = ' ' + y;
    for(int i=0; i<=m; i++) c[i][0] = 0;
    for(int j=0; j<=n; j++) c[0][j] = 0;
    for(int i=1; i<=m; i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(x[i] == y[j])    c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i-1][j], c[i][j-1]);
            maxv = max(maxv, c[i][j]);
        }
    }
    printf("%d\n", maxv);
}
int main()
{
    int q; string x, y;
    cin >> q;
    for(int i=0; i<q; i++)
    {
        cin >> x >> y;
        lcs(x, y);
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 7152
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[200010];
vector<int> v;
int b[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[200010];
    rep(i, N) cin >> a[i + 1];
    RREP(i, N, 1) {
        int sum = 0;
        for(int j = i; j <= N; j += i) {
            sum += b[j];
        }
        //cout << i << " " << sum << endl;
        if(sum % 2 != a[i]) {
            v.push_back(i);
            b[i]++;
        }
    }
    // rep(i, N) cout << b[i + 1] << " ";
    // cout << endl;
    cout << v.size() << endl;
    rep(i, v.size()) {
        if (i != 0) cout << " ";
        cout << v[i];
    }
    if(v.size())
    cout << endl;

    return 0;
}


Measured memory_bytes: 2936
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int a, b, c, d;


signed main(){
    cin >> a >> b >> c >> d;
    cout << a + b + c + d << endl;    


    return 0;
}

/*

*/


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

const int MAXN = 100;
const ll inf = (ll)1e18;
int n, a[MAXN + 5];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i];
}
ll kolko = inf;
for(int i = 1 ; i <= MAXN ; ++i){
	ll sad = 0;
	for(int j = 1 ; j <= n ; ++j){
		sad += (a[j] - i) * (a[j] - i);
	}
	kolko = min(kolko, sad);
}
cout << kolko << endl;

return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int a=1,n,k;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		if(a * 2 < a + k)
			a *= 2;
		else
			a += k;
	}
	
	cout << a << endl;
	
	return 0;
}


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

int isPrime(int x)
{
	int i;
	if(x<2)return 0;
	else if(x==2)return 1;
	if(x%2==0)return 0;
	for(int i=3;i*i<=x;i+=2)
	{
		if(x%i==0)return 0;
	}
	return 1;
}

int main()
{
	int n;
	cin>>n;
	for(int i=n; ;i++)
	{
		if(isPrime(i))
		{
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  ll ans=0;
  
  FOR(i,0,n+1){
    FOR(j,0,n+1){
		if(0<=m-i-j&&m-i-j<=n) ans++;          
    }
  }
  co(ans)
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, int> memo;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(!memo.count(s)){
            memo[s] = 1;
        }
    }

    cout << memo.size() << endl;

    return 0;
}

Measured memory_bytes: 19252
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	c := scanInt()
	s := scanString()

	if c == 0 {
		cnt := 0
		for i := 0; i < n; i++ {
			if s[i] == 'o' {
				cnt++
			}
		}

		if cnt!=k {
			fmt.Fprintln(wr)
		} else {
			for i := 0; i < n; i++ {
				if s[i] == 'o' {
					fmt.Fprintln(wr, i+1)
				}
			}
		}
		return
	}

	f := make([]bool, n)
	for i := 0; i < n; i++ {
		if s[i] == 'o' {
			for j := 0; j < c; j++ {
				i++
				if i >= n {
					break
				}
				f[i] = true
			}
		} else {
			f[i] = true
		}
	}

	for i := 0; i < n; i++ {
		if s[n-1-i] == 'o' {
			for j := 0; j < c; j++ {
				i++
				if i >= n {
					break
				}
				f[n-1-i] = true
			}
		} else {
			f[n-1-i] = true
		}
	}
	
	for i := 0; i < n; i++ {
		if !f[i] {
			fmt.Fprintln(wr, i+1)
		}
	}
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
const int MAX_T = 3000, MAX_M=300;
int M, start, goal,dice[6], *N;
 
bool isPositionValid(int p){return 0<=p && p<M;}
 
int* MakePath(int *path, int from){
    static bool visit[MAX_M] = {};
    static auto checkPath = [&path](int moveto)->int{
        if(!isPositionValid(moveto))	return 2*MAX_T;
        else{
            int position = moveto+ N[moveto];
            if(!visit[position]) MakePath(path, position);
            return  path[position]+1;
        }
    };
 
    if(path==NULL){
        path = new int[M];
        for(int m=0; m<M; m++) path[m] = MAX_T+1;
    }
 
    visit[from] = true;
    int bestpath = MAX_T;
    if(from==goal)  bestpath = 0;
    else{
        for(int r=0; r<6; r++){
            bestpath = min(bestpath, checkPath(from + dice[r]));
            bestpath = min(bestpath, checkPath(from - dice[r]));
        }
    }
    path[from] = bestpath;
    return path;
}
 
int main(){
    // 入力
    cin >> M;
    for(int r=0; r<6; r++)   cin >> dice[r];
    cin >> start >> goal;
	start--, goal--;
	N = new int[M];
    for(int m=0; m<M; m++)   cin >> N[m];
    
    int* path = MakePath(NULL, start);
     
    //本番
    int position = start;
    for(int t=0; t<MAX_T; t++){
        if(position == goal) break;
     
        int r;
        cin >> r;
        int d = dice[r-1];
 
        static auto tryMove = [&path](int moveto, int path_before, int& position)->bool{
			if(isPositionValid(moveto)){
                if(path_before > path[moveto + N[moveto]]){
					position = moveto + N[moveto];
					return true;
				}
			}
            return false;
        };
     
		int output;
        if     (tryMove(position + d, path[position], position)) output = 1;
		else if(tryMove(position - d, path[position], position)) output = -1;
		else output = 0;
		cout << output << endl;
    }
 
    delete[] N;
    delete[] path;
    return 0;
}

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

using namespace std;

using ll = long long;

ll solve(const int capacity, const vector<pair<int, ll>> &items) {
    const int sz = items.size();
    
    // dp[up to item index][capacity]
    vector<vector<ll>> dp(sz, vector<ll>(capacity + 1, 0));
    
    for (int i = 0; i != sz; ++i) {
        for (int c = 1; c <= capacity; ++c) {
            const auto w = items[i].first;
            const auto v = items[i].second;
            
            if (!i) {
                dp[i][c] = w <= c ? v    : 0;
                continue;
            }
            
            if (w > c) {
                dp[i][c] = dp[i - 1][c];
            } else {
                dp[i][c] = max(dp[i - 1][c], dp[i - 1][c - w] + v);
            }
        }
    }
    
    return dp[sz - 1][capacity];
}

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    
    int N, W;
    cin >> N >> W;
    vector<pair<int, ll>> items(N);
    
    for (auto &item : items) {
        int w;
        ll v;
        cin >> w >> v;
        item = {w, v};
    }
    
    cout << solve(W, items) << endl;
    
    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std; 
long long n,m,k;
long long dp[3010][3010][4];
long long a[3010][3010];
int main(){
	cin>>n>>m>>k;
	while(k--){
		long long u,v,w;
		cin>>u>>v>>w;
		a[u][v]=w;
	}
	dp[1][1][1]=a[1][1];
	for(long long i=1;i<=n;i++){
		for(long long j=1;j<=m;j++){
			for(long long k=0;k<=2;k++){
				dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
				dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+a[i+1][j]);
				dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
				dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+a[i][j+1]);
			}
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][3]);
			dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][3]+a[i+1][j]);
			dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][3]);
		}
	}
	cout<<max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])));
	return 0;
}

Measured memory_bytes: 356320
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n; cin >> n;
    while(true){
        if(n == 1){
            cout << n << endl;
            return 0;
        }
        for(int i = 1; i < n; i++){
            for(int j = 0; j < 7; j++){
                if(pow(i, j) == n){
                    cout << n << endl;
                    return 0;
                }
            }
        }
        n--;
    }
}

Measured memory_bytes: 256