akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(LL i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; 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;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  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の根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  LL n;
  cin >> n;
  vector<LL> v;
  rep(i,0,n){
    LL a;
    cin >> a;
    v.pb(a);
  }
  sort(all(v));
  reverse(all(v));
  LL b = 1;
  rep(i,0,n-1){
    b *= 4;
    b %= MOD;
  }
  LL res = 0;
  rep(i,0,n){
    LL c = 2*b;c%=MOD;
    LL d = b*i;d%=MOD;
    res += v[i] * (c + d);
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2420
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    
    (k, n) = [int(e) for e in lines[0].split(" ")]
    a = [int(e) for e in lines[1].split(" ")]

    return (k, n, a)


def solve(k, n, a):


    result = k+1
    for i in range(n):
        
        if a[i-1] < a[i]:
            right_dist = k - a[i] + a[i-1]
        else:
            right_dist = a[i-1] - a[i]
        
        if debug:
            log("%d, %d, %d" % (i, n, (i+1) % n))
        if a[i] < a[(i+1) % n]:
            left_dist = a[i] + k - a[(i+1) % n]
        else:
            left_dist = a[i] - a[(i+1) % n]
        
        result = min([result, right_dist, left_dist])
    
    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1<<20][2];
int list[100001][20];
int n,m,r,w;
int find(int a,int b,int t){
	//a~b?????????t??§???????????°????????°?????????
	return b-a-(list[b][t]-list[a][t]);
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)list[0][i]=0;
	for(int i=0;i<n;i++){
		cin>>r;
		for(int j=0;j<m;j++)list[i+1][j]=list[i][j];
		list[i+1][r-1]++;
	}
	w=1;
	for(int i=0;i<m;i++)w*=2;
	for(int i=0;i<w;i++)dp[i][0]=1145141919;
	dp[0][0]=0,dp[0][1]=0;

	for(int i=0;i<w;i++){
		bool will[20]={false};//????????§???????????????
		int e=1;
		for(int j=0;j<m;j++){
			if(i%(e*2)<e)will[j]=true;
			e*=2;
		}

		e=1;
		for(int j=0;j<m;j++){
			if(will[j]){
				dp[i+e][1]=dp[i][1]+list[n][j];
				dp[i+e][0]=min(dp[i+e][0],dp[i][0]+find(dp[i][1],dp[i+e][1],j));
			}
			e*=2;
		}
	}
	cout<<dp[w-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 19100
n= int( input() )
ss= [ input() for i in range(n) ]
 
ea=0
sb=0
easb=0
cnt= 0
for s in ss:
    cnt+= s.count("AB")
    la= s[-1]=="A"
    lb= s[ 0]=="B"
    if la: ea+=1
    if lb: sb+=1
    if la and lb: easb+=1
#
tot= cnt+min(ea,sb)
if ea==sb==easb and easb>0: tot-=1
print( tot )


Measured memory_bytes: 3700
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(N),
    N =:= 1 -> f1 ; f2.

f1 :- 
    writeln("Hello World").

f2 :- 
    get_number(A),
    get_number(B),
    X is A + B,
    writeln(X).


Measured memory_bytes: 8156
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<vector<int>> f(h , vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if (i+j == 0) {
                f[0][0] = (s[0][0] == '#');
            }
            else {
                f[i][j] = inf;
                if (i > 0) chmin(f[i][j], f[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
                if (j > 0) chmin(f[i][j], f[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'));
            }
        }
    }

    cout << f[h-1][w-1] << endl;

    return 0;
}

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

using namespace std;

int main()
{
    vector<int> X;
    int x;

    for(;;){
        cin >> x;
        if(x == 0) break;
        X.push_back(x);
    }

    for(int i = 0; i < X.size(); i++){
        cout << "Case " << (i+1) << ": " << X.at(i) << endl;
    }

}


Measured memory_bytes: 3128
a, b = map(int, input().split())
x = []
y = []
for i in range(a):
    x.append(str(b))
for i in range(b):
    y.append(str(a))
x = "".join(x)
y = "".join(y)
dic = [x, y]
dic.sort()
print(dic[0])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 K, A, B;
  cin >> K >> A >> B;
  rep(i, A, B + 1){
    if(i%K==0){
      cout << "OK\n";
      return;
    }
  }
  cout << "NG\n";
}

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

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/
char s[123456];
int  a[123456];

string ss[] = { "dream", "dreamer", "erase", "eraser" };

int main() {

  scanf("%s",s);
  int len = strlen (s);

  a[0] = 1;

  REP(i,len){
    //DEB(a[i])
    if(a[i]){
        REP(j,4){
            //DEB(ss[j].size())
            int ok = 1;
            REP(k, ss[j].size()){
                //cout << ss[j][k] << " " << s[i+k] << endl;

                if(i+k >= len) {ok = 0; break; }
                if( ss[j][k]!= s[i+k] ){ok = 0; break; }
            }
            if(ok) a[i+ss[j].size()] = 1;
        }
    }

  }
  if (a[len]) cout << "YES" << endl;
  else cout << "NO" << endl;




  return 0;
}


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

/* macros */
#define inf 1e9
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define vt vector
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define tc int t;cin>>t;while (t--){solve();}
#define gtc int t;cin>>t;int TC=1;while (t--) {cout << "Case #" << TC << ": " << solve() << "\n";TC++;}
#define gvtc int t;cin>>t;int TC=1;while (t--) {cout << "Case #" << TC << ": "; vsolve(); TC++;}
#define notc solve();
#define newline cout << "\n";
#define mod 1000000007
#define ret return 0;
#define sz(x) (int)x.size();
#define rep(i,a,b) for(int i=a;i<b;i++)
#define srt(x) sort(x.begin(), x.end())
#define rsrt(x) sort(x.rbegin(), x.rend())

int power(int a,int n) {
    if (n == 0) {
        return 1;
    }
    if (n == 1) {
        return a;
    }
    
    int X = power(a, n/2);
    if (n&1) {
        int y = (X%mod * X%mod)%mod;
        return (y%mod * a%mod)%mod;
    }else {
        return (X%mod * X%mod)%mod;
    }
}

void solve() {
    int n;
    cin>>n;
    
    int x = power(10,n);
    int y = power(9,n);
    int z = power(8,n);
    
    y = (y%mod + y%mod)%mod;
    int ans = (x - y + mod )%mod;
    ans = (ans%mod + z%mod)%mod;
    cout << ans << "\n";
}

int32_t main(){
    fastio
    notc
    ret
}


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

using namespace std;

typedef long long ll;

const int MAXN = 16;

int N;
ll a[MAXN][MAXN], group[1 << MAXN], dp[1 << MAXN];

ll score(int mask) {
    if (dp[mask] == -1)
        for (int s = mask; s > 0; s = (s - 1) & mask)
            if ((mask | s) == mask)
                dp[mask] = max(dp[mask], group[s] + score(mask & ~s));
    return dp[mask];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> a[i][j];
    for (int mask = 0; mask < (1 << N); mask++)
        for (int i = 0; i < N; i++)
            for (int j = i + 1; j < N; j++)
                if ((mask & (1 << i)) && (mask & (1 << j)))
                    group[mask] += a[i][j];
    memset(dp, -1, sizeof dp);
    dp[0] = 0;
    cout << score((1 << N) - 1) << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


int main(){
  ll n, x, P;
  ll Q = 1, T = 1;
  vector<ll> tbl(200000, -1);//x^2^i mod P
  std::cin >> n >> x >> P;
  if(x==0){
    std::cout << 0 << '\n';
    return 0;
  }

  T = x;
  ll st = -1;
  ll O = -1;
  for(;;Q++){
    if(tbl[T]!=-1){
      Q -= tbl[T];
      st = tbl[T];
      O = T;
      break;
    }
    tbl[T] = Q;
    T *= T;
    T %= P;
  }
  if(tbl[0]!=-1){
    ll lim = tbl[0];
    ll ans = 0;
    ll t = x;
    for(int i=0;i<min(lim, n);i++){
      ans += t;
      t = (t * t)%P;
    }
    std::cout << ans << '\n';
    return 0;
  }


  ll num = (n - st + 1) / Q;
  ll amari = (n - st + 1) % Q;
  ll cnt = 0;
  ll ans = 0;
  T = O;
  for(int i=0;i<Q;i++){
    cnt += T;
    T *= T;
    T %= P;
  }
  T = O;
  for(int i=0;i<amari;i++){
    ans += T;
    T *= T;
    T %= P;
  }
  T = x;
  for(int i=0;i<st-1;i++){
    ans += T;
    T *= T;
    T %=P;
  }
  std::cout << ans + num * cnt << '\n';
}


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    int ac=0,wa=0,tle=0,re=0;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        ac++;
        if(s=="WA")
        wa++;
        if(s=="TLE")
        tle++;
        if(s=="RE")
        re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
    

}

Measured memory_bytes: 3656
K=int(input())

def gcd(a,b):
    if b>a:
        a,b=b,a
    while a%b!=0:
        a,b=b,a%b
    return b

ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        X=gcd(a,b)
        for c in range(1,K+1):
            ans+=gcd(X,c)
print(ans)

Measured memory_bytes: 68648
#include <iostream>
#define inf (1LL<<60)
#define nmax 100000
using namespace std;
long long dp[nmax + 5];

int main()
{
    int i, j, n, w, we, va;
    cin >> n >> w;

    for (j = 1; j <= nmax; j++)
        dp[j] = inf;

    for (i = 1; i <= n; i++) {
        cin >> we >> va;
        for (j = nmax - va; j >= 0; j--)
            dp[j + va] = min(dp[j + va], dp[j] + we);
    }

    long long sol = 0;
    for (j = 0; j <= nmax; j++)
        if (dp[j] <= w)
            sol = j;

    cout << sol << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(void)
{
	int a,b,c;
	cin >> a >> b >> c;
	int ans;
	if(a<=b)
	{
		if(b<=c)
			ans=10*c+a+b;
		else
			ans=10*b+a+c;
	}
	else
	{
		if(a<=c)
			ans=10*c+a+b;
		else
			ans=10*a+b+c;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int n, k; cin >> n >> k;
  vi as(n); F0R (i, n) cin >> as[i];
  for (int i = 1; i + k - 1 < n; ++i) {
    cout << (as[i - 1] < as[i + k - 1] ? "Yes" : "No") << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3972
X = int(input())
for i in range(1,int(X**0.5)+1):
    if X%i==0:
        a = i
        b = X//i
        flag = 0
        for j in range(-1000,1000):
            B = j
            A = j+a
            if A**4+A**3*B+A**2*B**2+A*B**3+B**4==b:
                print(A,B)
                flag = 1
                break
        if flag==1:break
        a = X//i
        b = i
        flag = 0
        for j in range(1,1000):
            B = j
            A = j+a
            if A**4+A**3*B+A**2*B**2+A*B**3+B**4==b:
                print(A,B)
                flag = 1
                break

Measured memory_bytes: 68288
double P[102][101];char L[101],B[101];N,T,l,b,t,n,k;main(x){for(;scanf("%d%d%d%d",&N,&T,&l,&b),N;printf("%f\n",P[T][N])){
for(n=0;n<=N;n++)for(L[n]=B[n]=t=0;t<=T;t++)P[t][n]=0;
for(;l--;)scanf("%d",&x),L[x]=1;
for(;b--;)scanf("%d",&x),B[x]=1;
for(P[t=0][0]=1;t<T;P[t+1][N]+=P[t][N],t++)for(n=0;n<N;n++)for(k=1;k<=6;x=B[x]?0:x,P[t+1+L[x]][x]+=P[t][n]/6,k++)if(x=n+k,x>N)x=2*N-x;
}exit(0);}

Measured memory_bytes: 716
# coding: utf-8
# Your code here!
#D流用したので文字滅茶苦茶
N,M=map(int,input().split())

dp=[10**10]*2**N
dp[0]=0

for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    
    can_open=sum([2**(c[i]-1) for i in range(len(c))])
    
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open])


if dp[-1]==10**10:
    print(-1)
else:
    print(dp[-1])


Measured memory_bytes: 75936
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

d = inp()
c = inpl()
s = [inpl() for _ in range(d)]
res = 0
last = [0]* 26
for day in range(d):
    t = inp(); t -= 1
    res += s[day][t]
    for i in range(26):
        last[i] += 1
        if i == t:
            last[t] = 0
        res -= c[i] * last[i]
    print(res)

Measured memory_bytes: 79372
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int l, r; cin >> l >> r;
	int d = (l + 2018) / 2019;
	d *= 2019;
	if (l <= d && d <= r) {
		cout << 0 << endl; return;
	}
	else {
		int ans = mod;
		Rep1(i, l, r) {
			Rep1(j, i + 1, r) {
				int le = i % 2019;
				int ri = j % 2019;
				ans = min(ans, le*ri%2019);
			}
		}
		cout << ans << endl;
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}

Measured memory_bytes: 256
def main():
    from itertools import product
    n, s = int(input()), input()

    r, g, b = 0, 0, 0
    for x in s:
        if x == "R":
            r += 1
        if x == "G":
            g += 1
        if x == "B":
            b += 1

    ans = r * g * b
    rgb = {"R", "G", "B"}
    for i in range(1, n // 2 + 1):
        for j in range(i):
            x = s[j::i]
            for a, b, c in zip(x, x[1:], x[2:]):
                g = {a, b, c}
                if g == rgb:
                    ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include <stdio.h>

int main(){

  int i,j,tmp;
  int num[10];

  for(i=0;i<10;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(num[i]<num[j]){
        tmp=num[i];
        num[i]=num[j];
        num[j]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",num[i]);
  }
  return 0;
}


Measured memory_bytes: 600
for i in range(int(raw_input())):
    s = raw_input()
    for a in range(1, 1000):
        for b in range(26):
            def f(s, a, b):
                return ''.join([chr(((ord(c) - ord('a')) * a + b) % 26 + ord('a')) for c in s])
            if f('that', a, b) in s or f('this', a, b) in s:
                dic = dict([(chr((i * a + b) % 26 + ord('a')), chr(i + ord('a'))) for i in range(26)])
                print ''.join([dic.get(c, c) for c in s])
                break
        else:
            continue
        break

Measured memory_bytes: 4256
N=int(input())
A=list(map(int,input().split(" ")))
A_p = [ a for a in A if a > 0 ]
A_n = [ -1*a for a in A if a < 0 ]
A_0 = [ a for a in A if a == 0 ]

l_p = len(A_p)
l_n = len(A_n)
l_0 = len(A_0)

if l_p == 0:
    if l_n%2 == 0:
        print(sum(A_n+[0]))
    elif l_0 > 0:
        print(sum(A_n+[0]))
    else:
        tmp_n=min(A_n)
        A_n.remove(tmp_n)
        print(sum(A_n+[0])-tmp_n)
elif l_n == 0:
    print(sum(A_p+[0]))

elif l_n%2 == 0:
    print(sum(A_p)+sum(A_n))
else:
    if l_0 > 0:
        print(sum(A_p)+sum(A_n))
    else:
        if min(A_n) > min(A_p):
            tmp_n=min(A_p)
            A_p.remove(tmp_n)
            print(sum(A_p)+sum(A_n)-tmp_n)    
        else:
            tmp_n=min(A_n)
            A_n.remove(tmp_n)
            print(sum(A_p)+sum(A_n)-tmp_n)

Measured memory_bytes: 14412
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , a[ N ];
void init(){
  n = getint();
  for( int i = 1 ; i <= n ; i ++ )
    a[ i ] = getint();
}
void solve(){
  LL ans = 0;
  for( int i = 1 ; i <= n ; i ++ ){
    ans += a[ i ] / 2;
    a[ i ] %= 2;
    if( a[ i ] && a[ i + 1 ] ){
      ans ++;
      a[ i + 1 ] --;
    }
  }
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using node = pair<int, int>;
const int inf = numeric_limits<int>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n,c;
  cin >> n >> c;
  vector< vector<node> > v;
  v.resize(c);
  for(int i = 0;i < n;++i){
    int s,t,j;
    cin >> s >> t >> j;
    --j;
    v[j].push_back(node(2*s,2*t));
  }
  for(int i = 0;i < c;++i)
    sort(v[i].begin(),v[i].end());
  vector< node > v2;
  for(int i = 0;i < c;++i){
    if(v[i].empty())
      continue;
    int prevs = v[i][0].first;
    int prevt = v[i][0].second;
    for(int j = 1;j < (int)v[i].size();++j){
      if(v[i][j].first == prevt){
        prevt = v[i][j].second;
      }else{
        v2.push_back(node(prevs,prevt));
        prevs = v[i][j].first;
        prevt = v[i][j].second;
      }
    }
    v2.push_back(node(prevs,prevt));            
  }
  sort(v2.begin(),v2.end());
  priority_queue<int, vector<int>, greater<int>> que;
  que.push(v2[0].second);
  int res = 1;
  for(int i = 1;i < (int)v2.size();++i){
    if(que.top() > v2[i].first-1){
      ++res;
    }else{
      que.pop();
    }
    que.push(v2[i].second);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2552
#include<stdio.h>
#include<stdlib.h>
int dsc(const void *a,const void *b) {

    long *x = (long *) a;
    long *y = (long *) b;

    return *y - *x;
}
long main()
{
    long x,y,a,b,c,i;
    scanf("%ld %ld %ld %ld %ld", &x,&y,&a,&b,&c);
    long p[a],q[b],r[c],res[a+b+c];
    for(i=0;i<a;i++){
        scanf("%ld", &p[i]);
    }
    for(i=0;i<b;i++){
        scanf("%ld", &q[i]);
    }
    for(i=0;i<c;i++){
        scanf("%ld", &r[i]);
    }

    qsort(p,a,sizeof (long),dsc);
    qsort(q,b,sizeof (long),dsc);
    qsort(r,c,sizeof (long),dsc);

    for(i=0;i<x+y+c;i++){
        if(i<x){
            res[i] = p[i];
        }
        else if(i-x<y){
            res[i] = q[i-x];
        }
        else if(i-x-y<x+y+c){
            res[i] = r[i-x-y];
        }
    }
    qsort(res,x+y+c,sizeof (long),dsc);
    long sum=0;
    for(i=0;i<x+y;i++){
        sum+= res[i];
    }

    printf("%ld\n", sum);

    return 0;
}


Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
const int N = 405;
const int lg = 17;
const int mod = (int)1e9 + 7;
long long f(long long n,long long b){
    if(n == 0)return 0;
    return f((n / b), b) + (n % b);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n,s;
	cin >> n >> s;
	long long ans = (long long)1e18;
	if(n == s){
	    cout << n + 1,exit(0);
	}
	if(n <= 10){
	    for(long long b = 2;b <= 1000;b++){
	        if(f(n, b) == s){
	            ans = min(ans, b);
	        }
	    }
	}
	for(long long i = 2;i * i <= n;++i){
	    if(f(n, i) == s){
	        ans = min(ans, i);
	    }
	}
	for(long long i = 1;i * i <= (n - s);++i){
	    if((n - s) % i == 0){
	        long long b1 = i + 1;
	        long long b2 = ((n - s) / i) + 1;
	        if(f(n, b1) == s){
	            ans = min(ans, b1);
	        }
	        if(f(n, b2) == s){
	            ans = min(ans, b2);
	        }
	    }
	}
	if(ans == (long long)1e18)cout << -1; else cout << ans;
  	return 0;
} 

Measured memory_bytes: 3620
#include<iostream>
#include<set>
using namespace std;
#define df 0

int main(){
  if(df) printf("*debug mode*\n");
  int n,k; cin >>n >>k;
  int p[n];
  for(int i=0;i<n;i++){
    cin >>p[i];
  }

  set<int> s;
  for(int i=0;i<k;i++){
    s.insert(p[i]);
  }
  if(df){
    printf("s: ");
    for(int x: s){ printf("%d ",x); }
    printf("\n");
  }
  int a=0,cnt=1;
  for(int i=k;i<n;i++,a++){
    if(df)printf("%d %d\n",*(s.begin()),*(s.rbegin()));
    if(*(s.begin())==p[a] && *(s.rbegin())<p[i]){cnt--;}
    cnt++;
    s.erase(p[a]);
    s.insert(p[i]);
  }
  int dup=0,inc=1;
  for(int i=1;i<n;i++){
    if(p[i-1]<p[i]) inc++;
    else inc=1;
    if(df)printf("%d ",inc);
    if(inc==k)dup++;
  }
  dup--;
  if(df)printf("\n%d\n",dup);
  if(dup>0)cnt-=dup;
  cout << cnt;
}

/// confirm df==0 ///


Measured memory_bytes: 10368
def selectionSort(arr)
  count = 0
  arr.size.times do |i|
    mini_j = i
    i.upto(arr.size - 1) do |j|
      mini_j = j if arr[j] < arr[mini_j]
    end

    if mini_j != i
      arr[i], arr[mini_j] = arr[mini_j], arr[i]
      count += 1
    end
  end
  count
end

n = gets.to_i
arr = gets.split.map(&:to_i)

count = selectionSort(arr)
puts arr.join("\s")
puts count

Measured memory_bytes: 8652
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MOD = (int) 1e9 + 7;
const int MAXN = 3000;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) {
            ans = (1LL * ans * a) % MOD;
        }
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

int arr[MAXN + 1];

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

int dp[MAXN + 1][MAXN + 1], aux[MAXN + 1][MAXN + 1];
int last[MAXN + 1][MAXN + 1], p2[MAXN + 1], now;

inline void add(int l1, int c1, int l2, int c2) {
    if(last[l1][c1] < now) {
        dp[l1][c1] += aux[l1][c1];
        mod(dp[l1][c1]);
        aux[l1][c1] = 0;
        dp[l1][c1] = (1LL * dp[l1][c1] * p2[now - last[l1][c1] - 1]) % MOD;
        last[l1][c1] = now;
    }
    if(last[l2][c2] < now) {
        dp[l2][c2] += aux[l2][c2];
        mod(dp[l2][c2]);
        aux[l2][c2] = 0;
        dp[l2][c2] = (1LL * dp[l2][c2] * p2[now - last[l2][c2] - 1]) % MOD;
        last[l2][c2] = now;
    }
    aux[l2][c2] += dp[l1][c1];
    mod(aux[l2][c2]);
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, q;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> q;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= n; j++) {
            dp[i][j] = (arr[i] > arr[j]);
        }
    }
    p2[0] = 1;
    for(i = 1; i <= q; i++) {
        p2[i] = p2[i - 1] * 2;
        mod(p2[i]);
    }
    while(q > 0) {
        q--;
        int x, y;
        cin >> x >> y;
        now++;
        for(i = 1; i <= n; i++) {
            if(i != x && i != y) {
                add(x, i, y, i);
                add(i, x, i, y);
                add(y, i, x, i);
                add(i, y, i, x);
            }
        }
        add(x, y, y, x);
        add(y, x, x, y);
    }
    int ans = 0;
    for(i = 1; i <= n; i++) {
        for(j = i + 1; j <= n; j++) {
            dp[i][j] += aux[i][j];
            mod(dp[i][j]);
            dp[i][j] = (1LL * dp[i][j] * p2[now - last[i][j]]) % MOD;
            ans += dp[i][j];
            mod(ans);
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}



Measured memory_bytes: 105856
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int N, Q;
string S;
string T;
string D;
map<char, int> M;


bool isOK(int m, char d){
    if(d=='R'){
        for(int i=0; i<Q; i++){
            if(T[i]==S[m]) m += M[D[i]];
            if(m < 0) return true;
        }
        return false;
    }
    
    for(int i=0; i<Q; i++){
        if(T[i]==S[m]) m += M[D[i]];
        if(m > N-1) return true;
    }
    return false;
}


int solveR(){
    int ok = -1;
    int ng = N;
    while(abs(ok-ng) > 1){
        int mid = (ok + ng) / 2;
        
        if(isOK(mid, 'R')) ok = mid;
        else ng = mid;
    }
    return ok;
}

int solveL(){
    int ok = N;
    int ng = -1;
    while(abs(ok-ng) > 1){
        int mid = (ok + ng) / 2;
        if(isOK(mid, 'L')) ok = mid;
        else ng = mid;
    }
    return ok;
}


int main() {
    cin >> N >> Q;
    cin >> S;
    T.resize(Q);
    D.resize(Q);
    M['R'] = 1;
    M['L'] = -1;
    
    for(int i=0; i<Q; i++)
        cin >> T[i] >> D[i];
    
    int r_mx = solveR();
    int l_mn = solveL();
    
    cout << l_mn - r_mx - 1 << endl;
    return 0;
}


Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言

int main()
{
	int h, w, k;
	cin >> h >> w >> k;

	int i, j;
	vector<vector<char>>c(6, vector<char>(6));
	vector<int>a(6);
	vector<int>b(6);
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			cin >> c.at(i).at(j);
			if (c.at(i).at(j) == '#')
			{
				a.at(i)++;
				b.at(j)++;
			}
		}
	}
	int cnt = 0;
	
	

	int sum=0;
	for (i = 0; i < pow(2, h); i++) {
		for (j = 0; j < pow(2, w); j++)
		{
			for (int f = 0; f < h; f++)
			{
				for (int g = 0; g < w; g++)
				{
					if ((((i >> f) & 1) && ((j >> g) & 1)) && c.at(f).at(g) == '#')
					{
						sum++;
					}
				}
			}
			if (sum == k)cnt++;
			sum = 0;
		}
	}
	cout << cnt << endl;

	
}



/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 4104
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll N, T, A;
    cin >> N;
    cin >> T >> A;
    ll* H = new ll[N];
    
    ll resultNum = 0;
    double resultDiff = 10000000000;
    
    for(ll i = 0; i < N; i ++){
        cin >> H[i];
        double temp = T - H[i] * 0.006;
        if(resultDiff > abs(A - temp)){
            resultDiff = abs(A - temp);
            resultNum = i + 1;
        }
    }

    cout << resultNum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  
  int ans = 0, d;
  for(int i=1; i <= n; i++){
	int tmp = 0;
    d = i;
    for(int j = 0; j < 5; j++){
      tmp += d%10;
      d /= 10;
    }
    if(a <= tmp && b >= tmp){
      ans += i;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	nums := scanNums(n)

	dist := nums[0] + k - nums[n-1]

	for i := 0; i < n-1; i++ {
		diff := nums[i+1] - nums[i]
		if diff > dist {
			dist = diff
		}
	}

	fmt.Println(k - dist)
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

int main(void) {
	int n,a[100];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	bool flag = true;
	int cnt = 0;
	while(flag) {
		flag = false;
		for(int j = n-1;j > 0;j--) {
			if(a[j]<a[j-1]) {
				swap(a[j],a[j-1]);
				flag = true;
				cnt++;
			}
		}
	}
	for(int i = 0;i < n-1;i++) cout << a[i] << " ";
	cout << a[n-1] << endl << cnt << endl;
}



Measured memory_bytes: 3084
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,a,b = mi()
ans = 0
ans += (n//(a+b)) * a
tmp = n % (a+b)
tmp2 = min(a,tmp)
ans += tmp2
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int K = sc.nextInt();
      	int X = sc.nextInt();
      
      if(K * 500 >= X) System.out.println("Yes");
      else System.out.println("No");
    }
}

Measured memory_bytes: 22996
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll n, m, q, a[100000], cnt = 0, cnt2 = 0, h;
bool b[7][200000];

int dfs(int x, int y) {
	b[x][y] = false;
	if (x != 0 && b[x - 1][y])
		dfs(x - 1, y);
	if (x != 6 && b[x + 1][y])
		dfs(x + 1, y);
	if (y != 0 && b[x][y - 1])
		dfs(x, y - 1);
	if (y != h - 1 && b[x][y + 1])
		dfs(x, y + 1);
	return 0;
}

int main() {
	cin >> n >> m >> q;
	rep(q)
		cin >> a[i];
	if (m % 7) {
		rep(7)
			REP(200000, j)
				b[i][j] = true;
		rep(q) {
			REP(7, j) {
				b[(a[i] + m*j) % 7][(a[i] + m*j) / 7] =false;
			}
		}
		h = m;
		rep(m * 7) {
			if (b[i % 7][i / 7]) {
				++cnt;
				dfs(i % 7, i / 7);
			}
		}
		rep(7)
			REP(200000, j)
				b[i][j] = true;
		rep(q) {
			REP(14, j) {
				b[(a[i] + m*j) % 7][(a[i] + m*j) / 7] = false;
			}
		}
		h = m * 2;
		rep(m * 14) {
			if (b[i % 7][i / 7]) {
				++cnt2;
				dfs(i % 7, i / 7);
			}
		}
		cout << cnt + (cnt2 - cnt)*(n / m - 1) << endl;
		return 0;
	}
	else {
		rep(7)
			REP(200000, j)
				b[i][j] = true;
		rep(q) {
			b[a[i] % 7][a[i] / 7] = false;
		}
		h = m / 7;
		rep(m) {
			if (b[i % 7][i / 7]) {
				++cnt;
				dfs(i % 7, i / 7);
			}
		}
		rep(7)
			REP(200000, j)
				b[i][j] = true;
		rep(q) {
			REP(2, j) {
				b[(a[i] + m*j) % 7][(a[i] + m*j) / 7] = false;
			}
		}
		h = m * 2 / 7;
		rep(m * 2) {
			if (b[i % 7][i / 7]) {
				++cnt2;
				dfs(i % 7, i / 7);
			}
		}
		cout << cnt + (cnt2 - cnt)*(n * 7 / m - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> hs(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> hs[i];
    }
    sort(hs.begin(), hs.end());

    ll ans = 0;
    for (int i = 0; i < n - k; i++) {
        ans += hs[i];
    }

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

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()



int problemA()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemA();

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 256
fn read_multi<T: std::str::FromStr>() -> Vec<T> {
    let mut s = std::string::String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    //println!("Hello, world!");
    let vn: Vec<i32> = read_multi(); //i32
    //println!("{:?}", vn);

    if vn[1] == 100 {
        println!("{}", 100_i32.pow(vn[0] as u32) * 101);
    } else {
    let res: i32 = 100_i32.pow(vn[0] as u32) * vn[1];
    println!("{}", res);
    }
}


Measured memory_bytes: 2112
#include<cstdio>
#include<cstdlib>
#include<algorithm> 
#include<cmath>
#include<cstring>
using namespace std;

int getnum()
{
   char c=getchar();
   int num=0;
   while(c>'9' || c<'0') c=getchar();
   while(c<='9' && c>='0') num=num*10+c-'0',c=getchar();
   return num;
}

int main()
{
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  printf("%d\n",min(n*a,b));
} 

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n, maxw;
    cin >> n >> maxw;
    int w[n];
    int v[n];
    int sumv = 0;
    rep(i, 0, n) {
        cin >> w[i] >> v[i];
        sumv += v[i];
    }
    const int inf = 1000000000 + 1;
    vi dp(sumv + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = sumv - v[i]; j >= 0 ; j--) {//if reversed 0/n knapsack
            dp[j + v[i]] = min(dp[j + v[i]], w[i] + dp[j]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= sumv; i++) {
        if (dp[i] <= maxw) {
            ans = max(i, ans);
        }
    }
    cout << ans << endl;

    // cout << "hello";
    return 0;
}

Measured memory_bytes: 3968