akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
void rifl();
void cut(int k);

int n,N;
vector <int> card,CARD;

int main(){
  card.reserve(1010);
  CARD.reserve(1010);
  int m,k;
  cin >> n;
  N = n*2;
  for(int i=0;i<N;i++){
    card[i] = i+1;
  }

  cin >> m;
  for(int i=0;i<m;i++){
    CARD.clear();
    cin >> k;
    if(k==0) rifl();
    else cut(k);
  }

  //cout << endl << endl << endl;
  for(int i=0;i<N;i++){
    cout << card[i] << endl;
  }
}



void rifl(){
  for(int i=0,j=0;i<N;i+=2,j++){
    CARD[i] = card[j];
    CARD[i+1] = card[n+j];
  }


  for(int i=0;i<N;i++){
    card[i] = CARD[i];
  }
}

void cut(int k){
  int cnt=0;
  for(int i=0;k+i<N;i++,cnt++){
    CARD[i] = card[k+i];
  }
  for(int i=cnt,j=0;i<N;i++,j++){
    CARD[i] = card[j];
  }


  for(int i=0;i<N;i++){
    card[i] = CARD[i];
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define ull unsigned long long
#define IO(x,y) freopen(x,"r",stdin);freopen(y,"w",stdout)
#define fo(x) while(x-->0)
#define nl '\n'
#define pb push_back

#define MOD 1000000007

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// IO("in.txt", "out.txt");
	int n, m;
	cin >> n >> m;
	n++; m++;
	bool map[n][m];
	int i, j;
	string in;
	for(i=0; i<m; i++){
		map[0][i]=0;
	}
	for(i=1; i<n; i++){
		cin >> in;
		map[i][0]=0;
		for(j=1; j<m; j++){
			if(in[j-1]=='.')
				map[i][j]=1;
			else
				map[i][j]=0;
		}
	}
	int dp[n][m];
	for(i=1; i<n; i++){
		for(j=1; j<m; j++){
			if(i==1 && j==1)
				dp[i][j]=1;
			else
				dp[i][j]=(dp[i-1][j]*map[i-1][j]+dp[i][j-1]*map[i][j-1])%MOD;
		}
	}
	// for(i=1; i<n; i++){
	// 	for(j=1; j<m; j++){
	// 		cout << dp[i][j];
	// 	}
	// 	cout << nl;
	// }
	cout << dp[n-1][m-1];
}


Measured memory_bytes: 5120
#include <stdio.h>

int main (){
    int a, b, mark = 0, ctr = 0;
    scanf("%d %d", &a, &b);

    char input[a+b+1];
    scanf("%s", input);
    
    for(int i=0; i < a+b+1; i++){
        if(input[i]== '-' && i == a ){
            mark = 1;
        } else if (input[i] >= '0' && input[i] <= '9'){
            ++ctr;
            }
        }

    if(mark == 1 && ctr == a+b){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n, m;
char rc[101][101];

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

bool ok(int r, int c) {
    return 0 <= r and r < n and 0 <= c and c < m;
}

void dfs(int y, int x, char ch) {
    rep(d, 4) {
        int ny = y + dy[d], nx = x + dx[d];
        if (ok(ny, nx) and rc[ny][nx] == ch) {
            rc[ny][nx] = 'x';
            dfs(ny, nx, ch);
        }
    }
}

int main() {
    while (cin >> n >> m and n and m) {
        rep(i, n) rep(j, m) {
            cin >> rc[i][j];
        }
        int ans = 0;
        rep(i, n) rep(j, m) {
            char tmp = rc[i][j];
            if (tmp != 'x') {
                rc[i][j] = 'x';
                dfs(i, j, tmp);
                ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3540
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
  	int dp[];
  	Main(int n){
      dp = new int[n];
      for(int i = 0; i < dp.length; i++) {
    dp[i] = -1;
}
    }
	public static void main (String[] args) throws java.lang.Exception
	{
      	FastReader s = new FastReader();
		int  n = s.nextInt();
      	int k = s.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++)
		arr[i]= s.nextInt();
		Main ob = new Main(n);
		k = Math.min(k,n-1);
		int ans = ob.getCost(n-1,arr,k);
		System.out.println(ans);
	}
  int getCost(int n,int arr[], int k){
    if(dp[n]!=-1) return dp[n];
  	if(n==0){
    dp[0]=0;
      return 0;
    }
    if(n==1){
      dp[1]= Math.abs(arr[1]-arr[0]);
      return dp[1];
    }
    int ans= Integer.MAX_VALUE;
    for(int i = 1;i<=k;i++)
      ans = Math.min(ans,Math.abs(arr[n]-arr[n-i])+getCost(n-i,arr,Math.min(k,n-i)));
      dp[n] = ans;
    return dp[n];
  }


  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 50956
S = input()
N = len(S) + 1

ret = [0] * N
now = 0
for i in range(1, N) :
  if S[i - 1] == '<' :
    now += 1
    ret[i] = now
  else :
    now = 0

now = 0
for i in range(N - 2, -1, -1) :
  if S[i] == '>' :
    now += 1
    ret[i] = max(ret[i], now)
  else :
    now = 0
    
print(sum(ret))

Measured memory_bytes: 46536
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585

"""
import sys
from sys import stdin
input = stdin.readline


def closest_part1(points, n):
    # ?????¬???p324???
    if n <= 1:
        return float('inf')
    m = n // 2
    x = points[m][0]
    d = min(closest_part1(points[:m], m), closest_part1(points[m:], n-m))

    points.sort(key=lambda x:x[1])
    b = []
    for i in range(n):
        if (points[i][0] - x)**2 >= d:
            continue
        for j in range(len(b)):
            dx = points[i][0] - b[-j-1][0]
            dy = points[i][1] - b[-j-1][1]
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.append(points[i])
    return d


def closest_part2(points, n):
    if n <= 1:
        return float('inf')
    m = n // 2
    x = points[m][0]
    d = min(closest_part2(points[:m], m), closest_part2(points[m:], n-m))
    points.sort(key=lambda p:p[1])
    b = []
    for p in points:
        if (p[0] - x)**2 >= d:
            continue
        for q in b:
            dx = p[0] - q[0]
            dy = p[1] - q[1]
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.insert(0, p)
    return d


def closest_part3(points, n):
    if n <= 1:
        return float('inf')
    m = n // 2
    x = points[m][0]
    d = min(closest_part3(points[:m], m), closest_part3(points[m:], n-m))
    points.sort(key=lambda p:p[1])
    b = []
    for p in points:
        if (p[0] - x)**2 >= d:
            continue
        for q in b[::-1]:
            dx = p[0] - q[0]
            dy = p[1] - q[1]
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.append(p)
    return d


def main(args):
    n = int(input())
    points = [tuple(map(int, input().split())) for _ in range(n)]
    points.sort()               #  x????????§??????????????????

    result = closest_part3(points, n)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 84276
#include <iostream> //??\????????¨
#include <vector> //???????????±?????¨
#include <algorithm> //???????????¨
using namespace std;

int main(){
	int n;
	vector<int> high; //int????????????high?????£?¨?(????????????????????§????´???°?????????)

	for(int i=0;i<10;i++){
		cin >> n; //??´??°?????\???????????????n???????????????
		high.push_back(n); //push_back:?????°?????????????????????????????????
	}

	sort(high.begin(),high.end()); //begin:?????????????´???????????????¬??????????????????end:?????????????´???????????????¬???????????????

	for(int i=9;i>=7;i--){
			cout << high.at(i) << endl; //at:?????°????????????????´??????????
	}
	return 0;
}

Measured memory_bytes: 1216
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll K;
	string s;
	while(cin>>s>>K) {
		ll N = s.size();
		set<string> cs;
		REP(ci, 26) {
			REP(i, N) if(s[i]=='a'+ci) RANGE(k, 1, 6) {
				cs.insert(s.substr(i, k));
			}
			if(cs.size() > K*2) break;
		}
		vector<string> z(ALL(cs));
		sort(ALL(z));
		cout<<z[K-1]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

// Java8
public class Main
{
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		int[] a = new int[3];
		for(int i = 0; i < 3; i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[0] + a[1]);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    vi a(3);
    cin >>a[0]>>a[1]>>a[2];
    SORT(a);
    cout <<(a[2]-a[0]);
    
    return 0;
}

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

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

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

  int n;
  cin >> n;
  cout << n / 3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,i=1;
    while(1){
        cin>>x;
        if(x==0){
            break;
        }
        else{
            cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstring>
using namespace std;
int p[1000],q[1000],r[1000],c[1000],array[1001];
int main(){
	int n,a,b,d,e;
	bool f;
	while(cin >> n,n){
		f = true;
		memset(p,0,sizeof(int));
		memset(q,0,sizeof(int));
		memset(r,0,sizeof(int));
		memset(c,0,sizeof(int));
		memset(array,0,sizeof(int));
		for(int i = 0;i < n;++i){
			cin >> a >> b >> d >> e;
			array[i] = a;
			p[i] = b;
			q[i] = d;
			r[i] = e;
			c[i] = (4 * (b + e)) + (9 * d);
		}
		cin >> a >> b >> d >> e;
		for(int i = 0;i < n;++i){
			if(p[i] <= a && q[i] <= b && r[i] <= d && c[i] <= e) {
				cout << array[i] << endl;
				f = false;
			}
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
import sys
a=[[0]*10for _ in[0]*10]
p=[[(-1,0),(0,-1),(0,0),(0,1),(1,0)],[(-1,-1),(-1,1),(1,-1),(1,1)],[(-2,0),(0,-2),(0,2),(2,0)]]
for e in sys.stdin:
 x,y,s=map(int,e.split(','))
 for f in p[:s]:
  for s,t in f:
   if 0<=y+s<10 and 0<=x+t<10:a[y+s][x+t]+=1
print(sum(1 for r in a for c in r if c==0))
print(max(max(r)for r in a))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  vector<ll> s(n+1); rep(i, n) s[i+1] = s[i] + a[i];

  map<ll,ll> nums;
  rep(i, n+1) nums[s[i]]++;

  ll ans = 0;
  for(auto it : nums){
    ll num = it.second;
    ans += num*(num-1)/2;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 15104
import java.util.Scanner;

/**
 *
 * @author Ivan
 */
public class Main{
    
   
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        int size = scan.nextInt();
        int[] status = new int[size];
        int[] jumps = new int[size];
        
        scan.nextLine();
        String[] input = scan.nextLine().split(" ");
        
        for(int i = 0; i < size; i++) jumps[i] = Integer.parseInt(input[i]);
        
        status[0] = 0;
        status[1] = Math.abs(jumps[0] - jumps[1]);
        
        for(int i = 2; i < size; i++)
            status[i] = Math.min(Math.abs(jumps[i] - jumps[i - 1]) + status[i - 1], Math.abs(jumps[i] - jumps[i - 2]) + status[i - 2]);
        System.out.println(status[size - 1]);
    }
    
}

Measured memory_bytes: 37032
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
const ll inf = 1e9;
const ll zero = 0;
using namespace std;
int main(){
	string s,ans="YES";
	cin >> s;
	ll n = s.size();
	bool v[n+1]={};
	for (int i = 0 ; i < n;i++){
		if (s[i]=='e' and s[i+1]=='r' and s[i+2]!='a'){
			v[i]=1;
		}
	}
	ll it = 0;
	for (int i = 0;i<n;){
		//cout << s.substr(i,5)<<endl;
		if (s.substr(i,5)=="dream"){
			if (v[i+5]==1)
				i+=2;
			i+=5;
			it =i;
		} else if (s.substr(i,5)=="erase"){
			if (v[i+4]==1)
				i+=1;
			i+=5;
			it = i;
		} else{
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<string, int>> ST(N);
  for (int i = 0; i < N; i++) cin >> ST.at(i).first >> ST.at(i).second;
  string X;
  cin >> X;

  int x;
  for (int i = 0; i < N; i++) if (ST.at(i).first == X) x = i;

  int sum = 0;
  for (int i = x; i < N; i++) sum += ST.at(i).second;

  cout << sum - ST.at(x).second << "\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _T>
inline void _prfe(const char *_n, _T _c, bool _p = false){
    ITER(_c) _it=_c.begin();
    if(_p){ cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{ cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    string s;
    int n;
    map<string,set<int> > m;
    while(cin >> s >> n){
        m[s].insert(n);
    }
    FOREACH(it,m){
        cout << it->first << endl;
        bool flag = true;
        FOREACH(jt, it->second){
            if(!flag) cout << " ";
            cout << *jt;
            flag = false;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

# An efficient Python3 program to compute 
# sum of bitwise OR of all pair 

# Returns sum of bitwise OR 
# of all pairs 
def sumXOR(arr,n):
    ans=0
    for i in range(61):
        zero=0
        one=0
        for ai in arr:
            if ai>>i & 1:
                one+=1
            else:
                zero+=1
        ans+=zero*one*2**i
        ans%=mod
    return ans
        


# driver function 
n = int(input()) 
arr = list(map(int,input().split()))
ans = sumXOR(arr, n); 
print (ans) 

# This code is contributed by saloni1297 


Measured memory_bytes: 115124
A1, A2, A3 = map(int, input().split())
ans = 1000
for x in range(6):
    temp = 0
    if x == 0:
        temp += abs(A2 - A1)
        temp += abs(A3 - A2)
    elif x == 1:
        temp += abs(A3 - A1)
        temp += abs(A2 - A3)
    elif x == 2:
        temp += abs(A1 - A2)
        temp += abs(A3 - A1)
    elif x == 3:
        temp += abs(A3 - A2)
        temp += abs(A1 - A3)
    elif x == 4:
        temp += abs(A1 - A3)
        temp += abs(A2 - A1)
    elif x == 5:
        temp += abs(A2 - A3)
        temp += abs(A1 - A2)
    
    if temp < ans :
        ans = temp
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int
get_right_surface(int *surfaces, int top, int front)
{
	if (top == surfaces[0] && front == surfaces[1]) return surfaces[2];
	if (top == surfaces[0] && front == surfaces[2]) return surfaces[4];
	if (top == surfaces[0] && front == surfaces[4]) return surfaces[3];
	if (top == surfaces[0] && front == surfaces[3]) return surfaces[1];
	if (top == surfaces[1] && front == surfaces[5]) return surfaces[2];
	if (top == surfaces[1] && front == surfaces[2]) return surfaces[0];
	if (top == surfaces[1] && front == surfaces[0]) return surfaces[3];
	if (top == surfaces[1] && front == surfaces[3]) return surfaces[5];
	if (top == surfaces[2] && front == surfaces[1]) return surfaces[5];
	if (top == surfaces[2] && front == surfaces[5]) return surfaces[4];
	if (top == surfaces[2] && front == surfaces[4]) return surfaces[0];
	if (top == surfaces[2] && front == surfaces[0]) return surfaces[1];
	if (top == surfaces[3] && front == surfaces[1]) return surfaces[0];
	if (top == surfaces[3] && front == surfaces[0]) return surfaces[4];
	if (top == surfaces[3] && front == surfaces[4]) return surfaces[5];
	if (top == surfaces[3] && front == surfaces[5]) return surfaces[1];
	if (top == surfaces[4] && front == surfaces[2]) return surfaces[5];
	if (top == surfaces[4] && front == surfaces[5]) return surfaces[3];
	if (top == surfaces[4] && front == surfaces[3]) return surfaces[0];
	if (top == surfaces[4] && front == surfaces[0]) return surfaces[2];
	if (top == surfaces[5] && front == surfaces[1]) return surfaces[3];
	if (top == surfaces[5] && front == surfaces[3]) return surfaces[4];
	if (top == surfaces[5] && front == surfaces[4]) return surfaces[2];
	if (top == surfaces[5] && front == surfaces[2]) return surfaces[1];
	return 0;
}

int
main()
{
	int i;

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

	int top, front, right;
	int n_questions;
	scanf("%d", &n_questions);
	for (i = 0; i < n_questions; i++)
	{
		scanf("%d %d", &top, &front);
		right = get_right_surface(surfaces, top, front);
		printf("%d\n", right);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  string s = "";
  s += toupper(s1.at(0));
  s += toupper(s2.at(0));
  s += toupper(s3.at(0));

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
N, M, X = map(int,input().split())
fee = list(map(int,input().split()))
result_1 = []
result_2 = []

for i in fee:
    if i > X:
        result_1.append(i)
    else:
        result_2.append(i)

result = (min(len(result_1) ,len(result_2)))
print(result)

Measured memory_bytes: 9064
import sys
from functools import lru_cache
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    n, m = map(int, input().split())
    rooms = [set() for _ in range(n)] 
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        rooms[a].add(b)
        rooms[b].add(a)
    checked = set({0})
    # min_path = 0
    # print(rooms)
    queue = deque([])
    queue.append((0, 0, 0)) # room number, min path
    ans = [(-1, 10 ** 7)] * n
    while len(queue) > 0:
        # checked.add(current_room)
        current, path, parent = queue.popleft()
        # print(current)
        # print(current, path)
        if ans[current][0] == -1 or path <= ans[current][1]:
            ans[current] = (parent, path)
        # print(rooms[current])
        for i in rooms[current]:
            if i not in checked:
                queue.append((i, path + 1, current))
                checked.add(i)
    print('Yes')
    for i in range(1, n):
        print(ans[i][0] + 1)


if __name__ == '__main__':
    main()


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

int main() {
  vector<int> houses;
  int n, temp;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> temp;
    houses.push_back(temp);
  }
  
  sort(houses.begin(), houses.end());
  cout << houses[houses.size()-1]-houses[0];
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    int n;
    int k;
    int s=1;
    cin>>n>>k;
    while(n/k >0){
        s=s+1;
        n=n/k;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
    
	int h, w, n; cin >> h >> w >> n;
	int s = max(h, w);
	if (n % s != 0) { cout << n / s + 1 << endl; }
	else { cout << n / s << endl; }
	

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int[] ana = new int[3];
		String[] jal = new String[3];
		jal =line.split(" ");
		for(int i=0;i<jal.length;i++)
		ana[i] = Integer.parseInt(jal[i]);
		if(ana[2]>=ana[0]){
			if(ana[2]<=ana[1])
				System.out.println("Yes");
			else
				System.out.println("No");
				}
		else
			System.out.println("No");

	}
}


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

int main() {
	int X;
	cin >> X;
	int ans;
	if (X <= 599){
		ans = 8;
	}
	else if (X <= 799){
		ans = 7;
	}
	else if (X <= 999){
		ans = 6;
	}
	else if (X <= 1199){
		ans = 5;
	}
	else if (X <= 1399){
		ans = 4;
	}
	else if (X <= 1599){
		ans = 3;
	}
	else if (X <= 1799){
		ans = 2;
	}
	else if (X <= 1999){
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    string S[2001];
    S[0] = string(M+1, ' ');
    for(int i=1; i<=N; i++){
        cin >> S[i];
        S[i] = " " + S[i];
    }

    static int sum[2001][2001], sumL[2001][2001], sumU[2001][2001];
    for(int i=1; i<=N; i++) for(int j=1; j<=M; j++){
        if(S[i][j] == '1'){
            sum[i][j]++;
            if(S[i-1][j] == '1') sumU[i][j]++;
            if(S[i][j-1] == '1') sumL[i][j]++;
        }
    }
    for(int i=1; i<=N; i++) for(int j=1; j<=M; j++){
        sum[i][j] += sum[i-1][j];
        sumL[i][j] += sumL[i-1][j];
        sumU[i][j] += sumU[i-1][j];
    }
    for(int i=1; i<=N; i++) for(int j=1; j<=M; j++){
        sum[i][j] += sum[i][j-1];
        sumL[i][j] += sumL[i][j-1];
        sumU[i][j] += sumU[i][j-1];
    }

    for(int i=0; i<Q; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int B = sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
        int EL = sumL[x2][y2] - sumL[x1-1][y2] - sumL[x2][y1] + sumL[x1-1][y1];
        int EU = sumU[x2][y2] - sumU[x1][y2] - sumU[x2][y1-1] + sumU[x1][y1-1];
        int ans = B - (EL+EU);
        cout << ans << endl;
    }
}

Measured memory_bytes: 52736
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct Dice {
    int face[6];
    void setNum(int n, int num) {
        face[n] = num;
    }
    void roll(char ch) {
        if(ch == 'N') {
            int tmp = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = tmp;
        }
        else if(ch == 'W') {
            int tmp = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = tmp;
        }
        else if(ch == 'E') {
            int tmp = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = tmp;
        }
        else if(ch == 'S') {
            int tmp = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = tmp;
        }
    }
    int getTop() {
        return face[0];
    }
};
int main() {
    Dice d;
    int n;
    string s;
    for(int i = 0; i < 6; i++) {
        scanf("%d", &n);
        d.setNum(i, n);
    }
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        d.roll(s.at(i));
    }
    printf("%d\n", d.getTop());
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)

#define ll long long

const int N = 1000000;

int lp[N+1];
vector<int> pr;

int fak[1000001] = {0};

int main() {

	ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.in", "r", stdin);

    for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }

    // for (int i= 0;i<10;i++)
    //     cout<<pr[i]<<"\n";

    // cout<<"\n";
    // for (int i = 2;i<=15;i++) {
    //     cout<<i<<": "<<lp[i]<<"\n";
    // }

    int n,m;
    cin>>n;

    int i;
    std::vector<int> a(n);

    int maxelem = 0;

    for (i=0;i<n;i++) {
        cin>>a[i];

        if (lp[a[i]]>maxelem)
            maxelem = lp[a[i]];

        int x = a[i];

        int pred = -1;
        while (x>1) {
            
            if (pred != lp[x]) {
                fak[lp[x]]++;
                pred = lp[x];
            }


            // cout<<a[i]<<" "<<x<<" "<<lp[x]<<"\n";
            x/=lp[x];
        }

    }

    bool pairwise = true;
    bool setwise = true;

    for (i=1;i<=maxelem;i++) {
        if (fak[i] > 1) {
            pairwise = false;

            if (fak[i] == n) {
                setwise = false;
            }
        }
    }

    if (pairwise == true) 
        cout<<"pairwise coprime\n";
    else
    if (setwise == true)
        cout<<"setwise coprime\n";
    else
        cout<<"not coprime\n";

    // for (i=0;i<=15;i++) cout<<fak[i]<<"\n";



    return 0;
}

Measured memory_bytes: 15132
#include<cmath>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<assert.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define setIO(x) freopen(x".in","r", stdin);freopen(x".out","w",stdout);
typedef long long ll;
typedef unsigned long long ul;
typedef pair<int, int> pii;
const ul BASE = 107;
const ll LINF = 9e18 + 7;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
//-----------------head-----------------
int n, k, ans, a[N];
vector<int> e[N];
int dfs(int u, int p) {
	int D = 0;
	rep(i, 0, sz(e[u]))
	{
		int v = e[u][i];
		D = max(D, dfs(v, u) + 1);
	}
	if (D == k - 1 && p != 1)
		D = -1, ++ans;
	return D;
}
void solve() {
	ans = 0;
	if (a[1] != 1)
		++ans, a[1] = 1;
	rep(i, 2, n + 1)
		e[a[i]].pb(i);
	dfs(1, 1);
}
int main() {
	cin >> n >> k;
	rep(i, 1, n + 1)
		cin >> a[i];
	solve();
	cout << ans;
	return 0;
}


Measured memory_bytes: 13952
#include<iostream>
using namespace std;
int main(){
    while(1){
        int a,b;
        char op;
        cin >> a >> op >> b;
        if(op == '?')break;
        else if(op == '+')cout << a + b << endl;
        else if(op == '-')cout << a - b << endl;
        else if(op == '*')cout << a * b << endl;
        else if(op == '/')cout << a / b << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	ll a,b,t,i;
	cin>>a>>b>>t;
	ll ans= (t/a)*b;
	cout<<ans;
    return 0;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	map<int, ll> prt;
	for( int i = 1; i <= n; ++i ){
		int t = i;
		for( int k = 2; k <= i; ++k ){
			while( t % k == 0 ){
				t /= k;
				++prt[k];
			}
		}
	}
	ll prod = 1;
	for( auto &k : prt ){
		prod *= (k.second+1);
		prod %= mod;
	}
	cout << prod << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do
    n <- readLn :: IO Int
    fsn <- map ((map readInt . BC.words)) <$> replicateM n BC.getLine
    psn <- map ((map readInt . BC.words)) <$> replicateM n BC.getLine
    let fs = listArray (0,(n-1)) fsn
    let ps = listArray (0,(n-1)) psn

    let cd = [0,1]
    let css = [[c0,c1,c2,c3,c4,c5,c6,c7,c8,c9]|c0 <- cd , c1 <- cd , c2 <- cd , c1 <- cd , c3 <- cd , c1 <- cd , c4 <- cd , c5 <- cd , c6 <- cd , c7 <- cd , c8 <- cd , c9 <- cd ,[c0,c1,c2,c3,c4,c5,c6,c7,c8,c9] /= [0,0,0,0,0,0,0,0,0,0] ]
    let ans = [profit fs ps cs n | cs <- css]
    print (maximum ans)
    
profit fs ps cs n  = sum [profita fs ps cs i | i <- [1..n]]
profita fs ps cs i = (ps ! (i-1)) !! n
                     where n = count (fs ! (i-1)) cs 0


count :: [Int] -> [Int] -> Int -> Int
count [] bn n = n
count (a:an) (b:bn) n = if (a==1) && (b==1)
                        then 1 + (count an bn n)
                        else (count an bn n)


Measured memory_bytes: 1276
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{

        int n;
        int i;
        int j;
        int sum;

        scanf("%d",&n);

        for (i=0; i < n; i++) {
           j = i + 1;
           sum = sum + j;
        }
 
        printf("%d\n",sum);
        
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for(int t = 0; t < 3; t++){
		char c; cin >> c; cout << c; 
	}
	cout << endl << "\n"; 
}

Measured memory_bytes: 3640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;

long long int N;
long long int a[100000];
long long int b[100000];
long long int ans=0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = N - 1; i >= 0; i--) {
		if ((a[i] + ans) % b[i]) {
			ans += b[i] - (a[i] + ans) % b[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    final static int NIL = -1;
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        TNode root = new TNode(NIL);
        for(int i = 0; i < n; i++) {
            String cmd = input.next();
            if(cmd.equals("insert")) {
                int key = Integer.parseInt(input.next());
                TNode z = new TNode(key);
                root = insert(root, z);
            } else if (cmd.equals("print")) {
                inOrder(root);
                System.out.println();
                preOrder(root);
                System.out.println();
            }
        }
    }
    public static TNode insert(TNode root, TNode z) {
        TNode y = new TNode(NIL); // 前一个节点
        TNode x = root; // 当前节点

        z.left = new TNode(NIL);
        z.right = new TNode(NIL);

        while( x.key != NIL ){ // 当前节点不为空
            y = x; // y 指向当前节点
            if( z.key < x.key ) {
                x = x.left;
            } else {
                x = x.right;
            }
        }

        z.parent = y;
        if( y.key == NIL ){
            root = z;
        } else {
            if( z.key < y.key ) {
                y.left = z;
            } else {
                y.right = z;
            }
        }
        return root;
    }
    public static void preOrder(TNode node) {
        if(node.key == NIL) {
            return;
        }
        System.out.print(" " + node.key);
        preOrder(node.left);
        preOrder(node.right);
    }
    public static void inOrder(TNode node) {
        if(node.key == NIL) {
            return;
        }
        inOrder(node.left);
        System.out.print(" " + node.key);
        inOrder(node.right);
    }
}

class TNode {
    int key;
    TNode left, right ,parent;
    TNode(int key) {
        this.key = key;
    }
}



Measured memory_bytes: 220136
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        long res = 0;
        for(int a = 1; a <= K; a ++) {
            for (int b = 1; b <= K; b++) {
                for(int c = 1; c <= K; c++) {
                    res += gcd(a, b, c);
                }
            }
        }
        System.out.println(res);
    }
    private static int gcd(int a, int b, int c) {
        return gcd(gcd(a, b), c);
    }
    private static int gcd(int a, int b) {
        if( a == 0) {
            return b;
        }
        return gcd(b%a, a);
    }
}


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

int main(){
    char S[200000];
    scanf("%s",S);
    int countW = 0;
    long int locateW = 0;
    for(int i = 0;i < strlen(S);i++){
        if(S[i] == 'W'){
            locateW = locateW + i - countW;
            countW++;;
        }
    }
    printf("%ld\n",locateW);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> g[100005];ll n,t1,t2,l[100005],f[100005][2],mod=1e9+7;
ll dfs(ll lst,ll u,bool pt){
    ll res=1;
    if(l[u]==0) return f[u][0]=f[u][1]=1;
    if(f[u][pt]) return f[u][pt];
    for(int i=0;i<l[u];i++) {
        if(g[u][i]==lst) continue;
        dfs(u,g[u][i],0);
        if(!pt) dfs(u,g[u][i],1);
    }
    for(int i=0;i<l[u];i++)
    {
        int fl=g[u][i];
        if(fl==lst) continue;
        if(!pt) res=(res*(f[fl][0]+f[fl][1]))%mod;
        else res=(res*f[fl][0])%mod;
    }
    return f[u][pt]=res;
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<n;i++){
        scanf("%lld%lld",&t1,&t2);
        g[t1].push_back(t2);g[t2].push_back(t1);
        l[t1]++;l[t2]++;
    }
    printf("%lld",(dfs(0,1,0)+dfs(0,1,1))%mod);
    return 0;
}

Measured memory_bytes: 14976
#include <iostream>
#include <cstdio>

using std::cin;

template <typename T>
void read(T& x)
{
    x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); x = x * 10 + (c ^ 48), c = getchar());
}

int main()
{
    while (1)
    {
        int a = 0, b = 0;
        char c = ' ';
        cin >> a >> c >> b;
        if (c == '?')
            break;
        else if (c == '+')
            printf("%d\n", a + b);
        else if (c == '-')
            printf("%d\n", a - b);
        else if (c == '*')
            printf("%d\n", a * b);
        else
            printf("%d\n", a / b);
    }
    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
ll arr[8];
ll x[3];
ll n;
const int INF = 1e9;
void chmin(ll &a, int b) { if (a > b) a = b;}
ll rec(int piv,int a,int b,int c){
  if(piv==n){
    if (!a || !b || !c) return INF;
    return abs(a-x[0]) + abs(b-x[1]) + abs(c-x[2]);
  }
  ll minimum = rec(piv+1,a,b,c);
  chmin(minimum,rec(piv+1,a+arr[piv],b,c) + (a ? 10:0));
  chmin(minimum,rec(piv+1,a,b+arr[piv],c) + (b ? 10:0));
  chmin(minimum,rec(piv+1,a,b,c+arr[piv]) + (c ? 10:0));
  return minimum;
}
int main(){
  cin >> n >> x[0] >> x[1] >> x[2];
  for(int i=0;i<n;i++){
    cin >> arr[i];
  }
  cout << rec(0,0,0,0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
    int N,h[100005],dp[100005];
    scanf("%d",&N);
    for(int i = 1; i <= N; i++)
        scanf("%d",&h[i]);
    dp[1] = 0;dp[2]=abs(h[2]-h[1]);
    int m = 1;
    while(m+2<=N){
        dp[m+2] = min(dp[m+1]+abs(h[m+2]-h[m+1]),dp[m]+abs(h[m]-h[m+2]));
        m++;
    }
    printf("%d\n",dp[N]);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
 
    vl L(n), R(n);
    ll p = 0, q = 0;  // L[p]はLの最大値で、R[q]はRの最小値
    ll MAXL = 0, MINR = INF;
    rep(i, n) {
        cin >> L[i] >> R[i];
        R[i]++;
        if(MAXL < L[i]) {
            MAXL = L[i];
            p = i;
        }
        if(MINR > R[i]) {
            MINR = R[i];
            q = i;
        }
    }
 
    ll ans = 0;
    // 区間pと区間qを同じ集合に入れる場合
    rep(i, n) {
        if(i == p || i == q) {
            continue;
        }
        chmax(ans, max(0LL, R[q] - L[p]) + R[i] - L[i]);
    }
 
    // 区間pと区間qを違う集合に入れる場合
    vector<pair<ll, ll>> c(n);
    rep(i, n) {
        ll a = max(0LL, R[i] - L[p]);
        ll b = max(0LL, R[q] - L[i]);
        c[i] = make_pair(a, -b);
    }
    sort(all(c));
    ll u = -c[0].second;
    exrep(i, 1, n-1) {
        c[i].second *= -1;
        chmax(ans, c[i].first + u);
        chmin(u, c[i].second);
    }
 
    out(ans);
    re0;
}

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

int main(){
    int n,q;
    cin >> n >> q;
    queue<pair<string,int> > qu;
    for(int i=0; i<n; i++){
        string process;
        int time;
        cin >> process >> time;
        pair<string,int> p = make_pair(process,time);
        qu.push(p);
    }

    int all_time = 0;
    while(!qu.empty()){
        pair<string,int> a_process = qu.front();
        qu.pop();
        if(a_process.second <= q){
            all_time += a_process.second;
            cout << a_process.first << " " << all_time << endl;
        }else{
            all_time += q;
            a_process.second -= q;
            qu.push(a_process);
        }
    }
}


Measured memory_bytes: 6324
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int from, to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n; cin >> n;
	vint p(n) ;
	rep(i, n) cin >> p[i];
	rep(i, n) p[i]--;

	vint idx(n);
	rep(i, n) idx[p[i]] = i;
	
	ll ans = 0;
	set<int> s;
	for(int x=n-1; x>=0; x--){
		int i = idx[x];
		ll c = 0;
		{
			s.insert(i);
			vint l(2, -1);
			vint r(2, n);
			{
				auto it = s.find(i);
				rep(j, 2){
					if(it == s.begin()) break;
					it--;
					l[j] = *it;
				}
			}
			{
				auto it = s.find(i);
				rep(j, 2){
					it++;
					if(it == s.end()) break;
					r[j] = *it;
				}
			}
			vint ls(2);
			ls[0] = i-l[0];
			ls[1] = l[0]-l[1];
			vint rs(2);
			rs[0] = r[0]-i;
			rs[1] = r[1]-r[0];
			c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
		}
		ans += c*((ll)x+1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

x = int(input())

ans = 0

ans += 1000*(x//500)
x = x%500
ans += 5*(x//5)
print(ans)


Measured memory_bytes: 5500