akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		if (n % 2 == 0) {
			pr.println(n);
		} else {
			pr.println(n * 2);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21716
K,S=map(int,input().split())
if S<=K:
    print((S+2)*(S+1)//2)
elif S<=2*K:
    m=0
    for i in range(K+1):
        s=S-i
        if s<=K:
            m+=s+1
            
        else:
            c=s-K
            a=s-2*c
            m+=a+1         
    print(m)

else:
    s=3*K-S
    print((s+2)*(s+1)//2)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int c; cin >> c;
    if (30 <= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
#include<cstring>
#include<list>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	//freopen("hussien.in", "r", stdin);
	string x; map<string, string>mp;
	mp["ARC"] = "ABC", mp["ABC"] = "ARC";
	cin >> x;
	cout << mp[x];



	return 0;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() {
    int n;
    while (cin >> n && n) {
        vector<int> v[5];
        rep(i, n) rep(j, 5) {int p; cin >> p; v[j].push_back(p);}
        int flg = 0;
        int sum = 0;
        //cout << endl; rep(i, n) {rep(j, 5) cout << v[j][i] << " "; cout << endl;}
        while (1) {
            flg = 0;
            rep(i, n) { //まず全部の0
                rrep(j, 1, 5) { //start point
                    //cout << i << " " << j << endl;
                    if (v[j][i] == 0) continue;
                    int c = 1;
                    int k = j;
                    vector<int> vv;
                    vv.push_back(k - 1);
                    while (v[k][i] == v[k - 1][i]) {c++; vv.push_back(k); k++; if (k == 5) break;}
                    //cout << c << endl;
                    if (c >= 3) {
                        flg = 1;
                        sum += v[j][i] * c;
                        //cout << v[j][i] << " " << c << endl;
                        rep(l, vv.size()) {
                            v[vv[l]][i] = 0;
                        }
                    }
                }
            }
            if (n == 1) {cout << sum << endl; flg = 0; break;}
            //cout << endl; rep(i, n) {rep(j, 5) cout << v[j][i] << " "; cout << endl;}
            //slide phase
            rep(i, n) {
                rep(j, 5) {
                    if (v[j][i] == 0) {
                        for (int k = i; k >= 1; k--) {
                            v[j][k] = v[j][k - 1];
                        }
                        v[j][0] = 0;
                    }
                }
            }
            //cout << endl; rep(i, n) {rep(j, 5) cout << v[j][i] << " "; cout << endl;}
            if (flg == 0) break;
        }
        if (n != 1) cout << sum << endl;
    }
}



Measured memory_bytes: 3164
<?php

$n = trim(fgets(STDIN));
$s = explode(' ', trim(fgets(STDIN)));

$m = max($s);
for($i=1; $i<$n; $i++){
  $l = array_slice($s,0,$i);
  $r = array_slice($s,$i);
  if (abs(array_sum($l)-array_sum($r)) < $m ){
    $m = abs(array_sum($l)-array_sum($r));
  }  
}
echo $m;

?>

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll dp[2001]; // dp[i][j] := 合計がjの数列の総和

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll s;
    cin >> s;
    dp[0] = 1;
    for(int i=0;i<=2000;i++){
        for(int j=3;i+j<=2000;j++){
            dp[i+j] += dp[i];
            dp[i+j] %= mod;
        }
    }
    cout << dp[s] % mod  << endl;
}

Measured memory_bytes: 3672
/*************************************************************************
    > File Name: c.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月02日 星期四 21时59分33秒
 ************************************************************************/

#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline bool isp(int x){
    for(int i = 2; i*i <= x; i++)
        if(x%i == 0)
            return false;
    return true;
}

int main(){
    int x;
    scanf("%d", &x);
    while(!isp(x))
        x++;
    printf("%d\n", x);
    return 0;
}


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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;

int32_t main()
{
    IOS;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = (a+d-1)/d;
    int y = (b+c-1)/b;
    if(x >= y)
        cout << "Yes\n";
    else
        cout << "No\n";
}



Measured memory_bytes: 3588
#include<stdio.h>
#include<ctype.h>
/*
  void plus(int *, int);
  void minus(int *, int);
  void kake(int *, int);
*/
int main(){
  int i, j, tmp, flug=1, cnt=1;
  char check;
  int a[100]={0};
  int flugD=0;

  while(flug){
    if((check = getchar()) == '\n') flug = 0;
    /*数字か判断、連続なら計算でスペースならcnt++*/

    if(isdigit(check)){ //数字のとき
      if(flugD==1){ //連続してるなら*10して代入
	a[cnt] = a[cnt]*10 + (check - '0');
      } else{ //連続してないなら単に代入
	a[cnt] = check - '0';
	flugD = 1;
      }
    }
    if(isspace(check)){
      flugD = 0;
      cnt++;
    }
    
    switch(check){
    case '+':
      a[cnt-2] = a[cnt-2] + a[cnt-1];
      a[cnt-1] = 0;
      cnt -= 2;
      break;
    case '-':
      a[cnt-2] = a[cnt-2] - a[cnt-1];
      a[cnt-1] = 0;
      cnt -= 2;
      break;
    case '*':
      a[cnt-2] = a[cnt-2] * a[cnt-1];
      a[cnt-1] = 0;
      cnt -= 2;
      break;
    }
    
  }

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



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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){

    int a,b;
    cin >> a >> b;
    int cou=0;
    REAP(i,a,b+1){
        string s=to_string(i);
        string t=s;
        reverse(All(t));
        if(t==s)cou++;
    }
    cout << cou << endl;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
dp = [2**60] * N
dp[0] = 0
for i in range(N):
    if i - 1 >= 0:
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[N-1])


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

int main()
{
	string str;
	cin >> str;
	auto w = 0, n = 0, s = 0, e = 0;
	for (auto i : str) {
		if (i == 'W') w = 1;
		if (i == 'S') s = 1;
		if (i == 'N') n = 1;
		if (i == 'E') e = 1;
	}
	if ((s^n) == 0 && (w^e) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
 
int main()
{
  long long n, a, b, c, d;
  cin >> n >> a >> b;
  c = n/(a+b);
  d = n%(a+b);
  if (d < a){
    cout << (a*c) + d << endl; 
  }else {
  	cout << (a*c) + a << endl;    
  }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        100000
#define mod         998244353  
 
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                sum+=(__gcd(i,__gcd(j,k)));
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3648
#include <iostream>
#include<stdio.h>
using namespace std;
int  huiwen(int num);
int main()
{
    int m,n;
    scanf("%d %d",&m,&n);
    int sum=0;
    for(int i=m;i<=n;i++)
    {
       if(huiwen(i)==1)
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}
int huiwen(int num)
{
    int a=0;;
    int b=num;
    while(num>0)
    {
       a=a*10;
       a=a+num%10;
       num=num/10;
    }
    if(a==b)
        return 1;
    else
        return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;

auto cmp = [](ll x,ll y) {
  return x > y;
};

int main()
{
  int n;
  cin >> n;
  ll b[n + 10], a[n+10];
  ll suma = 0;
  ll sumb = 0;
  for(int i = 0;i < n;i++) {
    cin >> a[i];
    suma += a[i];
  }
  for(int i  =0;i < n;i++) {
    cin >> b[i];
    sumb += b[i];
  }

  vector<ll> aa;
  for(int i = 0;i < n;i++) {
    aa.push_back(a[i] - b[i]);
  }

  sort(aa.begin(),aa.end(),cmp);

  int res =0;
  ll sub = 0;
  for(int i = n-1;i >= 0;i--) {
    if(aa[i] >= 0) break;
    if(aa[i] < 0) {
      res++;
      sub += aa[i];
    }
  }

  for(int i = 0;i < n;i++) {
    if (sub >= 0)
    {
      break;
    }
    if(aa[i] > 0) {
      sub += aa[i];
      res++;
    }
  }

  if(sub >= 0) {
    cout << res << endl;
  } else {
    cout << -1 << endl;
  }

}


Measured memory_bytes: 2936
#include<iostream>
using namespace std;
int main()
{
  int x,n;
  cin>>x>>n;
  int A[n],i;
  int hash[106]={0};
  for(i=0;i<n;++i)
  {
  	cin>>A[i];
  	hash[A[i]]=1;
  }
  int b=x;
  int g=x;
  while(1)
  {
  if(hash[g]==0)
  {
  	cout<<g<<endl;
  	break;
  }
  if(hash[b]==0)
  {
  	cout<<b<<endl;
  	break;
  }
  g--;
  b++;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
 
int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	if(a <= c && b >= c) 
	{
	printf("Yes\n");
	} else {
	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  auto A = in(N);
  int zero, one, two;
  zero = one = two = 0;
  for (int a : A) {
    if (a % 4 == 0)
      two++;
    else if (a % 2 == 0)
      one++;
    else
      zero++;
  }
  if (one) {
    prif(two >= zero, "Yes", "No");
  } else {
    prif(two + 1 >= zero,  "Yes", "No");
  }
  return 0;
}


Measured memory_bytes: 640
import itertools

n = int(input())
p = list(map(int, input().split()))
q = tuple(map(int, input().split()))
srt = sorted(p.copy())
cnt = 1
cnt1 = 0
cnt2 = 0
for i in itertools.permutations(srt, n):
    if i == tuple(p):
        cnt1 = cnt
    if i == q:
        cnt2 = cnt
    cnt += 1
print(abs(cnt1 - cnt2))

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a-b <= c)
  {
    cout<<c-(a-b);
  }
  else
  {
    cout<<0;
  }
  return 0;
}
#include<bits/stdc++.h>
using namespace std;

Measured memory_bytes: 256
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

N, T = nil()

t = nil()

s = 0

for i in range(0, len(t)-1):
    f = T - (t[i+1] - t[i])
    if f > 0:
        s += f

print(N*T - s)


Measured memory_bytes: 26516
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long r){
  cout << r * r << endl;
}

int main() {
  long long r;
  scanf("%lld",&r);
  solve(r);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,a[MAXN];
int main()
{
    int type=0,ans=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1]) continue;
        if(a[i]>a[i-1])
        {
            if(type==0||type==1) type=1;
            else
            {
                ans++;
                type=0;
            }
        }
        else 
        {
            if(type==0||type==2) type=2;
            else
            {
                ans++;
                type=0;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 640
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll r, d, x;
    cin >> r >> d >> x;
    REP(i, 0, 10)
    {
        x = r * x - d;
        cout << x << NL;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    string s;
    cin >> s;
    set<char> se;
    for(int i=0;i<s.size();i++){
        se.insert(s[i]);
    }
    char c;
    for(int i=0;i<26;i++){
        if(se.count((char)(i+'a'))==0) {
            c = (i+'a');
            break;
        }
    }

    char res=s[s.size()-1];
    set<char> R;
    R.insert(res);
    if(s.size()<26){
        cout << s << c << endl;
        return 0;
    }
    else{
        for(int i=s.size()-2;i>=0;i--){
            if(s[i]>res) {
                R.insert(s[i]);
                res=s[i];
            }
            else{
                for(char ch=s[i];ch<='z';ch++){
                    if(R.count(ch)==1){
                        cout << s.substr(0,i) << ch << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << -1 << endl;

    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

int d[200000];
P p[200000];
vector<int>E[200000];
int col[200000];
int A[200000],B[200000];

int main(){
	int n,m;cin>>n>>m;
	rep(i,n){
		scanf("%d",&d[i]);
		p[i].first=d[i];
		p[i].second=i;
	}
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
		A[i]=a;B[i]=b;
	}
	sort(p,p+n);
	memset(col,-1,sizeof(col));
	rep(x,n){
		int i=p[x].second;
		bool ok=false;
		for(int u:E[i]){
			if(d[u]<=d[i])ok=true;
		}
		if(!ok){
			puts("-1");return 0;
		}
		if(col[i]==-1){
			col[i]=0;
			for(int u:E[i]){
				if(d[u]<=d[i])col[u]=1;
			}
		}
		queue<int>que;
		que.push(i);
		while(!que.empty()){
			int s=que.front();que.pop();
			for(int u:E[s]){
				if(d[u]>=d[s]&&col[u]==-1){
					col[u]=!col[s];
					que.push(u);
				}
			}
		}
	}
	rep(i,n){
		if(col[i])cout<<"W";
		else cout<<"B";
	}
	cout<<endl;
	rep(i,m){
		printf("%d\n",max(d[A[i]],d[B[i]]));
	}
}

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

#define fi first
#define se second

const int N = 200200;
const int mod = 1e9 + 7;

using namespace std;

int r, c, n;
int g[N];

bool good(int x, int y)
{
        if(x != 0 && x != r && y != 0 && y != c) return false;
        return true;
}

vector < pair < int, int > > A, B, C, D;

void add(int x, int y, int i)
{
        if(x == r){
                A.push_back({y, i});
        } else if(y == c){
                B.push_back({-x, i});
        } else if(x == 0){
                C.push_back({-y, i});
        } else{
                D.push_back({x, i});
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> r >> c >> n;

        for(int i = 0; i < n; i++){
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                if(!good(x1, y1) || !good(x2, y2)){
                        continue;
                }

                add(x1, y1, i);
                add(x2, y2, i);
        }

        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        sort(C.begin(), C.end());
        sort(D.begin(), D.end());

        vector < int > G;
        for(auto v: {A, B, C, D}){
                for(auto p: v){
                        int i = p.se;
                        if(!G.empty() && G.back() == i){
                                G.pop_back();
                        } else{
                                if(g[i]){
                                        cout << "NO" << "\n";
                                        return 0;
                                }
                                g[i] = 1;
                                G.push_back(i);
                        }
                }
        }
        cout << "YES" << "\n";
}


Measured memory_bytes: 4940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) {
		int MAX = 51000 ;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		int[] prime = new int[MAX + 1];
		
		try {
			//エラトステネスの篩
			for(int i = 2; i * i <= MAX; i++ ){
		      if(prime[i] == 1 ) continue ;
		      for(int j = i * 2; j <= MAX; j += i ) prime[j] = 1;
		    }
			
			while ((line = br.readLine()) != null) {
				line = line.trim();
				int num = Integer.parseInt(line);
				
				for(int i = 1; num - i  > 1; i++) {
					if(prime[num - i] == 0) {
						System.out.print((num - i) + " ");
						break;
					}
				}
				for(int i = 1; num + i  < 51000; i++) {
					if(prime[num + i] == 0) {
						System.out.println((num + i));
						break;
					}
				}
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define int long long
typedef long long ll;
typedef pair<int,int>pii;
#define MAXN 11234567890123
#define INF INT_MAX/2
#define MOD 1000000007

int m[112345];

void ft(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            m[i]++;
            n=n/i;
        }
    }
    m[n]++;

}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(1);
    cout.setf(ios::fixed);


    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        ft(i);
    }
    int resp=1;
    for(int i=2;i<=n;i++){
        resp*=m[i]+1;
        resp%=MOD;
    }

    cout<<resp<<endl;

    

    return 0;
} 
















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n;
    string s,t;
    cin>>n>>s>>t;
    ll cnt=0,i=0,j=0;
    while(cnt<2*n){
        if(cnt&1){
            cout<<t[j];
            j++;
        }
        else{
            cout<<s[i];
            i++;
        }
        cnt++;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3]=2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
const int MAX_N = 1000;
VI G[MAX_N];
VI color(MAX_N); //頂点iの色 (1 or -1)


int main() {
  double z=0,k,n,m,h,w,ans=0,sum=0,cnt=0,Max=-1e9,Min=1e9+1;
  string u;
  bool ok = false;
  cin >> h >>n;
  VL a(n);
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  
  if(sum >= h)
    cout << "Yes" << endl;
  else
   cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size();
    if(n%2){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<n;i+=2){
        if(s[i]!='h' || s[i+1]!='i'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N;
	cin >> N;
	if (N % 2 == 1) {
		N++;
	}
	cout << N / 2;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	while (true) {
		string t; cin >> t;
		if (t == "0")break;

		VS s(3); s[0] = t;
		rep(i, 2)cin >> s[i + 1];

		int ans = 0;

		//横
		rep(i, 3) {
			if (count(all(s[i]), 'b') == 3)ans = 1;
			else if (count(all(s[i]), 'w') == 3)ans = 2;
		}
		//縦
		rep(i, 3) {
			if (s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
				if (s[0][i] == 'b')ans = 1;
				else if (s[0][i] == 'w')ans = 2;
			}
		}
		//斜め
		if (s[0][0] == s[1][1] && s[1][1] == s[2][2]) {
			if (s[0][0] == 'b')ans = 1;
			else if (s[0][0] == 'w')ans = 2;
		}
		if (s[0][2] == s[1][1] && s[1][1] == s[2][0]) {
			if (s[0][2] == 'b')ans = 1;
			else if (s[0][2] == 'w')ans = 2;
		}

		puts(ans ? ans == 1 ? "b" : "w" : "NA");
	}
}


Measured memory_bytes: 3056
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    bool ans = false;

    cin >> s;

    if(s[0] == s[1] && s[1] == s[2] && s[0] == s[2])
        cout << "No" << endl;
    else 
        cout << "Yes" << endl;



    return 0;
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    n=list(input())
    m=int(''.join(n))
    cnt=sum([int(i) for i in n])
    print('Yes' if m%cnt==0 else 'No')


resolve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#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 f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    double l;
    cin >> l;
    double x = l/3;
    cout << fixed << setprecision(10) << x*x*x;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let xs =
        [1..N]
        |> List.map (fun x -> (x, N / x, N % x))
    let ans =
        List.exists (fun (x, y, z) -> x <= 9 && y <= 9 && z = 0) xs
    // eprintfn "%A" (xs, ans)
    if ans then
        printfn "Yes"
    else
        printfn "No"
    0

Measured memory_bytes: 13660
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n, k, s;
    cin >> n >> k >> s;

    vector<int64_t> vs(n);
    for (int i = 0; i < k; i++)
    {
        vs[i] = s;
    }
    for (int i = k; i < n; i++)
    {
        vs[i] = (s == 1000000000 ? s - 1 : s + 1);
    }
    for (int i = 0; i < n; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << vs[i];
    }
    cout << endl;
}


Measured memory_bytes: 2048
import           Control.Monad
import           Data.List
import           Data.List.Split
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

create :: String -> V.Vector Int
create x = V.fromList $ f x 0
  where
    f [_] i = [i]
    f (s1:s2:ss) i
      | s1 == 'A' && s2 == 'C' = i:f (s2:ss) (i + 1)
      | otherwise = i:f (s2:ss) i

main :: IO ()
main = do
  [n, q] <- map read . words <$> getLine
  as <- create <$> getLine
  replicateM_ q
    $ do
      [l, r] <- map read . words <$> getLine
      print (as V.! (r - 1) - as V.! (l - 1))



Measured memory_bytes: 8444
N,M = map(int,input().split())
R = []
for i in range(M):
  a = list(map(int,input().split()))
  b = a[0]
  c = a[1]
  R.append(b)
  R.append(c)
  
for l in range(1,N+1):
  ans = []
  ans = [i for i in R if i == l ]
  print(len(ans))


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
   
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
               String[] spl=line.split(" ");
               int n=Integer.parseInt(spl[0]),m=Integer.parseInt(spl[1]); if(n==0&&m==0)break;
               ArrayList<Integer> alInt=new ArrayList<Integer>();
               for(int i=1; i<=n;i++){alInt.add(i);}
               boolean firsttime=true;
               while(alInt.size()>1){
                   if(firsttime){firsttime=false;del_first(alInt,m);}
                   else{del_second(alInt,m);}
               }
                 System.out.println(alInt.get(0)+"");
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
    static int prevHold=30;// -- ninn me no hito ga motteta. sakki
     static void del_first(ArrayList<Integer>alInt,int m){
         
         int num = alInt.size();prevHold=num;
         int hold=prevHold;
         for(int i=1;i<=m;i++){
             hold = (hold==num)? 1: hold+1;
         }prevHold=hold; alInt.remove(hold-1);
     }
     static void del_second(ArrayList<Integer>alInt,int m){
         int num = alInt.size();prevHold -=1;if(prevHold==0){prevHold=num;}
         int hold=prevHold;
         for(int i=1;i<=m;i++){
             hold = (hold==num)? 1: hold+1;
         }prevHold=hold; alInt.remove(hold-1);
     }
     
}
 

Measured memory_bytes: 19040
#include<cstdio>
#include<vector>
#include<stack>

int posx,posy; 

void up(void){
	posy++;
	printf("U");
}

void down(void){
	posy--;
	printf("D");
}

void right(void){
	posx++;
	printf("R");
}

void left(void){
	posx--;
	printf("L");
}

int main(void){
	int sx,sy,tx,ty;
	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
	posx=sx; posy=sy;
	
	//一回目s->t
	while(posx<tx){
		right();
	}
	while(posy<ty){
		up();
	}
	//t->s
	while(posx>sx){
		left();
	}
	while(posy>sy){
		down();
	}
	//二回目
	down();
	while(posx<=tx){
		right();
	}
	while(posy<ty){
		up();
	}
	left();
	//t->s
	up();
	while(posx>=sx){
		left();
	}
	while(posy>sy){
		down();
	}
	right();
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.Math;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        if (n%1000 == 0) {
            System.out.println(0);
        } else {
            System.out.println(1000-(n%1000));
        }




    }





    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


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

int main(){
  int ans = 0, N;
  cin >> N;
  vector<vector<int>> a(N, vector<int>(3));
  
  for(int i = 0; i < N; i++) cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
  
  vector<vector<int>> dp(N+1, vector<int>(3));

  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(k == j) continue;
        dp.at(i + 1).at(k) = max(dp.at(i + 1).at(k), dp.at(i).at(j) + a.at(i).at(k));
      }
    }
  }
  
  for(int i = 0; i < 3; i++) ans = max(ans, dp.at(N).at(i));
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string str;cin>>str;
	str.pub('a'-1);
	while(str.size()>0){
		char sa=str.back();
		str.pob();
		for(char c=sa+1;c<='z';c++){
			bool ok=true;
			for(auto it:str){
				if(it==c){ok=false;break;}
			}
			if(ok){cout<<str<<c<<endl;return 0;}
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  vi a(n); rep(i, n) std::cin >> a[i];
  k--, n--;
  std::cout << (n + k-1) / k << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

std::vector<std::map<std::string, ull>> dp;
const std::vector<char> ACGT{'A', 'C', 'G', 'T'};
constexpr ull INF = 1000'000'007;

ull recursion(ui n, std::string str)
{
  assert(str.size() == 3);

  if(dp[n].count(str))
    return dp[n][str];
  
  if(!n)
    return 1;

  auto judge = [](std::string str){
    assert(str.size() == 4);
    if(str.find("AGC") != str.npos
    || str.find("GAC") != str.npos
    || str.find("ACG") != str.npos)
    {
      return false;
    }
    if(str[0] == 'A'
    && str[3] == 'C')
    {
      if(str[1] == 'G'
      || str[2] == 'G')
        return false;
    }
    return true;
  };

  ull res{};
  for(char c : ACGT)
  {
    std::string s = str + c;
    if(judge(s))
    {
      res = (res + recursion(n - 1, s.substr(1, 3))) % INF;
    }
  }
  dp[n][str] = res;
  return res;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  // string S{}; std::cin >> S;
  ui N{}; std::cin >> N;
  dp.resize(N + 1);

  auto ans = recursion(N, "TTT");

  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

int main(){
	string k;
	int a;
	cin>>a>>k;
	if(k.size() <= a) cout<<k<<endl;
	else{
		for(int i = 0 ; i < a ; i++) cout<<k[i];
		cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3596
N, A, B = map(int, input().split())

sum = 0
for i in range(1, N+1):
    num = i
    val = 0
    while True:
        val += num % 10
        if num // 10 > 0:
            num = num // 10
        else:
            break
    if A <= val <= B:
        sum += i
print(sum)


Measured memory_bytes: 67096
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	string s,t;cin>>s>>t;
	for(int i=0;i<t.length();i++){
		cout<<s[i]<<t[i];
	}
	if(s.length()-t.length()) cout<<s[s.length()-1];
}


Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define N -1

struct Node
{
  int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == N) return;
  D[u]=d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].left != N)
    h1=setHeight(T[u].left)+1;
  if(T[u].right != N)
    h2=setHeight(T[u].right)+1;

  return H[u]=(h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == N) return N;
  if(T[T[u].parent].left != u && T[T[u].parent].left != N)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != N)
    return T[T[u].parent].right;
  return N;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg=0;
  if(T[u].left != N) deg++;
  if(T[u].right != N) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == N){
    printf("root\n");
  }
  else if(T[u].left == N && T[u].right == N){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;
  scanf("%d", &n);

  for(int i=0; i< n; i++){
    T[i].parent = N;
  }

  for(int i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left=l;
    T[v].right=r;
    if(l != N) T[l].parent=v;
    if(r != N) T[r].parent=v;
  }

  for(int i=0; i<n; i++) {
    if(T[i].parent == N) root=i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(int i=0; i<n; i++)  print(i);

  return 0;
}



Measured memory_bytes: 2696
import math
def main():
    a,b, h, m = map(int,input().split())
    l = 360 * (m/60)
    s = 30 * h + 30 * (m/60)
    r = abs(s-l)
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(r))
    print(ans**0.5)
if __name__=='__main__':
    main()


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


int main (){
    int N;
    cin>>N;
    bool For=false;
    bool Lat=false;
    if(N/100>0&&N/100<13){
        For=true;
    }
    if(N%100>0&&N%100<13){
        Lat=true;
    }
    if(For&&Lat){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(For){
        cout<<"MMYY"<<endl;
    }
    else if(Lat){
        cout<<"YYMM"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
    
}

Measured memory_bytes: 384