akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(a, b, c) for(int a=b;a<c;a++)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int main() {
	char a[15];
	cin >> a;
	FOR(i, 0, 4) {
		cout << a[i];
	}
	cout << " ";
	FOR(i, 4, 12) {
		cout << a[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
package main

import "os"
import "fmt"
import "bufio"
import "strconv"

func main() {
    var sc = bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())

    if n / 2 * 2 == n {
        fmt.Printf("%d\n", n)
    } else {
        fmt.Printf("%d\n", n * 2)
    }
}


Measured memory_bytes: 640
s = input()

ans = len(s) // 2

for c in [chr(i + 97) for i in range(26)]:
    if c not in s:
        continue
    ma = 0
    for part in s.split(c):
        ma = max(ma, len(part))
    ans = min(ans, ma)

japaripark = ans
print(japaripark)


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

int main(){
	int n;
	do	{
		int** Mat;
		cin >> n;
		if (n == 0){
			break;
		}
		Mat = new int*[n];
		for (int i = 0; i < n; i++){
			Mat[i] = new int[n];
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				cin >> Mat[i][j];
			}
		}

		int sumrow;
		int* sumcol;
		sumcol = new int[n]();
		int sum = 0;

		for (int i = 0; i < n; i++){
			sumrow = 0;
			for (int j = 0; j < n; j++){
				cout.width(5);
				cout << Mat[i][j];
				sumrow += Mat[i][j];
				sumcol[j] += Mat[i][j];
			}
			cout.width(5);
			cout << sumrow << endl;
		}
		for (int j = 0; j < n; j++){
			cout.width(5);
			cout << sumcol[j];
			sum += sumcol[j];
		}
		delete[] sumcol;
		cout.width(5);
		cout << sum << endl;



		//行列delete
		for (int i = 0; i < n; i++){
			delete[] Mat[i];
		}
		delete[] Mat;
	} while (n != 0);

}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, h[90];

    cin >> n;
    REP(i, n)
    cin >> h[i];

    int res = 1;

    for (int i = 1; i < n; i++)
    {
        bool check = true;
        REP(j, i)
        if (h[j] > h[i])
            check = false;

        res += check;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b,c,d,t;
	string s;
	
	cin >> a >> b;
	if(a<=b)
		cout << "unsafe";
	else
		cout << "safe";

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		String newS = (s1.substring(0,1) + s2.substring(0,1) + s3.substring(0,1));
		System.out.println(newS.toUpperCase());
	}
}

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

int main(void)
{
    using namespace std;
    int n;
    scanf("%d", &n);

    // S:0, H:1, C:2, D:3
    int t[4][13] = {0};

    char ch;
    char skip;
    int num;
    for (int i = 0; i < n; i++) {
        scanf("%c", &skip);
        scanf("%c %d", &ch, &num);
        if (ch == 'S') {
            t[0][num - 1] = 1;
        } else if (ch == 'H') {
            t[1][num - 1] = 1;
        } else if (ch == 'C') {
            t[2][num - 1] = 1;
        } else if (ch == 'D') {
            t[3][num - 1] = 1;
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (t[i][j] == 0 && i == 0) {
                printf("S %d\n", j + 1);                
            } else if (t[i][j] == 0 && i == 1) {
                printf("H %d\n", j + 1);
            } else if (t[i][j] == 0 && i == 2) {
                printf("C %d\n", j + 1); 
            } else if (t[i][j] == 0 && i == 3) {
                printf("D %d\n", j + 1);
            }
        }
    }

}


Measured memory_bytes: 3196
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll f(ll h,ll w){
	ll res=INF;
	for(int i=1;i<w;i++){
		ll A=h*i,B=(w-i)*(h/2),C=(w-i)*((h+1)/2);
		res=min(res,max(A,max(B,C))-min(A,min(B,C)));
	}
	return res;
}

ll h,w;

int main(){
	cin>>h>>w;
	if(h%3==0||w%3==0){
		cout<<0<<endl;
		return 0;
	}
	ll res=min(h,w);
	res=min(res,f(h,w));
	res=min(res,f(w,h));
	cout<<res<<endl;
}

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

int main()
{
	int k;
	char s[101];
	int i;

	scanf("%d", &k);
	scanf("%s", s);

	if (k >= strlen(s))
	{
		printf("%s\n",s);
	}
	else
	{
		for (i = 0; i < k; i++)
		{
			printf("%c", s[i]);
		}
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 1620
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    ll A_count=0;
    ll B_count=0;
    REP(i, S.length()){
        if(S[i]=='A') A_count++;
        if(S[i]=='B') B_count++;
    }
    if(A_count*B_count==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv){
	int i,j;
	int n,m,*a,*b;
	int nm,c;

	// Input N*M
	scanf("%d %d",&n,&m);
	nm = n * m;
	// Input a
	a = malloc(sizeof(int)*n*m);
	for(i=0;i<nm;i++){
		scanf("%d", a+i);
	}
	// Input b
	b = malloc(sizeof(int)*m);
	for(i=0;i<m;i++){

		scanf("%d",b+i);
	}
	// Calc c & Output c
	for(i=0;i<n;i++){
		c = 0;
		for(j=0;j<m;j++){
			c += a[m*i+j] * b[j];
		}
		printf("%d\n",c);
	}

	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

string solve(const string &s){
	int n = s.size();
	string res;
	vi idx(n);
	int a = 0, b = 0;
	rep(i, n){
		if(s[i] == 'a') idx[i] = a++;
		else idx[i] = b++;
	}
	
	if(s[0] == 'a'){
		rep(i, n) if(s[i] == 'a'){
			res += "ab";
			for(int k = idx[i++]; i < n && idx[i] != k; i++);
		}
		return res;
	}
	
	rep(k, a){
		string tmp;
		rep(i, n) if(idx[i] >= k) tmp += s[i];
		res = max(res, tmp);
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k = 0; string s, ans, tmp;
	cin >> n >> s;
	vector<string> v;
	for(char c : s){
		tmp += c;
		k += c == 'a' ? 1 : -1;
		if(k == 0){
			v.pb(solve(tmp)); tmp.clear();
		}
	}
	for(int i = v.size() - 1; i >= 0; i--){
		if(ans < v[i] + ans) ans = v[i] + ans;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [[0 for i in range(m)] for j in range(n + 1)]
for j in range(n + 1):
    dp[j][0] = j
for j in range(n + 1):
    for i in range(1, m):
        if j >= c[i]:
            dp[j][i] = min(dp[j][i - 1], dp[j - c[i]][i] + 1)
        else:
            dp[j][i] = dp[j][i - 1]
print(dp[n][m - 1])


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

int main() {
	long long n, m, x, k;
	cin >> n >> m >> k;
	
	vector<long long> v1, v2;
	while(n--) cin >> x, v1.push_back(x);
	while(m--) cin >> x, v2.push_back(x);
	
	long long ans = 0, cnt = 0, sum = 0;
	
	for(int i=1; i<v1.size(); i++) v1[i] += v1[i-1];
	for(int i=1; i<v2.size(); i++) v2[i] += v2[i-1];
	
	int lkfr;
	for(long long i=-1; i<(int)v1.size(); i++) {
		if(~i and v1[i] > k) break;
		if(i > -1) lkfr = k - v1[i];
		else lkfr = k;
		
		long long id = upper_bound(v2.begin(), v2.end(), lkfr) - v2.begin() - 1;
		ans = max(ans, i + 1 + id + 1);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 7988
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
	const [n, max] = line.split(' ').map(Number);

	if (n === 0 && max === 0) {break;}

	const prices = lines.shift().split(' ').map(Number);

	const allSum = [];

	prices.map((priceA, indexA) => {
			prices.map((priceB, indexB) => {
				if (indexA !== indexB) {
					const sum = priceA + priceB;

					if(sum <= max) {
						allSum.push(sum);
					}
				}
			})
		}
	);

	const answer = allSum.sort((a,b) => b - a)[0];

	console.log(answer || 'NONE');
}



Measured memory_bytes: 55936
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <map>


using namespace std;



int main() {

	string S;
	string alpha ="abcdefghijklmnopqrstuvwxyz";
	bool key[26];

	for (int i = 0; i < 26; i++) {
		key[i] = true;
	}

	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26; j++) {
			if (alpha[j] == S[i]) {
				key[j] = false;
			}
		}
	}

	int i = 0;

	while (!key[i]) {
		i++;
	}

	if (i != 26) cout << alpha[i];
	else cout << "None";
	
	return 0;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

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

	while(1){
		if( n % 111 == 0 ){
			cout << n << endl;
			break;
		}
		n++;
	}
	ret 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<limits.h>

typedef struct group{
	int x;
	double height;//高さ
	double wh;//水面の高さ
	int check;//処理済みかどうか
	int p;// \ - 0,_ - 1,/ - 2
} G;

int box[20000]={};//探索して見つけたtopを格納
int z=0;

int topsearch(int len,double max,G *g)//max=探索済みのtop
{
	double m=-20000;
	int cnt=0;
	int i;
	int check;
	z=0;
	for(i=0;i<len;i++){
		if(max>g[i].height&&g[i].height>m) m=g[i].height;
	}
	for(i=0;i<len;i++){
		if(m==g[i].height){
			if(g[i].p==1) z=1;
			box[cnt]=i;
			cnt++;
		}
	}
	return cnt;
}

int main(void)
{
	G g[20000];
	char c[20000];
	double h=5,r=5,l=5;// 高さを求めるための変数r;right,l;left
	int len;
	int i,j;
	double max=20000;
	double result[20000]; //溜まった水の量を格納
	int cnt;
	double allsum=0,sum=0,add;
	scanf("%s",c);
	len=strlen(c);
	for(i=0;i<len;i++){//初期値入力
		g[i].check=0;
		if(c[i]=='/'){
			l=r;
			r++;
			g[i].height=(l+r)/2;
			g[i].p=2;
		}else if(c[i]=='_') {g[i].height=r;g[i].p=1;}
		else{
			l=r;
			r--;
			g[i].height=(l+r)/2;
			g[i].p=0;
		}
		g[i].wh=g[i].height;
	}
	for(i=0;box[0]!=-1;i++){
		box[0]=-1;
		cnt=topsearch(len,max,g);
		max=g[box[0]].height;
		if(cnt==1);
		else{
			for(j=box[0];j<=box[cnt-1];j++){
				if(j==box[0]&&c[box[0]]=='/') {
					g[j].check=1;
					j++;
				}
				if(j==box[cnt-1]&&c[box[cnt-1]]!='/'&&c[box[cnt-1]]!='_'){
					g[j].check=1;
					break;
				}
				if(g[j].check==0){
					if(z!=1) g[j].wh=max+0.5;
					else g[j].wh=max;
					g[j].check=1;
				}
			}
		}
	}
	for(cnt=0,i=0;i<len;i++){
		add=g[i].wh-g[i].height;
		if(add>0) {
			if(i+1<len){
				if(add==0.5&&g[i+1].wh-g[i+1].height==0.5&&g[i+1].p==0) {
					add=-1;
					sum+=0.5;
				}else sum+=add;
			}else sum+=add;
		}
		if(add<=0||i==len-1){
			if(sum!=0){
				result[cnt]=sum;
				allsum+=sum;
				cnt++;
				sum=0;
			}
		}
	}
	printf("%d\n%d",(int)allsum,cnt);
	for(i=0;i<cnt;i++){
		printf(" ");
		printf("%d",(int)result[i]);
	}
	printf("\n");
	/*for(i=0;i<len;i++) printf("%1.1f ",g[i].wh);
	printf("\n");
	for(i=0;i<len;i++) printf("%1.1f ",g[i].height);
	printf("\n");*/
	return 0;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {

  public static void Main (string[] args) {
    var X = ReadLineString();
    var Y = ReadLineString();

    var ans ="No";
    
    if(X.GroupBy(g => g).Select((x, i) => x.Count()).SequenceEqual(Y.GroupBy(g => g).Select((x, i) => x.Count()))){
      ans = "Yes";
    }

    /*test.ToList().ForEach(Console.WriteLine);
    test2.ToList().ForEach(Console.WriteLine);*/
    Console.WriteLine(ans);
  }

  static int ReadLineInt_1() {
    return int.Parse(Console.ReadLine());
  }
 static string ReadLineString() {
    return Console.ReadLine();
  }
  static IEnumerable<long> ReadLineLongList() {
    return Console.ReadLine().Split(' ').Select(long.Parse);
  }

}

Measured memory_bytes: 17376
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main(){
    FIN;
    ll n; cin >> n;
    vector<char> c(n);
    ll ans = 0;
    for(ll i=0;i<n;i++){
        cin >> c[i];
        if(c[i] == 'W') ans++;
    }

    ll ans2 = 0;
    ll cur = n-1;
    for(ll i=0;i<n;i++){
        if(c[i] == 'W'){
            for(ll j=cur;j>=i;j--){
                if(c[j] == 'R'){
                    c[i] = 'R';
                    c[j] = 'W';
                    ans2++;
                    break;
                }
                cur = j;
            }
        }
        if(cur <= i) break;
    }

    cout << min(ans,ans2) << endl;
    return 0;
}


Measured memory_bytes: 3652
a=[]
dp=[[0]*3 for i in range(3)]
for i in range(3):
    a1,a2,a3=map(int,input().split())
    a.append((a1,a2,a3))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for h in range(3):
            if a[j][h]==b:
                dp[j][h]=1
flag=0
for i in range(3):
    count=0
    for j in range(3):
        if dp[i][j]==1:
            count+=1
    if count==3:
        flag=1
for i in range(3):
    count=0
    for j in range(3):
        if dp[j][i]==1:
            count+=1
    if count==3:
        flag=1
count=0
for i in range(3):
    if dp[i][i]==1:
        count+=1
if count==3:
    flag=1
count=0
for i in range(3):
    if dp[2-i][i]==1:
        count+=1
if count==3:
    flag=1
#print(dp)
print('Yes' if flag==1 else 'No')

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	int a[200000];
	cin >> n;
	rep(i, 0, n)
		cin >> a[i];
	ll int s, r=0;
	s = a[0];
	rep(i, 1, n)
		r += a[i];
	ll int min;
	min = abs(r - s);
	rep(i, 1, n - 1) {
		r -= a[i];
		s += a[i];
		if (min > abs(r - s)) {
			min = abs(r - s);
		}
	}
	cout << min << endl;
	return 0;
}

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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 1e5 + 5;

vector < int > a[N];
queue < int > q;

int in[N], mx, d[N];

void bfs()
{
    while(!q.empty()) {
        int x = q.front();
        q.pop();
        mx = max(mx, d[x]);
        if(in[x] > 0) continue;
        for(auto v : a[x]) {
            if(d[v] < d[x] + 1) d[v] = d[x] + 1, q.push(v);
            --in[v];
        }
    }
}

int main()
{
    usain_bolt();

    int n, m;

    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int x, y;

        cin >> x >> y;
        a[x].push_back(y);
        ++in[y];
    }
    for(int i = 1; i <= n; ++i) if(in[i] == 0) q.push(i);
    bfs();
    cout << mx;
    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int Need(int x)
{
	x--;
	rep(i,5) x|=x>>(1<<i);
	return x+1;
}

struct SegmentTree{
	int size;
	vi data,index;
	SegmentTree(int s):size(Need(s)),data(size*2,-INFTY),index(size*2,-1){}
	SegmentTree(const vi& a):size(Need(a.size())),data(size*2,-INFTY),index(size*2,-1){
		copy(all(a),data.begin()+size);
		rep(i,a.size()) index[size+i]=i;
		for(int i=size;--i;){
			if(data[i*2]>=data[i*2+1])
				data[i]=data[i*2],index[i]=index[i*2];
			else
				data[i]=data[i*2+1],index[i]=index[i*2+1];
		}
	}
	int Get(int i){
		return data[size+i];
	}
	void Update(int i,int x){
		data[size+i]=x;
		for(i=(i+size)/2;i;i/=2){
			if(data[i*2]>=data[i*2+1])
				data[i]=data[i*2],index[i]=index[i*2];
			else
				data[i]=data[i*2+1],index[i]=index[i*2+1];
		}
	}
	int Query(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return -1;
		if(a<=l && r<=b) return index[i];
		int li=Query(a,b,i*2,l,(l+r)/2),ri=Query(a,b,i*2+1,(l+r)/2,r);
		int lv=li==-1?-INFTY:data[size+li],rv=ri==-1?-INFTY:data[size+ri];
		return lv>=rv?li:ri;
	}
	int Query(int a,int b){
		return Query(a,b,1,0,size);
	}
};

int main()
{
	for(int n,q;~scanf("%d%d",&n,&q) && n|q;){
		SegmentTree st(vi(n,0));
		rep(_,q){
			int a,v; cin>>a>>v; a--;
			st.Update(a,st.Get(a)+v);
			int i=st.Query(0,n);
			printf("%d %d\n",i+1,st.Get(i));
		}
	}
	
	return 0;
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
 string str;
  cin>>str;
  int cnt=0;
  for(int i=0;i<n-2;i++)
  {
    if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C')
    {
     cnt++; 
    }
  }
  cout<<cnt<<endl;
}


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;

#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    ll h;
    cin >> h;
    ll count=0;
    ll num=1;
    ll x=h;
    while(x>=1){
        
        count+=num;
        x/=2;
        num*=2;
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
	char a, b, c;
	int sum;

	scanf("%c%c%c", &a, &b, &c);
	sum = 700;
	if (a == 'o')
	{
		sum += 100;
	}
	if (b == 'o')
	{
		sum += 100;
	}
	if (c == 'o')
	{
		sum += 100;
	}

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128
def turn_check(inlist,p,q,x):
    s = q*x
    t = p-q
    return sum([ (max(i-s,0)+t-1)//t for i in inlist ]) <= x

n, a, b = [ int(v) for v in input().split() ]
h_list = [ int(input()) for i in range(n) ]
ok, ng = 10**9, 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if turn_check(h_list,a,b,mid):
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 10988
import collections
q = collections.deque()
q.append(input())

cnt = 0

while q:
    x = q.popleft()
    
    if x in ["dream","dreamer","erase","eraser"]:
        cnt += 1
        
    else:
        if 5 < len(x):
            if x[:5] in ["dream","erase"]:
                q.append(x[5:])
                
        if 6 < len(x):
            if x[:6] == "eraser":
                q.append(x[6:])
                
        if 7 < len(x):
            if x[:7] == "dreamer":
                q.append(x[7:])
                
print("YNEOS"[cnt==0::2])

Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    vector<int> x(5);
    int ans = 0;
    rep(i, 5)
    {
        cin >> x[i];
        if (x[i] == 0) ans = i + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3564
/*input
1000 1 1000
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 
 
 
ll n,i,j,k,m,c;

void solve()
{ long double n,m;
cin>>n>>m>>k;
c=ceil(n/m);
cout<<c*k;

}
 
 
 
signed main()
{// inputFile;


    fast;
    int T = 1;
    // cin >> T;
    ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

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

int main() { 
    int n, ans;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    ans = __gcd(a[0], a[1]);
    for(int i = 1; i < n; i++) ans = __gcd(ans, a[i]);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

int main() {
    using namespace std;
    int n,a,sum=0;
    cin>>n;
    for (int i = 0; i < n ; i++) {
        cin>>a;
        if (a%2==1&&i%2==0)
            sum++;
    }
    cout<<sum;
    return 0;
    }

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    long a[n + 1], b[n], ans = 0.0;

    //入力を受け取る
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n - 1) cin >> b[i];

    rep(i, 0, n - 1)
    {
        //勇者iが倒せる数が残っていないときは次の勇者へ
        if (b[i] == 0)
            continue;

        //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
        //都市iのモンスターを倒しきれないとき
        if (b[i] <= a[i])
        {
            ans += b[i];
            continue;
        }

        //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
        //都市iのモンスターは倒せるが都市i+1のモンスターは倒しきれないとき
        if (b[i] <= a[i] + a[i + 1])
        {
            ans += b[i];
            b[i] -= a[i];
            a[i + 1] -= b[i];
            continue;
        }

        //勇者iが都市i, i+1のモンスターをすべて倒しきれるときはすべて倒す
        ans += a[i] + a[i + 1];
        //a[i]も0にすべきだが、この変数はこの後使わないので省略
        a[i + 1] = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
a,b,h,m=map(int,input().split())
import math
pi=math.pi
s1=30*h+m/2
s2=6*m
s1s2=abs(s2-s1)
cos=math.cos(math.radians(s1s2))
print((a**2+b**2-2*a*b*cos)**0.5)

Measured memory_bytes: 9504
n = int(input())
l = [[0,0] for _ in range(n)]
for i in range(n):
    x,y = map(int,input().split())
    l[i] = [x-y,x+y]
ans = 0
for i in range(2):
    l2 = [l[j][i] for j in range(n)]
    ans = max(ans,max(l2)-min(l2))
print(ans)

Measured memory_bytes: 132124
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    ll N; cin >> N;
    ll ans = 0;
    for(int i = 1; pow(i,2) <= N; i++){
        ans = max(ans, pow(i,2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class Unionfind():
  def __init__(self,n=10**6):
    self.n=n
    self.root=[-1]*(n+1)
    self.rnk=[0]*(n+1)
  def find(self,x):
    if(self.root[x]<0):
      return x
    else:
      self.root[x]=self.find(self.root[x])
      return self.root[x]
  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if(x==y):return
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x]+=self.root[y]
      self.root[y]=x
    else:
      self.root[y]+=self.root[x]
      self.root[x]=y
      if(self.rnk[x]==self.rnk[y]):
        self.rnk[y]+=1
  def same(self,x,y):
    return self.find(x)==self.find(y)
  def count(self,x):
    return -self.root[self.find(x)]
uf=Unionfind()
n,q=map(int,input().split())
for _ in range(q):
  t,u,v=map(int,input().split())
  if t:print(int(uf.same(u,v)))
  else:uf.unite(u,v)

Measured memory_bytes: 98616
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vector<vi>adj(100005),wt1(100005),wt(100005);
set<pll>se;
set<pll>::iterator it;
ll ans[100005],dis[100005],dis1[100005];
int main(){
	std::ios::sync_with_stdio(false);
	ll n,m,s,t,i,u,v,a,b,val,val1,res,iinf=inf;
	iinf*=inf;	
	cin>>n>>m>>s>>t;
	rep(i,m){
		cin>>u>>v>>a>>b;
		adj[u].pb(v);
		adj[v].pb(u);
		wt[u].pb(a);
		wt[v].pb(a);
		wt1[u].pb(b);
		wt1[v].pb(b);
	}
	rep(i,n+1){
		dis[i]=iinf;
		dis1[i]=iinf;
	}
	dis[s]=0;
	dis1[t]=0;
	rep(i,n){
		se.insert(mp(dis[i+1],i+1));
	}
	while(!se.empty()){
		it=se.begin();
		se.erase(it);
		a=it->ss;
		b=it->ff;
		rep(i,adj[a].size()){
			if(dis[adj[a][i]]>b+wt[a][i]){
				se.erase(mp(dis[adj[a][i]],adj[a][i]));
				dis[adj[a][i]]=b+wt[a][i];
				se.insert(mp(dis[adj[a][i]],adj[a][i]));
			}
		}
	}
	rep(i,n){
		se.insert(mp(dis1[i+1],i+1));
	}
	while(!se.empty()){
		it=se.begin();
		se.erase(it);
		a=it->ss;
		b=it->ff;
		rep(i,adj[a].size()){
			if(dis1[adj[a][i]]>b+wt1[a][i]){
				se.erase(mp(dis1[adj[a][i]],adj[a][i]));
				dis1[adj[a][i]]=b+wt1[a][i];
				se.insert(mp(dis1[adj[a][i]],adj[a][i]));
			}
		}
	}
	res=0;
	val=10000000;
	val*=val;
	val*=10;
	val1=val-dis[n]-dis1[n];
	res=max(res,val1);
	fd(i,n-1,0){
		ans[i]=res;
		val1=val-dis[i]-dis1[i];
		res=max(res,val1);
	}
	rep(i,n){
		cout<<ans[i]<<endl;
	}
} 
	

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

typedef long long ll;

int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    if(a + 2 >= b || k < a+1){
        cout << ll(k+1) << endl;
        return 0;
    }
    ll s = k - (a + 1);
    ll ans = (s/2+1)*b - (s/2)*a + s%2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, int>;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int lcost = 0, rcost = 0;
    for (int i = 0; i < m; i++)
    {
        int temp;
        cin >> temp;
        if (temp < x)
            lcost++;
        if (temp > x)
            rcost++;
    }
    if (lcost < rcost)
        cout << lcost << endl;
    else
        cout << rcost << endl;

    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val As = Array.fill(N)(in.nextLong)

  def check(l: Int, r: Int, cur: Long, cnt: Long): Long = {
    if (r == N) cnt + (r - l).toLong * (r - l + 1) / 2
    else {
      if ((cur & As(r)) == 0) check(l, r + 1, cur + As(r), cnt)
      else check(l + 1, r, cur - As(l), cnt + r - l)
    }
  }

  println(check(0, 0, 0, 0))
}

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

int H,W,h,w,g[510][510];
LL sum;

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	for (i=1;i<=H;i++)
	for (j=1;j<=W;j++)
		g[i][j]=1000;
	for (i=h;i<=H;i+=h)
	for (j=w;j<=W;j+=w)
		g[i][j]=-1000ll*h*w+999ll;
	for (i=1;i<=H;i++)
	for (j=1;j<=W;j++)
		sum+=g[i][j];
	if (sum>0)
	{
		puts("Yes");
		for (i=1;i<=H;i++)
		{
			for (j=1;j<=W;j++)
				printf("%d ",g[i][j]);
			puts("");
		}
	}
	else puts("No");
}


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

using namespace std;

bool is_blackjack(vector<int> &cards)
{
    return (cards[0] == 1 && cards[1] >= 10);
}

int to_num(char ch)
{
    if (ch == 'A') {
        return 1;
    } else if (ch == 'T') {
        return 10;
    } else if (ch == 'J') {
        return 11;
    } else if (ch == 'Q') {
        return 12;
    } else if (ch == 'K') {
        return 13;
    }
    return (ch - '0');
}

int get_point(int c)
{
    return (c >= 10 ? 10 : c);
}

pair<int, int> get_point(vector<int> &cards)
{
    int point = 0, ace_cnt = 0;
    vector<int> ace;
    for (int i = 0; i < (int)cards.size(); i++) {
        if (cards[i] == 1) {
            ace_cnt++;
            point += 11;
        } else {
            point += get_point(cards[i]);
        }
    }
    int jk = 0;
    for (int i = 0; i < ace_cnt; i++) {
        if (point > 21) {
            point -= 10;
            jk++;
        }
    }
    return make_pair(point, ace_cnt - jk);
}

int main()
{
    int N;
    cin >> N;
    while (N--) {
        char ch;
        vector<int> cards;
        int pile[8];
        for (int i = 0; i < 2; i++) {
            cin >> ch;
            cards.push_back(to_num(ch));
        }
        sort(cards.begin(), cards.end());
        for (int i = 0; i < 8; i++) {
            cin >> ch;
            pile[i] = to_num(ch);
        }
        if (is_blackjack(cards)) {
            cout << "blackjack" << endl;
            continue;
        }
        pair<int, int> p;
        int point = 0;
        for (int i = 0; i < 8; i++) {
            p = get_point(cards);
            point = p.first;
            if (point <= 16) {
                cards.push_back(pile[i]);
            } else if (point == 17 && p.second > 0) {
                cards.push_back(pile[i]);
            } else {
                break;
            }
        }
        point = get_point(cards).first;        
        if (point > 21) {
            cout << "bust" << endl;
        } else {
            cout << point << endl;
        }
    }
    return 0;
}

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

int main() {
  int N,X;
  cin>>N>>X;
  vector<int> m(N);
  int sum=0;
  int mx=0;
  rep(i,N){
    cin>>m[i];
    sum += m[i];
  }
  X -= sum;
  mx += N;
  
  sort(m.begin(), m.end());
  mx += X/m[0];
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

// 深さ1上昇、増える文字数は1個以内(辞書順なので)
int n;
void dfs(int i, char c, string s) {
  if (i == n) {
    cout << s << '\n';
    return;
  }
  for (char nc = 'a'; nc <= c + 1; ++nc) dfs(i + 1, max(nc, c), s + nc);
}

int main() {
  cin >> n;
  dfs(0, 'a' - 1, "");
  return 0;
}

Measured memory_bytes: 3612
#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 r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  if(X < 0) X *= -1;
  
  if(X != 0){
    ll n = X / D;

    if(n >= K){
      cout << abs(X - D * K) << endl;
    }else{
      ll p = X - n*D;
      K -= n;

      if(K%2 == 0) cout << abs(p) << endl;
      else cout << abs(p-D) << endl;
    }
  }
  else { // X == 0
    if(K%2 == 0) cout << 0 << endl;
    else cout << D << endl;
  }
  
  return 0;
}




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

int main() {
	int N, x;

	cin >> N >> x;

	vector<int> a(N);

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

	sort(a.begin(), a.end());

	int ans = 0;
	for (int i = 0; i < N; i++) {
		x -= a[i];
		ans++;
		if (x < 0) {
			cout << (ans-1) << endl;
			return 0;
		}
	}

	if (x == 0) {
		cout << ans << endl;
		return 0;
	}
	if (x > 0) {
		cout << ans - 1 << endl;
		return 0;
	}


}



Measured memory_bytes: 256
n,m=map(int,input().split())
s = []
for i in range(m):
    pref,year=map(int,input().split())
    s.append([pref,year,i])
s.sort()
rank = 1
for i in range(m):
    if s[i][0] != s[i-1][0]:
        rank = 1
    s[i][1]=rank
    rank += 1
s.sort(key=lambda x: x[2]) 
for i in range(m):
    print("0"*(6-len(str(s[i][0])))+str(s[i][0])+"0"*(6-len(str(s[i][1])))+str(s[i][1]))

Measured memory_bytes: 24744
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int main(){
    int n;
    cin>>n;
    long long pow=1;
    for(int i=1; i<=n; i++){
        pow*=i;
        pow%=inf;
    }
    cout<<pow<<endl;

}


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

int main()
{

    //cinでファイルから読込
    ifstream in("./input.txt");
    cin.rdbuf(in.rdbuf());

    //cinの高速化
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C, ans;
    cin >> A;
    cin >> B;
    cin >> C;

    ans = C - (A - B);
    if (ans < 0)
    {
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int haiku = 0;
    if(a==5 && b==5 && c==7){
        haiku = 1;
    }
    else if(a==5 && b==7 && c==5){
        haiku =1;
    }
    else if(a==7 && b==5 && c==5){
        haiku=1;
    }
    if(haiku ==1) cout << "YES" << endl;
    else if(haiku==0) cout << "NO" << endl;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	int n, i, j, k;
	string t;
	vector<string>s;
	map<string, int >m;
	vector<pair<string, int> >a;
	vector< vector<ipair> >p;

	cin >> n;

	SIZE(p, 100);

	k = 0;
	rep(i, n) {
		cin >> t >> j;
		if (m.find(t) == m.end()) {
			m.insert(make_pair(t, k));
			PB(a, make_pair(t, k));
			PB(p[k], make_pair(j, i+1));
			k++;
		}
		else {
			PB(p[m.at(t)], make_pair(j, i + 1));
		}
	}
	sort(ALL(a));
	rep(i, a.size()) {
		sort(ALL(p[a[i].second]), greater<ipair >());
		rep(j, p[a[i].second].size()) {
			cout << p[a[i].second][j].second << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(RALL(v));
    v[0] /= 2;
    cout << accumulate(ALL(v),0) << endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)
#define INF 1000000000
#define mod 1000000007

const double MATH_PI = 3.1415926535897932384626433832795;

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double jv;

	h += m / 60;
	double r = fabs(MATH_PI * m / 30. - MATH_PI * h / 6.);

	xatop(r);

	if (r > MATH_PI)
		r = 2 * MATH_PI - r;

	xatop(r);

	jv = 1. * a * a + 1. * b * b - 1. * 2 * a * b * cos(r);

	jv = sqrt(jv);
	cout << setprecision(12) << jv << endl;

	return 0;
}


Measured memory_bytes: 4124
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  var data = chunk.replace( /\n/, '' ).split( ' ' );

  var W = parseInt( data[0] );
  var H = parseInt( data[1] );
  var x = parseInt( data[2] );
  var y = parseInt( data[3] );
  var r = parseInt( data[4] );
  if( 0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H ) {
    console.log( 'Yes' );    
  } else {
    console.log( 'No' );    
  }
} )

Measured memory_bytes: 7648
// AOJ 1016
#include<iostream>
#include<set>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int V, d;
const int N = 1001;
int F[1024];

int abs(int x) { return (x > 0 ? x : -x); }

const int VMAX = 1024;
int par[VMAX], Rank[VMAX];

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;

  if (Rank[x] < Rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (Rank[x] == Rank[y]) Rank[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int count_sets(int begin, int end) {
  set<int> s;
  for (int i = begin; i <= end; i++) {
    s.insert(par[i]);
  }
  return s.size();
}

int solve() {
  for (int i = 1; i <= V; i++) for(int j = 1; j <= V; j++) {
    if (abs(F[i] - F[j]) < d)
      unite(i, j);
  }

  return count_sets(1, V);
}

void init() {
  REP(i, 1024) {
    par[i] = i;
    Rank[i] = 0;
  }
}

int main() {
  F[0] = 1, F[1] = 2;
  for (int i = 2; i < 1024; i++) {
    F[i] = (F[i-1] + F[i-2]) % N;
  }

  while (cin >> V >> d) {
    init();
    cout << solve() << endl;
  }
}

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

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

typedef long long int ll;
typedef pair<int, int> P;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll watta = n / (a + b);
  ll amari = n % (a + b);
  ll ans = 0;

  if (amari == 0) {
    ans = watta * a;
    cout << ans << endl;
    return 0;
  } else if (amari <= a) {
    ans = watta * a + amari;
  } else if (amari > a) {
    ans = watta * a + a;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256