akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;
vi P;

bool check(const vi& p) {
  for (int i=0; i<N; i++) {
    if (p[i] != i+1) {
      return false;
    }
  }
  return true;
}

int main(int argc, char** argv) {
  cin >> N;
  P.resize(N);
  for (int i=0; i<N; i++) {
    cin >> P[i];
  }

  if (check(P)) {
    cout << "YES" << endl;
    return 0;
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      int pi = P[i];
      int pj = P[j];
      P[j] = pi;
      P[i] = pj;
      if (check(P)) {
        cout << "YES" << endl;
        return 0;
      }
      P[i] = pi;
      P[j] = pj;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  double e=a[n-1];
  double q=e/2; double m=2000000000; int b;
  for(int i=0;i<n;i++){
    if(m>abs(a[i]-q)){m=abs(a[i]-q); b=i;}
  }
  cout << a[n-1] << " " << a[b] << endl;
}

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

using namespace std;

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

  vector<int> dp(N, 0);
  for (int i = 1; i < N; i++) dp[i] = 1<<30;

  for (int i = 0; i < N; i++) {
    if (i+1 < N) dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]), dp[i+1]);
    if (i+2 < N) dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+2]);
  }
  cout << dp[N-1] << endl;
}


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

using namespace std;

const int inf = (int) 1e9;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int t;
  cin >> s >> t;
  int n = (int) s.size();
  vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(t + 2, 0)));
  for (int len = 1; len <= n; len++) {
    for (int i = 0; i + len <= n; i++) {
      for (int k = 0; k <= t; k++) {
        int j = i + len - 1;
        dp[i][j][k] = max(dp[i][j][k], max(dp[i + 1][j][k], j - 1 < 0 ? 0 : dp[i][j - 1][k]));
        if (s[i] == s[j]) {
          dp[i][j][k] = max(dp[i][j][k], 1 + (i < j) + (j - 1 < 0 ? 0 : dp[i + 1][j - 1][k]));
          dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k]);
        } else {
          dp[i][j][k + 1] = max(dp[i][j][k + 1], 2 + (j - 1 < 0 ? 0 : dp[i + 1][j - 1][k]));
        }
      }
    }
  }
  cout << dp[0][n - 1][t] << '\n'; 
  return 0;
}

Measured memory_bytes: 110336
#include <stdio.h>

int main(void){
    int i,a;
    a = 0;
    char s[4];
        scanf("%s",s);
        for(i = 0;i < 4;i++){
            if(s[i] == '+'){
                a++;
            }else{
                a--;
            }
        }

    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split())) 
flag =False
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      flag=True
      break
if flag==True:
  print('DENIED')
else:
  print('APPROVED')
    
      

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int l = 1, r = n;
  for (int i=0; i<m; ++i) {
    int dif = r - l;
    if (dif % 2 == 1 && n - dif >= dif) --r;
    cout << l << ' ' << r << endl;
    ++l, --r;
  }
  return 0;
}


Measured memory_bytes: 3596
// Try AtCoder
// authoer: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let m = get!();
    
    let mut a = vec![];
    for _ in 0..n {
        a.push(get!());
    }
    
    let mut bc = vec![];
    for _ in 0..m {
        let b = get!();
        let c = get!();
        bc.push((c, b));
    }
    
    a.sort();
    a.reverse();
    bc.sort();
    bc.reverse();
    
    let mut ai = 0;
    let mut bi = 0;
    let mut ans = 0;
    
    for _ in 0..n {
        if bi >= bc.len() || a[ai] > bc[bi].0{
            ans += a[ai];
            ai += 1;
        } else {
            ans += bc[bi].0;
            bc[bi].1 -= 1;
            if bc[bi].1 == 0 {
                bi += 1;
            }
        }
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 12540
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################


int main(){
  boost;
  int n;
  cin>>n;
  cout<<(1000-(n%1000))%1000;
}



Measured memory_bytes: 3640
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ls := make([]int, n)
	for i := range ls {
		sc.Scan()
		ls[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(ls)
	var cnt int
	for i := 0; i < n-2; i++ {
		a := ls[i]
		for j := i + 1; j < n-1; j++ {
			b := ls[j]
			ns := make([]int, 0)
			ns = append(ns, 0)
			ns = append(ns, ls[j+1:]...)
			ns = append(ns, 2e3+1)
			l := 0
			r := len(ns) - 1
			for r-l > 1 {
				x := (l + r) / 2
				if ns[x] < a+b {
					l = x
				} else {
					r = x
				}
			}
			cnt += l
		}
	}
	fmt.Println(cnt)
}

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
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main(){
  int n, y;
  cin >> n >> y;
  int ans_i = -1, ans_j = -1, ans_k = -1;
  for(int i = 0; i <= n; i++){
    for(int j = 0; i + j <= n; j++){
      if(i*10000 + j*5000 + (n - i - j)*1000 == y){
        ans_i = i;
        ans_j = j;
        ans_k = n-i-j;
        cout << ans_i <<" "<< ans_j <<" "<< ans_k << endl;
        return 0;
      }
    }
  }
  cout << ans_i <<" "<< ans_j <<" "<< ans_k << endl;
}


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

using namespace std;

const char WALL = '#';
const char ROAD = '.';

bool fill_step(const vector < vector<char>>& maze, vector<vector<int>>& work_map, const int step) {
	const int next_step = step + 1;
	const size_t h_limit = maze.size() - 1;
	const size_t w_limit = maze[0].size() - 1;
	bool anyFilled = false;
	for (size_t h = 0; h < maze.size(); h++) {
		for (size_t w = 0; w < maze[h].size(); w++) {
			if (work_map[h][w] != step) {
				continue;
			}

			if (h > 0 && maze[h - 1][w] == ROAD && work_map[h - 1][w] < 0) {
				work_map[h - 1][w] = next_step;
				anyFilled = true;
			}
			 if (h < h_limit &&  maze[h + 1][w] == ROAD && work_map[h + 1][w] < 0) {
				work_map[h + 1][w] = next_step;
				anyFilled = true;
			}
			if (w > 0 && maze[h][w-1] == ROAD && work_map[h][w - 1] < 0) {
				work_map[h][w - 1] = next_step;
				anyFilled = true;
			}
			 if (w < w_limit && maze[h][w+1] == ROAD && work_map[h][w + 1] < 0) {
				work_map[h][w + 1] = next_step;
				anyFilled = true;
			}
		}
	}

	return anyFilled;
}

int find_max(const vector<vector<char>>& maze, int init_y, int init_x) {
	vector<vector<int>> work_map;
	for (size_t h = 0; h < maze.size(); h++) {
		work_map.push_back(vector<int>(maze[h].size(), -1));
	}

	work_map[init_y][init_x] = 0;
	int step = 0;
	while (fill_step(maze, work_map, step)) {
		step++;
	}

	return step;
}

int main() {
	int height, width;
	cin >> height >> width;
	
	vector<vector<char>> maze;
	for (int h = 0; h < height; h++) {
		maze.push_back(vector<char>());
		for (int w = 0; w < width; w++) {
			char c;
			cin >> c;
			maze[h].push_back(c);
		}
	}

	int max_move = -1;
	for (int init_y = 0; init_y < height; init_y++) {
		for (int init_x = 0; init_x < width; init_x++) {
			if (maze[init_y][init_x] == ROAD) {
				max_move = max(find_max(maze, init_y, init_x), max_move);
			}
		}
	}

	cout << max_move << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
ll cal(ll x){
	return x*x*x*x*x;
}
ll x;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>x;
	for(ll i=-128;i<=128;i++){
		for(ll j=-128;j<=128;j++){
			if(cal(i)-cal(j)==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
int a[maxn];

int main(){
	memset(a,0,sizeof(a));
	string s;
	cin >> s;
	int len = s.size();
	for(int i = 1;i <= len;i++) a[i] = s[len-i] - '0';
	ll ans = 0;
	for(int i = 1;a[i]||i <= len;i++){
		a[i+1] += a[i] / 10;
		a[i] %= 10;
		if(a[i] < 5) ans += a[i];
		else if(a[i] > 5){
			ans += 10 - a[i];
			a[i+1]++;
		}else{
			if(a[i+1]>=5) {ans += 5;a[i+1]++;}
			else ans += 5;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5252
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3e3+5;
const int mod = 998244353;

int n;
int sm;
int ar[N];
int mem[N][N];

int go(int idx , int sum){
    if(sum == sm){
        return n - idx + 2;
    }
    if(sum > sm || idx > n){
        return 0;
    }
    if(~mem[idx][sum]){
        return mem[idx][sum];
    }
    int a = go(idx + 1 , sum + ar[idx]);
    int b = go(idx + 1 , sum);
    return mem[idx][sum] = (a + b) % mod;
}

int main(){
    cin >> n >> sm;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    memset(mem , -1 , sizeof mem);
    int ways = 0;
    for(int i = 1; i <= n; i++){
        ways += go(i , 0);
        ways %= mod;
    }
    cout << ways << "\n";
}


Measured memory_bytes: 35712
def solve():
  N, K = [int(x) for x in input().split()]
  A = [int(x) for x in input().split()]
  s, l = 0, 10**9
  # s: largest proven impossible
  # l: smallest proven possible
  while s + 1 < l:
    x = (s + l) // 2
    #print(x, s, l)
    c = 0
    for a in A:
      c += -(-a//x) - 1
    #print(c)
    if c <= K:  # x was possible
      l = x
    else:
      s = x
  return l
print(solve())


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define mod 998244353LL

#define maxn 1000005
#define log 20

int main()
{
    int h1 , m1 , h2 , m2 , k ;

    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k) ;

    printf("%d\n" , h2*60 + m2 - h1*60 - m1 - k ) ;

    return 0 ;
}


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
//#include "../cxx-prettyprint/prettyprint.hpp"

std::vector<int> values;
std::vector<int> weights;
std::map<std::pair<int, int>, int> memo;

int get_maximum_value(int i, int w) {
    if (i < 0 || w == 0) {
        return 0;
    } else if (memo.find({i, w}) != memo.end()) {
        return memo[{i, w}];
    } else {
        int max_value;
        if (weights[i] <= w) {
            max_value = std::max(get_maximum_value(i - 1, w - weights[i]) + values[i],
                                 get_maximum_value(i - 1, w));
        } else {
            max_value = get_maximum_value(i - 1, w);
        }
        memo[{i, w}] = max_value;
        return max_value;
    }
}

int main() {
    int N, W;
    std::cin >> N >> W;

    values.resize(N);
    weights.resize(N);
    for (int i = 0; i < N; i ++) {
        std::cin >> values[i] >> weights[i];
    }

    std::cout << get_maximum_value(N - 1, W) << std::endl;
}



Measured memory_bytes: 54520
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<" = "<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

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

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 100017;

string s;

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

	int ans = 0;
	cin >> s;
	ans = s.size()/2;
	FOR (i,0,s.size())
	if (s[i] == 'p') ans--;
	cout << ans;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define MAX_N 1001
using namespace std;
//lcs
int n,m;
string s,t;
int dp[MAX_N+1][MAX_N+1];
void solve(){
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  cout<<dp[n][m]<<endl;
}


int main(){
  int N;
  cin>>N;
  while(N--){
    cin>>s>>t;
    n=s.size();
    m=t.size();
    solve();
  }
  return 0;
}
//greatest common divisor
/*int main() {
  int a,b;
  cin >> a >>b;
  cout << __gcd(a,b)<<endl;
  return 0;
  }*/
//lcm
//__builtin_popcount()

//flymake
/*(require 'flymake)
 
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
 
(push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks)
 
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
(custom-set-variables
 '(ansi-color-names-vector ["#2d3743" "#ff4242" "#74af68" "#dbdb95" "#34cae2" "#008b8b" "#00ede1" "#e1e1e0"])
 '(custom-enabled-themes (quote (tsdh-light))))

*/

Measured memory_bytes: 5124
#include "bits/stdc++.h"

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


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

    const int N = 1e6 + 5;
    ll k, x = 7, c = 1; cin >> k;
    bool vis[N] = {};
    while(x % k != 0){
        if(vis[x]) break;
        vis[x] = 1;
        x = (x*10 + 7) % k;
        c++;
    }
    if(x % k) c = -1;
    cout << c;
    return 0;
}


Measured memory_bytes: 4620
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e5 + 10;

priority_queue<int > q;

int n,m;

int main()
{   
	read(n); read(m);
	for(int i=1,x;i<=n;i++){
		read(x);
		q.push(x);
	}
	while(m--){
		int tmp = q.top(); q.pop();
		q.push(tmp/2);
	}
	ll res = 0;
	while(q.size()){
		res += q.top(); q.pop();
	}
	cout<<res<<endl;
	return 0;
}

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

int D;

int c[27];
int s[366][27];
int last[27];

const ll INF = 1e9;

vector<int> ans;
ll ans_score;

ll calcScore(){
    rep(i,27) last[i] = 0;
    ll score = 0;
    for(int d = 1; d <= D; ++d){
        int t = ans[d];
        score += s[d][t];
        last[t] = d;
        for(int i = 1; i <= 26; ++i){
            score -= c[i] * (d - last[i]);
        }
    }
    return score;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> D;
    for(int i = 1; i <= 26; ++i) cin >> c[i];
    for(int i = 1; i <= D; ++i){
        for(int j = 1; j <= 26; ++j){
            cin >> s[i][j];
        }
    }
    ans.resize(D, 1);
    ans_score = calcScore();
    //local search
    std::random_device rnd;
    std:: mt19937 mt(rnd());
    std::uniform_int_distribution<> randD(1,D);
    std::uniform_int_distribution<> randA(1,26);
    rep(_,100000){
        int d = randD(mt);
        int q = randA(mt);
        int old = ans[d];
        ans[d] = q;
        ll score = calcScore();
        if(ans_score > score) ans[d] = old;
        else ans_score = score;
    }
    rep(i,D) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
using Int = long long int;
#define rep(n,k) for(int i = (int)n;i<k;i++)
int main(){
   int N;cin>>N;
   int count=0;
   for(int i=1;i<=N;i++){
      int a=i;
      int b;
      if(N%a!=0){
         b=(int)(N/a)+1;
      }
      else b=(int)(N/a);

      count+=b-1;
   }
  cout<<count<<endl;
}

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

int n;
//int Map[401][401];
int xx[4]={-1,0,1,0};
int yy[4]={0,-1,0,1};

typedef struct{
  int x;
  int y;
}data;

int main(){
  while(cin>>n , n){
    //  memset(Map,0,sizeof(Map));
    //    int x=200;
    //    int y=200;
    int xmax,xmin;
    int ymax,ymin;
    xmax=xmin=200;
    ymax=ymin=200;
    vector<data> vec(n);
    data d;
    d.x=d.y=200;
    vec[0]=d;
    //  Map[y][x]=1;
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      d=vec[a];
      d.x+=xx[b];
      d.y+=yy[b];
      vec[i]=d;
      //Map[d.y][d.x]=1;
      if(xmax < d.x) xmax = d.x;
      if(xmin > d.x) xmin = d.x;
      if(ymax < d.y) ymax = d.y;
      if(ymin > d.y) ymin = d.y;
    }
    cout<<xmax - xmin + 1 << " " <<ymax - ymin + 1<<endl;

  }
  return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cctype>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long

int A[200010];

int main()
{
	#ifdef LOCAL
		freopen("E:\\tmp\\input.txt", "r", stdin);
		freopen("E:\\tmp\\output.txt", "w", stdout);
	#endif

	int n, i, minv, maxv;
	scanf("%d", &n);
	for(i=0; i<n; ++i) scanf("%d", &A[i]);
	maxv = -1e9-1, minv = A[0];
	for(i=1; i<n; ++i) {
		maxv = max(maxv, A[i]-minv);
		minv = min(minv, A[i]);
	}
	printf("%d\n", maxv);

	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

struct SegmentTree {
private:
    int n;
    vector<ll> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<ll> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
  void update(int x, ll val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = min(node[2*x+1], node[2*x+2]);
    }
  }
  ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す
    if(r <= a || b <= l) return INF;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
};

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

  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];

  SegmentTree segTree(a);

  ll ans = INF;
  for(int k = 0; k < N; k++){
    // k: シフト回数
    ll tmp_ans = 0;
    for(int i = 0; i < N; i++){
      //自分からシフトk回の範囲
      ll min_val = INF;

      ll tmp = segTree.getmin(max(i-k, 0), i+1);
      chmin(min_val, tmp);
      if(i < k){
        tmp = segTree.getmin(N-(k-i), N);
        chmin(min_val, tmp);
      }
      tmp_ans += min_val;
    }
    tmp_ans += k * x;
    chmin(ans, tmp_ans);
  }

  // cout << " " << endl;
  // cout << segTree.getmin(0, 1) << endl;
  // cout << segTree.getmin(0, 2) << endl;
  // cout << segTree.getmin(1, 2) << endl;

  cout << ans << endl;






  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<int,int>val;
    int ans = 0;
    int k;
    for(int i = 0;i<n;i++){
        cin >> k;
        if(val[k] == 0){
            ans++;
            val[k]++;
        }
        else{
            ans--;
            val[k]--;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


string color[]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
int red[]={0,0,0,0,255,255,255,255};
int green[]={0,0,255,255,0,0,255,255};
int blue[]={0,255,0,255,0,255,0,255};

string s;
int r,g,b;

int trance(char c){
    if('0'<=c&&c<='9')return c-'0';
    else return c-'a'+10;
}

int main(){
    while(cin>>s&&s!="0"){
        r=trance(s[1])*16+trance(s[2]);
        g=trance(s[3])*16+trance(s[4]);
        b=trance(s[5])*16+trance(s[6]);
        string ret;
        double num=INF<double>();
        REP(i,8){
            double num2=sqrt((r-red[i])*(r-red[i])+(g-green[i])*(g-green[i])+(b-blue[i])*(b-blue[i]));
            if(num>=num2){
                num=num2;
                ret=color[i];
            }
        }
        cout<<ret<<endl;
    }
}


Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  rep(i,n) scanf("%d",&a[i]);
  
  rep(i,n-1){
    result += min(m,a[i+1]-a[i]);
  }
  result+=m;
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 110000;
int cnt[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        cnt[x]++;
    }
    int ans = max(cnt[0], cnt[0] + cnt[1]);
    for (int i = 1; i <= 100001; i++){
        ans = max(ans, cnt[i] + cnt[i - 1] + cnt[i + 1]);
    }
    cout << ans;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        mut d: [i64; n],
    }
    d.sort();
    println!("{}", d[n / 2] - d[n / 2 - 1]);
}


Measured memory_bytes: 3772
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int a,b;
     cin>>a>>b;
     for(int i=1;i<=maxx;i++){
        int aa=(i*0.08),bb=(i*0.1);
        if(aa==a && bb==b) {
            cout<<i<<endl;
            return 0;
        }
     }
     cout<<-1<<endl;

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
ans = [0, 0]
j = 0
now = -1
count = 1
for i in range(N):
  if A[i] == now:
    count += 1
    if count == 2:
      ans[j] = now
      if j == 1:
        print(ans[0] * ans[1])
        quit()
      j += 1
    if count == 4:
      print(now * now)
      quit()
      
  else:
    now = A[i]
    count = 1

print(0)

Measured memory_bytes: 20064
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));

$divmax = $vArray[0];
foreach($vArray as $i => $v){
    $dArray = divisor($v, $divmax);
    foreach($dArray as $d){
        @$map[$d]++;
    }
    $tmpmax = 0;
    foreach($map as $k => $c){
        if($c > $i - 1){
            $tmpmax = max($tmpmax, $k);
        }
    }
    $divmax = $tmpmax;
}
$max = 1;
foreach($map as $value => $count){
    if($count >= $n - 1){
        $max = max($max, $value);
    }
}
echo $max;

function divisor($n, $divmax){
    if(!isset($GLOBALS["cache"][$n])){
        for($i = min(ceil(sqrt($n)), 10**10); $i >= 1; $i--){
            if($n % $i == 0){
                $f[] = $i;
                $f[] = $n / $i;
            }
        }
        sort($f);
        $GLOBALS["cache"][$n] = array_unique($f);
    }
    return $GLOBALS["cache"][$n];
}

Measured memory_bytes: 14840
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int m, nmin, nmax;

int main() {
    while(cin >> m >> nmin >> nmax, m&&nmin&&nmax){
        vector<int> v;
        int maxV=0;
        for(int i=0; i<m; ++i){
            int a; cin >> a; v.push_back(a);
        }
        int index=0;
        for(int i=nmin; i<=nmax; ++i){
            int temp = v[i-1]-v[i];
            if(maxV <= temp){
                index = i; maxV = temp;
            }
        }
        cout << index << endl;
    }
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(b%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  if(a*2 <= b && a*4 >= b){
    cout << "Yes" << endl;
    return 0;
  } 
  cout << "No" << endl;
  return 0;
}

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

ll gcd(long long x, long long y){
    return y ? gcd(y, x % y) : x;
}

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


int main(){
    int n;
    cin >> n;
    ll t[n],x = 1;
    for(int i = 0; i < n; i++){
        cin >> t[i];
        x = lcm(x,t[i]);
    }
    
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    N, W = map(int, input().split())
    w, v = [0 for _ in range(N)], [0 for _ in range(N)]
    for i in range(N):
        w[i], v[i] = map(int, input().split())
    ans = solve(N, W, w, v)
    print(ans)


def solve(N, W, w, v):
    dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
    for i in range(1, N + 1):
        for j in range(W + 1):
            if 0 <=  j - w[i - 1]:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1])
            else:
                dp[i][j] = dp[i - 1][j]
    #print(dp)
    return dp[N][W]


if __name__ == '__main__':
    main()

Measured memory_bytes: 171656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A > 12) {
			System.out.println(B);
		} else if(A > 5) {
			System.out.println(B / 2);
		} else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 21204
import java.util.Scanner;

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

	String s;

	public void run() {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		int ans = 0;
		if(s.charAt(0)=='1') ans++;
		if(s.charAt(1)=='1') ans++;
		if(s.charAt(2)=='1') ans++;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[110][4][4][4];  // dp[i+1][c1][c2][c3] : i文字目までで末尾3文字がc1c2c3のときの条件を満たす文字列の数
 
int main() {
    ll n;
    cin >> n;

    // A = 0, G = 1, C = 2, T = 3
    // XAGC, XGAC, XACG, AXGC, AGXC
    // X012, X102, X021, 0X12, 01X2   

    dp[0][3][3][3] = 1;
    rep(i, n) {
        rep(c1, 4) {
            rep(c2, 4) {
                rep(c3, 4) {
                    rep(x, 4) {
                        if(c2 == 0 && c3 == 1 && x == 2) {
                            continue;
                        }
                        if(c2 == 1 && c3 == 0 && x == 2) {
                            continue;
                        }
                        if(c2 == 0 && c3 == 2 && x == 1) {
                            continue;
                        }
                        if(c1 == 0 && c3 == 1 && x == 2) {
                            continue;
                        }
                        if(c1 == 0 && c2 == 1 && x == 2) {
                            continue;
                        }
                        dp[i+1][c2][c3][x] += dp[i][c1][c2][c3];
                        dp[i+1][c2][c3][x] %= mod;
                    }
                }
            }
        }
    }
    
    ll ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    
    out(ans);
    re0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

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

	FOR(i, a, b + 1) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;


}


Measured memory_bytes: 3636
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    ll L, R;
    ll max_L = -1;
    ll min_R = 10000000;
    REP(i, M) {
        cin >> L >> R;
        if (L > max_L) max_L = L;
        if (R < min_R) min_R = R;
    }
    cout << max(0LL, (min_R - max_L + 1)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define YN(c) (c)?(print("YES")):(print("NO"))
#define Yn(c) (c)?(print("Yes")):(print("No"))
#define yn(c) (c)?(print("yes")):(print("no"))
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  in(s);in(w);
  if(s>w){
    print("safe");
  }else{
    print("unsafe");
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    int a, b, t;
    cin >> a >> b >> t;
    int taimu = 0;
    int ans = 0;
    while(t > taimu) {
        taimu += a;
        ans += b;
    }
    if(taimu != t) ans -= b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, q, cnt[N];
vector <int> g[N];

void dfs (int v = 1, int pr = 0) {
   cnt[v] += cnt[pr];
   for (auto to : g[v])
      if (to != pr)
         dfs (to, v);   
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> q;
   for (int i = 1; i < n; i ++) {
      int x, y;
      cin >> x >> y;
      g[x].pb (y);
      g[y].pb (x);
   }
   while (q --) {
      int val, v;
      cin >> v >> val;
      cnt[v] += val;
   }
   dfs ();
   for (int i = 1; i <= n; i ++) cout << cnt[i] << ' ';

}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 20096
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(3);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const ll MOD =(ll)1e9+7;
const ll INF = (ll)1e18+5;
const int nn=1e5+5;
int main()
{
    _SAD()
    int n;
    cin>>n;
    if(n)cout<<0<<nl;
    else cout<<1<<nl;
    return 0;
}


Measured memory_bytes: 3656
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = sorted(list(map(int,input().split())))

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[-1] and x>0:
        ans+=i
        p.pop()
        x -= 1
    elif q and i == q[-1] and y>0:
        ans += i
        q.pop()
        y -= 1
    elif i == r[-1] and x+y-c>0:
        ans += i
        r.pop()
        c += 1
print(ans)

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

int main(){
    int n,k;
    cin >> n >> k;
    
    int d[k];
    int a[k][n];
    bool have_o[n+1];
    
    for(int i=0;i<k;i++){
        for(int j=0;j<n;j++){
            a[i][j] = 0;
        }
    }
    for(int i=0;i<=n;i++){
        have_o[i] = false;
    }
    
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> a[i][j];
        }
    }
    
    for(int i=0;i<k;i++){
        for(int j=0;j<d[i];j++){
            have_o[a[i][j]] = true;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(have_o[i] == false) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3648
// abc135_a
// #include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(void){
	int A, B;
	cin >> A >> B;
	for (int i = 0; i < A || i < B; i++) {
		if (abs(A - i) == abs(B - i)) {
			cout << i << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
import math
S = int(input())

res = 0
m = 10 ** 9 + 7
n = 0
for i in range(S//3):
    n += 1
    r = S - 3 * (i+1)
    
    res += (math.factorial(n + r - 1) // (math.factorial(r) * math.factorial(n-1))) % m
print (res % m)

Measured memory_bytes: 9204