akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if(a1*t1 + a2*t2 > b1*t1 + b2*t2){
    swap(a1,b1);
    swap(a2,b2);
  }else if(a1*t1 + a2*t2 == b1*t1 + b2*t2){
    cout << "infinity" << endl;
    return 0;
  }
  ll ans ;
  if(a1 < b1){
    cout << 0 << endl;
    return 0;
  }else{
    ll one_period = (b1*t1 + b2*t2) - (a1*t1 + a2*t2);
    ll half_period = a1*t1 - b1*t1;
    if(half_period % one_period ==0){
      ans = (half_period / one_period) * 2;
    }else{
      ans = (half_period / one_period) *2 + 1;
    }
    cout << ans << endl;     
  }
}

Measured memory_bytes: 256
#include <stdio.h>

char A(char q[100],int a);
char B(char w[100],int s);
char C(char e[100],int d);


int main() {

char a[100],b[100],c[100],ans,result;
int i,j,k;
 i=j=k=0;

scanf("%s %s %s",a,b,c);

ans = A(a,i);
i++;

while(ans != '\0'){
if(ans == 'a'){
ans = A(a,i);
i++;
result = 'A';
}
else if(ans == 'b'){
ans = B(b,j);
j++;
result='B';
}
else {
ans = C(c,k);
k++;
result='C';
}}

printf("%c",result);

return 0;
}

char A(char a[100],int i){
char q;
q = a[i];
return q;
}

char B(char b[100],int j){
char q;
q = b[j];
return q;
}

char C(char c[100],int k){
char q;
q = c[k];
return q;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

ll dp[100001];

int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl h(n);
    rep(i,n){
        cin>>h[i];
        if(i>0) dp[i] = inf;
        if(i>0) dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = MAX(0, s - 2 * k); x <= k; ++x)
    {
        ans += (s - x >= k ? 2 * k + x - s + 1 : MAX(0, s - x + 1));
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.*

fun findFloodsEndIndex(region: String, index: Int): Int {
    // 下り斜面までskip
    var findIndex = region.indexOf("\\", index)
    // 下り斜面がなかったら終了
    if (findIndex == -1) {
        return findIndex
    }
    // 下り斜面開始位置と同じ高さ or 一番高い上り斜面の終わり位置を返す
    findIndex++
    var depth = 1
    var minDepth = Int.MAX_VALUE
    var endIndex = -1
    while (findIndex < region.length) {
        if (region[findIndex] == '\\') {
            depth++
        } else if (region[findIndex] == '/') {
            depth--
            if (depth < minDepth) {
                endIndex = findIndex
                minDepth = depth
            }
        }
        if (depth == 0) {
            return findIndex
        }
        findIndex++
    }
    return endIndex
}

fun calcFloodsArea(region: String, index: Int): Int {
    var area = 0.0
    var depth = 0
    for (i in index downTo 0) {
        when(region[i]) {
            '/' -> {
                area += depth
                depth++
                area += 0.5
            }
            '\\' -> {
                area += 0.5
                depth--
                area += depth
            }
            else -> {
                area += depth
            }
        }
        if (depth == 0) {
            break
        }
    }
    return area.toInt()
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val region = scanner.nextLine()
    val floodsAreas = mutableListOf<Int>()

    var index = 0
    while (index < region.length) {
        // 水たまりの最後の位置を返す
        index = findFloodsEndIndex(region, index)
        // 水たまりが見つからなかった場合は終了
        if (index == -1) {
            break
        }
        // 水たまりの面積を算出
        floodsAreas.add(calcFloodsArea(region, index))
        index++
    }
    println(floodsAreas.sum())
    print(floodsAreas.size)
    if (floodsAreas.size > 0) {
        println(" " + floodsAreas.joinToString(" "))
    } else {
        println()
    }
}


Measured memory_bytes: 30644
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: usize,
        s: chars,
    );
    if n % 2 != 0 {
        println!("No");
        return;
    }
    let half = n / 2;
    for i in 0..half {
        if s[i] != s[i+half] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;
const int M = 1e9 + 7;

int power(int a, int b) {
	if (b == 0)
		return 1;
	int sml = power(a, b / 2);
	int ans = (sml * sml) % M;
	if (b % 2 == 0)
		return ans;
	return (ans * a) % M;
}

int32_t main()
{
	GO;
	int n;
	cin >> n;
	int ans = power(10, n);
	int value = (2 * power(9, n)) % M;
	ans = (ans - value + 3 * M) % M;
	ans = (ans + power(8, n)) % M;
	// int ans = (power(9, n) - (2 * power(8, n)) % M + power(7, n) + 3 * M) % M;
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3644
main()
{
    char S[100001],tmp[100001];
    int i=0, ans=0, l, j=0, k=0;
    scanf("%s", S);
    
    l=strlen(S);
    for(i=0;i<l;i++)
    {
        if(S[i]=='0')j++;
        if(S[i]=='1')k++;
    }
    
    printf("%d",j+k>=2?l-abs(j-k):0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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

   for (int n = 0; n <= N; n++) {
      for (int m = 0; m <= M; m++) {
         if (K == n * M + m * N - 2 * n * m) {
            cout << "Yes" << endl;
            return 0;
         }
      }
   }
   cout << "No" << endl;
   return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A == B){
    cout << "Draw" << endl;
  }
  else if(A == 1){
    cout << "Alice" << endl;
  }
  else if(B == 1){
    cout << "Bob" << endl;
  }
  else if(A > B){
cout << "Alice" << endl;
  }
else if(A < B){
cout << "Bob" << endl;
}
}


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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll k;
    cin >> k;
    int cnt = 1;
    ll shift = 7;
    while(cnt <= k+10) {
        shift = shift % k;
        if(shift == 0) { cout << cnt << endl; return 0; }
        shift = shift * 10 + 7;
        cnt++;
    }
    cout << "-1" << endl;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main ()
{
    cin.sync_with_stdio(0);
    ll n, d; cin >> n >> d;
    //vector<pll> ps (n);
    ll c = 0;
    FOR (i, 0, n)
    {
        ll x, y;
        cin >> x >> y;
        if ((x*x + y*y) <= d*d) c ++;
    }
    cout << c << endl;
} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 3644
def solve(s):
    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            return '%d %d' % (i+1, i+2)

    for i in range(len(s) - 2):
        if s[i] == s[i+2]:
            return '%d %d' % (i+1, i+3)

    return '-1 -1'

s = input()
print(solve(s))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

    set<int> s1, s2;

    for(int i = 0; i <= f; i++){
        for(int j = 0; j <= f; j++){
            int x = (100*a)*i + (100*b)*j;
            if (x != 0 && x <= f) s1.insert(x);
        }
    }

    for(int i = 0; i <= f; i++){
        for(int j = 0; j <= f; j++){
            int x = c*i + d*j;
            if (x <= f) s2.insert(x);
        }
    }

    double maxN = -1;
    int ans1 = 0, ans2 = 0;
    for(int w: s1){
        for(int s: s2){
            if (w+s <= f && s <= (w/100)*e){
                double n = ((double)100*s) / (w+s);
                if (chmax(maxN, n)){
                    ans1 = w + s;
                    ans2 = s;
                }
            }
        }
    }
    printf("%d %d\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 3832
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long sum = 0;
    ArrayList<Integer> nth = new ArrayList<Integer>();
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      nth.add(a);
      sum += nth.get(i);
    }
    int min = nth.get(0);
    for (int i = 1; i < n; i++) {
      min = Math.min(min, nth.get(i));
    }
    int max = nth.get(0);
    for (int i = 1; i < n; i++) {
      max = Math.max(max, nth.get(i));
    }

    System.out.println(min + " " + max + " " + sum);

    sc.close();
  }
}



Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,t,c,ti,i;
  vector<P> r;
  cin >> n >> t;
  for (i=0;i<n;i++){
    cin >> c >> ti;
    r.push_back(P(c,ti));
  }
  sort(r.begin(),r.end());
  for (i=0;i<n;i++) if (r.at(i).second<=t) break;
  if (i==n) cout << "TLE" << endl;
  else cout << r.at(i).first << endl;
  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()




void solve() {
	ll n, s = 0; cin >> n;
	ll a[n];
	fr(i, 0, n)cin >> a[i];
	fr(i, 1, n) {
		if (a[i] <= a[i - 1]) {
			s += (a[i - 1] - a[i]);
			a[i] = a[i - 1];
		}
	}
	cout << s;
}





int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ":\n";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}






Measured memory_bytes: 5208
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

vector<string> weeks = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int mm,dd;
void solve() {
    int day = 2;
    for(int i=1;i<mm;i++) day += month[i-1];
    day += dd;
    day %= 7;
    cout<<weeks[day]<<endl;

}
int main() {
    while(cin>>mm>>dd) {
        if(mm+dd==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define inf 2e9
using namespace std;

int main(int argc, char **argv){
    int n;
    cin >>n;
    cout<<3*n*n<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
    const int INF = 100000;
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<tuple<int, int, int>> abc;
    for (int n = 0; n != N; ++n){
        int a, b, c;
        cin >> a >> b >> c;
        abc.emplace_back(make_tuple(a, b, c));
    }

    vector<vector<int>> dp(401, vector<int>(401, INF));
    dp[0][0] = 0;

    for (auto & elem : abc){
        int a, b, c;
        tie(a, b, c) = elem;
        for (int x = 400; x >= a; --x){
            for (int y = 400; y >= b; --y){
                if (dp[x][y] > dp[x - a][y - b] + c){
                    dp[x][y] = dp[x - a][y - b] + c;
                }
            }
        }
    }

    int maxK = min(400/Ma, 400/Mb);
    int min_cost = INF;
    for (int k = 1; k <= maxK; ++k){
        int x = k * Ma;
        int y = k * Mb;
        if (dp[x][y]) min_cost = min(min_cost, dp[x][y]);
    }
    if (min_cost == INF){
        cout << -1 << endl;
    }else{
        cout << min_cost << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll ZERO = 0;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        A--;
        vec.at(i) = A;
    }
    vector<int> cnt(N);
    for(int i = 0;i < N;i++) {
        cnt.at(vec.at(i)) = i;
    }
    int ret = 0;
    int cnt2 = 1;
    for(int i = 0;i < N - 1;i++) {
        if(cnt.at(i) < cnt.at(i + 1)) {
            cnt2++;
        }
        else {
            ret = max(ret,cnt2);
            cnt2 = 1;
        }
    }
    ret = max(ret,cnt2);
    cout << N - ret << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=a-i;j++)
		{
			int k=a-i-j;
			if(i*10000+j*5000+k*1000==b)
			{
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	cout<<"-1 -1 -1"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare(const void* x, const void* y){
  return *(int*)x-*(int*)y;
}

int main(){
  int N,K;
    scanf("%d%d",&N,&K);
  int h[N+1];
  int i;
  int dif=1000000000;

  for(i=0;i<N;i++) scanf("%d",&h[i]);

  qsort(h,N,sizeof(int),compare);

  for(i=0;i<=N-K;i++){
    if(h[i+K-1]-h[i]<dif) dif=h[i+K-1]-h[i];
  }

  printf("%d\n",dif);

  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
long long N,M,X;
long long ans;
int dataList[12][12];
int cList[12];

void dfs(vector<int> P){
    if(P.size() == N){
        long long now = 0;
        std::vector<long long> AList = std::vector<long long>(M);
        rep(i,N){
            if(P[i] == 0){continue;}
            now += cList[i];
            bool isOk = true;
            rep(j,M){
                AList[j] += dataList[i][j];
                if(AList[j] < X){
                    isOk = false;
                }
            }
            if(ans == 0 && isOk){ans = now;}
            if(isOk){
                ans = min(ans, now);
                return;
            }
        }
        return;
    }
    P.push_back(0);
    while(P.back() <= 1){
        dfs(P);
        P.back()++;
    }
}

int main(){
    cin >> N >> M >> X;
    vector<long long> A(M);
    long long sum = 0;
    rep(i,N){
        long long c;
        cin >> c;
        cList[i] = c;
        rep(j,M){
            long long temp;
            cin >> temp;
            dataList[i][j] = temp;
        }
    }
    ans = 0;
    dfs(vector<int>());
    if(ans == 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 3628
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>		
#include <stdio.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int n;
	cin >> n;
	vector<string> w(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	bool ok = true;
	for (int i = 0; i < n - 1; i++) {
		if (w[i][w[i].length() - 1] != w[i + 1][0]) {
			ok = false;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (w[i] == w[j]) {
				ok = false;
			}
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    int X, Y;
    cin >> X;
    Y = K - X;
    if (X > Y){
      sum += Y * 2;
    }
    else{
      sum += X * 2;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
cnt=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        cnt[b-1]+=1
    elif H[a-1]==H[b-1]:
        cnt[a-1]+=1
        cnt[b-1]+=1
    else:
        cnt[a-1]+=1
print(cnt.count(0))


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

using namespace std;

const int N = 300 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

bool req(long long n) {
    cout << "? " << n << endl;
    char res;
    cin >> res;
    return res == 'Y';
}

void solve() {
    auto cur = 1ll;
    bool flag = false;

    for (int i = 0; !flag && i < 15; cur = 10 * cur, ++i)
        if (!req(cur))
            flag = true;

    if (!flag) {
        cur = 1ll;

        for (int i = 0; i < 15; cur = 10 * cur, ++i)
            if (req(cur + 1)) {
                cout << "! " << cur << endl;
                return ;
            }

        assert(false);
    }

    cur = max(1ll, cur / 100);
    auto l = cur;
    auto r = cur * 10 - 1;

    for (; l < r; ) {
        auto m = (l + r) / 2;

        if (req(m * 10))
            r = m;
        else
            l = m + 1;
    }

    cout << "! " << r << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    return 0;
}



Measured memory_bytes: 596
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        d: usize,
    );

    println!("{}", (n + 2 * d) / (2 * d + 1));
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    string s;cin>>s;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<' '<<i+2<<endl;
            return 0;
        }
    }
    rep(i,s.size()-2){
        if(s[i]==s[i+2]){
            cout<<i+1<<' '<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 3692
#include<cstdio>
int sima(int x,int y);
char SIMA[14][14];
int main ()
{
    while(scanf("%s",SIMA[1]+1)!=EOF){
        int i,j,ans=0;
        for(i=2;i<13;i++){
            scanf("%s",SIMA[i]+1);
        }
        for(i=1;i<13;i++){
            for(j=1;j<13;j++){
                if(SIMA[j][i]=='1'){
                    ans+=sima(j,i);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
int sima(int x,int y)
{
    if(SIMA[x][y]=='0' || SIMA[x][y]==0) return 1;
    else SIMA[x][y]='0';
    return sima(x+1,y)*sima(x,y+1)*sima(x-1,y)*sima(x,y-1);
}

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

int main(){
    int m;
    cin >> m;
    for(int i=0; i<m; ++i){
        int result, amount, year, n, max = 0;
        cin >> amount;
        cin >> year;
        cin >> n;
        for(int j=0; j<n; ++j){
            int a = amount;
            int kind, t;
            double r;
            scanf("%d %lf %d", &kind, &r, &t);
            if(kind == 0){
                int b = 0;
                for(int k=0; k<year; ++k){
                    b += (a * r);
                    a -= t;
                }
                result = a + b;
            }else{
                for(int k=0; k<year; ++k) a+=(a*r-t);
                result = a;
            }
            if(max < result) max = result;
        }
        cout << max << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 2e6 + 5;

int h,w,a,b;
int m[1001][1001];

int main(){
    cin>>h>>w>>a>>b;
    for (int i=0;i<b;i++){
        for (int j=0;j<w;j++) cout<<(j<a);
        cout<<"\n";
    }
    for(int i=0;i<h-b;i++){
        for(int j=0;j<w;j++) cout<<(j>=a);
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1280
s = list(input())
t = list(input())
ans = 0
for i in range(len(s)):
    if s == t:
        ans = 1
        break
    a = s[0]

    for j in range(len(s)-1):
        s[j] = s[j+1]

    s[-1] = a

if ans == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int N;
	cin >> N;
	vector<double> x(N);
	vector<string> u(N);
	double res = 0;
	REP(i, N) {
		cin >> x[i] >> u[i];
		if (u[i] == "BTC") res += 380000 * x[i];
		else res += x[i];
	}
	printf("%.10f\n", res);

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

ll N;
ll a[200010];
ll sum = 0;
bool fl = true;
ll mi = 1ll<<60;

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

  rep( i, N )
  {
    std::cin >> a[i];
    sum += a[i];
    fl &= a[i]%2 == 0;
    chmin( mi, a[i] );
  }

  if( N&1 )
    std::cout << (sum&1 ? "First" : "Second") << std::endl;
  else
    std::cout << (!(sum&1) && !(mi&1) ? "Second" : "First") << std::endl;

  return 0;
}


Measured memory_bytes: 4660
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  vector<ll> p(n);

  for(int i = 0; i < n; ++i){
    cin >> p[i];
  }

  ll ans = 0;
  ll min = 1000000;

  for(int i = 0; i < n; ++i){
    if(p[i] < min){
      ++ans;
      min = p[i];
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char[] c = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			c[i] = s.charAt(i);
		}
		for (int i = 0; i < s.length(); i+=2) {
			System.out.print(c[i]);
		}
	}
}


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

using ll = long long;

int main() {
    ll N, M, K;  cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) cin >> B[i];
    vector<ll> sum_a(N + 1), sum_b(M + 1);
    for (int i = 0; i < N; ++i) sum_a[i + 1] = sum_a[i] + A[i];
    for (int i = 0; i < M; ++i) sum_b[i + 1] = sum_b[i] + B[i];
    // DUMP(sum_a, sum_b);

    ll ans = 0;
    int j = M;
    for (int i = 0; i <= N; ++i) {
        while (j > 0 && sum_a[i] + sum_b[j] > K) --j;
        if (j == 0) {
            if (sum_a[i] > K) continue;
        }
        // DUMP(i, j);
        ans = max(ans, (ll)(i + j));
    }

    cout << ans << endl;
}


Measured memory_bytes: 9604
import math
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""

n = int(input())
ans = 0
dp = [0,0,0,0,0]
for i in range(n):
    s = input()
    if (s[0]=='M'): dp[0]+=1
    elif (s[0]=='A'): dp[1]+=1
    elif (s[0]=='R'): dp[2]+=1
    elif (s[0]=='C'): dp[3]+=1
    elif (s[0]=='H'): dp[4]+=1
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += dp[i]*dp[j]*dp[k]

print(ans)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll m,n,t,vis[4000];

int main()
{
    scanf("%lld",&m);
    for(int i=-1000;i<=1000;++i)
    vis[t++]=pow(i,5);
    for(int i=-1000;i<=1000;++i)
    {
    	ll a=m+pow(i,5);
    	n=lower_bound(vis,vis+t,a)-vis;
    	if(vis[n]==a) 
    	{
    		t=n-1000;n=i;break;
		}
	}
	printf("%lld %lld",t,n);
	return 0;
}


Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
using namespace std;
typedef long long LL;
typedef double ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int SIZE=200;
int A[SIZE];
int solve(){
	int N,M;
	cin >> N >> M;
	queue<int> odds;
	int odd=0;
	VI As;
	REP(i,M){
		cin >> A[i];
		if(A[i]&1) {
			odds.push(A[i]);
			odd++;
		}
	}
	if(N&1){
		if(1<odd) return -1;
		As.PB(odds.front());
		REP(i,M) if(A[i]%2 == 0) As.PB(A[i]);
	}
	else{
		if(2<odd) return -1;
		if(odd){
			As.PB(odds.front());
			REP(i,M) if(A[i]%2 == 0) As.PB(A[i]);
			odds.pop();
			As.PB(odds.front());
		}
		else{
			REP(i,M) if(A[i]%2 == 0) As.PB(A[i]);
		}
	}
	if(N==1){
		cout << 1 << endl << 1 << endl << 1 << endl;
		return 0;
	}
	if(M==1){
		cout << A[0] <<endl << 2 <<endl << A[0]-1 << " " << 1 << endl;
		return 0;
	}
	REP(i,As.size()){
		if(i!=As.size()-1)
			cout << As[i]<<" ";
		else cout << As[i] << endl;
	}
	REP(i,As.size()){
		if(i==0){
			if(As[0]!=1) {
				cout << As.size() << endl;
				cout << As[0]-1 << " "; 
			}
			else{
				cout << As.size()-1 << endl;
			}
		}
		else if(i==As.size()-1){
			cout << As[i]+1 << endl;
		}
		else{
			cout << As[i] <<" ";
		}
	}
	return 0;
}
int main(){
	int ans=solve();
	if(ans==-1) cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;
int main(){
  ll h,n;
  cin>>h>>n;
  ll a[n];
  ll b[n];
  rep(i,n) cin>>a[i]>>b[i];
  ll dp[h+1];
  rep(i,h+1) dp[i]=INF;
  dp[0]=0;
  rep(i,n){
    rep(j,h+1){
      if(j<a[i]) dp[j]=min(dp[j],b[i]);
      else{
        dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
      }
    }
  }
  
  cout<<dp[h]<<endl;
      
  
  
}
    
    
        
    

Measured memory_bytes: 384
S = raw_input()

areas = []
stack = []
for i,c in enumerate(S):
    if c == "\\":
        stack.append(i)
    elif c == "/":
        if len(stack) > 0:
            j = stack.pop()
            area = i-j
            while len(areas) > 0:
                p,a = areas.pop()
                if j < p:
                    area += a
                else:
                    areas.append((p, a))
                    break
            areas.append((j, area))

A = map(lambda x:x[1], areas)
print sum(A)
if len(A) == 0:
    print "0"
else:
    print len(A), " ".join(map(str, A))


Measured memory_bytes: 5272
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();

	int b = scan.nextInt();

	if( a >= 1 && a <= 9 && b>= 1 && b <=9)
		System.out.println(a * b);
	else
		System.out.println("-1");


	}


}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50;

int n, m;
string s;

int a[N][N], b[N][N];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < n; j++) {
			a[i][j] = (s[j] == '#');
		} 
	}
	
    for (int i = 0; i < m; i++) {
		cin >> s;
		for (int j = 0; j < m; j++) {
			b[i][j] = (s[j] == '#');
		} 
	}
	
	bool ans = false;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool valid = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (b[k][l] != a[i + k][j + l]) {
						valid = false;
						break;
					} 
				}
				if (!valid) break;
			}
			if (valid) {
				ans = true;
				break;
			}
		}
		if (ans) break;
	} 

	ans ? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        Arrays.sort(s);
        Arrays.sort(t);
        String sort_s = String.valueOf(s);
        String sort_t = String.valueOf(t);

        String sort_rev_t = new StringBuilder(sort_t).reverse().toString();

        if(sort_s.compareTo(sort_rev_t) < 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
    
}

Measured memory_bytes: 22736
import java.util.*;
import java.math.*;
import java.text.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		boolean[] prime = new boolean[1000001];
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for(int i=2; i<1000; i++){
			if(prime[i]){
				for(int j=2; i*j<1000000; j++){
					prime[i*j] = false;
				}
			}
		}
		
		while(true){
			int a = in.nextInt();
			int d = in.nextInt();
			int n = in.nextInt();
			if((a|d|n)==0) break;
			int ans = a;
			while(true){
				if(prime[a]) n--;
				if(n==0) break;
				a+=d;
			}
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 13000
from collections import deque
q=deque()
n=int(input())

for i in range(n):
    cmd=input()
    if cmd=="deleteFirst":
        try:
            q.popleft()
        except:
            pass
        
    elif cmd=="deleteLast":
        try:
            q.pop()
        except:
            pass
        
    else:
        cmd,number=cmd.split()
        if cmd=="delete":
            try:
                q.remove(number)
            except:
                pass
            
        elif cmd=="insert":
            q.appendleft(number)
        
print(*q)


Measured memory_bytes: 69740
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
N, K = MAP()
S = input()
cnt = 0
for i in range(1, N):
	if S[i] == S[i-1]:
		cnt += 1

print(min(N-1, cnt+2*K))

Measured memory_bytes: 10580
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
 
int main() {
	fastio;
	ll x;
	cin>>x;
	ll ans = 0;
	ans += (x/500)*1000;
	x -= (x/500)*500;
	ans += (x/5)*5;
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
typedef long double ld;
signed main(){
int n,k;
cin >>n>>k;
vector<bool> a(n);
REP(i,n){
  a[i]=false;
}
REP(i,k){
int d;
cin >>d;
REP(j,d){
    int an;
    cin  >> an;
   a[an-1]=true;
}
}
int ans=0;
REP(i,n){
if(a[i]==false)
ans++;
}
cout << ans;
}

Measured memory_bytes: 3632
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val (a, b, c, d) = sc.nextLine().map { it.toString().toInt() }
    val arr = arrayOf(b, c, d)
    for (i in 0 until 8) {
        var n = a
        var s = a.toString()
        for (j in 0 until 3) {
            if ((1.shl(j) and i) != 0) {
                n += arr[j]
                s += "+"
                s += arr[j].toString()
            } else {
                n -= arr[j]
                s += "-"
                s += arr[j].toString()
            }
        }
        if (n == 7) {
            s += "=7"
            println(s)
            return
        }
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31136
n, m = map(int, input().split())
VW = [tuple(map(int, input().split())) for i in range(n)]
V = [v for v, w in VW]
W = [w for v, w in VW]
# n, m = 4, 5
# V = [4, 5, 2, 8]
# W = [2, 2, 1, 3]
# DP[i][j]=i個の品物で価値j以上で最小の重さ
sv = sum(V)
inf = 10**10
DP = [[inf for j in range(sv+1)] for i in range(n+1)]
DP[0][0] = 0
for i in range(n):
    for j in range(sv+1):
        if j < V[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i][j-V[i]]+W[i])
for j in range(sv, 0, -1):
    if DP[n][j] <= m:
        print(j)
        exit()
print(0)



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

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

    int d, g;
    cin >> d >> g;
    vector<int> P(d), C(d);
    REP(i, d) cin >> P[i] >> C[i];

    int ans = 1e9;
    for(int i = 0; i < (1 << d); i++){
        int cnt = 0, cost = 0;
        for(int j = 0; j < d; j++){
            if((i >> j) & 1){
                cnt += P[j];
                cost += C[j] + P[j] * (j + 1) * 100;
            }
        }
        if(cost < g){
            for(int j = d - 1; j >= 0; j--){
                if((i >> j) & 1);
                else{
                    for(int k = 0; k < P[j]; k++){
                        cost += (j + 1) * 100;
                        cnt++;
                        if(cost >= g) break;
                    }
                }
                if(cost >= g) break;
            }
        }
        //cout << "i : " << i << "|cnt : " << cnt << "|cost : " << cost << endl;
        if(cost >= g) ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)1e5 + 9;
ll pf[N];
ll a[N];
int main(){
    fastIO;
    int n;
    cin >> n;
    for(int i = 1; i <= n ;i  ++ ){
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    int res = 1;
    for(int i = 1 ;i <= n; i ++ )
        pf[i] = pf[i - 1] + a[i];
    for(int i = n-1; i >= 1; i -- ){
        if(pf[i] * 2ll >= a[i + 1])
            res ++ ;
        else
            break;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1792