akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;

 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n;
	cin >> n;
	vector<int> a(n);
	multiset<int, greater<int>> st;
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
		st.insert(a[i]);
	}
	
	int ans = 0;
	for(int i = n - 1; i >= 0; -- i)
	{
		int top = *st.begin();
		ans += max(0ll, top - a[i]);
		st.erase(st.find(a[i]));
	}
	
	cout << ans << '\n';
	
	return 0;
}
 
 
 
 

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

string replace(string s, int start, int end, string p) {
	int c = 0;
	for (int i = start; i <= end; i++) {
		s[i] = p[c++];
	}
	return s;
}


string print(string s, int start, int end) {
	string sout="";
	for (int i = start; i <= end; i++) {
		sout += s[i];
	}
	return sout;
}

string reverse(string s) {
	string sout="";
	size_t num = s.size();
	for (int i = 1; i <= num; i++) {
		sout += s[num - i];
	}
	return sout;
}

string reverse(string s,int start, int end) {
	string scut = print(s, start, end);
	string srev = reverse(scut);
	return replace(s, start, end, srev);
}


int main()
{
	string str;
	int n;
	cin >> str >> n;
	for (int i = 0; i < n; i++) {
		string cmd,arg;
		int a1, a2;
		cin >> cmd >> a1 >> a2;
		if (cmd == "print") {
			cout << print(str, a1, a2) << endl;
		}
		else if (cmd == "reverse") {
			str = reverse(str, a1, a2);
			//cout << str << endl;
		}
		else if (cmd == "replace") {
			cin >> arg;
			str = replace(str, a1, a2, arg);
			//cout << str << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3212
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        Console.WriteLine(s.Length - s.Zip(s.Skip(1), (x, y) => x == y ? 1 : 0).Sum());
    }
}



Measured memory_bytes: 13408
#include <stdio.h>

int main(void) {
	int i, n, m, min = 1000000, max = -1000000;
	long long sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &m);
		sum += m;
		if (m < min) {
			min = m;
		}
		if (m > max) {
			max = m;
		}
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
	int n,x,a=0;
	while (true){
		a = 0;
		cin >> n >> x;
		if (n == 0 && x == 0){
			break;
		}
		for (int i = 1; i < n-1; i++){
			for (int j = i+1; j < n ; j++){
				for (int k = j+1; k<n + 1; k++){
					if (i + j + k == x){
						a++;
					}
				}
			}
		}
		cout << a<<endl;
	}
}


Measured memory_bytes: 3088
S = input()
d = int(S[0])
T = []
U = []
for i in range(len(S)):
  T.append(d)
  d = (d + 1) % 2
  U.append(d)
count1 = 0
count2 = 0
for i in range(len(S)):
  if int(S[i]) != T[i]:
    count1 += 1
  if int(S[i]) != U[i]:
    count2 += 1
print(min(count1, count2))

  


Measured memory_bytes: 4852
def Warshall_Floyd(edges,N):
  import copy
  d=copy.deepcopy(edges)
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

inf=float("inf")
N,M=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(M)]
A=[[inf for j in range(N)] for i in range(N)]#最短距離map
for i in range(N):
  A[i][i]=0
for i in range(M):
  A[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
  A[abc[i][1]-1][abc[i][0]-1]=abc[i][2]
Ans=Warshall_Floyd(A,N)
ans=0
for j in range(M):
  u=abc[j][0]-1
  v=abc[j][1]-1
  for s in range(N):
    if Ans[s][u]+abc[j][2]==Ans[s][v]:
      ans+=1
      break
print(M-ans)

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

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

struct runner{
	int t,v;
	double p;
};

const int INF=1000000000;

vector<runner> vr;
double mem[51][51][101];
// kÍxe·éêÌ
double calcPer(int n,int k,int idx){
	if(!EQ(mem[n][k][idx],INF))
		return mem[n][k][idx];
	double p = vr[idx].p;
	if(k==0)
		return 1.0;
    return mem[n][k][idx]=(((double)n/k)*calcPer(n-1,k-1,idx)*p);
}
int main(){
	int n,m,L;
	for(int i = 0; i < 51; i++)
		for(int j = 0; j < 51; j++)
			for(int k = 0; k < 101; k++)
				mem[i][j][k]=INF;
	cin>>n>>m>>L;
	for(int i = 0; i < n; i++){
		runner r;
		int p;
		cin>>p>>r.t>>r.v;
		r.p=(double)p/100;
		vr.push_back(r);
	}
	// êl¸ÂßÄ¢­
	for(int i = 0; i < n; i++){
		double sumPer=0.0;
		if(vr[i].v!=0){
			// ©ªª¢­ÂÌêÅxe·é©
			for(int j = 0; j <= m; j++){
				// »ÝÌxeÅxe·ém¦
				double cper=calcPer(m,j,i)*pow((double)(1-vr[i].p),m-j);
                double selfTime=((double)L/vr[i].v)+vr[i].t*j;
				// »ê¼êÌGÉÂ¢Ä²×é
				for(int k = 0; k < n; k++){
					// ©ª©gÜ½ÍA¬xª0Ìi[Í³·é
					if(i==k||EQ(vr[k].v,0.0))
						continue;
					double enemPer=1.0;
					// èª¢­ÂÈãÌêÅxeµ½çAÔÉ¤©ð`FbN
					for(int l = 0; l <= m; l++){
                        // GÌBðvZ
                        double enemyTime=((double)L/vr[k].v)+vr[k].t*l;
						// àµGÌBÔª©ªÌBÔðãñÁ½çI¹
						if(!EQ(enemyTime,selfTime)&&enemyTime>selfTime)
                            break;
                        // ±ÌÌêÅxe·ém¦
                        double p=calcPer(m,l,k)*pow((double)(1-vr[k].p),m-l);
                        // ¡ñÌxeðæéêÍÂ±ÆªoÈ¢ÌÅA}CiX
						enemPer-=p;
					}
					// »ÝcÁÄ¢ém¦ªAGª©ªæèx­B·ém¦
					cper*=enemPer;
				}
				// cperª»Ìm¦
				sumPer+=cper;
			}
		}
		printf("%.7f\n",sumPer);
	}
	return 0;
}

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

using namespace std;

int main(){
    long long N,A[100000],i,gcd;
    

    cin>>N;
    for(i=0;i<N;i++)cin>>A[i];

    gcd=A[0];
    for(i=1;i<N;i++){
        gcd=__gcd(gcd,A[i]);
    }
    cout<<gcd;
}

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

int dist(vector<int> x, vector<int> y) {
  int d = x.size();
  int ret=0;
  rep(i,d) {
    ret+=(x[i]-y[i])*(x[i]-y[i]);
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,d;
  cin>>n>>d;
  vector<vector<int>> xs = vector<vector<int>>(n,vector<int>(d));
  rep(i,n) {
    rep(j,d) cin>>xs[i][j];
  }
  set<int> squares;
  rep(i,1000) {
    squares.insert(i*i);
  }
  int ans=0;
  rep(i,n) {
    repeat(j,i+1,n) {
      if(squares.find(dist(xs[i],xs[j]))!=squares.end()) {
	ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define pb push_back
 
int main ()
{
    ios_base::sync_with_stdio(false) ; 
    cin.tie(NULL) ;
 
    lli n , m ;
    cin >> n >> m ;

    if (n == 1 || m == 1)
    {
        cout << "1" << endl ;
        return 0 ;
    }

    double ans = ceil(((double) n * m) / 2) ;    
    lli p = ans ;
    cout << p << endl ;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<string> s(n);
  REP(i, n) { cin >> s[i] >> a[i]; }
  string x;
  cin >> x;
  ll idx = -1;
  REP(i, n) {
    if (s[i] == x) {
      idx = i;
    }
  }
  ll ans = 0;
  FOR(i, idx + 1, n) { ans += a[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int cnt = 0;
    for (int i = a; i<=b; i++)
    {
     if(c%i==0) cnt++;
    }
    System.out.println(cnt);
    scan.close();
  }
}


Measured memory_bytes: 26404
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int N;cin>>N;
  int cnt = 0;
  VI d(N);rep(i , N)cin>>d[i];
  SORT(d);
  for(int t = 1;t < N;t++){
    if(d[t] != d[t - 1])cnt++;
  }
  cout<<cnt + 1;
}


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

#define rep(i, n) for (int i = 0; i < (n); i ++)
static const int INF = 0x3f3f3f3f;

struct state {
        int y, x, cost;
        bool right;
        bool operator < (const state& r) const { return cost < r.cost; }
        bool operator > (const state& r) const { return cost > r.cost; }
};

void dijkstra(vector<vector<char>>& M, int w, int h) {
        priority_queue<state, vector<state>, greater<state>> q;
        rep(i, h) rep(j, w) if (M[i][j] == 'S') q.push((state){ i, j, 0, true });
        rep(i, h) rep(j, w) if (M[i][j] == 'S') q.push((state){ i, j, 0, false });
        int dis[70][40][2];
        rep(i, 70) rep(j, 40) rep(k, 2) dis[i][j][k] = INF;
        while (!q.empty()) {
                state p = q.top(); q.pop();
                dis[p.y][p.x][p.right] = p.cost;
                if (M[p.y][p.x] == 'T') {
                        cout << p.cost << endl;
                        return;
                }
                for (int dx = 1; dx <= 3; dx ++) {
                        for (int dy = -2; dy <= 2; dy ++) {
                                if (abs(dx) + abs(dy) <= 3) {
                                        state np;
                                        np.x = p.x + dx * (p.right ? 1 : -1);
                                        np.y = p.y + dy;
                                        if (np.y < 0 || h <= np.y || np.x < 0 || w <= np.x) continue;
                                        if (M[np.y][np.x] == 'X') continue;
                                        if (M[np.y][np.x] == 'S') continue;
                                        else if (M[np.y][np.x] == 'T') {
                                                np.cost = p.cost;
                                        } else np.cost = p.cost + (M[np.y][np.x] - '0');
                                        np.right = !p.right;
                                        if (dis[np.y][np.x][np.right] > np.cost) {
                                                q.push(np);
                                        }
                                }
                        }
                }
        }
        cout << -1 << endl;
        return;
}

int main() {
        int w, h;
        while (cin >> w >> h && w) {
                vector<vector<char>> M(h, vector<char> (w));
                rep(i, h) rep(j, w) cin >> M[i][j];
                dijkstra(M, w, h);
        }
        return 0;
}

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

int main()
{
	int q = 0;
	int	p0x = 0, p0y = 0, p1x = 0, p1y = 0, p2x = 0, p2y = 0, p3x = 0, p3y = 0;
	double x = 0, y = 0, u = 1;

	cin >> q;
	
	for (int i = 0; i < q; i++) {
		cin >> p0x >> p0y >> p1x >> p1y >> p2x >> p2y >> p3x >> p3y;

		u = (p1y - p0y) * (p3x - p2x) - (p3y - p2y) * (p1x - p0x);

		x = (double)((p0x * p1y - p1x * p0y) * (p3x - p2x) 
				- (p2x * p3y - p3x * p2y) * (p1x - p0x)) / u;
		y = (double)((p0x * p1y - p1x * p0y) * (p3y - p2y) 
				- (p2x * p3y - p3x * p2y) * (p1y - p0y)) / u;

		cout << setprecision(10) << setiosflags(ios::fixed | ios::showpoint ) 
			 << x << " " << y << endl;
	}
		
	return 0;
}

Measured memory_bytes: 3280
S = str(input())
N = int(len(S))
cnt = 0
S_list = list(S)
for i in range(1,N):
    if S_list[i-1] == S_list[i]:
        if S_list[i-1] == "0":
            cnt += 1
            S_list[i] = "1"
        elif S_list[i-1] == "1":
            cnt += 1
            S_list[i] = "0"
print(cnt)

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

using namespace std;

int main() {
	int w, h;
	char mat[112][112];

	scanf("%d %d", &h, &w);

	for (int i=0; i<112; ++i) {
		for (int j=0; j<112; ++j) {
			mat[i][j] = '#';
		}
	}

	for (int i=1; i<=h; ++i) {
		for (int j=1; j<=w; ++j) {
			scanf(" %c", &mat[i][j]);
		}
	}

	for (int i=0; i<=h+1; ++i) {
		for (int j=0; j<=w+1; ++j) {
			printf("%c", mat[i][j]);
		}
		puts("");
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int tmp = 0;
        for(int i = 100;i>=1;i--){
            if(a % i == 0 && b % i == 0){
                tmp++;
                if(tmp == k){
                    System.out.println(i);
                }
            }
        }
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#define rep(i,N) for(i=0;i<N;i++)

int main(){
  long n,x,i,j,prev,b,v;
  scanf("%ld",&n);
  int expo[n+1];
  rep(i,n+1) expo[i] = 0;
  expo[1] = 1;

  for(b=2;b<=n;b++){
    v = b*b;
    while(v<=n){
      expo[v] = 1;
      v *= b;
    }
  }

  //printf("hi");
  for(i=n ; i >= 1; i--){
    if(expo[i]){
    printf("%ld\n",i);
    break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
void main() {
	auto N = ri;
	auto A = readAs!(int[]);
	int[][] m = new int[][](N);
	foreach(i, v; A) {
		m[v.to!int-1] ~= i.to!int;
	}
	foreach(i; 0..N) {
		m[i].length.writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 17252
#include <iostream>

int main(int argc, char **argv) {
	int num, i, a, b, c;
	
	std::cin >> num;
	
	for(i = 0; i < num; i++) {
		std::cin >> a >> b >> c;
		if (a*a + b*b == c*c ||
		    b*b + c*c == a*a ||
			c*c + a*a == b*b) {
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
	}
}


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

int count = 0;

void swap(int* x, int* y){
  int temp = *x;
  *x = *y;
  *y = temp;
}

void bubbleSort(int a[], int n){
  bool flag = 1;
  while(flag){
    flag = 0;
    for(int j = n-1; j > 0; --j){
      if(a[j-1] > a[j]){
        swap(&a[j-1], &a[j]);
        flag = 1;
        ++ count;
      }
    }
  }
}

void output(int a[], int n, int count){
  for(int i = 0; i < n-1; ++i) cout << a[i] << " ";
  cout << a[n-1] << endl;
  cout << count << endl;
}

int main(){
  int n;
  cin >> n;
  int a[100];
  for(int i = 0; i < n; ++i) cin >> a[i];
  
  bubbleSort(a, n);
  output(a, n, count);
  return 0;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

// 素因数分解 O(√n)
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;

    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }

    if (n != 1) res[n] = 1;

    return res;
}

int main() {
    INIT;

    ll N, P;
    cin >> N >> P;

    map<ll, ll> primes = prime_factor(P);
    ll a = 1;
    for (auto e : primes) {
        // cout << e.first << ":" << e.second << endl;
        while (e.second >= N) {
            a *= e.first;
            e.second -= N;
        }
    }
    cout << a << endl;

    return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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


struct product
{
    int v;
    int w;
};

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

    int N, W;
    cin >> N >> W;

    vector< product > pr(N + 1);
    pr[0].w = pr[0].w = 0;
    rep (i, N)
    {
        cin >> pr[i + 1].w >> pr[i + 1].v;
    }

    s64 dp[N + 1][W + 1];
    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= W; ++j)
        {
            if (i == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (j < pr[i].w)
                {
                    dp[i][j] = dp[i - 1][j];
                }
                else
                {
                    dp[i][j] = MAX(dp[i - 1][j], dp[i - 1][j - pr[i].w] + pr[i].v);
                }
            }
        }
    }

    cout << dp[N][W] << "\n";
    return 0;
}



Measured memory_bytes: 79232
n = int(input())
hist = [""] * 6

for _ in range(n):
    h = float(input())

    if h < 165:
        hist[0] += "*"
    elif 165 <= h < 170:
        hist[1] += "*"
    elif 170 <= h < 175:
        hist[2] += "*"
    elif 175 <= h < 180:
        hist[3] += "*"
    elif 180 <= h < 185:
        hist[4] += "*"
    else:
        hist[5] += "*"

for i in range(6):
    print(str(i+1) + ":" + hist[i])



Measured memory_bytes: 5612
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var input = Reads();
            var n = input[0];
            var a = input[1];
            var b = input[2];
            var s = Console.ReadLine();
            long count = 0;
            long x = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'a')
                {
                    if (count < a + b) { Console.WriteLine("Yes"); count++; }
                    else Console.WriteLine("No");
                }
                else if (s[i] == 'b')
                {
                    x++;
                    if (count < a + b && x <= b) { Console.WriteLine("Yes"); count++; }
                    else Console.WriteLine("No");
                }
                else Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}




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

int ans(int sum, int max, int n, int k, int s){
    if(sum > s) return 0;
    if(k==0){
        if(sum==s){
            return 1;
        }else{
            return 0;
        }
    }
    int count=0;
    for(int i=max+1; i+k-1<=n; i++){
        count += ans(sum+i, i, n, k-1, s);
    }
    return count;
}

int main(){
    while(1){
        int n,k,s;
        cin >> n >> k >> s;
        if(n==0) break;

        cout << ans(0,0,n,k,s) << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
typedef pair<int,int> P;
int main(void)
{
	int n,q,i,a,b,v[200001],x,p1,x1;
	P pp[200001];
	scanf("%d %d",&n,&q);
	for(i=0;i<n-1;i++)	scanf("%d %d",&pp[i].first,&pp[i].second);
	sort(pp,pp+n-1);
	for(i=1;i<=n;i++)	v[i]=0;
	for(i=0;i<q;i++)	{
		scanf("%d %d",&p1,&x1);
		v[p1]+=x1;
	}
	for(i=0;i<n-1;i++)	{
		a=pp[i].first;	b=pp[i].second;
		x=v[a];
		v[b]+=x;
	}
	printf("%d",v[1]);
	for(i=2;i<=n;i++)	printf(" %d",v[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 4608
(defun solve (n)
  (if (= n 0)
      0
      (multiple-value-bind (quotient remainder)
          (floor n 500)
        (if (> remainder 5)
            (+ (* quotient 1000) (* 5 (floor remainder 5)))
            (* quotient 1000)))))

(princ (solve (read)))


Measured memory_bytes: 13412
#include<stdio.h>

int main()
{
    int a, b, c,one,two;
    scanf("%d %d %d", &a, &b, &c);
    one = b;
    two = c;
    if(b+c>a)
    {
        one = a;
        two = c - (a - b);
    }
    else
    {
        one = b + c;
        two = 0;
    }
    printf("%d", two);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	rep(i, 3) {
		if (s[i] == t[i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  int sum = 0;
  REP(i,n) sum += a[i];
  int cnt = 0;
  REP(i,n){
    if(4 * m * a[i] >= sum) ++cnt;
  }

  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli a[20] = {};

int main(void) {
	lli n;

	cin >> n;

	FOR(n)
		cin >> a[i];

	lli ans = 0;

	for (int i = 1; i < n - 1; i++) {
		if ((a[i - 1] > a[i] && a[i] > a[i + 1]) || (a[i - 1] < a[i] && a[i] < a[i + 1])) {
			ans++;
		}
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, H, M = map(int, input().split())

H = H % 12
X = H * 60 + M

AX = X / 720.0 * 360
BX = M / 60.0 * 360

D = abs(AX - BX + (10 ** -12))

ANS = A ** 2 + B ** 2 - 2 * B * A * math.cos(math.radians(D))

print(math.sqrt(ANS))


Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if (a-b>=0) cout << "delicious" << endl;
  else if(abs(a-b)<=x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int t;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int a,b;cin>>a>>b;
	int k=(b-a*2)/2;
	int p=a-k;
	if(k<0||p<0){cout<<"No";return 0;
	}
	if(k*4+p*2==b)cout<<"Yes";else cout<<"No";
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	
	for(int i = 0; i < n; i++)
		cout << s[i] << t[i];

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int INF = 1e9;
const int MAX_N = 1e6;
int dp[MAX_N + 1], dp_odd[MAX_N + 1];

void Init()
{
    int nth = 1;
    int tetra = 0;
    for (int i = 1; i <= MAX_N; ++i)
        dp[i] = dp_odd[i] = INF;

    while (tetra <= MAX_N) {
        tetra = (nth * (nth + 1) * (nth + 2)) / 6;
        if (tetra % 2 == 0) {
            for (int i = 0; i + tetra <= MAX_N; ++i)
                dp[i + tetra] = min(dp[i + tetra], dp[i] + 1);
        }
        else {
            for (int i = 0; i + tetra <= MAX_N; ++i) {
                dp[i + tetra] = min(dp[i + tetra], dp[i] + 1);
                dp_odd[i + tetra] = min(dp_odd[i + tetra], dp_odd[i] + 1);
            }
        }

        nth++;
    }
}

int main()
{
    Init();

    int n;
    while (cin >> n, n) {
        cout << dp[n] << " " << dp_odd[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 8972
use input::Input;

fn main() {
    let mut input = Input::default();

    let a: u32 = input.parse();
    let ans = a + a * a + a * a * a;
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2116
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=200000+10;
const int INF=int(1e8);
int main() {
	int a,b,n;
	while(~scanf("%d %d %d",&a,&b,&n)) {
		int sum=a+b;
		if(n>=a&&n<=sum)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main()
    {
        // 整数の入力
        int X;
        cin >> X;
      
        // 出力
        if(X==3 || X==5 || X==7)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
    }

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count[][][] = new int[4][3][10];
		int i, j, k;
		int n = sc.nextInt();
		for(i = 0; i < n; i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			
			count[b - 1][f - 1][r - 1] += v;
		}
		for(i = 0; i < 4; i++) {
			for(j = 0; j < 3; j++) {
				for(k = 0; k < 10; k++) {
					System.out.print(" " + count[i][j][k]);
				}
			System.out.println();
			}
		if(i != 3) System.out.println("####################");
		}
	}

}



Measured memory_bytes: 29976
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int total = 0;
		total += sc.nextInt();
		total += sc.nextInt() * 5;
		total += sc.nextInt() * 10;
		total += sc.nextInt() * 50;
		total += sc.nextInt() * 100;
		total += sc.nextInt() * 500;
		out.println(total < 1000 ? 0 : 1);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 24444
n = gets.to_i
n_fact = (1..n).inject(1, &:*)
mul = n_fact / n
cities = (1..n).map { gets.split.map(&:to_i) }
perm = cities.permutation(2)
total = perm.map do |seq|
  a, b = seq 
  (Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2))*mul
end.inject(&:+)

puts total / n_fact

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

int main(void){
  int N;
  int min_A=1000000001, max_A=0;
  cin >> N;
  int A[N];
  for(int i=0;i<N;++i){
    cin >> A[i];
  }
  for(int i=0;i<N;++i){
    min_A = min(A[i], min_A);
    max_A = max(A[i], max_A);
  }
  cout << max_A - min_A << endl;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    ans = float('inf')
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
   ll n,i,ans,k,m;
    cin>>n>>m>>k;
    n=(n+m-1)/m;
    cout<<k*n el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m; ll k; cin >> m >> k;
  if(k == 0) {
    rep(i, 1<<m) cout << i << ' ' << i << ' ';
    cout << "\n";
  } else if(k >= (1<<m)) {
    cout << -1 << "\n";
  } else {
    ll x = 0;
    rep(i, 1<<m) if(i != k) x ^= i;
    if(x == k) {
      rep(i, 1<<m) if(i != k) cout << i << ' ';
      cout << k << ' ';
      rrep(i, (1<<m)) if(i != k) cout << i << ' ';
      cout << k << "\n";
    } else {
      cout << -1 << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3620
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll a,b,c;
  cin >> a >> b >> c;

  cout << (b/ a > c ? c : b / a ) << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n,l;
    cin >> n >> l;
    vector<int> azi(n);
    int hoge = 999;
    int hoge2 = 0;
    for(int i=0;i<n;i++){
        azi.at(i) = l+i+1-1;
        if(hoge > abs(azi.at(i))){
            hoge = abs(azi.at(i));
            hoge2 = azi.at(i);
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += azi.at(i);
    }
    cout << sum-hoge2 << endl;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main() {
  int N,h,j,i;
  cin >> N;
  h = N/100;
  j = (N/10)%10;
  i = (N%100)%10;
  if (h==9){
    h = 1;
  }else{
    h = 9;
  }
  if (j==9){
    j = 1;
  }else {
    j = 9;
  }
  if (i==9){
    i = 1;
  }else {
    i = 9;
  }
  cout << h << j << i <<"\n";
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    vi mm(2019,0);
    vi mm2(2019,0);
    ll curr=0;
    mm[0]++;
    ll ans=0;
    rep(i,0,sz(s)-1){
        curr=(10*curr+(s[i]-'0'))%2019;
        ans=(ans+mm[curr]);
        ll temp=curr;
        mm[temp]++;
        rep(j,0,2018)
            mm2[(j*10)%2019]=mm[j];
        mm=mm2;
        // rep(j,0,2019) mm[j]=mm[]
        // cout<<ans<<endl;
        // fill_n(all(mm2),0);
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k, a[1005];
	cin >> n >> k;
	for (int i=1; i<=n; i++) cin >> a[i];
	sort (a+1, a+n+1);
	ll sum = 0;
	for (int i=1; i<=k; i++) sum+=a[i];
	cout << sum;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
int i, N, ans, max;
cin >> N;
int h[N];
for (i=0;i<N;i++){
cin >> h[i];
}
ans=0;
max=1;

for (int j=0; j<N;j++){
if (h[j]>=max)
{
ans++;
max=h[j];
}
}
cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
typedef map<ll, int> mli;

const int S4X = 178;

ll pow5(int x) {
    return 1ll * x * x * x * x * x;
}

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

    mli s5;
    for (int i = 0; i <= S4X; i++) {
        s5[pow5(i)] = i;
    }

    int x;
    cin >> x;

    for (int i = 0; i <= S4X; i++) {
        if (s5.count(pow5(i) - x)) {
            cout << i << " " << s5[pow5(i)-x] << endl;
            return 0;
        }

        if (s5.count(x - pow5(i))) {
            cout << i << " " << -s5[x-pow5(i)] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b){
    if(b==0)return a;
    else return gcd(b, a%b);
}

long lcm(long a,long b){
    return a*b / gcd(a,b);
}

int main(){
    long a,b;cin >> a >> b;

    cout <<  lcm(a,b)  << endl;
    
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007

const int INF = 1e9;

int main() {
    int K; cin >> K;
    vi d(K, INF);
    d[1] = 1;

    deque<pii> q;
    q.push_front(pii(1, 1));

    while (!q.empty()) {
        pii val = q.front(); q.pop_front();
        int s, dist; tie(s, dist) = val;

        if (d[(s + 1) % K] > dist + 1) {
            d[(s + 1) % K] = dist + 1;
            q.push_back(pii((s + 1) % K, dist + 1));
        }
        if (d[(10 * s) % K] > dist) {
            d[(10 * s) % K] = dist;
            q.push_front(pii((10 * s) % K,dist));
        }

    }

    cout << d[0] << endl;


}


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

int main() {
    long long n, p, q, sum = 0;
    cin >> n >> p >> q;
    vector<long long> s(n);
    for (int i = 0; i < n; ++i) {
        long long c;
        cin >> c;
        sum += c;
        s[i] = p * (q - i) - c;
    }
    sort(s.begin(), s.end());
    long long ans = sum;
    for (int i = 0; i < n; ++i)
        ans = max(ans, sum += s[n - i - 1] + 2 * p * i);

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

Measured memory_bytes: 6804