akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	int div_row,div_col,num;
};

int N,M;

void func(){
	int scenely[N][N],picture[4][M][M];

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)scanf("%d",&scenely[i][k]);
	}

	for(int i = 0; i < M; i++){
		for(int k = 0; k < M; k++)scanf("%d",&picture[0][i][k]);
	}

	//??????????????¢?????????
	//90
	for(int i = 0; i <= M-1; i++){
		for(int k=0; k <= M-1; k++){
			picture[1][k][M-1-i] = picture[0][i][k];
		}
	}

	//180
	for(int i=0; i <= M-1; i++){
		for(int k=0; k <= M-1;k++){
			picture[2][k][M-1-i] = picture[1][i][k];
		}
	}

	//270
	for(int i=0; i <= M-1; i++){
		for(int k=0; k <= M-1;k++){
			picture[3][k][M-1-i] = picture[2][i][k];
		}
	}

	Info data[4][M*M];
	int index[4] = {0,0,0,0};

	for(int i = 0; i < 4; i++){
		for(int row = 0; row < M; row++){
			for(int col = 0; col < M;col++){
				if(picture[i][row][col] != -1){
					data[i][index[i]].div_row = row;
					data[i][index[i]].div_col = col;
					data[i][index[i]].num = picture[i][row][col];
					index[i]++;
				}
			}
		}
	}

	int ans_row = -1,ans_col = -1;
	bool FLG = false;

	for(int i = 0; i <= N-M; i++){
		for(int k = 0; k <= N-M; k++){
			for(int a = 0; a < 4; a++){
				FLG = true;
				for(int b = 0; b < index[a];b++){
					if(scenely[i+data[a][b].div_row][k+data[a][b].div_col] != data[a][b].num){
						FLG = false;
						break;
					}
				}
				if(FLG){
					ans_row = i+data[a][0].div_row;
					ans_col = k+data[a][0].div_col;
					break;
				}
			}
			if(FLG)break;
		}
		if(FLG)break;
	}

	if(!FLG){
		printf("NA\n");
	}else{
		printf("%d %d\n",ans_col+1,ans_row+1);
	}
}


int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define rep(x,b,c) for(int x=b;x<c;x++)
#define  pb(x) push_back(x)
int main(){
    int n,r;
	cin>>n>>r;
	if(n>=10){
		cout<<r;
	}
	else{
		int a=0;
		a=100*10-100*n;
		a+=r;
		cout<<a;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t;
	int x(0);
	rep(i, 0, s.length()) {
		if (s[i] != 'x')t.push_back(s[i]);
		else x++;
	}
	string t_rev(t);
	reverse(all(t_rev));
	if (t != t_rev) {
		cout << -1 << endl;
		return 0;

	}


	int ans(0);
	int l = 0, r = s.length() - 1;
	while (l < r) {
		if (s[l] == s[r])l++, r--;
		else if (s[l] == 'x')l++, ans++;
		else if (s[r] == 'x')r--, ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

signed main(){
    int n; cin >> n;
    int num[n];
    rep(i,n) num[i]=0;
    for(int i=1;i<=n;i++){
        if(is_prime(i)){
            int j=i;
            while(n/j>0){
                num[i]+=n/j;
                j*=i;
            }
        }
    }
    ll n3=0,n5=0,n15=0,n25=0,n75=0;
    rep(i,n){
        if(num[i]>1) n3++;
        if(num[i]>3) n5++;
        if(num[i]>13) n15++;
        if(num[i]>23) n25++;
        if(num[i]>73) n75++;
    }
    ll ans=(n3-n5)*n5*(n5-1)/2;
    ans+=n5*(n5-1)*(n5-2)/2;
    
    ans+=(n3-n25)*n25;
    ans+=n25*(n25-1);
    
    ans+=(n5-n15)*n15;
    ans+=n15*(n15-1);
    
    ans+=n75;
    
    cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
A = list(int(i) for i in (input().split()))

cnt = 0
tmp_sum = 0
minimum = 1000000000
for i in range(n):
  if(A[i] <= 0):
    cnt += 1
    tmp_sum = tmp_sum - A[i]
    if(minimum > A[i] * (-1)):
      minimum = A[i] * (-1)
  elif(A[i] > 0):
    tmp_sum = tmp_sum + A[i]
    if(minimum > A[i]):
      minimum = A[i]
if((cnt % 2) == 1):
  sum = tmp_sum - minimum * 2
else:
  sum = tmp_sum
print(sum)
    

Measured memory_bytes: 14464
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1<<30;

int main() {
  int N; cin >> N;
  int X[N];
  for(int i = 0; i < N; i++) cin >> X[i];
  int ans = inf;
  for(int i = 1; i <=100; i++) {
    int tmp = 0;
    for(int j = 0; j < N; j++) {
      tmp += (X[j] - i) * (X[j] - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string st; cin>>st;
    int n=st.length(); st.insert(0," ");
    int l=-1,r=-1;
    for (int i=1; i <= n-1; i++)
        if (st[i] == st[i+1]){
            l=i, r=i+1;
            break;
        }
    for (int i=1; i <= n-2; i++)
        if (st[i] == st[i+2]){
            l=i, r=i+2;
            break;
        }
    cout<<l<<' '<<r;
    return 0;
}

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

int main() {
	// your code goes here
	
	int a,b,c;
	
	cin>>a>>b>>c;
	

		if((a == b && a == 5) && c == 7){
			cout << "YES"<<endl;
		}else if ((a == c && a == 5) && b == 7){
			cout << "YES"<<endl;
		}else if ((b == c && b == 5) && a == 7){
			cout << "YES"<<endl;
		}else{
			cout << "NO" << endl;
		}

	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int i,j,n,m,x;
    int a[100][100],b[100];
     
    scanf("%d %d",&n,&m);
     
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
     
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
     
    for(i=0;i<n;i++){
        x = 0;
        for(j=0;j<m;j++){
            x += a[i][j] * b[j];
        }
        printf("%d\n",x);
    }
    return 0;
}

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

void solve()
{
    ll n,w;
    cin>>n>>w;
    ll weight[n];
    ll value[n];
    for(ll i=0;i<2*n;i++)
    {
        cin>>weight[i];
        cin>>value[i];
    }
    ll arr[n][w+1];
    for(ll i=1;i<w+1;i++)
    {
        if (weight[0]>i)
            arr[0][i]=0;
        else
            arr[0][i]=value[0];
    }
    for(ll i=0;i<n;i++)
        arr[i][0]=0;
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<w+1;j++)
        {
            ll include=0,exclude=0;
            if (j-weight[i]>=0)
                include=value[i]+arr[i-1][j-weight[i]];
            exclude=arr[i-1][j];
            arr[i][j]=max(include,exclude);
        }
    }
    cout<<arr[n-1][w]<<"\n";
        
}
int main()
{
    solve();
    
    
    
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using std::cin;
using std::cout;
using std::endl;
using std::getline;
using std::string;

int main()
{
    string n, word, shuffle;
    int num,m;
    cin >> n;
    word = n;
    cin >> m;

    while (cin >> n && n != "-")
    {
        if (std::all_of(n.cbegin(), n.cend(), isdigit))
        {
            num = atoi(n.c_str());
            shuffle = word.substr(num);
            word = word.erase(num);
            word = shuffle + word;
        }
        else if (std::all_of(n.cbegin(), n.cend(), isalpha))
        {
            cout << word << endl;
            word = n;
            cin >> m;
        }
    }

    cout << word << endl;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	
	string s;
	cin >> s;
	
	for (int mask = 0; mask < 4; mask++) {
		// 0が羊, 1が狼
		int st0 = (mask >> 0) & 1,
			st1 = (mask >> 1) & 1;
		cerr << "(0, 1) " << st0 << ", " << st1 << endl;
		vector<int> states(N, -1);
		states[0] = st0;
		states[1] = st1;
		
		bool complete = true;
		
		for (int i = 1; i <= N; i++) {
			// i,i-1を利用して次の状態を決定する。
			int cur = i % N;
			int nxt = (cur + 1) % N;
			int prv = (cur - 1 + N) % N;
			int nxtstate = -1;
			
			if (states[cur] == 0) { // 羊
				if (s[cur] == 'o') nxtstate = states[prv];
				else nxtstate = states[prv] ^ 1;
			} else {	// 狼
				if (s[cur] == 'o') nxtstate = states[prv] ^ 1;
				else nxtstate = states[prv];
			}
			if (states[nxt] >= 0 && states[nxt] != nxtstate) complete = false;
			
			states[nxt] = nxtstate;
		}
		
		if (!complete) continue;
		
		for (int i = 0; i < N; i++) {
			cout << "SW"[states[i]];
		}
		cout << endl;
		
		return 0;
	}
	
	cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 1016
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)


Measured memory_bytes: 3060
import sys
from math import ceil, floor

def cut_logs(x, a):
    return sum(ceil(ai / x) - 1 for ai in a)


def resolve(in_):
    n, k = map(int, next(in_).split())
    logs = tuple(map(int, next(in_).split()))  # A
    assert n == len(logs)
    max_logs = max(logs)

    lb = 0
    ub = max_logs
    while ub - lb > 1:
        mid = (ub + lb) // 2
        v = cut_logs(mid, logs)
        # print(f'{lb=} {mid=} {ub=} {v<=k=} {v=} {k=}')
        if v <= k:
            ub = mid
        else:
            lb = mid
    # print(f'end: {lb=} {mid=} {ub=} {v<=k=} {v=} {k=}')

    return ub


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29368
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
int N;
int A[200005];
int B[200005];
signed main(){
    scanf("%lld",&N);
    rep(i,N){
        scanf("%lld %lld",&A[i],&B[i]);
        //中央値が1/2の場合があるので2倍しておく
        A[i]*=2;B[i]*=2;
    }
    //Aの中央値、Bの中央値を求める
    int AM,BM;
    int ans=0;
    sort(A,A+N);sort(B,B+N);
    if(N%2){//奇数
        AM=A[N/2];BM=B[N/2];
        //AMからBMの間の2の倍数が全て中央値になりうる
        ans=(BM-AM)/2+1;
    }else{
        AM=(A[N/2]+A[N/2-1])/2;
        BM=(B[N/2]+B[N/2-1])/2;
        //AMからBMの間の整数が全て中央値になりうる
        ans=BM-AM+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4828
// B.

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	long long n, a, e = 0, o = 0, p, ans;
	cin >> n >> a;
	e = (a % 2) ? 2 : 1;
	o = (a % 2) ? 1 : 2;
	for (int i = 1; i < n; ++i) {
		cin >> a;
		long long pe = e, po = o;
		e = (a % 2) ? (pe * 3 + po * 2) : (pe * 3 + po);
		o = (a % 2) ? po : (po * 2);
	}
	cout << e << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000009LL
 
LL k[100][10000];

int main(){
    while(1){
		memset(k, 0, sizeof(k));
        int n;
        cin >> n;
        if(n==0)return 0;
        VI v;
        int s=0;
        REP(i,n){
            int tmp;
            cin >> tmp;
            v.PB(tmp);
        }
        SORT(v);
        FOR(i, 1, n-1)s+=v[i];
        cout << s/(n-2) << endl;
    }
}

Measured memory_bytes: 9036
#include <stdio.h>
#include <string.h>

int calculation(int a, int b, int *c){
	int i,x;
	x=1;
	if(1<=a&&a<=100){ //??¶?´?
		for(i=0;i<b;i++){ //?????????????¨????
			x=x*a;
		}
		*c=x;
		if(c!=NULL){
			return 0;
		}
		else{
			return (-1);
		}
	}
	else
	{
		return (-1);
	}
}

int main(){
	int a,b,c,r;
	scanf("%d",&a); //??\???
	b=3;
	r=calculation(a,b,&c);
	if(r==0){
	printf("%d\n",c); //??????
	return 0;
	}
	else
	{
		printf("over\n"); //?????????
		return 1;
	}
}

Measured memory_bytes: 1804
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll;



ll ans,mx,sum,mn=1e8;
int main(){
	ll h,n;
	cin>>h>>n;
	for(int i=0; i<n; i++){
		ll a;
		cin>>a;
		sum+=a;
	}
	if(sum>=h) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
double r;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> r;
	printf("%.12lf\n",2.0*pi*r);
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//int frq[123];
int main(){
	Lancer();
	ll n;
	cin >> n;
	if (n % 4 == 0 || n % 7 == 0)
		cout << "Yes";
	else {
		bool ch = false, ok = false;
		int i = n;
		while (n>4)
		{
			n -= 4;
			if (n% 7 == 0){
				ch = true;
				break;
			}
		}
		while (i>7)
		{
			i -= 7;
			if (i % 4 == 0){
				ok = true;
				break;
			}
		}
		if (ch || ok) cout << "Yes";
		else cout << "No";
	}
	cout << endl;
	return 0;
}


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

int main()
{
	long long  n,sum =0 ;
	cin>>n;
	for(long long  i=1;i<=n;i++)
	{
		if(i%5!=0 && i%3!=0){
			sum += i;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  int p=0;
  for(i=0;i<n;i++){
    if(s[i+1]!=s[i])
      p++;
  }
  printf("%d\n",p);
  return 0;}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.append(0)

ans = 0
rem = 0
for i in range(N+1):
    if A[i] <= B[i] + rem:
        ans += A[i]
        rem = min(B[i] + rem - A[i], B[i])
    else:
        ans += B[i] + rem
        rem = 0
print(ans)


Measured memory_bytes: 82020
/**
 * Created by hiramekun at 18:47 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll x;
    cin >> x;
    cout << x / 500 * 1000 + x % 500 / 5 * 5 << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
  while (true) {
    i32 e;
    cin >> e;
    if (e == 0) break;
    i32 ans = inf<i32>;
    for (i32 z = 0; z * z * z <= e; ++z) {
      i32 s0 = z * z * z;
      for (i32 y = 0; s0 + y * y <= e; ++y) {
        i32 s1 = s0 + y * y;
        i32 x = e - s1;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace aoj_ALDS1_3_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int commandCount = int.Parse(Console.ReadLine());
			LinkedList<int> list = new LinkedList<int>();
            for (int i = 0; i < commandCount; i++)
			{
				string[] inputArray = Console.ReadLine().Split(' ');
                switch (inputArray[0])
				{
					case "insert":
						list.AddFirst(int.Parse(inputArray[1]));
						break;

					case "delete":
						list.Remove(int.Parse(inputArray[1]));
						break;

					case "deleteFirst":
						list.RemoveFirst();
						break;

					case "deleteLast":
						list.RemoveLast();
						break;

					default:
						break;
				}
			}

			Console.WriteLine(string.Join(" ", list));
        }
    }
}



Measured memory_bytes: 73320
#include <stdio.h>

int main() {
  while(1) {
    long a, b;
    long i = 2;
    long GCM = 1;
    long LCM = 1;

    if (scanf("%ld %ld", &a, &b) == EOF) break;

    while ((i<=a)&&(i<=b)) {
      if ((a%i==0)&&(b%i==0)) {
        GCM *= i;
        a /= i; b/= i;
      }
      else
        i++;
    }
    LCM = GCM * (a/LCM) * (b/LCM);
    printf("%ld %ld\n", GCM, LCM);
  }
  return 0;
}

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

int main()
{

  int n;
  while(cin>>n){
    if( n == 0 ) break;

    int score[n];
    for(int i = 0; i < n; ++i){
      score[i] = 0;
    }
    for(int i = 0; i < n*(n-1)/2; ++i){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      --a;
      --b;
      
      score[a] += c>d?3:c==d?1:0;
      score[b] += d>c?3:c==d?1:0;
    }

    vector<pair<int,int> > v;
    for(int i = 0; i < n; ++i){
      v.push_back( make_pair(score[i], i) );
    }
    sort(v.begin(), v.end());

    int rank[n];

    /*
    for(int i = 0; i < n; ++i){
      cout << score[i] << endl;
    }
    */
    
    for(int i = n-1; i >= 0; --i){
      rank[ v[i].second ] = n-1-i+1;
      if( i<n-1 && v[i].first == v[i+1].first){
        rank[ v[i].second ] = rank[ v[i+1].second ];
      }
    }
    
    for(int i = 0; i < n; ++i){
      cout << rank[i] << endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int H = sc.nextInt();
      int W = sc.nextInt();
      int[][] a = new int[H][W];
      for (int i = 0; i < H * W; i++) {
        a[(int) i / W][(int) i % W] = sc.nextInt();
      }
      print(solve(a));
    }
  }

  public static int[][] solve(int[][] a) {
    int[][] r = new int[a.length * a[0].length][4];
    int rlen = 0;
    for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < a[0].length; j++) {
        rlen = solve2(i, j, a, r, rlen);
      }
    }
    return r;
  }

  public static int solve2(int x, int y, int[][] a, int[][] r, int rlen) {
    if (a[x][y] % 2 == 0) {
      return rlen;
    }
    if (x + 1 < a.length) {
      if (a[x + 1][y] == 1) {
        a[x][y]--;
        a[x + 1][y] += 1;
        setRoute(r, rlen, x, y, x + 1, y);
        return rlen + 1;
      }
    }
    if (y + 1 < a[0].length) {
      if (a[x][y + 1] == 1) {
        a[x][y]--;
        a[x][y + 1] += 1;
        setRoute(r, rlen, x, y, x, y + 1);
        return rlen + 1;
      }
    }
    if (x + 1 < a.length) {
      a[x][y]--;
      a[x + 1][y] += 1;
      setRoute(r, rlen, x, y, x + 1, y);
      return rlen + 1;
    }
    if (y + 1 < a[0].length) {
      a[x][y]--;
      a[x][y + 1] += 1;
      setRoute(r, rlen, x, y, x, y + 1);
      return rlen + 1;
    }
    return rlen;
  }

  public static void setRoute(int[][] r, int pos, int x, int y, int x2, int y2) {
    r[pos][0] = x;
    r[pos][1] = y;
    r[pos][2] = x2;
    r[pos][3] = y2;
  }

  public static void print(int[][] r) {
    int print = r.length;
    for (int i = 0; i < r.length; i++) {
      if (r[i][0] == 0 && r[i][1] == 0 && r[i][2] == 0 && r[i][3] == 0) {
        print = i;
        break;
      }
    }
    System.out.println(print);
    for (int i = 0; i <= print; i++) {
      if (r[i][0] == 0 && r[i][1] == 0 && r[i][2] == 0 && r[i][3] == 0) {
        break;
      }
      System.out.println(IntStream.of(r[i]).map(e -> e + 1).mapToObj(String::valueOf)
          .collect(Collectors.joining(" ")));
    }
  }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,a,b; cin>>n>>a>>b;
	int64_t ans=0;
	int fx; cin>>fx;
	for(int i=1;i<n;++i){
		int x; cin>>x;
		ans+=min((size_t)(x-fx)*a,(size_t)b);
		fx=x;
	}
	cout<<ans<<"\n"s;
}

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

const long long MOD = 1000000007;
int N;
long long dp[101][5][5][5];

int main() {
  cin >> N;
  dp[0][0][0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < 5; ++j) {
      for (int k = 0; k < 5; ++k) {
        for (int l = 0; l < 5; ++l) {
          for (int m = 1; m < 5; ++m) {
            if (k == 1 && l == 3 && m == 2) continue;
            if (k == 1 && l == 2 && m == 3) continue;
            if (k == 3 && l == 1 && m == 2) continue;
            if (j == 1 && k == 3 && m == 2) continue;
            if (j == 1 && l == 3 && m == 2) continue;
            dp[i][k][l][m] += dp[i-1][j][k][l];
            dp[i][k][l][m] %= MOD;
          }
        }
      }
    }
  }
  long long res = 0;
  for (int i = 1; i < 5; ++i) for (int j = 1; j < 5; ++j) for (int k = 1; k < 5; ++k) res += dp[N][i][j][k], res %= MOD;
  cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a<10&&b<10?a*b:-1);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))


Measured memory_bytes: 364416
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 const double PI=3.14159265359;
 
 int main()
 {
   double a,b,c,theta;
   cin>>a>>b>>theta;
   c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(theta/180*PI));
   double s=1.0/2*a*b*sin(theta/180*PI);
   double C=a+b+c;
   double h=2*s/a;
   printf("%.8lf\n%.8lf\n%.8lf\n",s,C,h);
   //while(1);
   return 0;
 }

Measured memory_bytes: 3228
from collections import deque
 
def solve(h, w, a):
    used = [[True] * (w+2) for _ in range(h+2)]
    que = deque()
    for r in range(h):
        used[r+1][1:-1] = map(lambda _:_=="#", a[r])
        for c in range(w):
            if a[r][c] == "#":
                que.append((r+1, c+1, 0))
    neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
    while que:
        r, c, k = que.popleft()
        for dr, dc in neighbors:
            nr, nc = r+dr, c+dc
            if not used[nr][nc]:
                que.append((nr, nc, k+1))
                used[nr][nc] = True
    return k
 
h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(solve(h, w, a))

Measured memory_bytes: 137192
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
/*.....................................................................................................................*/
 
    const ll mod=998244353;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=200005,inf=1e14;

/*......................................................................................................................*/

signed main()
{
    fast;
    ll n;
    cin>>n;
    ll a[n],s[n],c[n-1];
    For(i,n)cin>>a[i];
    ll ans=0;
    For(i,n)
    {
        cin>>s[i];
        ans+=s[i];
    }
    For(i,n-1)cin>>c[i];
    For(i,n-1)
    {
        if(a[i]==a[i+1]-1)ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 3552
/*input
1000000000
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	ll n, x;
	cin >> n;
	x = (n/500) * 1000;
	n %= 500;
	x += (n/5) * 5;
	cout << x << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
//		cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
import sys
def input():
    return sys.stdin.readline()[:-1]
N,Q=map(int,input().split())
a=list(map(int,input().split()))
class BIT:
    def __init__(self,len_A):
        self.N = len_A + 10
        self.bit = [0]*(len_A+10)
    # sum(A0 ~ Ai)
    # O(log N)
    def query(self,i):
        res = 0
        idx = i+1
        while idx:
            res += self.bit[idx]
            idx -= idx&(-idx)
        return res
    # Ai += x
    # O(log N)
    def update(self,i,x):
        idx = i+1
        while idx < self.N:
            self.bit[idx] += x
            idx += idx&(-idx)
    def __str__(self):
        return f"{self.bit}"
b=BIT(N)
for i in range(N):
    b.update(i,a[i])
for i in range(Q):
    p,q,r=map(int,input().split())
    if p:
        print(b.query(r-1)-b.query(q-1))
    else:
        b.update(q,r)

Measured memory_bytes: 65152
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b ;
    if((a*b)%2==0){
        cout << "Even" << endl;
    }    
    else {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 3596
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cout<<setprecision(10);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define gcj cout<<"Case #"<<tc<<": "
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val,n) foo(i,0,n+5) x[i]=val;
#define mset2(x,val,n,m) foo(i,0,n+5) foo(j,0,n+5) x[i][j]=val;
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6+8;

int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#define UMAP unordered_map<ll,ll,custom_hash>

ll t=1;randomINIT;
//<<-----Declare Variable Here------->>//
ll n,k,a[200000],dp[200000];
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//
void MAIN(ll tc){
	cin>>n>>k;
	foo(i,1,n) cin>>a[i];
	mset1(dp,INF,n+1);
	dp[1]=0;
	foo(i,2,n){
		foo(j,1,k){
			if(i-j>=1)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
			else break;
		}
	}
	// foo(i,1,n) cout<<dp[i]<<" ";
	cout<<dp[n]<<"\n";

}

int main(){
	fastio;
	// cin>>t;
	foo(i,1,t){
		MAIN(i);
	}
 
    // #ifndef ONLINE_JUDGE
    // cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    // #endif
}

Measured memory_bytes: 1792
n = gets.chomp.to_i
input_values = []
n.times do
  value = gets.chomp.to_i
  input_values.push(value)
end

def isprime(n)
 #  if n < 2
 #   return false
 # elsif n == 2
 #   return true
 # end
 #
 #  for i in 2..(n-1)
 #   if n % i == 0
 #      return false
 #    end
 #  end
 #  return true
 case n
  when 1
    false
  when 2
    true
  else
    (2..n-1).each do |m|
      q, r = n.divmod(m)
      return true if q < m
      return false if r.zero?
    end
  end
end


num_of_prime = 0
for i in 0..(n-1)
  if isprime(input_values[i]) == true
    num_of_prime += 1
  end
end

puts num_of_prime

Measured memory_bytes: 8760
from operator import itemgetter

def main():
    num_prefecture, num_city = list(map(int, input().rstrip().split()))
    prefecture_list = []
    for i in range(num_prefecture):
        prefecture_list.append([])
    #print(prefecture_list)
    id_list = []
    for idx_city in range(num_city):
        p_belong, y_born = list(map(int, input().rstrip().split()))
        p_belong -= 1 # 0から始まるようにする
        prefecture_list[p_belong].append([idx_city, y_born])
    
    #print(prefecture_list)
    # 各県のリスト内で, 市の誕生順にソートする
    for l in prefecture_list:
        l.sort(key = itemgetter(1))
    
    #print(prefecture_list)
    
    for idx_p, l in enumerate(prefecture_list):
        for x, [idx_city, y_born] in enumerate(l):
            id_first = '{0:06d}'.format(idx_p + 1)
            id_end = '{0:06d}'.format(x + 1)
            id_num = str(id_first) + str(id_end)
            id_list.append([idx_city, id_num])
    
    id_list.sort(key = itemgetter(0))
    
    for id_num in id_list:
        print(id_num[1])
    
if __name__ == '__main__':
    main()

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

int main() {
  vector<char> a(4);
  for(int i=0;i<4;i++){
    cin>>a.at(i);
  }
  if(a.at(0)==a.at(1)&&a.at(1)==a.at(2)){
    cout<<"Yes"<<endl;
  }
  else if(a.at(1)==a.at(2)&&a.at(2)==a.at(3)){       
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    long long k;
    long long d;
    cin >> x >> k >> d;
    long long mostnear = abs(x)%d;
    if(mostnear/d+k<=abs(x)/d){
        cout <<abs(x)-(k*d);
    }
    else if(abs(x/d)%2==0&&k%2==0)cout << mostnear;
    else if(abs(x/d)%2==1&&k%2==1)cout << mostnear;
    else cout << abs(mostnear-d);

}

Measured memory_bytes: 3592
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y
from math import ceil

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    n, x,t = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    print(ceil(n/x)*t)

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

using namespace std;

int main()
{
    multiset<int> price;
    int n, k, result = 0;
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)
    {
        int p;
        cin >> p;
        price.insert(p);
    }
    for(auto i : price)
    {
        if(k==0)
            break;
        result += i;
        k--;
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void)
{
    int a, b, y;
    scanf("%d %d", &a, &b);
    
    if((a+b)%2 != 0)
        a = a+1;
    
    y = (a+b)/2;
    printf("%d\n", y);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
ll dp[(ll)(2e5+2)];
ll MOD = 998244353;
int main(){
	memset(dp,0,sizeof dp);
	int n,k;cin>>n>>k;
	vector<pii > v(k);
	for(int i=0;i<k;i++){
		cin>>v[i].first>>v[i].second;
	}
	// int ans=0;
	dp[0]=1;
	vector<ll> pref(n+1);
	ll pref_sum=0;
	for(int i=0;i<n;i++){
		dp[i] += pref_sum;
		for(int j=0;j<k;j++){
			int L = v[j].first;
			int R = v[j].second;
			if(i+L<n) pref[i+L]+=dp[i];
			// pref[i+L] = pref[i+L]%MOD;
			if(i+L<n&&pref[i+L]>MOD) pref[i+L] -= MOD;
			if(i+R+1<n) {
				pref[i+R+1]-=dp[i];
				if(pref[i+R+1]<0) pref[i+R+1] += MOD;
			}
		}
		pref_sum+=pref[i+1];
		if(pref_sum>MOD) pref_sum-=MOD;
		if(pref_sum<0) pref_sum+=MOD;
	}
	cout<<dp[n-1]%MOD<<endl;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int n, m;
const long long Mod = 924844033;
long long f[5001][5001];
const int Maxn = 4000;
long long dp[5001];
typedef pair<int, long long> ii;
vector<ii> a;
long long g[5001];
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //-------------------------------
    cin >> n >> m;
    g[0] = 1;
    for (int i = 1; i <= n; i++)
        g[i] = g[i - 1] * i % Mod;
    for (int i = 0; i <= Maxn; i++)
        f[i][0] = 1, f[i][1] = i - 1;
    for (int i = 2; i <= Maxn; i++)
    {
        for (int j = 2; j < i; j++)
        {
            f[i][j] = (f[i - 1][j] + f[i - 2][j - 1]) % Mod;
        }
    }
    dp[0] = 1;
    for (int i = 1; i <= m; i++)
    {
        int x = i;
        int cnt = 1;
        while (x + m <= n)
        {
            cnt++;
            x += m;
        }
        for (int t = 1; t <= 2; t++)
        {
            for (int id = n; id >= 1; id--)
            {
                for (int k = 1; k <= min(id, cnt); k++)
                {
                    (dp[id] += dp[id - k] * f[cnt][k]) %= Mod;
                }
            }
        }
    }
    long long res = 1;
    for (int i = 1; i <= n; i++)
    {
        res *= i;
        res %= Mod;
    }
    long long t = -1;
    for (int i = 1; i <= n; i++)
    {
        res += dp[i] * g[n - i] * t;
        res %= Mod;
        res += Mod;
        res %= Mod;
        t = -t;
    }
    //res = (res - dp[a.size()][m] + Mod * Mod) % Mod;
    cout << res;
    return 0;
}

Measured memory_bytes: 82124
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    Map<Integer,Boolean> memo = new HashMap<>();
    String[] words = new String[]{"dream","dreamer","erase","eraser"};
    if (dp(0,s,memo,words) == true){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

  }
  public static boolean dp(int i, String s, Map<Integer,Boolean> memo, String[] words){
    if (i == s.length()){return true;}
    if (!memo.containsKey(i)){
      boolean ans = false;
      for (String word: words){
        if (s.substring(i).startsWith(word) == true){
          ans = ans || dp(i + word.length(),s,memo,words);
        }
      }
      memo.put(i,ans);
    }
    return memo.get(i);
  }
}

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

using namespace std;

#define ll long long
#define pb() push_back()


void solve() {
    int n,x,t;
    cin>>n>>x>>t;
    if (n % x == 0) {
        cout << n/x*t;
    } else {
        cout << (n/x+1)*t;
    }
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){int n;
cin>>n;
vector<int> vec(n);
for(int i=0;i<n;i++){
  cin>>vec.at(i);
}
 sort(vec.begin(), vec.end());
 int sum=9999999;
 for(int i=vec.at(0);i<vec.at(n-1)+1;i++){
   int s=0;
   for(int j=0;j<n;j++){
     s+=(i-vec.at(j))*(i-vec.at(j));
     
   }
   if(sum>s){
     sum=s;
   }
 }
 cout<<sum<<endl;
}  


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;

int main()
{
    int n;

    cin >> n;

    vector <int> v(n), summ(n);

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

    int64_t sum = 0;
    summ[n - 1] = 0;
    summ[n - 2] = abs(v[n - 1] - v[n - 2]);
    for (int i = n - 3; i >= 0; i--)
    {
        summ[i] = min(summ[i + 1] + abs(v[i + 1] - v[i]), summ[i + 2] + abs(v[i + 2] - v[i]));
    }

    cout << summ[0];
    return 0;
}


Measured memory_bytes: 1024