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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}
//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}
//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}
//累乗(xのn乗%mod)
ll mod_pow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//大文字->小文字(+32)
//少数はなるべく整数に

void Main()
{
  str s; cin >> s;
  for(ll i = 0;i < s.size();i++)
  {
    if(i % 2 == 0&&s[i] == 'L') fYn(0);
    else if(i % 2 == 1&&s[i] == 'R') fYn(0);
  }
  fYn(1);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	

int n;
cin>>n;
bool f=false;
while(n)
{
	int r=n%10;
	if(r==7)
	f=true;
	n/=10;
}
if(f)
cout<<"Yes";
else
cout<<"No";

}return 0;}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
        int num[5];
        int i, j, tmp;

        for ( i = 0 ; i < 5 ; i = i + 1 )
        {
                scanf( "%d", &num[i] );
        }


        for ( i = 0 ; i < 4 ; i = i + 1 )
        {
                for ( j = i + 1 ; j < 5 ; j = j + 1 )
                {
                        if ( num[j] > num[i] )
                        {
                                tmp = num[j];
                                num[j] = num[i];
                                num[i] = tmp;
                        }
                }
        }


        fprintf( stdout, "%d %d %d %d %d\n", num[0], num[1], num[2], num[3], num[4] );
        return 0;
}

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

const int MAX = 1e3 + 5;
int vis[MAX][MAX], grid[MAX][MAX], m, n;
char c;
bool inside(int x, int y, int a, int b){
    return 0 <= x + a && x + a < n && 0 <= y + b && y + b < m;
}
int main(){
    cin >> n >> m;
    queue<pair<pair<int, int>, int>> queue;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> c;
            if (c == '#'){
                queue.emplace(make_pair(make_pair(i, j), 0));
                vis[i][j] = 1;
            }
        }
    }
    int ans = 0;
    while(queue.size()){
        pair<pair<int, int>, int> p = queue.front();
        int cx = p.first.first;
        int cy = p.first.second;
        int ct = p.second;
        ans = max(ans, ct);
        queue.pop();
        for (int a: {-1, 0, 1}){
            for (int b: {-1, 0, 1}){
                if (abs(a) != abs(b) && inside(cx, cy, a, b)){
                    if (!vis[cx + a][cy + b]){
                        queue.emplace(make_pair(make_pair(cx + a, cy + b), ct + 1));
                        vis[cx + a][cy + b] = 1;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 19180
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

bool compare(int n1, int n2) {
	if (abs(n1) < abs(n2))return true;
	return false;
}

int main()
{
	int apple[201];
	int n, l,ans=0;
	cin >> n >> l;
	for (int i = 1; i <= n; i++) {
		apple[i-1] = l + i - 1;
	}
	sort(apple, apple + n, compare);
	apple[0] = 0;
	for (int i = 0; i < n; i++) {
		ans += apple[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

    int ans = min(c, b/a);

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


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


int main()
{
	int n;

	std::cin >> n;

	std::map<int, int> m;

	for (size_t i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		m[a]++;
	}

	std::cout << m.size() << std::endl;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), S(N + 1);
    rep(i, N) cin >> A[i];
    rep(i, N) S[i + 1] = S[i] + A[i];

    ll ans = abs(S[N] - S[1] * 2);
    for (int i = 1; i < N; i++) {
        chmin(ans, abs(S[i] - (S[N] - S[i])));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


int main() {
	int N, answer;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	answer = 1;
	bool ok = true;

	for (int i = 1; i < N; i++) {
		ok = true;
		for (int j = 0; j < i; j++) {
			if (H[j] <= H[i]) {
				continue;
			}
			ok = false;
			break;
		}
		if (ok) {
			answer++;
		}
	}

	cout << answer << endl;
}

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

int main() {
  string c;
  std::cin >> c;
  if (c=="a") {
    /* code */std::cout << "vowel" << '\n';
  }
   else if (c=="e") {
    /* code */std::cout << "vowel" << '\n';
  }
  else if (c=="i") {
    /* code */std::cout << "vowel" << '\n';
  }
  else if (c=="o") {
    /* code */std::cout << "vowel" << '\n';
  }
  else if (c=="u") {
    /* code */std::cout << "vowel" << '\n';
  }
  else{
    std::cout << "consonant" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin >> n;
    if (n > 81){ cout << "No"; return 0;}
    for (int i=1; i<= 9; i++){
        if (n%i == 0 && n/i <= 9){
            cout << "Yes"; return 0;
        }
    }
    cout << "No";
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll h;
  cin >> h;
  ll ans = 1;
  while (ans <= h) {
    ans *= 2;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#define N 200005
using namespace std;
int n,a[N],ans;
map<int,int> s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s[a[i]]++;
	sort(a+1,a+1+n);
	for(int i=n;i;i--)
		if(s[a[i]]>0){
			int t=(1<<((int)log2(a[i])+1))-a[i];
			if((a[i]!=t && s[t]>0) || (a[i]==t && s[t]>1)){
				ans++;
				s[a[i]]--;
				s[t]--;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19968
let calc a b =
  let rec iter i =
    if i == 0 then
      []
    else if a mod i == 0 && b mod i == 0 then
      i :: iter (i - 1)
    else iter (i - 1)
  in iter 100
let () =
  let (a, b, k) = Scanf.scanf "%d %d %d" (fun a b k -> (a, b, k)) in
  let l = calc a b in
  (*List.iter (fun e -> e |> string_of_int |> print_endline) l*)
  List.nth l (k - 1) |> string_of_int |> print_endline



Measured memory_bytes: 2432
use std::process::exit;
use proconio::input;

fn main() {
  input! {
    n: u32,
  };
  match n % 10 {
    2 | 4 | 5 | 7 | 9 => println!("hon"),
    0 | 1 | 6 | 8 => println!("pon"),
    3 => println!("bon"),
    _ => exit(1)
  };
}

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

int main() {
    ll n,k,p=1000000007;
    cin >> n >> k;
    vector<ll> a(n);for(int i=0;i<n;i++) cin >> a[i];  
    ll ans=0,ta=0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(a[i]>a[j]) ta++;
        }
    }
    ans += k*ta; ans %= p;

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    vector<ll> b(n);
    for(int i = 1; i < n; i++) {
        if(a[i]==a[i-1]) b[i]=b[i-1];
        else b[i]=i;
    }

    ll x=k*(k-1)/2; x%=p;
    for(int i = 0; i < n; i++) {
        ll y=b[i];
        y *= x;
        y %= p;
        ans += y;
        ans %= p;
    }

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


Measured memory_bytes: 3592
#include <string.h>
#include <stdio.h>
typedef long long ll;
ll m = 1000000007;
char mat[1005][1005];
int vis[1005][1005], memo[1005][1005];

ll solve(int i, int j)
{
    if(vis[i][j])
        return memo[i][j];
    vis[i][j]++;
    if(i==1 && j>1)
        return memo[i][j] = solve(i, j-1);
    if(i>1 && j==1)
        return memo[i][j] = solve(i-1, j);
    if(i==1 && j==1)
        return memo[i][j] = 1;
    
    return memo[i][j] = (solve(i-1, j) + solve(i, j-1))%m;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    memset(vis, 0, sizeof(vis));
    memset(memo, 0, sizeof(memo));
    int h, w;
    char dummy;
    scanf("%d %d", &h, &w);
    scanf("%c", &dummy);
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
            scanf("%c", &mat[i][j]);
        scanf("%c", &dummy);
    }
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(mat[i][j] == '#')
                vis[i][j]++;
        }            
    }
    printf("%lld\n", solve(h, w));
    // for(int i=1; i<=h; i++)
    // {
    //     for(int j=1; j<=w; j++)
    //     {
    //         printf("%d ", memo[i][j]);
    //     }            
    //     printf("\n");
    // }
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n,i,j,k,t,temp;
    LL truth=0;
    string s="";
    char str[500003];
    LL now=200003;
    LL queries;
    cin>>s;
    LL len=s.length();
    LL start,end;
    start=now-1;
    
    for(i=0;i<len;i++)
    {
        str[i+now]=s[i];
    }
    end=now+len;
    LL f,c;
    cin>>queries;
    while(queries--)
    {
        cin>>t;
        if(t==1)
        {
            truth^=1;
        }
        else
        {
            char ch;
            cin>>f>>ch;
            if((f==1 && truth==0) || (f==2 && truth==1))
            {
                str[start--]=ch;
            }
            else
            {
                str[end++]=ch;
            }            
        }        
    }
    if(truth==1)
    {
        for(i=end-1;i>start;i--)
        {
            cout<<str[i];
        }
        cout<<endl;
    }
    else
    {
        for(i=start+1;i<end;i++)
        {
            cout<<str[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1104
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
a = [I() for _ in range(N)]
a = list(map(lambda x:x-1,a))

ans = -1

# 訪れる順序、indexは移動回数
route = [0]
# 訪れた番号、高速検索用にhash tableを使う
visited = set([0])
next = a[0]

while True:
    if next in visited:
        loopStart = route.index(next)
        break
    else:
        route.append(next)
        visited.add(next)
        next = a[next]
        
# print(route)
# 番号2のボタンが含まれる   
if 1 in visited:
    ans = route.index(1)

print(ans)

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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int a[3][3];
	for(int i = 0; i<3; i++){
		for(int j = 0; j<3; j++) cin>>a[i][j];
	}
	int n; cin>>n;
	unordered_map< int, int > m;
	for(int i = 0; i<n; i++){
		int b; cin>>b;
		m[b]++;
	}

	int vis[3][3] = {};
	for(int i = 0; i<3; i++){
		for(int j = 0; j<3; j++){
			if(m[a[i][j]]) vis[i][j] = 1;
		}
	}
	bool ok = 0;
	for(int i = 0; i<3; i++){
		if(vis[i][0] && vis[i][1] && vis[i][2]) ok = 1;
		if(vis[0][i] && vis[1][i] && vis[2][i]) ok = 1;
	}
	if(vis[0][0] && vis[1][1] && vis[2][2]) ok = 1;
	if(vis[0][2] && vis[1][1] && vis[2][0]) ok = 1;

	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


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

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

ll N, M, K;

const int MAX = 2 * 1e5;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();
    ll ans = 0;
    for(int i=0;i<M;i++){
        ll res = (ll) (M - i) * N * N * i % MOD;
        ans = (ans + res) % MOD;
    }
    for(int i=0;i<N;i++){
        ll res = (ll) (N - i) * M * M * i % MOD;
        ans = (ans + res) % MOD;
    }
    ans = ans * COM(N * M - 2, K - 2) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 4992
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
	fast;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum = min(a,k);
	k-=min(a,k);
	k-=min(b,k);
	sum-=min(c,k);
	cout<<sum;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int n;
        cin>>n;
        int r[n], c[n], a[n][n];
        for(int i=0;i<n;i++) cin>>r[i]>>c[i];
        for(int i=0;i<n;i++)
                a[i][i] = 0;

        for(int i=1;i<n;i++){
                for(int j=0;j+i<n;j++){
                        a[j][j+i] = 2000000000;
                        for(int k=0;k+1<=i;k++)
                                a[j][j+i] = min(a[j][j+i], a[j][j+k]+a[j+k+1][j+i] + r[j]*c[j+k]*c[j+i]);
                }
        }
        cout<<a[0][n-1]<<endl;
        return 0;
}


Measured memory_bytes: 3108
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,k,h[100010];
int ans[100110];
signed main(){
    I(n); I(k);
    REP(i,n) I(h[i]);
    REP(i,n+1) ans[i] = 1LL << 60;
    ans[0] = 0;
    REP(i,n){
        REPS(leap,min(k,n-i-1)){
            ans[i+leap] > ans[i] + abs(h[i] - h[i+leap]) &&
                (ans[i+leap] = ans[i] + abs(h[i] - h[i+leap]));
        }
    }
    cout << ans[n-1] << endl;;
}

Measured memory_bytes: 1792
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
vector<int>g[110];
int e[100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c;scanf("%d",&c);
		for(int j=0;j<c;j++){
			int d;scanf("%d",&d);d--;g[i].push_back(d);
		}
	}
	for(int i=0;i<b;i++)scanf("%d",e+i);
	int ret=0;
	for(int i=0;i<(1<<a);i++){
		bool ok=true;
		for(int j=0;j<b;j++){
			int cnt=0;
			for(int k=0;k<g[j].size();k++){
				if(i&(1<<g[j][k]))cnt++;
			}
			if(cnt%2!=e[j])ok=false;
		}
		if(ok)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 256
s = input()
q = int(input())
rev = 0
mae = []
usiro = []

for i in range(q):
    a = input()
    
    if a[0] == '1':
        rev += 1
    else:
        if (int(a[2]) + rev) % 2 == 1:
            mae.append(a[4])
        else:
            usiro.append(a[4])
            
mae = mae[::-1]
mae2 = "".join(mae)
usiro2 = "".join(usiro)
if rev%2 == 0:
    print(mae2 + s + usiro2)
else:
    ans = mae2 + s + usiro2
    print(ans[::-1])

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

typedef long long ll;

#define PB push_back
int n, m, q;
vector<int> seq(10, 1);
vector<int> a(50), b(50), c(50), d(50);

int solve(int cpos) {
    int sum = 0;
    if (cpos == n) {
        for (int i = 0; i < q; ++i) {
            if (seq[b[i]] - seq[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        return sum;
    }
    if (cpos == 0) {
        sum = solve(1);
    } else {
        for (int i = seq[cpos - 1]; i <= m; ++i) {
            seq[cpos]=i;
            sum = max(sum, solve(cpos + 1));
        }
    }
    return sum;
}


int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> q;
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    cout << solve(0) << "\n";
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  string s;
  cin >> s;
  reverse(all(s));
  vector<pair<string, int>> vec{{"maerd", 5}, {"remaerd", 7}, {"esare", 5}, {"resare", 6}};
  auto itr = s.begin();
  bool flag = true;
  while (flag) {
    flag = false;
    allrep(v, vec) {
      if (s.end() - itr >= v.second && equal(all(v.first), itr)) {
        itr += v.second;
        flag = true;
        break;
      }
    }
  }
  cout << (itr == s.end() ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    string str;
    cin >> str;
    int A[4];

    for(int i=0;i<4;i++) A[i] = str[i] - '0';

    for(int i=0;i<(1<<3);i++){
        int sum = A[0];
        //cout << i<< "==";
       for(int k=0;k<3;k++){
           if((i>>k)&1){
               sum +=A[k+1];
           }else{
               sum -=A[k+1];
           }
           //cout << sum <<" ";
       }
       if(sum == 7){
           cout << A[0];
           for(int k=0;k<3;k++){
               if((i>>k)&1) cout << "+";
               else cout << "-";
               cout << A[k+1];
           }
           cout << "=7"<<endl;
         return 0;
       }
    }
     
     
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

if Y/N > 10000 or Y%1000 != 0:
  print("-1 -1 -1")
  exit()
  
for x in range(N+1):
  for y in range(N-x+1):
    z = N-x-y
    if x*10000+y*5000+z*1000 == Y:
      print(x,y,z)
      exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

char s[105];
int ans;

signed main(){
	scanf("%s",s);
	for(int i=0,j=strlen(s)-1;i<j;i++,j--) if(s[i]^s[j]) ans++;
	write(ans);
}

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

long long calc(long long n, long long x, long long y)
{
  long long g = x * y / __gcd(x, y);
  return n - n / x - n / y + n / g;
}

int main()
{
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << calc(b, c, d) - calc(a - 1, c, d) << endl;
}


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int xa=min(a,k);
    k-=xa;
    int xb=min(b,k);
    k-=xb;
    int xc=k;
    int ans=xa-xc;
    cout<<ans<<endl;

    return 0;
}


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

const int MOD = 1e9+7;

int f[100005][15];
string s;

int main()
{
	cin>>s;
	if(isdigit(s[0]))
		f[0][s[0]-48] = 1;
	else
		for(int i=0;i<=9;i++)
			f[0][i] = 1;
	for(int i=1;i<s.length();i++)
	{
		if(isdigit(s[i]))
		{
			for(int j=0;j<=12;j++)
			{
				f[i][(j*10+s[i]-48)%13] += f[i-1][j]%MOD;
				f[i][(j*10+s[i]-48)%13] %= MOD;
			}
		}
		else
		{
			for(int j=0;j<=9;j++)
				for(int k=0;k<=12;k++)
				{
					f[i][(k*10+j)%13] += f[i-1][k]%MOD;
					f[i][(k*10+j)%13] %= MOD;
				}
		}
	}
	cout<<f[s.length()-1][5]<<endl;
	
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

vec make(int n, int a, int b){
    if(n == 1) return {a, b};
    int diff = a ^ b, bit = -1;
    int a_bit, b_bit;
    rep(i,n) if((diff>>i) & 1) {
        bit = i;
        a_bit = ((a>>bit)&1)<<bit;
        b_bit = ((b>>bit)&1)<<bit;
    }
    int la = ((a >> (bit + 1))<<bit) + a % (1<<bit);
    int rb = ((b >> (bit + 1))<<bit) + b % (1<<bit);
    vec left = make(n - 1, la, la ^ 1), right = make(n - 1, la ^ 1, rb);
    vec res(1<<n);
    rep(i, 1<<(n - 1)){
        res[i] = ((left[i] >> bit)<<(bit + 1)) + left[i] % (1<<bit) + a_bit;
    }
    rep(i, 1<<(n - 1)){
        res[i + (1 << (n - 1))] = ((right[i]>>bit)<<(bit + 1)) + right[i] % (1<<bit) + b_bit;
    }
    return res;
}

int main() {
    cin>>N>>A>>B;
    ll diff = A ^ B;
    vec bit(0);
    rep(i,N) if((diff>>i)&1) bit.push_back(i);
    if(bit.size() % 2 == 0){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    vec ans = make(N, A, B);
    rep(i,1<<N){
        cout<<ans[i];
        (i != (1<<N) - 1 ? cout<<' ' : cout<<endl);
    }
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<stdlib.h>
int main(void) {
  int a, b;
  //a = atoi(argv[1]);
  //b = atoi(argv[2]);
  scanf("%d%d", &a, &b);
  int c,d,e;
  c = a + b;
  d = c;
  c = a - b;
  if(c > d) {d = c;}
  c = a * b;
  if(c > d) {d = c;}
  printf("%d\n", d);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  // ll INF = INT_MAX;
  // ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const int N = 2e5 + 5;


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("input.txt");

      int n;
      cin>>n;
      string s;
      cin>>s;
      int l = 0;
      int r = n-1;
      int cnt = 0;
      int from_beg = 0;
      int from_end = 0;
      while (l<n && s[l]=='R') {l++; from_beg++;}
      while (r>=0 && s[r]=='W') {r--;from_end++;}
      if (l>=r){
        cout<<"0\n";
        return 0;
      } 
      while (l<r){
        cnt++;
        swap(s[l], s[r]);
        while (l<n && s[l]=='R') {l++; from_beg++;}
      while (r>=0 && s[r]=='W') {r--;from_end++;}
      }
      cout<<cnt<<"\n";

}

Measured memory_bytes: 3480
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
x = (t-a)/0.006

before = max(h)
ans = 0
i = 0
for i in range(n):
  if abs(h[i]-x) < before:
    before = abs(h[i]-x)
    ans = i+1
print(ans)



Measured memory_bytes: 3060
n,m = map(int,input().split())
g = [[] for _ in range(n)] 

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n 
    d[u] = 0 
    l = [[] for _ in range(n)] 
    dic = {}
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
                l[i].append(v)
                dic[i] = v
    return d,l,dic
d,l,dic = bfs(0)
if None in d:
    print("No")
else:
    print("Yes")
    l.remove(l[0])
    [print(i[0]+1) for i in l]

Measured memory_bytes: 51204
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
     mut aa: [usize; n]
    };

    aa.sort();
    aa.reverse();

    let mut x = 0;
    let mut y = 0;

    for i in 0..n {
        if i % 2 == 0 {
            x += aa[i]
        } else {
            y += aa[i]
        }
    }

    println!("{}", x - y);
}


Measured memory_bytes: 2092
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());

        // 主処理
        double side = l / 3.0;
        double result = side * side * side;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int n;
	for (; cin >> n; )
	{
		if (n == 0)
		{
			break;
		}

		int cnt = 0;
		for (int i = 0; i <= n; i += 5)
		{
			int j = i;
			for (; j > 0;)
			{
				if (j % 10 == 0)
				{
					cnt++;
					j /= 10;
				}
				else if (j % 5 == 0)
				{
					cnt++;
					j /= 5;
				}
				else
				{
					break;
				}
			}
		}

		cout << cnt << endl;
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int x, n;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  set<int> p;
  rep(i,n) {
    int k;
    cin >> k;
    p.insert(k);
  }
  // 本人banされていない
  if (p.find(x) == p.end()) {
    cout << x << endl;
    return 0;
  }

  int diffm = x+1;
  for(int i = x-1; i >= 0; --i) {
    if(p.find(i) == p.end() && diffm >= x - i) {
      diffm = x-i;
      break;
    }
  }


  int diffp = 101 - x;
  for(int i = x+1; i <= 100; ++i) {
    if(p.find(i) == p.end() && diffp > i-x) {
      diffp = i - x;
      break;
    }
  }
  if (diffm > diffp) {
    cout << diffp + x << endl;
  } else {
    cout << x - diffm << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  a <- getIs
  putStrLn $ bool "Yes" "No" (any (\x -> mod x 2 == 0) a)


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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;

stack<int>s;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,f;cin>>n;
    if(n==0) {
        cout<<0;return 0;
    }
    if(n>=0) f=1;
    else f=-1;
    n=abs(n);
   while(n){
       int k=n/2;
       if(n%2){
        s.push(1);
        if(f==-1) k++;
       }
       else  s.push(0);
       f=-f;
       n=k;
   }

    while(s.size()) {
        cout<<s.top();
        s.pop();
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
char s[100005];int f[14][100005],n,pw[100005];
int dfs(int x,int re){
    if(x==n) return re==5;
    if(f[re][x]!=-1) return f[re][x];
    int cur=0;
    if(s[x+1]=='?') rep(i,0,9) cur=(cur+dfs(x+1,(re+i*pw[x])%13))%mod;
    else cur=dfs(x+1,(re+(s[x+1]-48)*pw[x])%13)%mod;
    return f[re][x]=cur;
}
int main()
{
    scanf("%s",s+1);n=strlen(s+1);
    reverse(s+1,s+n+1);
    pw[0]=1;rep(i,1,n+1) pw[i]=(pw[i-1]*10)%13;
    rep(i,0,12) rep(j,0,n) f[i][j]=-1;
    printf("%d",dfs(0,0));
    return 0;
}

Measured memory_bytes: 12032
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int sum=0;
int amount=0;
int p=0;
int q=0;
int count=0;
while((line=br.readLine())!=null){
String[] values=line.split(",");
p=Integer.parseInt(values[0]);
q=Integer.parseInt(values[1]);
sum+=p*q;
amount+=q;
count++;
}
System.out.println(sum);
System.out.println(Math.round((float)amount/count));
}
}

Measured memory_bytes: 16900
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int K,A,B; cin >> K >> A >> B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3648
n,c,k = gets.split.map(&:to_i)
time = n.times.map{gets.to_i}.sort

i = time[0]
counter = 1
per = 1
(1..n-1).each do |a|
  if k >= time[a] - i && c > per
    per += 1
  else
    per = 1
    counter += 1
    i = time[a]
  end
end

p counter

Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x;
	cin>>x;
	for (int i=-200;i<=200;i++)
	{
		for (int j=-200;j<=200;j++)
		{
			if (1ll*i*i*i*i*i-1ll*j*j*j*j*j==x)
			{
				cout<<i<<' '<<j;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3608
require "prime"

k = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]

n = gets.to_i
f = n.prime_division
#p f
f.map!{|p, e|
	k.find_index{|i| i > e}
}
#p f
puts f.sum

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

int main(){
	int h,w,x[2010][2010],cnt[2010][2010] = {};
	string s[2010];
	cin >> h >> w; w--;
	int ma = h;
	for(int i = 0;i < h;i++){
		cin >> s[i];
		for(int j = 0;j < w;j++){
			x[i][j] = (s[i][j] == s[i][j + 1]);
			if(!i || x[i][j] != x[i - 1][j]) cnt[i][j] = 1;
			else cnt[i][j] = cnt[i - 1][j] + 1;
		}
	}
	for(int i = 0;i < h;i++){
		int l[2010],r[2010];
		stack<int> st;
		for(int j = 0;j < w;j++){
			while(!st.empty() && cnt[i][st.top() - 1] >= cnt[i][j]) st.pop();
			if(st.empty()) l[j] = 0;
			else l[j] = st.top();
			st.push(j + 1);
		}
		while(!st.empty()) st.pop();
		for(int j = w - 1;j >= 0;j--){
			while(!st.empty() && cnt[i][st.top()] >= cnt[i][j]) st.pop();
			if(st.empty()) r[j] = w;
			else r[j] = st.top();
			st.push(j);
		}
		for(int j = 0;j < w;j++) ma = max(ma,(r[j] - l[j] + 1) * cnt[i][j]);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 35968
from itertools import combinations
n = int(input())
l = list(map(int,input().split()))
c = combinations(l,3)
k=0
for (a,b,c) in c:
	if a+b>c and b+c>a and c+a>b and a!=b and b!=c and a!=c:
		k+=1
print(k)

Measured memory_bytes: 9176
N, K = map(int, input().split())

MOD = 10**9 + 7
sum = 0
for j in range(K, N+1):
    MIN = j * (j-1) // 2
    MAX = (N+1)*N//2 - (N+1-j)*(N-j)//2
    # print(MAX, MIN)
    sum += MAX - MIN + 1
    
print(sum % MOD + 1)

Measured memory_bytes: 9184
#include "stdio.h"

int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<3;i++)for(int j=i+1;j<3;j++)if(a[i]>a[j]){
		int temp = a[i]; a[i] = a[j];a[j]=temp;
	}
	printf("%d",a[2] - a[0]);
}

Measured memory_bytes: 128
def kuro(x,y,c):
    dcr=0
    for cc in c:
        if cc[0] in x:
            dcr+=1
        if cc[1] in y:
            dcr+=1   
    for i in x:
        for j in y:
            if [i,j] in c:
                dcr-=1
    return dcr

def nshinsu(x,h):
    lis=[]
    xx=x
    for i in range(h-1,-1,-1):
        if xx >= 2**i:
            lis.append(i)
            xx=xx-(2**i)
    return lis
h,w,k= map(int,input().split())
c =[]
black=0
ans=0
for i in range(h):
    l= input()
    for j in range(w):
        if l[j]=="#":
            c.append([i,j])
            black+=1
for i in range(2**h):
    for j in range(2**w):
        x =nshinsu(i,h)
        y =nshinsu(j,w)
        d =kuro(x,y,c)
        if d== black-k:
            ans+=1
        #print(x,y,d)
print(ans)



Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int l, r;
    cin >> l >> r;
    if (r - l < 2023) {
        int ans = 2018;
        for (int i = l; i <= r; ++i) {
            for (int j = i + 1; j <= r; ++j) {
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}


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

long long int N, a[150], b[150];
char s[55][55];

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < 150; ++i){
        b[i] = 114514;
    }
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < 150; ++j){
            a[j] = 0;
        }
        scanf(" %s", s[i]);
        for(char c : s[i]){
            ++a[c];
        }
        for(int j = 48; j < 126; ++j){
            b[j] = min(b[j], a[j]);
        }
    }
    for(int i = 48; i < 126; ++i){
        for(int j = 0; j < b[i]; ++j){
            cout << char(i);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int A,B,C,X,Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = 1000000000;
	for (int i = 0;i < max(X,Y) * 2 + 1;i+=2) {
		int a = X - i/2;
		int b = Y - i/2;
		if (a < 0) a = 0;
		if (b < 0) b = 0;
		ans = min(ans,a*A+b*B+i*C);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int j,m=0,n;long long k,cnt;
int main() 
{cin>>n>>k;
 int a[n+1],a1[n+1];
 for(int i=1;i<=n;i++){
   cin>>a[i];a1[i]=0;} 
 j=1;
 while(a1[j]==0)
 { a1[j]=m+1;
  if(m==k){cout<<j;return 0;}
  j=a[j];m++;} 
 cnt=(k-a1[j]+1)%(m+1-a1[j]); 
 while(cnt--)
 {j=a[j];}
 cout<<j; 
 return 0;}


Measured memory_bytes: 5188
#include<stdio.h>
int ans[55];
int main()
{
int n,m,i,x,y;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++)
{
scanf("%d%d",&x,&y);
ans[x]++;
ans[y]++;
}
for(i=1;i<=n;i++)
printf("%d\n",ans[i]);
return 0;
}

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

using namespace std;

int main(){
    int N; cin>>N;
    double x,ans=0.0;
    string u;
    for(int i=1;i<=N;i++){
        cin>>x>>u;
        if(u=="BTC"){
            ans+=x*380000;
        }else{
            ans+=x;
        }
    }
    printf("%.8f",ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];

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

        Arrays.sort(d);
        
        System.out.println(d[n/2]-d[n/2-1]);

        sc.close();
    }    
}


Measured memory_bytes: 52744
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	int N, A, B;
	int min, max;
	cin >> N >> A >> B;

	min = A * (N - 1) + B;
	max = B * (N - 1) + A;
	int ans = max - min + 1;
	
	if (ans < 0)ans = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def main():

    while True:
        try:

            a, b = map(int, input().split())
            print(euclid_algorithm(a, b))

        except EOFError as e:
            break

def euclid_algorithm(a, b):

    while a and b:

        if a > b:
            a = a - b
        else:
            b = b - a

    return a if a else b

if __name__ == '__main__':
    main()

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

int n;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	map<int, string> mp;
	mp[0] = "pon";
	mp[1] = "pon";
	mp[2] = "hon";
	mp[3] = "bon";
	mp[4] = "hon";
	mp[5] = "hon";
	mp[6] = "pon";
	mp[7] = "hon";
	mp[8] = "pon";
	mp[9] = "hon";
	cout << mp[n % 10];
	return 0;
}
//10-09-2020 21:20:37

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
    long long int i,n,max,sum,min,input;

    cin >> n;
    cin >> max;
    sum=min=max;

    for(i=2;i<=n;i++)
    {
        cin >> input;
        if(input>=max)
        max=input;
        if(input<=min)
        min=input;
        sum=sum+input;


    }

    cout<< min << " " << max << " " << sum << endl;


}


Measured memory_bytes: 3116