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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
}


Measured memory_bytes: 35628
#include <iostream>
#include <cstring>
using namespace std;
string a;
void solve()
{
    if (a=="SSS") cout<<0;
    else if (a=="RSS"||a=="SRS"||a=="SSR"||a=="RSR") cout<<1;
    else if (a=="RRS"||a=="SRR") cout<<2;
    else if (a=="RRR") cout<<3;
    cout<<endl;
}
int main()
{
    while(cin>>a)
        solve();
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> s(n);
    rep(i, 0, n) cin >> s[i];

    ll ans = 0;
    rep(c, 1, n)
    {
        ll score = 0;
        set<int> idx_set;
        int l = 0, r = n - 1;
        rep(x, 0, n)
        {  
            ll a = n - 1 - x * c;
            ll b = a - c;
            if (b <= 0) break;
            if (x*c>= n) break;
            
            if (idx_set.count(n-1-x*c) > 0)
                break;
            idx_set.insert(n-1-x*c);

            if (idx_set.count(x*c) > 0)
                break;
            idx_set.insert(x*c);


            score += s[x*c];
            score += s[n-1-x*c];
            
            ans = max(ans, score);
            // cout << c << ' ' << x << ' ' << score << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7552
#include<stdio.h>
 
int N,idx;
char S[105];
 
int fact();
int expr();
int term();
int number();
 
int expr()
{
    int res=term();
    for(;S[idx]=='+'||S[idx]=='-';)
    {
        char op=S[idx++];
        int tmp=term();
        if(op=='+')res+=tmp;
        else res-=tmp;
    }
    return res;
}
 
int term()
{
    int res=fact();
    for(;S[idx]=='*'||S[idx]=='/';)
    {
        char op=S[idx++];
        int tmp=fact();
        if(op=='*')res*=tmp;
        else res/=tmp;
    }
    return res;
}
 
int fact()
{
    int res;
    if(S[idx]=='(')
    {
        idx++;
        res=expr();
        idx++;
    }
    else
        res=number();
    return res;
}
 
int number()
{
    int res=0;
    for(;'0'<=S[idx]&&S[idx]<='9';idx++)
    {
        res=res*10+S[idx]-'0';
    }
    return res;
}
 
 
int main()
{
    scanf("%d\n",&N);
    for(;N--;)
    {
        idx=0;
        gets(S);
        printf("%d\n",expr());
    }
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

typedef pair<long long int, int> P;

vector<P> PF(long long int n){

    vector<P> res;
    long long int num = n;
    int count;

    // dividing n by the small numbers. 
    // if first divide by 2 as much as possible, n can be only divided by other prime numbers higher than 2. 
    for(long long int i = 2; i*i <= n; i++){
        if(num%i != 0) continue;

        count = 0;
        while(num%i == 0){
            num/=i;
            count++;
        }

        res.push_back(P(i, count));
    }

    if(num>1){
        res.push_back(P(num,1));
    }
    return res;
}

int main(){

    long long int n;
    cin >> n;

    int count = 0;

    vector<P> res;
    res = PF(n);

    // for(P p : res){
    //     cout << p.first << " " << p.second << endl;
    // }

    for(P p : res){
        for(int i = 1; p.second-i >= 0; i++){
            count++;
            p.second-=i;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, height[(int)1e5 + 5], opt[(int)1e5 + 5];

int main(){
  FAST_IO  
  cin >> N;
  for(int rep = 0; rep < N; ++rep) cin >> height[rep];
  for(int rep = 0; rep < N; ++rep) opt[rep] = INF;

  opt[0] = 0;
  for(int idx = 0; idx < N - 1; ++idx){
    for(int s : {1, 2}){
      min_self(opt[idx + s], opt[idx] + abs(height[idx + s] - height[idx]));
    }
  }

  cout << opt[N - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,maxn=0,high=0;
	cin>>n;
	char s[200];
	for(i=0;i<n;++i){
		cin>>s[i];
		if(s[i]=='I')
		high+=1;
		else high-=1;
		if(high>maxn)maxn=high;
	}
	cout<<maxn;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	string s;
	cin>>s;
	if(s.length()==2)cout<<s<<endl;
	else 
	{
		for(int i=2;i>=0;i--)cout<<s[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, M = list(map(int, input().rstrip().split(' ')))
S = list(map(int, input().rstrip().split(' ')))
T = list(map(int, input().rstrip().split(' ')))
dp = [[0] * (N + 1) for _ in range(M + 1)]

for i in range(1, M+1):
    for j in range(1, N+1):
        if S[j-1] == T[i-1]:
            dp[i][j] = dp[i-1][j] + dp[i][j-1] + 1
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        dp[i][j] = dp[i][j] % 1000000007
            
print((dp[-1][-1]+1) % 1000000007)


Measured memory_bytes: 73180
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  set<int> st;
  rep(i,n){
    int hoge;
    cin >> hoge;
    st.insert(hoge);
  }
  cout << st.size() << endl;
    
}

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

int main() {
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int d1 = j % 10;
            int d10 = j / 10;
            if (d1 >= 2 && d10 >= 2 && d1*d10 == i)
                ans++;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(text){console.log(text);}//standard output
//[no]param
//0:noConvert	1:singleNum	2:spaceList	3:newLineList	4:spaceNumList	5:newLineNumList
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = input[0];
  var list = myconv(input[1],4);
  var output = 0;
  for(var i = 0; i < list.length; i++){
    output += list[i] - 1;
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 7500
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;
int main()
{
    fio;
    ll t, c, p, a, n, q, k, i, l, m, u, f, j, x, y, b, d;
    cin >> n;
    vector<pair<int, int>> v;
    for (i = 0; i < n; i++)
        cin >> a >> b, v.pb({a, b});
    f = 0;
    for (i = 2; i < n; i++)
    {
        if (v[i].ss == v[i].ff && v[i - 2].ss == v[i - 2].ff && v[i - 1].ss == v[i - 1].ff)
        {
            f = 1;
            break;
        }
    }
    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int X;
    cin >> X;

    int n = 100;
    int cnt = 0;
    while(n < X) {
        n *= 1.01;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>


// 1フロア10部屋、3階建ての公舎4棟の入居、退去の情報を読み込んで入居者数を出力する
// b棟f階r番目v追加 or -v退去
int main()
{
	int aiRoom[4][3][10];

	int iCnt1, iCnt2, iCnt3;

	for (iCnt1 = 0; iCnt1 < 4; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < 3; iCnt2++)
		{
			for (iCnt3 = 0; iCnt3 < 10; iCnt3++)
			{
				aiRoom[iCnt1][iCnt2][iCnt3] = 0;
			}
		}
	}

	int iInputN, iInputB, iInputF, iInputR, iInputV;
	scanf("%d", &iInputN);

	while (iInputN > 0)
	{
		scanf("%d %d %d %d", &iInputB, &iInputF, &iInputR, &iInputV);
		aiRoom[iInputB - 1][iInputF - 1][iInputR - 1] += iInputV;
		iInputN--;
	}

	for (iCnt1 = 0; iCnt1 < 4; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < 3; iCnt2++)
		{
			for (iCnt3 = 0; iCnt3 < 10; iCnt3++)
			{
				printf(" %d", aiRoom[iCnt1][iCnt2][iCnt3]);
			}
			printf("\n");
		}
		if (iCnt1 != 3)
		{
			printf("####################\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main() {
	int n,flag=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int m;
		cin >> m;
		if (m % 2 == 0)
		{
			if (m % 3 == 0 || m % 5 == 0)
				continue;
			else {
				return cout << "DENIED", 0;
			}
		}
		else
			continue;
	}
	return cout << "APPROVED", 0;
}

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

Measured memory_bytes: 2608
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
using ld = long double;
using ll = long long;
using pll = pair<ll, ll>;
//-----------------------------

void solve()
{
	double sum = 0;
	ll n; cin >> n;
	for (int i = 0; i < n; i++) {
		double t; string s;
		cin >> t >> s;
		sum += (s == "JPY") ? t : t * 380000.0;
	}
	cout << sum;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
#ifdef LocaL
	freopen("input.txt", "r+", stdin);
	freopen("output.txt", "w+", stdout);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<pair<ll, ll>> CB(M);
    REP(i, M) cin >> CB[i].second >> CB[i].first;

    SORT(A);
    SORTR(CB);
    ll res = 0;
    int idx = 0;
    for (auto &p : CB) {
        if (idx == N || p.first <= A[idx]) break;
        REP(i, p.second) {
            if (idx == N || p.first <= A[idx]) break;
            A[idx] = p.first;
            ++idx;
        }
    }
    REP(i, N) res += A[i];
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();


    if (A == B) {
    System.out.println("Draw");
    }
    else if (A == 1 || A > B && B != 1){
      System.out.println("Alice");
    }
    else if (B == 1 || A < B && A != 1){
      System.out.println("Bob");
    }
  }
}


Measured memory_bytes: 23124
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=3e3+100;
const int mod=1e9+7;
int f[maxn][maxn],a[maxn];
int ksm(int num,int t){
    int res=1;
    for(;t;t>>=1,num=1ll*num*num%mod){
        if(t&1)res=1ll*num*res%mod;
    }
    return res;
}
int main(){
    int n,q;cin>>n>>q;
    rep(i,1,n)cin>>a[i];
    rep(i,1,n)rep(j,1,n)f[i][j]=a[i]<a[j];
    ll inv2=ksm(2,mod-2);
    rep(i,1,q){
        int x,y;cin>>x>>y;
        f[x][y]=f[y][x]=inv2*(f[x][y]+f[y][x])%mod;
        rep(j,1,n){
            if(j==x||j==y)continue;
            f[x][j]=f[y][j]=inv2*(f[x][j]+f[y][j])%mod;
            f[j][x]=f[j][y]=inv2*(f[j][x]+f[j][y])%mod;
        }
    }
    ll last=0;rep(i,1,n)rep(j,1,i-1)last=(last+f[i][j])%mod;
    cout<<last*ksm(2,q)%mod;
    return 0;
}

Measured memory_bytes: 40012
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<bool> rate(8,false);
  int extra = 0;

  rep(i,n){
    int a; cin >> a;
    int grade = a/400;
    if(grade<=7){
      rate[grade] = true;
    }else{
      extra++;
    }
  }

  int ans = 0;
  rep(i,8) if(rate.at(i)) ans++;

  int ans_max, ans_min;
  if(ans == 0){
    ans_max = extra;
    ans_min = 1;
  }else{
    ans_max = ans + extra;
    ans_min = ans;
  }

  cout << ans_min << " " << ans_max << endl;

}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	vector <int> h(n), zero(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0, active = 0;
	for (int i = 0; i < n; i++) {
		if (active < h[i]) {
			ans += h[i]-active;
			active = h[i];
		}
		else {
			active = h[i];

		}
	}
	cout << ans;


	cout << endl;
	return 0;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  
  int ans = 1;
  int d = 0;
  
  rep(i,n){
    d += l[i];
    if(d<=x) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
q=N

keta = 0
for num in range(100):
    q, mod = divmod(q, K)
    keta=keta+1
    if q==0:
        break


print(keta)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	ll H, W;
	
	cin >> N >> H >> W;
	int count = 0;

	for (int i = 0; i < N; i++)
	{
		ll h, w;
		cin >> h >> w;
		if ((h >= H) && (w >= W))
		{
			count++;
		}
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int modul = 1000000007;

int main() {
	int n, w;
	cin >> n >> w;

	char field[n][w];
	long long ways[n][w]; 

	for (int i = 0;i < n;i++) 
		for (int j = 0;j < w;j++) { cin >> field[i][j]; ways[i][j] = 0; }

	ways[0][0] = 1;
	
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < w;j++) {
			if ((i == 0 && j == 0) || field[i][j] == '#') continue;
			else if (i == 0) ways[i][j] = ways[i][j - 1];
			else if (j == 0) ways[i][j] = ways[i - 1][j];
			else ways[i][j] = (ways[i][j - 1] + ways[i - 1][j]) % modul;	        	
		}
	}	

	if (n == 1 && w == 1) cout << 0;
	else cout << ways[n - 1][w - 1];
}

Measured memory_bytes: 9088
#include<cstdio>
#define MAX 10000
#define NIL -1

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

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

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

int setHeight(int u){
	int h1 = 0,h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

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

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}else if(T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}


int main(){
	int v,l,r,root = 0;
	scanf("%d",&n);
	
	for(int i = 0;i < n;i++) T[i].parent = NIL;
	
	for(int i = 0;i < n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	for(int i = 0;i < n;i++) if (T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i = 0;i < n;i++) print(i);
	return 0;
} 


Measured memory_bytes: 2736
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    string s, t;
    cin >> s >> t;
    ll ans = 0;
    for(ll i = 0; i < s.size(); i++)if(s[i] == t[i])ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 100000000

using namespace std;

int main(void){

  int L;
  while( cin >> L , L ){

    int M,N;
    int ans = 0;
    for( int i = 1 ; i <= 12 ; i++ ){
      cin >> M >> N;
      L -= ( M - N );
      if( L <= 0 ){
	ans = i;
	L = MAX;
      }
    }
    if( ans ) cout << ans << endl;
    else cout << "NA" << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
A,B,C,D,E,F =map(int,input().split())

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    bmax = (F-100*A*a)//B
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        
        for c in range(cmax,-1,-1):
            dmax = (F-100*A*a-100*B*b-C*c)//D
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))
                    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[10001],b[10001];
int main(){
  int n;
  int hito[501];
  int m;
  int tyoku[501];
  //int a[10001],b[10001];
  while(1){
    cin>>n;
    cin>>m;
    if(n==0 && m==0) break;
    int ans=0;
    for(int i=1;i<=n;i++){
      hito[i]=0;
      tyoku[i]=0;
    }
    
    for(int i=0;i<m;i++){
      
      cin>>a[i]>>b[i];
      if(a[i]==1){
	tyoku[b[i]]=1;
	hito[b[i]]=1;
      }else if(b[i]==1){
	tyoku[a[i]]=1;
	hito[a[i]]=1;
      }
    }
    for(int i=0;i<m;i++){
      if(tyoku[a[i]]==1 && tyoku[b[i]]==0){
	hito[b[i]]=1;
	//cout<<i<<endl;
      }else if(tyoku[a[i]]==0 && tyoku[b[i]]==1){
	hito[a[i]]=1;
	//cout<<i<<endl;
      }
     
    }
    for(int i=2;i<=n;i++){
      if(hito[i]){
	//cout<<i<<endl;
	ans++;
      }
    }
    cout<<ans<<endl;
  }
}
    

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <iomanip>

using namespace std;

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

    int t = 251;

    vector<vector<int>> x(a, vector<int>(b, t));

    for (int i = 0; i + c - 1 < a; i += c) {
        for (int j = 0; j + d - 1 < b; j += d) {
            x[i + c - 1][j + d - 1] = -t * (c * d - 1) - 1;
        }
    }

    long long s = 0;

    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            s += x[i][j];
        }
    }

    if (s <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;

        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                cout << x[i][j] << " \n"[j + 1 == b];
            }
        }
    }
}


Measured memory_bytes: 2304
n, m = map(int, input().split())
a = [int(a) for a in input().split()]    
required_matches = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}

dp = [0] + [-1] * n
for used_matches in range(1, n+1):
    usable_digits = [ai for ai in a if used_matches - required_matches[ai] >= 0]
    if usable_digits != []:
        dp[used_matches] = max([dp[used_matches-required_matches[ai]]*10 + ai
            for ai in usable_digits])
print(dp[n])


Measured memory_bytes: 14516
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    /*
    ll N=30;
    ll dp[N][N];memset(dp,0,sizeof(dp));
    rep(sum,0,N*2){
        rep(i,0,N-1){
            ll j=sum-i;
            if(j<0||j>N-1)continue;
                for(ll mi=2;mi<=i;mi+=2){
                    if(j+mi/2<=N-1)if(dp[i-mi][j+mi/2]==0)dp[i][j]=1;
                }
                for(ll mj=2;mj<=j;mj+=2){
                    if(i+mj/2<=N-1)if(dp[i+mj/2][j-mj]==0)dp[i][j]=1;
                }
            
        }
    }
    rep(i,0,N-1){
        rep(j,0,N-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll s,t;cin>>s>>t;
    if(s>t)swap(s,t);
    if(t>=s+2){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Brown"<<endl;
    }
    
    return 0;
}



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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



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

int main(){
	ios::sync_with_stdio(0);cin.tie(NULL);
	string s; cin>>s;
	
	string aux (s.rbegin(),s.rend());
	if(s==aux){
		string s1 (s.begin(),s.begin()+(s.size()-1)/2);
		string s2 (s.begin()+(s.size()+3)/2-1,s.end());
		string s3 (s1.rbegin(),s1.rend());
		string s4 (s2.rbegin(),s2.rend());
		if(s1==s3&&s2==s4){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
	else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++ ) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int x; cin >> x;
  if(400 <= x && x < 600) cout << 8 << "\n";
  else if(600 <= x && x < 800) cout << 7 << "\n";
  else if(800 <= x && x < 1000) cout << 6 << "\n";
  else if(1000 <= x && x < 1200) cout << 5 << "\n";
  else if(1200 <= x && x < 1400) cout << 4 << "\n";
  else if(1400 <= x && x < 1600) cout << 3 << "\n";
  else if(1600 <= x && x < 1800) cout << 2 << "\n";
  else if(1800 <= x && x < 2000) cout << 1 << "\n";      
  return 0;
}


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

int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}


bool powered(int x){
	map<int,int>cnt;
	vector<int>v;
	for(int i=2;i*i<=x;i++){
		while(i>1&&x%i==0){
			cnt[i]++;
			x/=i;
		}
	}
	if(x>0)cnt[x]++;
//  	for(auto&& u:cnt)cout<<u.first<<" "<<u.second<<endl;cout<<endl;
  
	for(auto&& u:cnt){if(u.first!=1)v.push_back(u.second);}
	int y=v[0];	
	for(auto&& u:v)y=gcd(y,u);
	if(y>1)return true;
	else return false;
}


int main(){
	int x;cin>>x;
	for(int i=x;i>=2;i--){
		if(powered(i))cout<<i<<endl,exit(0);
	}
	cout<<1<<endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] sp = s.split("");
        int[] n = new int[4];
        String ans = "No";
        for(int i=0; i<4; i++) {
            n[i] = Integer.parseInt(sp[i]);
        }
        if(n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3]) ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i*j==N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;

  vector<char> A(H*W);
  for(int i = 0; i < A.size(); i++){
  	cin >> A.at(i);
  }

  for(int i =0; i < W+2; i++){
  	cout << '#';
  }cout << endl;
 
 for(int j=0; j < H; j++){
  	cout << '#';
	for(int i =0; i < W; i++){
      cout << A.at(W*j + i);
      
	}cout << '#' << endl;
  }
 
  for(int i =0; i < W+2; i++){
  	cout << '#';
  }cout << endl;
}

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

typedef long long ll;
const int N = 1000 + 5, MOD = 1e9 + 7;

int n, m;
ll dp[N][N];
char grid[N][N];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= m; j++) cin >> grid[i][j];

  dp[1][1] = 1;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      if(grid[i][j] == '.') {
        ll a = 0, b = 0;
        if(i-1 >= 1) a = dp[i-1][j];
        if(j-1 >= 1) b = dp[i][j-1];
        if(i != 1 or j != 1) dp[i][j] = (a+b)%MOD;
      }
    }
  }
  cout << dp[n][m] << "\n";
}


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

int main() {
    int64_t a, b, k;
    cin >> a >> b >> k;

    if (k <= a) {
        a -= k;
    } else if (k <= a + b) {
        b -= k - a;
        a = 0;
    } else {
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4010;
int n,pre[maxn][3],suf[maxn][3];
char s[maxn];
int d[maxn];
ll ans;
int main() {
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) {
		if (s[i]=='R') d[i]=0;
		else if (s[i]=='G') d[i]=1;
		else d[i]=2;
	}
	for (int i=1;i<=n;i++) {  //前缀和 
		for (int j=0;j<3;j++) pre[i][j]=pre[i-1][j];
		pre[i][d[i]]++;
	}
	for (int i=n;i>=1;i--) {  //后缀和 
		for (int j=0;j<3;j++) suf[i][j]=suf[i+1][j];
		suf[i][d[i]]++;
	}
	for (int i=1;i<=n;i++) {
		for (int j=0;j<3;j++)
		for (int k=0;k<3;k++)
			if (d[i]!=j&&j!=k&&k!=d[i])  //3个字母不同 
				ans+=pre[i-1][j]*suf[i+1][k];
	}
	for (int i=1;i<=n;i++)
	for (int j=i+1,k;j<=n;j++) {  //处理j-i==k-j的情况 
		k=j*2-i;
		if (j<k&&k<=n) {
			if (d[i]!=d[j]&&d[j]!=d[k]&&d[k]!=d[i]) ans--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int on(const vector<vector<int> >& s, const vector<int>& p, vector<int>& now, int i)
{
    if(i != (int)now.size()){
        int sum = 0;
        now[i] = 0;
        sum += on(s, p, now, i+1);
        now[i] = 1;
        sum += on(s, p, now, i+1);
        return sum;
    }
    else{
        int x, ret = 0;
        for(int j = 0; j < (int)p.size(); j++){
            x = 0;
            for(int k = 0; k < (int)now.size(); k++){
                x += s[j][k] && now[k];
            }
            if(x % 2 == p[j]) ret += 1;
        }
        return (ret == (int)p.size());
    }
}

int main()
{
    int n, m, k, ss;
    cin >> n >> m;
    vector<vector<int> > s(m, vector<int> (n));
    vector<int> p(m), now(n, 0);
    for(int i = 0; i < m; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> ss;
            s[i][ss-1] = 1;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }
    cout << on(s, p, now, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

ll mp[31][100010];

void solve() {
    ll N, C;
    cin >> N >> C;
    REP(i, N) {
        ll s, t, c;
        cin >> s >> t >> c;
        c--;
        for(ll j = s - 1; j < t; j++) {
            mp[c][j] |= 1;
        }
    }
    ll ans = 0;
    REP(t, 100010) {
        ll tmp = 0;
        REP(c, C) {
            tmp += mp[c][t];
        }
        ans = max(ans, tmp);
    }
    out(ans);
}

int main() {
    fast_io;
    solve();
    return 0;
}

Measured memory_bytes: 23680
N = int(input())
dp = [0, 0, 0]
for _ in range(N):
    a, b, c = map(int, input().split())
    dp = [a+max(dp[1], dp[2]), b+max(dp[0], dp[2]), c+max(dp[0], dp[1])]
print(max(dp))

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

using namespace std;

int main(){

    int n;
    cin >> n;

    int sum = 0;
    int l, r;
    for(int i = 0; i < n; i++){
	cin >> l >> r;
	sum += (r - l + 1);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,d,s;
  while(scanf("%d",&d)!=EOF){
    s=0;
    for(i=0;i<600/d;i++){
      s+=(d*((d*i)*(d*i)));
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 596
S = input()
count1 = 0
count2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] != '0':
            count1 += 1
        else:
            count2 += 1
    else:
        if S[i] != '1':
            count1 += 1
        else:
            count2 += 1
print(min(count1,count2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
ll A[200010], B[200010];

signed main(){
    cin >> N;
    REP(i, N) cin >> A[i] >> B[i];
    sort(A, A + N);
    sort(B, B + N);
    ll x, y;
    if(N % 2 == 0) x = A[N / 2 - 1] + A[N / 2];
    else x = A[N / 2];
    if(N % 2 == 0) y = B[N / 2 - 1] + B[N / 2];
    else y = B[N / 2];
    ll ans = (y - x) + 1;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 6740
import java.util.Scanner;

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


        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());

        int count = 0;

        for (int i = 0; i < n; i++) {
            double x1 = Double.parseDouble(sc.next());
            double x2 = Double.parseDouble(sc.next());

            if (Math.sqrt(x1 * x1 + x2 * x2) <= d) {
                count++;
            }
        }

        System.out.println(count);


    }

}


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

int main() {
  int A, B, tmp;
  int count = 0;
  int s1, s2, s3, s4, s5;
  
  cin >> A >> B;
  for(int i = A; i <= B; i++){
    tmp = i;
    s1 = tmp % 10;
    tmp /= 10;
    s2 = tmp % 10;
    tmp /= 10;
    s3 = tmp % 10;
    tmp /= 10;
    s4 = tmp % 10;
    tmp /= 10;
    s5 = tmp % 10;
    if(s1 == s5 && s2 == s4) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N,a;
  int max = 0;
  int min = 999999999;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> a;
    if(max < a) max = a;
    if(min > a) min = a;
  }
  cout << max - min <<endl;
}

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

int main() {
   
  int n, k;
  cin >> n >> k;
  int x = 1;
  
  for (int i = 1; i < n+1; i++){
    if (x > k){
       x += k;
       continue;
       }
    
    x *= 2;
  }
  
  cout << x << endl;
}


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

int main(void) {
	int n;
	double u, sum = 0.0;
	char x[3], j[5] = "JPY";
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> u >> x;
		if(!strcmp(j,x))
			sum += u;
		else
			sum = sum + u * 380000;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   while(1){
       int n,x,t=0;
       scanf("%d%d",&n,&x);
       
     if(n==0&&x==0)
     break;
     
     for(int i=1;i<=n;i++){
         for(int j=i+1;j<=n;j++){
             for(int k=j+1;k<=n;k++){
                 if(i+j+k==x){
                 t++;
                 }
             }
         }
     }
     
     printf("%d\n",t);
   }
    return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    //時計は12*60で360度
    //単身は60で360度
    //
    double x = m * 6;
    double y = (h * 60 + m) * 360.0 / (12.0 * 60.0);
    double j = a * a + b * b - 2 * cos((x - y) / 180.0 * M_PI) * a * b;
    j = sqrt(j);
    cout << fixed << setprecision(15) << j;
    //cout << cos(x - y) << endl;
    //cout << (x - y);
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
const int inf = 0x3f3f3f3f;

int main() {
    int n, cur = 0, ans = 0;
    char str[N];
    scanf("%d%s", &n, str);
    for(int i = 0; i < n; i++) {
        cur += (str[i]=='I'?1:-1);
        ans = max(cur, ans);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
require 'matrix'

def len3d(x, y)
  l2=0.0
  0.upto(3-1){|i|
    l2 += (x[i] - y[i])**2
  }
  return Math.sqrt(l2)
end

def heron(a,b,c)
  s = (a + b + c) / 2.0
  return  Math.sqrt(s*(s-a).abs*(s-b).abs*(s-c).abs)
end

Eps=1e-9
def solve(a,b,c,d,e)   # returns true if beam hits barrier.
  # a, b, c: ????????¢???????§???¢??????????????????????????????
  # d:???????????????????????????
  # e:???????????????????????????
  # a + s*u + t*v = d + x*w ????§£??????(0<x<1) ???P(d+xw)???????§???¢ABC????????¨???????????°??????????????????????????????
  # ??????????????????true?????§???????????°false????????????
  u = c - a
  v = b - a
  w = e - d
  m = Matrix.columns([u, v, -w])

#  abort("Impssible case") if m.determinant.abs <Eps
  return false if m.determinant.abs <Eps
  parms = m.lup.solve(d - a)

  s = parms[0]
  t = parms[1]
  x = parms[2]
# ???P???????§???¢ABC??????????????¢??¨??´???DE??¨?????????
  return false if x < 0 or x > 1.0
  p = d + x*w
# ????§???¢ PAC, PAB, PBC?????¢???????????¨????§???¢ABC?????¢????????????????????°???P???ABC???????????????
  pa = len3d(a, p)
  pb = len3d(b, p)
  pc = len3d(c, p)

  ab = len3d(b, a)
  ac = len3d(c, a)
  bc = len3d(c, b)

  s0=heron(ab,ac,bc)
  s1=heron(pa,pc,ac)
  s2=heron(pa,pb,ab)
  s3=heron(pb,pc,bc)

  return  (s1+s2+s3-s0).abs <Eps
end

def main
  if true then
#  if false then
    fh=STDIN
  else
    #fh=open("in1_0115a.txt")
    #fh=open("in1_0115b.txt")
    fh=open("in1_0115c.txt")
  end
  d1,d2,d3=fh.gets.chomp.split.map{|x| x.to_i}
  e1,e2,e3=fh.gets.chomp.split.map{|x| x.to_i}

  a1,a2,a3=fh.gets.chomp.split.map{|x| x.to_i}
  b1,b2,b3=fh.gets.chomp.split.map{|x| x.to_i}
  c1,c2,c3=fh.gets.chomp.split.map{|x| x.to_i}

  d=Vector[d1,d2,d3]
  e=Vector[e1,e2,e3]
  a=Vector[a1,a2,a3]
  b=Vector[b1,b2,b3]
  c=Vector[c1,c2,c3]

  if solve(a,b,c,d,e) then
    puts "MISS"
  else
    puts "HIT"
  end

end

if $0 == __FILE__ then
  main
end

Measured memory_bytes: 9340
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        a:i32,b:i32,x:i32,
    }
    println!("{}",if a<=x&&x<=a+b{"YES"}else{"NO"});
}

Measured memory_bytes: 2164
N = int(input())
src = [list(map(int,input().split())) for i in range(N)]

ans = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if src[i][j] > src[i][k] + src[k][j]:
                print(-1)
                exit()
            src[i][j] = min(src[i][j], src[i][k] + src[k][j])

for i in range(N-1):
    for j in range(i+1,N):
        use = True
        for k in range(N):
            if k==i or k==j: continue
            if src[i][j] == src[i][k] + src[k][j]:
                use = False
                break
        if use:
            ans += src[i][j]
print(ans)

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

int main(void){
  int num[5];

  for( int i = 0 ; i < 5 ; i++ ) cin >> num[i];

  stable_sort( num , num+5 );

  for( int i = 4 ; i >= 0 ; i-- ){
    if( i == 4 ) cout << num[i];
    else cout << " " << num[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> b(n);
  rep(i,n) cin >> b[i];
  vector<ll> a2(0);
  vector<ll> b2(0);
  rep(i,n){
    if(a[i]>b[i]) b2.push_back(a[i]-b[i]);
    if(a[i]<b[i]){
      if((b[i]-a[i])%2==1) a2.push_back(b[i]-a[i]-1);
      else a2.push_back(b[i]-a[i]);
    }
  }
  bool f=1;
  ll suma=0;
  rep(i,a2.size()){
    suma+=a2[i];
  }
  ll sumb=0;
  rep(i,b2.size()){
    sumb+=b2[i];
  }
  if(suma>=sumb*2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  
}

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

int main() {
  int n,d ; cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n) {
    rep(j,d) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i,n) {
    rep(j,n) {
      if (i == j) continue;
      double dist = 0;
      rep(k,d) {
        dist += pow(x[i][k] - x[j][k], 2);
      }
      dist = pow(dist, 0.5);
      if (dist - (int)dist == 0) ans++;
    }
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 384