akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
const int mod = 1e9+7;
int R, C;
char gr[1001][1001];
vector<vector<LL> > dp(1001, vector<LL>(1001, 0));
map<pair<int, int>, int> fr;
int dr[] = {1, 0};
int dc[] = {0, 1};
bool vd(int r, int c){
    return !(r < 0 || r >= R || c < 0 || c >= C || gr[r][c] == '#');
}
void bfs(int r, int c){
    queue<pair<int, int> > q;
    q.push(mp(r, c));
    fr[mp(r, c)] = 1;
    while (!q.empty()){
        r = q.front().x;
        c = q.front().y;
        //cout << r << ' ' << c << endl;
        fr[mp(r, c)]--;
        q.pop();
        if (fr[mp(r, c)] != 0)
            continue;
        for (int i = 0; i < 2; ++i){
            int nr = r+dr[i], nc = c + dc[i];
            if (vd(nr, nc)){
                q.push(mp(nr, nc));
                if (fr.find(mp(nr, nc)) == fr.end())
                    fr[mp(nr, nc)] = 1;
                else
                    fr[mp(nr, nc)] ++;

                dp[nr][nc] = (dp[nr][nc] + dp[r][c])%mod;
            }
        }
    }
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    scanf("%d %d\n", &R, &C);
    for (int i = 0; i < R; ++i){
        for (int j = 0; j < C; ++j){
            scanf("%c", &gr[i][j]);
        }
        if (i != R-1)
            scanf("\n");
    }
//    for (int i = 0; i < R; ++i)
//        for (int j = 0; j < C; ++j)
//            printf("%s\n", gr[i]);
    dp[0][0] = 1;
    bfs(0,0);
    cout << dp[R-1][C-1];
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */


Measured memory_bytes: 55936
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
int index, N, L[100];
int len_sum = 0;
int len_max = 0;

    scanf("%d", &N);
    for (index = 0; index < N; ++index)
    {
      scanf("%d", &L[index]);
      len_sum += L[index];
      if (L[index] > len_max) len_max = L[index];
    }

    if (len_sum - len_max > len_max)
    {
      printf("Yes\n");
    }
    else
    {
      printf("No\n");
    }
  
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long perimeter = scanner.nextLong();
        long numberOfHouses = scanner.nextLong();

        long maxDistance = 0;
        long first = scanner.nextInt();
        long previous = first;
        long sum = 0;
        for (long i = 0; i < numberOfHouses - 1; i++) {
            long next = scanner.nextLong();
            long currentDistance = next - previous;
            sum += currentDistance;
            previous = next;
            if (currentDistance > maxDistance) {
                maxDistance = currentDistance;
            }
        }
        long lastDistance = perimeter - previous + first;
        sum += lastDistance;
        if (lastDistance > maxDistance) {
            maxDistance = lastDistance;
        }
        System.out.println(sum - maxDistance);
    }
}


Measured memory_bytes: 64784
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedList;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();
		int c[][] = new int[3][n];

		for (int i = 0; i < n; i++) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			int k = scn.nextInt();
			c[0][i] = a;
			c[1][i] = b;
			c[2][i] = k;
		}
		int dp[][] = new int[3][n];
		dp[0][0] = c[0][0];
		dp[1][0] = c[1][0];
		dp[2][0] = c[2][0];
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				dp[j][i] = Math.max(dp[j][i], Math.max(dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]) + c[j][i]);
			}
		}
		int ans = Math.max(dp[0][n - 1], Math.max(dp[1][n - 1], dp[2][n - 1]));

		System.out.println(ans);

	}

}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int main()
{
  string s;
  cin >> s;
  
  int ans=100000000;
    int ss=s.size();
  for(int i=1;i<=ss;i++){
  if(s[i-1] != s[i]){
  ans=min(ans,max(i,ss-i));
  }
  }
	if(ans == 100000000){
    cout << ss <<endl;
    }else{
  cout<<ans<<endl;
    }
}

Measured memory_bytes: 512
var
	a, cnt, x : int64;
    
    
    
    
begin
	a := 100;
    cnt := 0;
    readln(x);
    while (a < x) do
    begin
    	a := trunc(a * 1.01);
        cnt := cnt + 1;
    end;
    writeln(cnt);
end.

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll N,K;
    cin >> N >> K;
    vector<pair<ll, ll> >ab(N);
    rep(i,N) cin >> ab[i].first >> ab[i].second;

    ll tmp = 0;
    ll key = 0;
    
    sort(all(ab));
    rep(i,N)

    while( tmp < K )
    {
        tmp += ab[key].second;
        key++;
    }
    cout << ab[key-1].first << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int c1,c2,sum,v1,v2,v3;

    cin >>c1 >> c2;

   
    v1=c1%3;
    v2=c2%3;
    sum=c1+c2;
    v3=sum%3;

    if(v1==0 || v2==0 || v3==0)
    {
        cout << "Possible" << endl;
    }
    else{cout << "Impossible" << endl;}


    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ing_total = 0
N = int(n/2)
if n % 2 == 1:
    print("No")
else:
    for i in range(N):
        if s[i] == s[i+N]:
            ing_total +=1
        else:
            ing_total += 0
    if N == ing_total:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string s;
  int odd = 0;
  int even = 0;
  cin >> s;
  rep(i,s.size()){
    if(s[i] == '1') odd ++;
    else even ++;
  }
  cout << min(odd,even)*2 << endl;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if (n == 0 && x == 0) break;
			int count = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					if (i == j || i + j >= x) continue;
					for (int k = 1; k <= n; k++) {
						if (i == k || j == k) continue;
						if (i + j + k == x) count++;
					}
				}
			}
			System.out.println(count / 6);
		}
		sc.close();
	}
}

Measured memory_bytes: 26840
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll h[1000000];
ll dp[10000000];
int main() {
	ll n;
	cin >> n;
	int k;
	cin >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		dp[i] = 1000000000;
	}
	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = max(i - k, 0); j <i; j++){
			dp[i] = min(dp[i],dp[j]+ abs(h[i] - h[j]));
	    }
	}
	cout << dp[n-1] << endl;
	return 0;

}

Measured memory_bytes: 3072
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define ALL(a)					(a).begin(),(a).end()
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;

	int tmp = N;
	int sum = 0;
	while (tmp) {
		sum += (tmp % 10);
		tmp /= 10;
	}

	if (N % sum == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



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

const int N = 2e5 + 10;
int n;
int pre[N];

int Find(int x){
    int r = x;
    while(pre[r] != r)
        r = pre[r];
    int i = x, j;
    while(pre[i] != r){
        j = pre[i];
        pre[i] = r;
        i = j;
    }
    return r;
}
void Merge(int x, int y){
    int xx = Find(x);
    int yy = Find(y);
    if(xx != yy) pre[xx] = yy;
}
int main(){
    int m, u, v;
    scanf("%d%d", &n,&m);
    for(int i=1;i<=n;i++) pre[i] = i;
    while(m--){
        scanf("%d%d",&u,&v);
        if(u == 1 || v == 1 || u == n || v == n)
            Merge(u, v);
    }
    if(Find(1) == Find(n)) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,da,dq;
char st[10000];
int main()
{
cin>>n;
for(int i=1; i<=n; i++)
{
	cin>>st[i];
	if(st[i]=='I')dq++;
	else dq--;
	if(dq>da)da=dq;
}
cout<<da<<endl;
return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
cnt = [0]*n

ac_cnt = 0
wa_cnt = 0
for _ in range(m):
    _p, _s = map(str, input().split())
    _p = int(_p)-1
    #print("%d %s"%(_p, _s))
    if cnt[_p] != -1:
        #print(_s)
        if _s == 'WA':
            cnt[_p] += 1
        else:
            ac_cnt += 1
            wa_cnt += cnt[_p]
            cnt[_p] = -1

print("%d %d"%(ac_cnt, wa_cnt))

Measured memory_bytes: 51928
<?php

// define('DEBUG', true);
define('DEBUG', false);

function gcd($a, $b){
    if (DEBUG) echo "gcd($a, $b)\n";
    if($b == 0) {
        $ret = $a;
    } else {
        $ret = gcd($b, $a % $b);
    }
    if (DEBUG) echo "ret(gcd) = " . $ret . PHP_EOL;
    return $ret;
}

function lcm($a, $b){
    if (DEBUG) echo "lcm($a, $b)\n";
    $g = gcd($a, $b);
    $ret = $a / $g * $b;
    if (DEBUG) echo "ret(lcm) = " . $ret . PHP_EOL;
    return $ret; 
}

fscanf(STDIN, "%d", $N);

for ($i = 0; $i < $N; ++$i) {
    fscanf(STDIN, "%d", $a[$i]);
}

$ans = $a[0];

for ($i = 1; $i < $N; ++$i) {
    $ans = lcm($ans, $a[$i]);
}

echo $ans . PHP_EOL;


Measured memory_bytes: 4728
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
bool a[10][10];
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    rep(i,h)rep(j,w){
        char c;
        cin >> c;
        a[i][j] = c == '#';
    }
    int ans = 0;
    rep(i,1<<h)rep(j,1<<w){
        int cnt = 0;
        rep(ii,h)rep(jj,w)if(i>>ii&1)if(j>>jj&1)if(a[ii][jj])cnt++;
        if(cnt == k)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;
int a[123456], k; string s;
signed main() {
	cin >> k >> k >> s;
	int f = 0, l = 0;
	for (int i = 0; f < s.size(); i++) {
		int qw = (i+1) % 2;
		while (f < s.size() && s[f] - '0' == qw) f++;
		a[i] = f;
		l++;
	}
	a[l] = f; l++;
	if (l / 2 <= k) {
		cout << s.size() << endl;
		return 0;
	}
	k = k * 2 + 1;
	int ans = 0;
	for (int i = k - 1; i < l; i += 2) {
		if (i == k - 1)ans = max(ans, a[i]);
		else ans = max(ans, a[i] - a[i - k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>

using namespace std;

string stre(int s){
    stringstream ss;
    ss << s;
    return ss.str();
}

string inter(string s,string s2){
    int sum = 0;
    bool flag = false;

    int a=1,dig=0;
    for(int i=0;i<s.length();i++){
	if(s[i] == 'm'){
	    dig = 1000;
	    flag = true;
	}else if(s[i] == 'c'){
	    dig = 100;
	    flag = true;
	}else if(s[i] == 'x'){
	    dig = 10;
	    flag = true;
	}else if(s[i] == 'i'){
	    dig = 1;
	    flag = true;
	}else a = int(s[i] - '0');
	if(flag){
	    sum += a*dig;
	    dig = 0;
	    a = 1;
	    flag = false;
	}
    }
    for(int i=0;i<s2.length();i++){
	if(s2[i] == 'm'){
	    dig = 1000;
	    flag = true;
	}else if(s2[i] == 'c'){
	    dig = 100;
	    flag = true;
	}else if(s2[i] == 'x'){
	    dig = 10;
	    flag = true;
	}else if(s2[i] == 'i'){
	    dig = 1;
	    flag = true;
	}else a = int(s2[i] - '0');
	if(flag){
	    sum += a*dig;
	    dig = 0;
	    a = 1;
	    flag = false;
	}
    }
    string code= stre(sum);
    string res = "";
    string c("mcxi");
    int size = code.length();
    for(int i=0;i<size;i++){
	if (code[i] == '0') continue;
	else if (code[i] == '1') {
	    res += c[i + 4 - size];
	    continue;
	}
	res += code[i] ;
	res += c[i + 4 - size];
    }

    return res;
}


int main(){

    int n;
    cin >> n;
    string s1,s2;
    for(int i=0;i<n;i++){
	    cin >> s1 >> s2 ;
	cout << inter(s1,s2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
INFTY = 10**8
H,N = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[INFTY for _ in range(H+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
for i in range(1,N+1):
    for h in range(1,H+1):
        dp[i][h] = dp[i-1][h]
        if h>=A[i-1][0]:
            dp[i][h] = min(dp[i][h],dp[i][h-A[i-1][0]]+A[i-1][1])
        else:
            dp[i][h] = min(dp[i][h],A[i-1][1])
print(dp[N][H])

Measured memory_bytes: 125276
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  float m,sum=0,c=0;
  cin>>n>>m;
  float a[n];
  for (int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  float temp=(1/(4*m))*sum;
  //float tmp=temp*sum;
  for (int i=0;i<n;i++)
  {
    if(a[i]>=temp)
      c++;
  }
  if(c>=m)
    cout<<"Yes";
  else
    cout<<"No";
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}




int main() {
    READ(0);
    int n;
    ll d,a;
    cin>>n>>d>>a;
    vector<ii> x(n);
    FOR(i,n) cin>>x[i].first>>x[i].second;
    sort(x.begin(),x.end());
    int idx=0;
    ll bombs=0;
    vector<pair<int,ll>> hh;
    int q=0;
    ll acum=0;
    while(idx<n){
        while (q<hh.size() && hh[q].first<x[idx].first){
            acum -= hh[q++].second;
        }
        if (acum>=x[idx].second){++idx;continue;}
        int b = (x[idx].second-acum)/a + ((x[idx].second-acum)%a != 0);
        bombs += b;
        ll pos = d*2+x[idx].first;
        if (pos<x[n-1].first)
            hh.emplace_back(pos,a*b);
        acum += a*b;
        ++idx;
    }
    cout << bombs;


}



Measured memory_bytes: 7664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];
ll now = 0, ans = 0;

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n){
        if (now > a[i]) ans += now - a[i];
        else now = max(now, a[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int N,X;
	cin>>N>>X;
	int m;
	cin>>m;
	X=X-m;
	for (int i=0;i<N-1;++i){
		int tmp;
		cin>>tmp;
		if(tmp<m) m=tmp;
		X=X-tmp;
	}
	int add;
	add=X/m;
	cout<<N+add<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 700
bool conn[N+1][N+1] = {};
vector<int> adj[N+1];
void link(int u, int v) {
    adj[u].push_back(v);
    adj[v].push_back(u);
}
bool vis[N+1] = {};
int p[N+1] = {};
int depth[N+1] = {};
int sz[N+1] = {};
template <typename PreFunction, typename PostFunction>
int dfs(int u, const PreFunction& pre, const PostFunction& post) {
#ifdef DEBUG
    using pre_actual_type = typename callable_traits<PreFunction>::function_type;
    using pre_expected_type = typename callable_traits<void(int)>::function_type;
    static_assert(is_same<pre_actual_type, pre_expected_type>::value, "dfs 'pre' must be void(int)");
    using post_actual_type = typename callable_traits<PostFunction>::function_type;
    using post_expected_type = typename callable_traits<void(int)>::function_type;
    static_assert(is_same<post_actual_type, post_expected_type>::value, "dfs 'post' must be void(int)");
#endif
    int ans = 1;
    vis[u] = true;
    depth[u] = depth[p[u]] + 1;
    sz[u] = 1;
    pre(u);
    for(int v : adj[u]) {
        if(not vis[v]) {
            p[v] = u;
            ans += dfs(v, pre, post);
            sz[u] += sz[v];
        }
    }
    post(u);
    return ans;
}
int dfs(int u) { return dfs(u, [](int u) {}, [](int u) {}); }
int n, m;
bool color[N+1];
vector<int> black_counts;
vector<int> white_counts;
int mem[N+1][N+1];
int opt(int i, int x) {
    int& ans = mem[i][x];
    if(ans == -1) {
        if(i == black_counts.size()) {
            ans = x * (x - 1) / 2 + (n - x) * (n - x - 1) / 2;
        } else {
            ans = min(opt(i + 1, x + black_counts[i]), opt(i + 1, x + white_counts[i]));
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        conn[u][v] = conn[v][u] = true;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(not conn[i][j]) {
                link(i, j);
            }
        }
    }
    fill(vis, vis + n + 1, false);
    bool can = true;
    for(int u = 1; u <= n and can; u++) {
        if(not vis[u]) {
            color[u] = true;
            int black = 0, white = 0;
            dfs(u, [&](int u) {
                color[u] = not color[p[u]];
                (color[u] ? black : white)++;
            }, [&](int u) {
                for(int v : adj[u]) {
                    can &= color[v] != color[u];
                }
            });
            black_counts.push_back(black);
            white_counts.push_back(white);
        }
    }
    if(can) {
        memset(mem, -1, sizeof mem);
        cout << opt(0, 0) << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


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

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


int main() {
    ll n,ans=0,p=-1; cin>>n;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    reverse(al(a));
    rep(i,n){
        if(a[i]>=p-1 && a[i]+i<n){
            if(a[i]!=p-1) ans+=a[i];
            p=a[i];
        }
        else{
            ans=-1; break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int a,b,c,d,k;cin>>a>>b>>c>>d>>k;
    int hour=k/60;
    int mini=k%60;
    int x,y;
    if(d>=mini)y=d-mini;
    else{
        mini-=d;
        y=60-mini;
        c--;
    }
    x=c-hour;
    int ans=60*(x-a)+y-b;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()

if s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5584
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;
	auto num = 0;
	vector<string> s(H);
	for (auto i = 0; i < H; ++i)
	{
		cin >> s[i];
		for (auto j = 0; j < W; ++j)
		{
			if (s[i][j] == '.')
			{
				++num;
			}
		}
	}

	auto ans = -1;
	int offset[4][2] = { {0, 1}, {1, 0}, {0,-1}, {-1, 0} };
	vector<vector<int>> d(H, vector<int>(W, 0));
	queue<pair<int, int>> q;
	q.push({ 0, 0 });
	d[0][0] = 1;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();

		for (auto i = 0; i < 4; ++i)
		{
			auto nx = p.first + offset[i][0];
			auto ny = p.second + offset[i][1];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H)
			{
				continue;
			}

			if (s[ny][nx] == '#')
			{
				continue;
			}

			if (d[ny][nx] > 0 )
			{
				continue;
			}

			d[ny][nx] = d[p.second][p.first] + 1;
			q.push({ nx, ny });
		}
	}

	if (d[H - 1][W - 1] > 0)
	{
		ans = num - d[H - 1][W - 1];
	}
	cout << ans << endl;

	return 0;
}

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

Measured memory_bytes: 720
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
   
*/

/*
 *   ITERATIVE SOLUTION
 */
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
string s,t;
int i,j,n,m;
vector<vector<int>>dp;
void get_string()
{
    int i=0;
    int res=dp[0][0];
    while(i<n&&res>0)
    {
       while(dp[i][0]==dp[i+1][0])i++;
       cout<<s[i];res--;
       i++;
    }
    cout<<"\n";
}
void get_string2()
{
    int i=0,j=0;
    int cnt=dp[0][0];
   while (i<n&&j<m) 
   { 
      if (s[i]==t[j]&&cnt>0) 
      { 
        cout<<s[i];
        i++;j++;cnt--; 
      } 
      else if (dp[i+1][j]>dp[i][j+1]) 
         i++; 
      else
         j++; 
   }
 cout<<"\n"; 
}
void solve()
{
    cin>>s>>t;
    n=sz(s)+1;m=sz(t)+1;
    dp=vector<vector<int>>(n,vector<int>(m,0));
   
    n--;m--;
    for(i=n;i>=0;i--)
    {
        for(j=m;j>=0;j--)
        {
            if(i==n||j==m)dp[i][j]=0;
            else if(s[i]==t[j])dp[i][j]=dp[i+1][j+1]+1;
            else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    /*fo(i,0,n+1)
    {
       fo(j,0,m+1)cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    get_string2();
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (char c : n) {
        sum += c - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3720
n, k = tuple(map(int, input().split()))
l = list(map(int, input().split()))

sums = [0 for _ in range(n+1)]
for i in range(n):
    exp = (1 + l[i]) / 2
    sums[i+1] = sums[i] + exp

ans = 0
for idx in range(n-k+1):
    diff = sums[idx+k] - sums[idx]
    ans = max(ans, diff)

print(ans)


Measured memory_bytes: 25060
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int r,g,b;
	cin>>r>>g>>b;
	int ans = r*100+g*10+b;
	if (ans%4 == 0)
	{
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 256
L, R= list(map(int, input().split()))

def get_amari():
    min_ = 2019
    for i in range(L,R):
        for j in range(i+1, R+1):
            if (i*j)%2019 < min_:
                min_ = (i*j)%2019
    return min_
   
def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

if get_flg3() & get_flg673():
    print(0)
else:
    print(get_amari())


Measured memory_bytes: 3064
import java.util.Scanner;
import java.lang.Math;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        if(x >= 0.5*a*a*b) {
        		double d = Math.toDegrees(Math.atan((a*a*b-x)*2/(a*a*a)));
        		System.out.println(d);
        } else {
        		double d = Math.toDegrees(Math.atan(0.5*a*b*b/x));
        		System.out.println(d);
        }
    }
}

Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char s[200005];
    scanf("%s",s);
    int k;
    cin>>k;
    char c=s[k-1];
    for(int i=0;i<n;i++)
    {
        if(s[i]==c)
        cout<<c;
        else
        cout<<'*';
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()


def diff_count(a, b):
    c = 0
    for aa, bb in zip(a, b):
        if aa != bb:
            c += 1
    return c


min_d = len(t)

for i in range(len(s)-len(t)+1):
    ss = s[i:i + len(t)]
    d = diff_count(ss, t)
    if d < min_d:
        min_d = d

print(min_d)


Measured memory_bytes: 9124
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A; cin >> A;
    cout << A + A*A + A*A*A << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3652
import java.util.Scanner;

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

    int s = sc%60;
    int m = sc/60%60;
    int h = sc/60/60;

    System.out.println( h + ":" + m + ":" + s);

  }
}


Measured memory_bytes: 26404
N = int(input())
S, P = (
    zip(*(
        (s, -int(p))
        for s, p in (input().split() for _ in range(N))
    )) if N else
    ((), ())
)

ans = '\n'.join(
    str(i)
    for _, _, i in sorted(zip(S, P, range(1, N + 1)))
)

print(ans)


Measured memory_bytes: 3060
#!/usr/bin/env python3


def main():
    S = input()
    N = len(S)
    m = 10**9 + 7
    # dp[i][j]:= 先頭からi-1文字目までみてABCのうちj文字目まで選んでいた時の残りの処理の個数
    dp = [[0]*4 for _ in range(N+1)]
    for i in range(N,-1,-1):
        for j in range(3,-1,-1):
            # print(i,j)
            if i == N:
                if j == 3:
                    # print(i,j)
                    dp[i][j] = 1
                else:
                    dp[i][j] = 0
            else:
                if S[i] == '?':
                    dp[i][j] = dp[i+1][j] * 3 % m
                else:
                    dp[i][j] = dp[i+1][j]
                
                if j < 3:# S[i]文字を選択する場合
                    if S[i] == '?' or S[i] == 'ABC'[j]:
                        dp[i][j] += dp[i+1][j+1]
                        dp[i][j] %= m

    print(dp[0][0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 31980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,n,m,x,v,cnt1=0,cnt2=0;
     cin>>n>>m>>x;
     for(int i=0;i<m;i++)
     {
         cin>>v;
         if(v>x)
            cnt1++;
         else
            cnt2++;
     }
     cout<<min(cnt1,cnt2)<<endl;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

int main() {
  int A, B;
  cin >> A >> B;
  char ch;
  bool flag = true;
  rep(i, 0, A) {
    cin >> ch;
    if ('0' <= ch && ch <= '9') {
      continue;
    } else {
      flag = false;
    }
  }

  cin >> ch;
  if (ch != '-') {
    flag = false;
  }

  rep(i, A+1, A+B+1) {
    cin >> ch;
    if ('0' <= ch && ch <= '9') {
      continue;
    } else {
      flag = false;
    }
  }

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

  return 0;
};


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigitalGifts solver = new BDigitalGifts();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigitalGifts {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            double ans = 0;

            for (int i = 0; i < n; i++) {
                double x = in.nextDouble();
                double m = in.next().equals("JPY") ? 1 : 380000;

                ans += x * m;
            }

            out.format("%f%n", ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



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

int main(void){
	int R0,W0,C,R;
	while(cin >> R0 >> W0 >> C >> R,R0){
		rep(ans,100000){
			if(R0+ans*R >= C*W0){
				cout << ans << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3060
/*s1190073  Rina Sato
  File name: prog6b.c
  This is a program that do partition.
*/

#include <stdio.h>

int main(void){
  int i,j,x,p,r,temp1,temp2,n,tempC,tempc;
  int A[100001],count[100001];

  scanf("%d",&n);
  p = 0;
  r = n-1;
  for(i = p ; i <= r ; i++){
    scanf("%d",&A[i]);
    count[i] = i;
  }
  x = A[r];
  i = p-1;

  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i = i+1;
      temp1 = A[i];
      tempC = count[i];
      A[i] = A[j];
      count[i] = count[j];
      A[j] = temp1;
      count[j] = tempC;
    }
  }
  
  temp2 = A[i+1];
  tempc = count[i+1];
  A[i+1] = A[r];
  count[i+1] = count[r];
  A[r] = temp2;
  count[r] = tempc;
  
  for(i = p ; i <= r ; i++){
    if((A[i] == x) && (count[i] == r)){
      printf("[%d]",A[i]);
    }
    else{
      printf("%d",A[i]);
    }
    if(i < r){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
} 

Measured memory_bytes: 1196
n = input()
for i in range(n):
    C = raw_input()
    for A in range(1,26):
        if len([x for x in range(2,26) if 26%x==0 and A%x==0])==0:
            for B in range(26):
                P = ""
                for x in C:
                    if ord("a")<=ord(x)<=ord("z"):
                        P += chr((A*(ord(x)-ord("a"))+B)%26+ord("a"))
                    else:
                        P += x
                if "this" in P or "that" in P:
                    print P

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

int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a == 'H')
    {  
    	if(b == 'H') printf("H\n");
    	if(b == 'D') printf("D\n");
	}
	else if(b == 'H') printf("D\n");
	else printf("H\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 100005;
int gi()
{
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
int n,m,fa[N],dis[N];
int find(int x)
{
	int ff=fa[x];
	if (x==fa[x]) return x;
	fa[x]=find(fa[x]);
	dis[x]+=dis[ff];
	return fa[x];
}
int abs(int x){return x>0?x:-x;}
int main()
{
	n=gi();m=gi();
	for (int i=1;i<=n;i++) fa[i]=i;
	while (m--)
	{
		int l=gi(),r=gi(),d=gi();
		if (find(l)^find(r))
		{
			int fl=find(l),fr=find(r);
			int dd=dis[r]-dis[l]-d;
			if (dd>0) swap(fl,fr);
			fa[fr]=fl,dis[fr]=abs(dd);
		}
		else
		{
			if (dis[r]-dis[l]!=d)
				return puts("No"),0;
		}
	}
	return puts("Yes"),0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,s;
	cin>>n>>s;
	int count=0;
	int g[n];
	for(int i=0;i<n;i++)cin>>g[i];
	for(int i=0;i<n;i++){
		if(g[i]>=s)count++;
	}
	cout<<count<<endl;
	
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n, a[100001];

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

	int s = 1, ans = 0;
	bool used[100001] = { false };
	while (1) {
		ans++;
		used[s] = true;
		s = a[s];
		if (s == 2)
			break;
		if (used[s]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;

#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back

void solve() {
    int n; cin >> n;
    vector<ll> a(n);
    for (auto &i : a) cin >> i;
    sort(all(a));
    reverse(all(a));
    multiset<ll> kek;

    ll res = a[0];
    kek.insert(-a[1]);
    kek.insert(-a[1]);

    for (int i = 2; i < n; i++) {
        auto it = kek.begin();
        res -= *it;
        kek.erase(it);
        kek.insert(-a[i]);
        kek.insert(-a[i]);
    }

    cout << res;
}

int main() {
    solve();
}

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

int main(){
        int n,m;
        cin >> n>>m;
        int arr[m];
  for(int i = 0;i< m;i++)
    arr[i] = 0;
        for(int i = 0; i < n;i++)
        {
                int k;
                cin >>k;
                for(int j = 0;j<k; j++)
                {
                        int a;
                        cin >>a;
                        arr[a-1]++;
                }
        }
        int ans = 0;
        for(int i = 0;i< m; i++)
        {
                if(arr[i]==n)
                {
                        ans++;
                }
        }
        cout << ans << endl;
}



Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

H,W = map(int,input().split())

tb = ['#' + input() + '#' for i in range(H)]
L = ''
for i in range(W+2):
	L = L +'#'

print(L)
for i in tb:
	print(i)
print(L)

Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 2010;

int main()
{
    int p = MAX, j = MAX, t;
    REP(3){ cin >> t; p = min(p, t);}
    REP(2){ cin >> t; j = min(j, t);}
    cout << p + j - 50 << endl;

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin >>v.at(i);
  }
  for(int i=0; i<n; i++){
    if ((v.at(i))%2!=0) continue;
    else{
      if((v.at(i)%3)!=0 && (v.at(i))%5!=0){
        cout<<"DENIED"<<endl;
        return 0;
    }
    }
  }
  cout<<"APPROVED"<<endl;
}

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

//#define debug_mode

#ifdef debug_mode
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
using std::endl;
#endif

#ifndef debug_mode
using namespace std;
#endif

void func_to_be_create();

int main(){

    #ifdef debug_mode
    int TEST_NUM = 3;
    while( TEST_NUM --){
    #endif

        func_to_be_create();

    #ifdef debug_mode
    }
    #endif
    return 0;

}

void func_to_be_create(){
    int N;
    cin >> N;
    while(N){
        int a = N % 10;
        if ( a == 7){
            cout << "Yes" << endl;
            return ;
        }else{
            N /= 10;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
import bisect
N = int(input())
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)

Measured memory_bytes: 3188