akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define PB push_back
#define MP make_tuple
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 105;
constexpr int MAX_M = 1005;
//constexpr int MAX_H = 1005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

int d[MAX_N], n, m, flg[MAX_M];

vector<pii> G[MAX_N];
tuple<int, int, int> ed[MAX_M];

void Dijkstra(int s) {
    fill(d, d + MAX_N, INF);
    d[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({ 0, s });

    while (pq.size()) {
        pii p = pq.top();
        pq.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < G[v].size(); ++i) {
            int to = G[v][i].second, cost = G[v][i].first;
            if (d[to] <= p.first + cost) continue;
            d[to] = p.first + cost;
            pq.push({ d[to], to });
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        ed[i] = MP(a, b, c);
        G[a].PB({ c, b });
        G[b].PB({ c, a });
    }

    for (int i = 0; i < n; ++i) {
        Dijkstra(i);
        for (int j = 0; j < m; ++j) {
            int a = get<0>(ed[j]), b = get<1>(ed[j]), cost = get<2>(ed[j]);
            if (min(d[a], d[b]) + cost == max(d[a], d[b])) {
                flg[j] = true;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < m; ++i) {
        if (!flg[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A,B;
    cin >>A >> B;
    int C,D;
    cin >>C >>D;
    cout << min(A,B) + min(C,D) << enld;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int n, tmp;

int main(){
    while(scanf("%d", &n) != EOF){
        if(n == 0) break;

        int ice[10];
        std::fill(ice, ice + 10, 0);

        for(int i = 0; i < n; i++){
            scanf("%d", &tmp);

            ice[tmp]++;
        }

        for(int i = 0; i < 10; i++){
            if(ice[i] == 0) printf("-\n");
            else{
                for(int j = 0; j < ice[i]; j++){
                    printf("*");
                }
                printf("\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.rmi.Remote;
import java.util.ArrayList;

class Main{
	public static void main(String args[]){
		(new Main()).commercial();
	}

	ArrayList<Integer[]> intervalArray;

	void commercial(){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String str = new String();
			while((str = br.readLine()) != null){
				String strs[] = str.split(" ");
				int n = Integer.parseInt(strs[0]);
				if(n == 0) return;

				int start_minute = stringTimeToMinute(strs[1]);
				int end_minute = stringTimeToMinute(strs[2]);

				//System.out.println("Channel: " + n + "\t Start: " + start_minute + "\t End:" + end_minute);

				intervalArray = new ArrayList<Integer[]>();

				for(int i = 0; i < n; i++){
					int k = Integer.parseInt(br.readLine());

					str = br.readLine();
					strs = str.split(" ");

					Integer interval[] = new Integer[2];
					interval[0] = start_minute;

					for(int j = 0; j < k; j++){
						interval[1] = stringTimeToMinute(strs[2 * j]);
						// printArray(interval);
						//intervalArray.add(interval);
						addInterval(interval);
						interval = new Integer[2];
						interval[0] = stringTimeToMinute(strs[2 * j + 1]);
					}
					interval[1] = end_minute;
					// printArray(interval);
					//intervalArray.add(interval);
					addInterval(interval);
				}
				//printArray(intervalArray);

				int max_interval = 0;
				for(int i = 0; i < intervalArray.size(); i++){
					Integer targetInterval[] = intervalArray.get(i);
					int interval_minute = targetInterval[1] - targetInterval[0];
					if(max_interval < interval_minute) max_interval = interval_minute;
				}
				System.out.println(max_interval);
			}
		}catch(Exception e){
			System.err.println(e);
		}
	}

	void addInterval(Integer newInterval[]){
		ArrayList<Integer[]> removeArray = new ArrayList<Integer[]>();

		for(int i = 0; i < intervalArray.size(); i++){
			Integer targetInterval[] = intervalArray.get(i);
			if(newInterval[1] < targetInterval[0]){
				continue;
			}else if(targetInterval[1] < newInterval[0]){
				continue;
			}else{
				newInterval[0] = Math.min(newInterval[0], targetInterval[0]);
				newInterval[1] = Math.max(newInterval[1], targetInterval[1]);
				removeArray.add(targetInterval);
			}
		}
		intervalArray.removeAll(removeArray);
		intervalArray.add(newInterval);
	}

	int stringTimeToMinute(String input_str){
		int input_int = Integer.parseInt(input_str);
		int hour_part = input_int / 100;
		int minute_part = input_int % 100;
		int result = hour_part * 60 + minute_part;
		return result;
	}

	void printArray(ArrayList<Integer[]> array){
		for(int i = 0; i < array.size(); i++){
			printArray(array.get(i));
		}
	}

	static void printArray(Integer array[]){
		for(int i = 0; i < array.length; i++){
			System.out.print(array[i] + "\t");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 16908
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

typedef struct{int first;int second;}P;
int upcmpllp(const void *a, const void *b){
    if(((P*)a)->first!=((P*)b)->first)return(((P*)a)->first>((P*)b)->first?1:-1);
    else return(((P*)a)->second==((P*)b)->second?0:(((P*)a)->second>((P*)b)->second ?1:-1));
}
void sort_up(P *a,int n){qsort(a,n,sizeof(P), upcmpllp);}

int H,W,M;
P hw[303030];
int cntx[303030] = {0},cnty[303030] = {0};

ll solve(){
    sort_up(hw,M);
    rep(i,M) {
        cntx[hw[i].first]++;
        cnty[hw[i].second]++;
    }
    ll mx = 0,my = 0;
    rep(i,H+1) if(cntx[i] > mx) mx = cntx[i];
    rep(i,W+1) if(cnty[i] > my) my = cnty[i];
    ll myc = 0;
    rep(i,W+1) if(cnty[i] == my) myc++;
    int tmpc,tx,flag=1;
    rep(i,M) {
        if(cntx[hw[i].first] == mx){
            tmpc = 0, tx = hw[i].first;
            while(i < M && hw[i].first == tx){
                if(cnty[hw[i].second] == my) tmpc++;
                i++;
            }
            i--;
            if(tmpc < myc){
                flag = 0;
                break;
            }
        }
    }
    return mx+my-flag;
}

int main(){
    scanf("%d%d%d", &H,&W,&M);
    rep(i, M) scanf("%d%d", &hw[i].first,&hw[i].second);
    printf("%lld\n", solve());
}

Measured memory_bytes: 6408
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            for (int i = 0; i < 2; i++)
            {
                if (A > B)
                {
                    ans += A;
                    A--;
                }
                else
                {
                    ans += B;
                    B--;
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


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

const int data[6]={500,100,50,10,5,1};
int main() {
	// your code goes here
	int n;
	while(cin>>n && n){
		n=1000-n;
		int ans=0;
		for(int i=0;i<6;i++){
			ans+=n/data[i];
			n%=data[i];
			
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

public class Main{
	
	
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			int cnt = 0;
			String s  = br.readLine();
			for(int i=0;i<6;i++){
				if(s.charAt(i) == '1'){
					cnt++;
				}
			}
			System.out.println(cnt);
		}catch(Exception e){
			
		}
		
	}
	
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    vector<int> a;
    vector<bool> flg;
    
    cin >> N;
    a.resize(N);
    flg.resize(N, true);
    for (int i=0; i<N; i++) {
        cin >> a[i];
        a[i]--;
    }
    
    int i;
    int count=0;
    for (i=0; flg[i]==true && a[i]!=1; i=a[i]) {
        count++;
        flg[i]=false;
    }
    if (flg[i]==false) {
        cout << -1;
    } else {
        cout << count+1;
    }
}


Measured memory_bytes: 640
s = input()
bit_pre = 0
bit_post = 0
if 1 <= int(s[:2]) and int(s[:2]) <= 12:
    bit_pre = 1
if 1 <= int(s[2:]) and int(s[2:]) <= 12:
    bit_post = 1
if bit_pre and bit_post:
    print("AMBIGUOUS")
elif bit_pre:
    print("MMYY")
elif bit_post:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> A){
	ll res = A[0]-1, p = 2;
	repn(i,N-1) {
		if (A[i] != p) {
			res += (A[i]-1)/p;
		} else {
			p++;
		}
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a, b, c, i;
    cin >> a >> b >> c; 
	i = abs(a-c);
	if(c>(a+b)){
	cout<<0<<' '<<0;
	}else if(c>a){
		cout<<0<<' '<<(b-i);
	}else{
	
	cout<<i<<' '<<b;
	}
	
	
	
	


}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	sort(a, a + 3);
	printf("%d\n", a[0] + a[1]);
	
	Please AC;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    char s[11];

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

    if (a>=3200){
        printf("%s",s);
    }
    else {
        printf("red");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 302;
const ll mod = 1000000007;
const long long int inf = 2*(1e16);
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
 
 
 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


ld dp[N][N][N];

int main()
{
    ld n;
    decimal(10);
    cin>>n;
    ll cnt1=0,cnt2=0,cnt3=0;
    ll a;
    rep(i,n){
        cin>>a;
        if(a==1) cnt1++;
        if(a==2) cnt2++;
        if(a==3) cnt3++;
    }
    dp[0][0][1] = n;
    for(ll i = 2;i<=n;i++){
        dp[0][0][i] = dp[0][0][i-1]+n/i;
    }
   // cout<<dp[0][0][3]<<endl;
    for(ll i = 0;i<=cnt3;i++){
        for(ll j = 0;j<=cnt2+cnt3;j++){
            //if(j+i>n) break;
            for(ll k = 0;k<=n;k++){
                if(j==0 && i==0) break;
               // if(i+j+k>n) break;
              //  cout<<"i = "<<i<<" j = "<<j<<" k = "<<k<<endl;
                dp[i][j][k] = n/(i+j+k);
                if(i!=0){
                    dp[i][j][k] += ((ld)i/(i+j+k))*dp[i-1][j+1][k];
                }
                if(j!=0) dp[i][j][k] += ((ld)j/(i+j+k))*dp[i][j-1][k+1];
                if(k!=0) dp[i][j][k] += ((ld)k/(i+j+k))*dp[i][j][k-1];


                
            }

        }
    }

    cout<<dp[cnt3][cnt2][cnt1]<<endl;
    
    



}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 430336
def draw(h,w):
	s = "#" * w
	for i in range(0,h):
		print s
	print

if __name__ == "__main__":
	while True:
		h,w = map(int, raw_input().split())
		if h==0 and w==0:
			break
		else:
			draw(h,w)

Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	ll a,b;
	cin >> a >> b;
	ll left,right;
	left=a;
	right=b;
	ll answer=0;
	while(true){
		if(left%4==0){
			break;
		}
		left++;
	}
	while(true){
		if(right%4==0){
			break;
		}
		right--;
	}
	if(left>=right){
		for(ll i=a;i<b+1;i++){
			answer^=i;
		}
		cout << answer << endl;
		return 0;
	}
	ll ans_left,ans_right;
	ans_left=0;
	ans_right=0;
	for(ll i=a;i<left;i++){
		ans_left^=i;
	}
	for(ll i=right;i<b+1;i++){
		ans_right^=i;
	}

	answer=ans_left^ans_right;
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
x = int(input())

mod = x % 11
ans = 0

if mod == 0:
    ans = 2 * int(x / 11)
elif mod <= 6:
    ans = 2 * int(x / 11) + 1
else:
    ans = 2 * int(x / 11) + 2

print(ans) 

Measured memory_bytes: 3064
import Control.Applicative
import Text.Printf
readDigits = map read <$> words <$> getLine :: IO [Int]
main = do
    ab@[a,b] <- readDigits
    let d = a `div` b
    let r = a `mod` b
    let f = (\[a,b] -> a / b) $ map realToFrac ab
    printf "%d %d %.5f\n" d r (f :: Double)

Measured memory_bytes: 3984
#include <stdio.h>
int main(void){
  int n,a[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=n-1;i>0;i--)
    printf("%d ",a[i]);
  printf("%d\n",a[0]);
  return 0;
}

Measured memory_bytes: 596
//Bi-smi llāh

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



int main(){
	int s, w; cin >> s >> w;
	if(w >= s){
		cout << "unsafe\n";
	}else{
			cout << "safe\n";
		}
	return 0;
	}


Measured memory_bytes: 3588
n, m, = map(int, input().split())

a =[]
b =[]
for i in range(n):
    at, bt, = map(int, input().split())
    a.append(at)
    b.append(bt)

c = sorted(zip(a,b))
ans = 0
for (s, t) in c:
    if m >= t:
        ans += s * t
        m -= t
    else:
        ans += s * m
        break

print(ans)



Measured memory_bytes: 18572
//https://atcoder.jp/contests/dp/tasks/dp_b
//shauryakr
#include<bits/stdc++.h>
using namespace std;
int arr[100010], n, K;
int dp[100010];
int solve(int ind)
{
    if(ind == n-1)
        return 0;
    if(dp[ind]!= -1)
        return dp[ind];
    int ans = solve(ind+1) + abs(arr[ind+1] - arr[ind]);
    for(int i=2; i<=K && i+ind < n; i++)
    {
        ans = min(ans, solve(ind+i) + abs(arr[ind+i] - arr[ind]));
    }
    dp[ind] = ans;
    return ans;
}
int main()
{
    cin >> n >> K;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0) << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;       //情報の数
    int b, f, r, v; //b棟f階のr番 v人が入居 4_3_10
    int room_data[20][20][20] = {0};

    for (int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;

        if (room_data[b][f][r] != 0)
        {
            room_data[b][f][r] += v;
        }
        else
        {
            room_data[b][f][r] = v;
        }
    }

    for (int i = 1; i < 5; i++) ///四棟
    {
        for (int j = 1; j < 5; j++) //三階+#
        {
            for (int k = 1; k < 11; k++) //番号
            {
                if (room_data[i][j][k] != 0)
                {
                    cout << ' ' << room_data[i][j][k];
                }
                else if (j == 4)
                {
                    if (i != 4)
                    {
                        cout << "##";
                    }
                    else if (i == 4)
                    {
                        break;
                    }
                }
                else
                {
                    cout << ' ' << '0';
                }
            }
            if (j == 4 && i == 4)
            {
                break;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int u,k,v;
	int time;
	
	int[] discover;
	int[] finish;
	int[] color;
	//white=0, black=1, glay=-1
	int[][] list;
	
	public void input() {
		n = sc.nextInt();
		discover = new int[n];
		finish = new int[n];
		color = new int[n];
		list = new int[n][n];
		for(int i=0; i<n; i++) {
			u = sc.nextInt();
			k = sc.nextInt();
			while(k > 0) {
				v = sc.nextInt();
				list[u-1][v-1] = 1;
				k--;
			}
		}
	}
	
	public void dfs() {
		for(int i=0; i<n; i++) { color[i] = 0; }
		time = 0;
		for(int i=0; i<n; i++) { if(color[i] == 0) visit(i); }
	}
	
	public void visit(int u) {
		color[u] = -1;
		discover[u] = ++time;
		for(int i=0; i<n; i++) { if(color[i] == 0 && list[u][i]==1) visit(i); }
		color[u] = 1;
		finish[u] = ++time;
	}

	public void output() { for(int i=0; i<n; i++) { System.out.println(i+1+" "+discover[i]+" "+finish[i]); } }
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.dfs();
		obj.output();
	}
}



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

// 文字列長
int nagasa(string s) {
   return (int)(s.length());
}

int main() {
   int k;
   string s;
   cin >> k >> s;
   if (nagasa(s) <= k) {
      cout << s << endl;
   }
   else {
      cout << s.substr(0,k) + "..." << endl;
   }
   return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <map>

using namespace std;

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

	vector<int> a(n, 0), plus(n, 0), minus(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		plus[i] = a[i] + i + 1;
		minus[i] = a[i] - (i + 1);
	}

	map<int, long long> plus_cnt, minus_cnt;
	for (auto x: plus) {
		plus_cnt[x]++;
	}
	for (auto x: minus) {
		if (x < 0) {
			minus_cnt[x]++;
		}
	}

	long long ans = 0;
	for (auto p: minus_cnt) {
		ans += p.second * plus_cnt[-p.first];
	}
	cout << ans << endl;
	return 0;
}


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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c) puts("Yes");
	else puts("No");
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b&&b<c){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}


Measured memory_bytes: 3064
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

struct UnionFind{
    P: Vec<usize>,
}

impl UnionFind {
    fn new(n:usize) -> UnionFind{
        UnionFind {P:(0..n).collect()}
    }
    fn get_parent(&mut self,n:usize) -> usize{
        if self.P[n] == n{ return n;}
        let p = self.P[n];
        self.P[n] = self.get_parent(p);
        self.P[n]
    }
    fn is_unite(&mut self,x:usize,y:usize) -> bool{
        self.get_parent(x)==self.get_parent(y)
    }
    fn merge(&mut self,x:usize,y:usize){
        if self.is_unite(x,y) {return;}
        let i = self.get_parent(x);
        let j = self.get_parent(y);
        self.P[j] = i;
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N = iter.next().unwrap().parse::<usize>().unwrap();
    let mut XY = (0..N).map(|i| (
            i,
            iter.next().unwrap().parse::<isize>().unwrap(),
            iter.next().unwrap().parse::<isize>().unwrap()
        )).collect::<Vec<_>>();
    
    XY.sort_by_key(|x| x.1);
    let mut dX = BinaryHeap::new();
    for i in 0..N-1{
        dX.push((XY[i].1-XY[i+1].1,XY[i].0,XY[i+1].0));
    }
    dX.push((-1e10 as isize,0,0));

    XY.sort_by_key(|x| x.2);
    let mut dY = BinaryHeap::new();
    for i in 0..N-1{
        dY.push((XY[i].2-XY[i+1].2,XY[i].0,XY[i+1].0));
    }
    dY.push((-1e10 as isize,0,0));

    let mut T = UnionFind::new(N);
    let mut ans = 0;

    for _ in 0..2*(N-1){
        let dx = dX.pop().unwrap();
        let dy = dY.pop().unwrap();
        let mut d = 0;
        let mut i = 0;
        let mut j = 0;
        if dx.0 > dy.0{
            dY.push(dy);
            d = -dx.0;
            i = dx.1;
            j = dx.2;
        } else {
            dX.push(dx);
            d = -dy.0;
            i = dy.1;
            j = dy.2;
        }
        if T.is_unite(i, j){continue;}
        ans += d;
        T.merge(i, j);
    }
    println!("{}",ans);


}

Measured memory_bytes: 22628
import java.util.*;
import java.io.*;
public class Main {

    private static Integer solve(int []a, int []b, int []c, int N) {
        int [][]dp = new int[3][N];
        dp[0][0] = a[0];
        dp[1][0] = b[0];
        dp[2][0] = c[0];


        for(int i=1; i < N; ++i) {
            dp[0][i] = a[i] + Math.max(dp[1][i-1], dp[2][i-1]);
            dp[1][i] = b[i] + Math.max(dp[0][i-1], dp[2][i-1]);
            dp[2][i] = c[i] + Math.max(dp[1][i-1], dp[0][i-1]);
        }

        return Math.max(dp[0][N-1], Math.max(dp[1][N-1], dp[2][N-1]));
    }

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int N = Integer.parseInt(br.readLine());
        

        String []s = null;
        

        int []a = new int[N];
        int []b = new int[N];
        int []c = new int[N];

        for(int i=0; i < N; ++i) {
            s = br.readLine().split(" ");
            a[i] = Integer.parseInt(s[0]);
            b[i] = Integer.parseInt(s[1]);
            c[i] = Integer.parseInt(s[2]);
        }

        System.out.println(solve(a, b, c, N));
    }
}

Measured memory_bytes: 50648
def resolve():
    '''
    code here
    '''
    import collections
    import itertools
    import numpy as np
    N = int(input())
    Ss = [input()[0] for _ in range(N)]

    march_letter = [item for item in Ss if item in ['M', 'A', 'R', 'C', 'H']]
    march_cnt = collections.Counter(march_letter)

    if len(march_cnt) < 3:
        res = 0
    else:
        res_list = itertools.combinations(march_cnt.values(),3)

        res = 0
        for element in res_list:
            res += np.prod(np.array(element))
    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 28380
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<functional>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
const int MAXN = 100 + 10;
ll K;
ll a[MAXN];
int main() {
	while (cin >> K) {
		ll n = 50;
		ll k;
		k = K%n;
		ll tn = K / n;
		if (k == 0) {
			cout << n << endl;
			for (int i = 1; i <= n; ++i) {
				cout << tn + n - 1 << " ";
			}
			cout << endl;
		}
		else {
			//前k大
			cout << n << endl;
			ll base = n - 1 + tn - k + 1;
			ll tmp = base;
			for (int i = 1; i <= n - k; ++i) {
				cout << --tmp << " ";
			}
			for (int i = 1; i <= k; ++i) {
				cout << base + i << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll W,H,x,y;

int main(){

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

cin>>W>>H>>x>>y;
long double ans=W*H/2.0;
ll type=0;
W==2*x&&H==2*y?type=1:type=0;
cout<<fixed<<setprecision(20)<<ans<<" "<<type<<endl;

}
	

Measured memory_bytes: 3804
N = int(input())
T = list(map(int, input().split()))
V1 = list(map(int, input().split()))
V1.append(0)

ST = [0] * (N + 1)
for i in range(N):
    ST[i + 1] = ST[i] + T[i]

V2 = [0] * N
for i in range(N):
    V2[i] = V1[i + 1] + ST[i + 1]
z = V2[-1]
for i in range(N - 1, -1, -1):
    if V2[i] > z:
        V2[i] = z
    else:
        z = V2[i]


Vmax = [0] * (ST[-1] * 2 + 1)
j = 0
t = 0
for i, Tn in enumerate(ST):
    while t < Tn or j == 0:
        Vmax[2 * t + j] = min(V1[i - 1], V2[i - 1])
        V2 = [x - 0.5 for x in V2]
        t += j
        j ^= 1

v, cnt = 0, 0
for i in range(ST[-1] * 2):
    nVmax = Vmax[i + 1]
    nv = min(v + 0.5, nVmax)
    cnt += (v + nv) * 0.5 / 2
    v = nv

print(cnt)


Measured memory_bytes: 3444
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = float('inf')
for key in range(1 << N):
    if bin(key).count('1') < K:
        continue
    cost = 0
    height = 0
    for i in range(N):
        if not (key & (1 << i)):
            height = max(A[i], height)
            continue
        height = max(A[i], height+1)
        cost += height - A[i]
    ans = min(ans, cost)
print(ans)




Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<string> v = {"AC", "WA", "TLE", "RE"};
	vector<int> c(4, 0);
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		for (int j = 0; j < 4; ++j)
		{
			if (s == v[j])
				c[j] ++;
		}
	}
	for (int i = 0; i < 4; ++i)
	{
		cout << v[i] << ' ' << 'x' << ' ' << c[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

A = LIST()

plus0 = []
minus = []
zero = []

for a in A:
    if a >= 0:
        plus0.append(a)
    if a == 0:
        zero.append(a)
    if a < 0:
        minus.append(a)

# print(plus0)
# print(minus)
# print(zero)

if (len(minus) == N and K%2 == 1) or (plus0 and minus and N == K and len(minus)%2 == 1):
    # 答えはマイナスなので最小化を目指す
    if (len(minus) == N and K%2 == 1):
        minus.sort(reverse=True)  # 小さい方からKこ
        ans = 1
        for i in range(K):
            ans *= minus[i]
            ans %= mod
    else:
        ans = 1
        for x in minus+plus0:
            ans *= x
            ans %= mod
    print(ans)
else:
    if len(plus0) == N:
        ans = 1
        plus0.sort(reverse=True)
        for i in range(K):
            ans *= plus0[i]
            ans %= mod
        print(ans)
        exit()

    # 答えは0以上なので最大化を目指す
    ans = 1
    cnt = 0
    plus0.sort()
    minus.sort(reverse=True)
    # print(plus0)
    # print(minus)
    while cnt != K:
        if cnt == K-1 or len(minus) <= 1:
            ans *= plus0.pop()
            cnt += 1
        else:
            if not plus0:
                ans *= minus.pop()
                ans *= minus.pop()
                cnt += 2
            elif len(plus0) == 1:
                if plus0[0] > minus[-1]*minus[-2]:
                    ans *= plus0.pop()
                    cnt += 1
                else:
                    ans *= minus.pop()
                    ans *= minus.pop()
                    cnt += 2
            else:
                if plus0[-1]*plus0[-2] > minus[-1]*minus[-2]:
                    ans *= plus0.pop()
                    cnt += 1
                else:
                    ans *= minus.pop()
                    ans *= minus.pop()
                    cnt += 2
        ans %= mod
    print(ans)


Measured memory_bytes: 108404
#include<bits/stdc++.h>
using namespace std;
int n,x;
int last[100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	int bd=0;
	memset(last,-1,sizeof(last));
	long long res=0;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		for(int j=0;j<20;j++){
			if(x & (1<<j)){
				bd=max(bd,last[j]+1);
				last[j]=i;
			}
		}
		res+=(long long)(i-bd+1);
	}
	cout<<res<<endl;
	return 0;
}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll n,m,k,s=0,c=0,x=0,s2=0,d=0;vector<ll>v;
    cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(s<=k)s+=a[i];
        if(s<=k){c++;v.push_back(a[i]);}
        if(s>k&&x==0)x=2,s2=s-a[i];
    }
    if(x==0)s2=s;
    s=0;
    for(int i=1;i<=m;i++){
        cin>>b[i];
        if(s<=k)s+=b[i];
        if(s<=k)d++;
    }
    c=max(c,d);
    ll x1=1,e;e=v.size();
    while(d>0){
        //v.push_back(b[x1]);
        d-=1;s2+=b[x1];x1++;e+=1;
        if(s2<=k)c=max(c,e);
        else{
            while(s2>k){
                s2-=v.back();v.pop_back();e-=1;
            }
        }
    }
    cout<<c;
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;      
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int N; cin >> N;
  vi a(N+1); rep(i,N) cin >> a.at(i+1);

  vi b(N+1);
  for (int i = N; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= N; j += i) {
      sum ^= b.at(j);
    }
    b.at(i) = sum^a.at(i);
  }

  vi ans;
  for (int i = 1; i <= N; i++) {
    if (b.at(i)) ans.push_back(i);
  }

  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans.at(i), i+1==ans.size()?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a[3],i,j,c;
    for(i=0;i<3;i++)cin>>a[i];
    for(i=0;i<3;i++)
    {
        for(j=0;j<2;j++)
        {
            if(a[j]>a[j+1])
            {
                c=a[j];
                a[j]=a[j+1];
                a[j+1]=c;
            }
        }
    }
   for(int i = 0; i < 3; i++){
    cout << a[i];
    if(i < 2){
      cout << " ";
    }
  }

  cout << endl;

    return 0;
}

Measured memory_bytes: 1164
from collections import deque
arr = deque()
prev = None
num = 0
for c in input():
  if prev is not None and c != prev:
    arr.append(num)
    num = 0
  prev = c
  num += 1
arr.append(num)

while len(arr) > 2:
  if arr[0] > arr[-1]:
    v = arr.pop()
    v += arr.pop()
    arr.append(v)
  else:
    v = arr.popleft()
    v += arr.popleft()
    arr.appendleft(v)

print(max(arr))

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ld  long double
#define pb push_back
#define fe first
#define se second
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e4;
int dp[N][N];
string s1,s2;
int n,m;

int main()
{ cool;
 cin>>s1>>s2;  
 int n=s1.size();
 int m=s2.size();
 string s;
 int cnt=0;

  for(int i=0;i<=n;i++)
  	 { for(int j=0;j<=m;j++)
  	 	 { if(i==0 || j==0)
  	 	 	 dp[i][j]=0;
  	 	   else if(s1[i-1] == s2[j-1])
  	 	   	{ 
  	 	   	  dp[i][j]=max({dp[i-1][j-1]+1,dp[i-1][j],dp[i][j-1]});
  	 	   	   
  	 	   	 // cout<<s1[i-1];
  	 	   		 	   	     	 	  
  	 	    }
  	 	  else
  	 	    { dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
  	 	    }
  	     }
  	 }  	 
  	 
  	cnt=dp[n][m];
  	int i=n,j=m;

  	while(1)
  		 { if(cnt==0)
  		 	 break;
  		   else if(dp[i-1][j-1]+1==dp[i][j] && s1[i-1]==s2[j-1])
  		     { s+=s1[i-1];
  		     	i--;
  		     	j--;
  		     	--cnt;
  		     }
  		   else if(dp[i][j]==dp[i-1][j])
  		     --i;
  		   else if(dp[i][j]==dp[i][j-1])
  		    --j;  	 

  		 }
  	  	 reverse(s.begin(),s.end());
  	  	 if(s.size()==0)
  	  	 	{ cout<<" "<<endl;
  	  	      return 0;
  	  	    }  
  	  	 cout<<s;     
  	

  	 return 0;
}


Measured memory_bytes: 117888
N = int(input())
A = []
B = list(map(int,input().split()))

A.append(B[0])

for i in range(len(B)-1):
    if B[i] < B[i+1]:
        A.append(B[i])
    else:
        A.append(B[i+1])

A.append(B[-1])

print(sum(A))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int n, l;
	cin >> n >> l;
	vector<int> a(n+1);
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		a[i] = l + i - 1;
		sum += a[i];
		if (a[i] < 0)a[i] = -a[i];
	}
	sort(a.begin(), a.end());
	if (0 < l)a[1] = -a[1];
	cout << sum + a[1] << endl;
  
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
//#define MOD 998244353
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF = 1LL << 60;
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;

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

int main(){
    string s;
    cin >> s;
    if (s[s.size()-1]=='s'){
        s+='e';
        s+='s';
    }else{
        s+='s';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
n, k = (int(i) for i in input().split())
S = input()
ans = 0
before = S[0]
l = []
c = 0
for s in S:
    if s != before:
        l.append(c)
        c = 1
    else:
        c += 1
    before = s
l.append(c)

ans = n-len(l)+k*2
if ans > n-1:
    ans = n-1
print(ans)

Measured memory_bytes: 3956
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

struct UnionFind
{
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x)
  {
    if (d[x] < 0)
      return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    // 根は負で管理している
    if (d[x] > d[y])
      swap(x, y);
    // x大きい方
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y)
  {
    return root(x) == root(y);
  }
  int size(int x)
  {
    return -d[root(x)];
  }
};

int deg[100005];
vector<int> to[100005];

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }
  rep(i, k)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i, n)
  {
    int ans = uf.size(i) - 1 - deg[i];
    for (int u : to[i])
    {
      if (uf.same(i, u))
        ans--;
    }
    printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const ll N = 2e5;

ll n, r, x[N + 1], pref[N + 1];

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  	cin >> n >> r;
	rep(i, 1, n + 1){
		cin >> x[i]; 
		pref[i] = pref[i - 1] + x[i];
	}
	ll res = INF;
	rep(k, 1, n + 1){
		ll cnd = (n + k) * r + 2 * (pref[n] - pref[n - k]), mlt = 3;
		for(ll lst = n; lst > 0; lst -= k){
			if(cnd > res){
				break;
			}
			cnd += (pref[lst] - pref[max(0ll, lst - k)]) * mlt;
			mlt += 2;
		}
		DBG(k, cnd);
		res = min(res, cnd);
	}
	cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int x[5];

int main(int argc, char* argv[]) {
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0)
      cout << i + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int cnt=0, ans=0;
    for(int n=1; n<=N; n++){
        cnt=0;
        if(n%2==0) continue;
        for(int sub=1; sub<=n; sub++){
            if(n%sub==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int questions, ACs = 0, WAs = 0, TLEs = 0, REs = 0;
	char input[4];

	cin >> questions;

	for (int i = 1; i <= questions; i++)
	{
		cin >> input;
		if (input[0] == 'A')
		{
			ACs++;
		}
		else if (input[0] == 'W')
		{
			WAs++;
		}
		else if (input[0] == 'T')
		{
			TLEs++;
		}
		else
		{
			REs++;
		}
	}

	cout << "AC x " << ACs << "\n";
	cout << "WA x " << WAs << "\n";
	cout << "TLE x " << TLEs << "\n";
	cout << "RE x " << REs << "\n";

	return 0;

}

Measured memory_bytes: 3172
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi

max=a[0]
sum=0
a.each do |aa|
  diff=max-aa
  sum+=diff if diff>0
  max=aa if max<aa
end
puts sum

Measured memory_bytes: 30100
x=int(input())
over=x//100
d100=x%100
d5=d100//5
d4=(d100%5)//4
d3=((d100%5)%4)//3
d2=(((d100%5)%4)%3)//2
d1=(((d100%5)%4)%3)%2
if over>=d5+d4+d3+d2+d1:
  print(1)
else:
  print(0)



Measured memory_bytes: 38384
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int l = sc.nextInt();
        int[] a = new int[l];
        for (int i = 0; i < l; i++) {
            a[i] = sc.nextInt();
        }

        // 0 - hidari 0
        // 1 - hidari g
        // 2 - k
        // 3 - migi g
        // 4 - migi 0
        long INF = 2L << 60;
        long[][] dp = new long[l + 1][5];
        for (int i = 1; i < dp.length; i++) {
            for (int j = 0; j < 5; j++) {
                dp[i][j] = INF;
            }
        }

        for (int i = 0; i < l; i++) {

            for (int j = 0; j < 5; j++) {
                long nex = 0;
                if (j == 0 || j == 4) {
                    nex = dp[i][j] + a[i];
                }
                if (j == 1 || j == 3) {
                    if (a[i] % 2 == 0 && a[i] != 0)
                        nex = dp[i][j];
                    else if (a[i] == 0) {
                        nex = dp[i][j] + 2;
                    } else {
                        nex = dp[i][j] + 1;
                    }

                }
                if (j == 2) {
                    if (a[i] % 2 == 1)
                        nex = dp[i][j];
                    else
                        nex = dp[i][j] + 1;
                }

                for (int k = j; k < 5; k++) {
                    dp[i + 1][k] = Math.min(dp[i + 1][k], nex);
                }
            }
        }
        long ans = dp[l][0];
        for (int i = 0; i < 5; i++) {
            ans = Math.min(ans, dp[l][i]);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 98540
#include <cstdio>
#include <map>
using namespace std;

int main() {
    int a, b, c, d;
    map<int, int> m;
    int ans = 0;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    for (int i = a; i <= b; i++) {
        m[i]++;
    } 
    for (int i = c; i <= d; i++) {
        m[i]++;
    }
    for (auto x: m) {
       if (x.second == 2) ans++; 
    }
    if (ans == 0) printf("%d\n", 0);
    else printf("%d\n", ans - 1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int A[n+1], mx1 = 0, mx2 = 0;
    for (int i=0; i<n; i++) {
        cin >> A[i];
        if (mx1 <= A[i]) mx2 = mx1, mx1 = A[i];
        else if (mx2 < A[i]) mx2 = A[i];
    }
    
    for (int i=0; i<n; i++){
        if (A[i] == mx1) cout << mx2 << endl;
        else cout << mx1 << endl;
    }
}

Measured memory_bytes: 2432