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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<vector<int>> f(n,vector<int>(10)),p(n,vector<int>(11));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }
    long long ans = -100000000000;
    for(int i = 0; i < (1<<10); i++) {
        int counter = 0;
        if(__builtin_popcount(i) == 0) {
            continue;
        }
        for(int j = 0; j < n; j++) {
            int open = 0;
            for(int k = 0; k < 10; k++) {
                if((i >> k) & 1) {
                    if(f[j][k] == 1) {
                        open++;
                    }
                }
            }
            counter += p[j][open];
        }
        ans = max(ans,(long long)counter);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
   ll n,m,s,k,kk,i,kkk,ss,j;
   cin>>n;
   k=maxn; kk=0;
   s=maxn;ss=0;
   for(i=0;i<n;i++)
   cin>>d[i];
   for(j=1;j<=105;j++)
   {  ss=0;
   for(i=0;i<n;i++)
   {
   	ss=ss+((j-d[i])*(j-d[i]));
   }
//   printf("%lld ",ss);
   	s=min(ss,s);
   }
   printf("%lld\n",s); 
   
}

Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
          
            //??????????????????
            var read = Console.ReadLine();
            //var temp_string = read.Split(' ');

            var temp = read.ToCharArray();

            string ans = "";

            foreach(char c in temp)
            {
                if(char.IsUpper(c))
                {
                    ans += char.ToLower(c);
                }
                else if(char.IsLower(c))
                {
                    ans += char.ToUpper(c);
                }
                else
                {
                    ans += c;
                }
            }

            Console.WriteLine(ans);
            
        }
    }
}

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

int dp[100][3001];
int main(){
  while(1){
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int n, m, s, i, j, k, ans = 0;
    scanf("%d%d%d", &n, &m, &s);
    if(n == 0 && m == 0 && s == 0)return 0;
    n *= n;
    for(i = 1;i <= m;i++){
      for(j = n;j > 0;j--){
	for(k = i;k <= s;k++){
	  dp[j][k] += dp[j - 1][k - i];
	  dp[j][k] %= 100000;
	}
      }
    }
    printf("%d\n", dp[n][s]);
  }
}

Measured memory_bytes: 1780
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

macro_rules! get_vec {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_vec!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, m) = get_tuple!(usize, usize);
    let v_a = get_vec!(usize);

    let sum: usize = v_a.iter().sum();
    let thresh = (sum as f64) / (4.0 * m as f64);
    let choosable = v_a.into_iter().filter(|&a| a as f64 >= thresh).count();
    let ans = if choosable >= m { "Yes" } else { "No" };
    println!("{}", ans)
}


Measured memory_bytes: 2160
program main
  implicit none
  integer :: N
  integer :: digit
  integer :: out
  integer :: i
  read(*,*) N
  digit = int(log10(real(N))+1)
  out = 0
  do i = 1, digit-1, 2
     out = out + (10**(i)-10**(i-1))
  end do

  if ( mod(digit,2) /= 0) then
     out = out + N - 10**(digit-1) + 1
  end if
  write(*,'(i0)') out 
  stop
end program main


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

typedef long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans;
    if(a > b){
        ans = 0;
    }else if(n == 1){
        if(a == b){
            ans = 1;
        }else{
            ans = 0;
        }
    }else{
        ans = (b-a)*(n-2) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
local n = io.read("n")
local colpos, col, dp= {}, {}, {}
local last = -1
mof = 1000000000+7
for i = 1, n do
    local x = io.read("n")
    if last ~= x then
        col[#col+1] = x
        dp[#col] = {0, 0}
        colpos[x] = colpos[x] or {head = 1}
        colpos[x][#colpos[x] + 1] = #col
        last = x
    end
end
n = #col
dp[1][1] = 1
dp[n+1] = {}
for i = 1, n do
    local x = col[i]
    local last_pos = colpos[x][colpos[x].head]
    if last_pos == i then
        dp[i][2] = dp[i][1]
    else
        dp[i][2] = dp[last_pos][2] + dp[i][1]
        dp[i][1] = dp[i][1] + dp[last_pos][2]
    end
    dp[i+1][1] = dp[i][1]

    dp[i][1] = dp[i][1] % mof
    dp[i][2] = dp[i][2] % mof
    if last_pos ~= i then
        colpos[x].head = colpos[x].head + 1
    end
    -- print(string.format("dp[%d] = {%d,%d}; col = %d", i,dp[i][1],dp[i][2], col[i]))
end
print(dp[n][1])

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


int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i+=2) {
        string s_odd = "RUD";
        if (count(s_odd.begin(), s_odd.end(), s.at(i)) == 0) {
            cout << "No" << endl;
            return 0;
        }
    }


    for (int i = 1; i < s.size(); i+=2) {
        string s_even = "LUD";
        if (count(s_even.begin(), s_even.end(), s.at(i)) == 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()

typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

void solve(){
    int n;
    cin >> n;
    int a[n + 20];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            for(int i1 = j + 1; i1 <= n; i1++){
                if(a[i] == a[j])//|| a[i] == [i1] || a[i1] == a[j]){
                    continue;
if(a[i1] == a[j])//|| a[i] == [i1] || a[i1] == a[j]){
                    continue;
if(a[i] == a[i1])//|| a[i] == [i1] || a[i1] == a[j]){
                    continue;
                if(a[i] + a[j] > a[i1]){
                    ans++;
                }
            }
        }
    }
    cout << ans;
}

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





Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  string s;
  cin >> s;
  if (s <= "2019/04/30") {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int i,bubble[N],a,j,cnt=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&bubble[i]);
  }
  for(j=0;j<a;j++){
    for(i=a-1;i>=j+1;i--){
      if(bubble[i]<bubble[i-1]){
	int c=bubble[i];
	bubble[i]=bubble[i-1];
	bubble[i-1]=c;
	cnt++;
      }
    }
  }
  for(i=0;i<a;i++){
    printf("%d",bubble[i]);
    if(i!=a-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<stdio.h>
using namespace std;

void trace(int A[],int N){
	for(int i=0;i<N;i++){
		if(i > 0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void bubbleSort(int A[],int N){
	bool flag = 1;
	int sw = 0;
	for(int i=0;flag;i++){
		flag = 0;
		for(int n=N-1;n>i;n--){
			if(A[n-1] > A[n]){
				swap(A[n],A[n-1]);
				flag = 1;
				sw++;
			}
		}
	}
	trace(A,N);
	cout << sw << endl;
}

int main(){
	int N;
	int A[100];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	bubbleSort(A,N);
	return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

bool cross(double x[], double y[]){
    REP(i, 4){
        double v1, v2, v3;
        v1 = (x[(i)%4]-x[(i+1)%4])*(y[(i)%4]-y[(i+3)%4]) - (y[(i)%4]-y[(i+1)%4])*(x[(i)%4]-x[(i+3)%4]);
        v2 = (x[(i+1)%4]-x[(i+2)%4])*(y[(i+1)%4]-y[(i+4)%4]) - (y[(i+1)%4]-y[(i+2)%4])*(x[(i+1)%4]-x[(i+4)%4]);
        v3 = (x[(i+2)%4]-x[(i+3)%4])*(y[(i+2)%4]-y[(i+5)%4]) - (y[(i+2)%4]-y[(i+3)%4])*(x[(i+2)%4]-x[(i+5)%4]);
        if ( !(v1 < 0 && v2 < 0 && v3 < 0) && !(v1 > 0 && v2 > 0 && v3 > 0) ) {
            return false;
        }
    }
    return true;
}

int main(){
    double x[4], y[4];
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
        ,&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]) != EOF) {
        if (cross(x, y)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll GCD(ll a,ll b){
	if(b==0){
		return a;
	}
	return GCD(b,a%b);
}
int main() {
	ll n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	if(n<m){
		swap(n,m);
		swap(s,t);
	}
	ll gcd=GCD(max(n,m),min(n,m));
	ll a=n/gcd,b=m/gcd;
	map<ll,char>ch;
	bool ans=true;
	for(int i=1;i<=t.size();i++){
		char nowt=t[i-1];
		ll num=i;
		num=a*(i-1)+1;
		ch[num]=nowt;
	}
	for(int i=1;i<=s.size();i++){
		char nows=s[i-1];
		ll num=i;
		num=b*(i-1)+1;
		if(ch[num]!=0&&ch[num]!=nows){
			ans=false;
		}
	}
	cout << (ans? a*b*gcd:-1);
	// your code goes here
	return 0;
}

Measured memory_bytes: 10880
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string A,B,C;
    cin >> A >> B >> C;
    if(A.back() == B.front() && B.back() == C.front()) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
int main(){
  int h,w,k,masu[7][7]={0},ans=0;char s[7];
  scanf("%d%d%d",&h,&w,&k);
  rep(i,h){scanf("%s",s);rep(j, w)if(s[j]=='#')masu[i][j]=1;}
  rep(allh,1<<h)rep(allw,1<<w){
    int tmp=0,masur[7][7]={0};
    rep(i,h)if(allh&(1<<i))rep(j,w)masur[i][j]++;
    rep(j,w)if(allw&(1<<j))rep(i,h)masur[i][j]++;
    rep(i,h)rep(j,w)if(masu[i][j]&&!masur[i][j])tmp++;
    if(tmp==k)ans++;
  }
  printf("%d",ans);
}

Measured memory_bytes: 1732
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var S = inputArray[0].Select(x=>x).ToArray();

			var stock = 0;
			var rest = 0;
			for (int i = 0; i < S.Length; i++) {
				var c = S[i];

				if (c=='S') {
					stock++;
					continue;
				}
				
				if (stock>0) {
					stock--;
				}
				else {
					rest++;
				}

			}

			//答えの出力
			var ans = rest*2;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

int n,w;
int a[110];
int c[110];
int dp[110000];

void solve(){
	cin >> n >> w;
	rep(i,0,n){
		cin >> c[i] >> a[i];
		for(int k=w;k>=0;k--){
			if(k-c[i]<0)
				break;
			dp[k] = max(dp[k],dp[k-c[i]]+a[i]);
		}
	}
	cout << dp[w] << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


Measured memory_bytes: 4404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef pair <P,int> PP;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<P> > graph(n);
    rep (i, n - 1) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        graph[a].emplace_back(b, c);
        graph[b].emplace_back(a, c);
    }
    int q, k; cin >> q >> k; k--;
    vector<ll> dist(n);
    vector<bool> used(n);
    priority_queue<pair<ll, int> > que;
    que.emplace(0, k);
    while (!que.empty()) {
        pair<ll, int> p = que.top(); que.pop();
        if (used[p.second]) continue;
        dist[p.second] = p.first;
        used[p.second] = true;
        for (P i : graph[p.second]) {
            if (!used[i.first]) que.emplace(p.first + i.second, i.first);
        }
    }
    rep (i, n) eprintf("%lld ", dist[i]); eprintf("\n");
    rep (_, q) {
        int x, y; cin >> x >> y; x--; y--;
        cout << dist[x] + dist[y] << "\n";
    }
    return 0;
}

Measured memory_bytes: 10096
sx,sy,tx,ty=map(int,input().split())
path1=(tx-sx)*"R"+(ty-sy)*"U"
path2=(tx-sx)*"L"+(ty-sy)*"D"
path3="D"+(tx-sx+1)*"R"+(ty-sy+1)*"U"+"L"
path4="U"+(tx-sx+1)*"L"+(ty-sy+1)*"D"+"R"
print(path1+path2+path3+path4)


Measured memory_bytes: 3060
from bisect import bisect_left, bisect_right

n = int(input())
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        l = bisect_left(stick, stick[j] - stick[i] + 1)
        r = bisect_right(stick, stick[i] + stick[j] - 1) - 1
        if r < 0 or l >= n:
            break
        count += r - l + 1
        if l <= i <= r:
            count -= 1
        if l <= j <= r:
            count -= 1
print(count // 3)

Measured memory_bytes: 74588
#include<iostream>
using namespace std;
 
int main()
{
int a,b,c,A,B,C,d,e,f,i,n;
for(i=0;i<3;i++){
cin>>a>>b>>c>>A>>B>>C;
n=(3600*A+60*B+C)-(3600*a+60*b+c);
d=n/3600;
e=(n-3600*d)/60;
f=n-(3600*d+60*e);
cout<<d<<' '<<e<<' '<<f<<'\n';
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI A(M),B(M);
  rep(i,M) cin>>A[i]>>B[i];
  VVI X(8,VI(8));
  rep(i,M){
    X[A[i]-1][B[i]-1]=1;
    X[B[i]-1][A[i]-1]=1;
  }
  if(N!=8){
    rep(i,N){
      if(i) X[i][N]=1;
    }
    rep(i,7-N){
      X[6-i][7-i]=1;
    }
  }
  int ans=0;
  rep(i,8){
    if(i==0) continue;
    if(X[0][i]==0) continue;
    rep(i2,8){
      if(i2==0||i2==i) continue;
      if(X[i][i2]==0) continue;
      rep(i3,8){
        if(i3==0||i3==i||i3==i2) continue;
        if(X[i2][i3]==0) continue;
        rep(i4,8){
          if(i4==0||i4==i||i4==i2||i4==i3) continue;
          if(X[i3][i4]==0) continue;
          rep(i5,8){
            if(i5==0||i5==i||i5==i2||i5==i3||i5==i4) continue;
            if(X[i4][i5]==0) continue;
            rep(i6,8){
              if(i6==0||i6==i||i6==i2||i6==i3||i6==i4||i6==i5) continue;
              if(X[i5][i6]==0) continue;
              rep(i7,8){
                if(i7==0||i7==i||i7==i2||i7==i3||i7==i4||i7==i5||i7==i6) continue;
                if(X[i6][i7]==0) continue;
                ans++;
              }
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

void solve(int N, vector<int> A)
{
    int64_t res = 0;
    int prev = 0;
    for (int i = 0; i < N; i++)
    {
        if (A.at(i) < prev)
        {
            res += prev - A.at(i);
        }
        prev = max(prev, A.at(i));
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin>>p[i];
    }
    int flag = 0;
    for(int i = 0; i < n - 1; i++){
        if(p[i] > p[i+1]){
            flag = 1;
            int mn = i;
            for(int j = i+1; j < n; j++){
                if(p[j] < p[mn])
                    mn = j;
            }
            int tmp = p[mn];
            p[mn] = p[i];
            p[i] = tmp;
            break;
        }
    }
    if(flag == 1){
        int flag2 = 0;
        for(int i = 0; i < n-1; i++){
            if(p[i] > p[i+1]){
                flag2 = 1;
                break;
            }
        }
        if(flag2 == 1){
            cout<<"NO";
        } else{
            cout<<"YES";
        }
    }
    if(flag == 0){
        cout<<"YES";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   string s;
   cin>>s;
   int co=0;
   rep(i,0,3)
   {
       int j=i;
       while(j<3 && s[j]=='R')
        j++;
       co=max(co,j-i);


   }
   cout<<co<<endl;

   }





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

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

	int h, w;
	cin >> h >> w;
	char a[h][w]; 
	for(int  i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h + 2; i++) {
		for(int j = 0; j < w + 2; j++) {
			if(i == 0 || i == h + 1) {
				cout << '#';
			}else {
				if(j == 0 || j == w + 1) {
					cout << '#';
				}else {
					cout << a[i - 1][j -1];
				}
			}
		}
		cout << "" << endl;
	}
}

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


int main(){
    string S;
    cin >> S;

    ll BlackState = 0;
    for(int i=0;i<S.size()-1;i++){
        if(S[i] == 'W'){
            BlackState++;
        }else{
            break;
        }
    }
    ll ans =0;
    ll whitePlace =BlackState;

    for(int i=BlackState;i<S.size();i++){
        if(S[i] == 'W'){
            ans += (i-whitePlace);
            whitePlace++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a;
    string b;
    cin >> a >> b;
    ll tb = (b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    ll ans = a*tb;
    ans /= (ll)100;
    cout << ans << endl;
}

Measured memory_bytes: 3620
//c.......

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    char *s;
    s = (char*)malloc(1000);
    scanf("%s",s);
    int len = (int)strlen(s);
    printf("%c%d%c",s[0],(len-2),s[len-1]);
    return 0;
}


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

even = 0
odd = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

odd_rest = odd % 2
even += odd // 2
even_rest = even % 2

if (odd_rest + even_rest) == 2:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 14112
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool abc=0;
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
                abc=1;
        }
    if(abc==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

string opr(bool ov){
  if(ov) return "+";
  else return "-";
}

int main(){
  int A,result, id;
  cin >> A;
  int elem[4] = {(int)(A/1000),(int)((A%1000)/100),(int)((A%100)/10),A%10};
  
  bool op[8][3];
  
  for(int i = 0; i < 8; i++){
    if(i < 4) op[i][0] = false;
    else op[i][0] = true;
    if(i % 4 < 2) op[i][1] = false;
    else op[i][1] = true;
    if(i % 2 < 1) op[i][2] = false;
    else op[i][2] = true;
  }

  for(id = 0; id < 8; id++){
    result = elem[0];
    for(int i = 0; i < 3; i++){
      if(op[id][i]) result += elem[i+1];
      else result -= elem[i+1];
    }
    if(result == 7) break;
  }
  cout << elem[0];
  for(int i = 0; i < 3; i++){
    cout << opr(op[id][i]) << elem[i+1];
  }
  cout << "=7" << endl;

  return 0;
}


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

int main(void){
    int n;
    int flag=0;
    string s1,s2;
    
    
    cin>>n;
    cin>>s1>>s2;
    
    long long int ans = 1;
    int i = 1;
    
    if(s1[0] == s2[0]){
        ans = 3;
        flag = 0;
    }else{
        ans = 6;
        i++;
        flag = 1;
    }
    
    for(;i<n;i++){
        if(s1[i] == s2[i]){
            if(flag == 0){
                ans *= 2;
            }
            else{
            }
            flag = 0;
        }
        else{
            if(flag == 0){
                ans *= 2;
            }
            else{
                ans *= 3;
            }
            i++;
            flag = 1;
        }
        ans = ans % MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int M,D;
    int ans=0;
    cin>>M>>D;
    for(int i=1;i<=M;i++)
    {
        for(int j=22;j<=D;j++)
        {
            if(j/10>=2&&j%10>=2&&(j/10)*(j%10)==i)
            {ans++;
          }
        }
    }
    cout<<ans;
}

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

int main(){
  int N;
  cin >> N;
  vector <int> A(N);
  rep(i,N){
   cin >> A.at(i);
  }
  int t = 0;
  rep(i,N){
    if( (i+1) % 2 != 0){
      if(A.at(i) % 2 != 0){
        t++;
      }
    }
  }
  cout << t << endl;

}

  



  

Measured memory_bytes: 3628
//bismillah
//created by anaksoleh
//24 Dec 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int N,W;
ll dp[100005];
ll w[103];
ll v[103];

void solve()
{
    for(int i = 1 ; i <= N ; i++){
        for(int c = W ; c >= w[i] ; c--){
            dp[c] = max(dp[c],dp[c - w[i]] + v[i]);
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> W;
    for(int i = 1 ; i <= N ; i++){
        cin >> w[i] >> v[i];
    }
    solve();
    cout << dp[W] << '\n';

    return 0;
}

Measured memory_bytes: 1024
<?php

$stdin = trim(fgets(STDIN));  

$number = explode(" ", $stdin);

$a = $number[0];
$b = $number[1];

if ( $a < $b) {
    echo "a < b";
} elseif ($a > $b){
    echo "a > b";
} elseif ($a == $b) {
    echo "a == b";
}

?>

Measured memory_bytes: 6532
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W,K;
    cin>>H>>W>>K;
    vector<vector<int>> dp(H+1,vector<int>(W,0)); dp[0][0]=1;
    rep(i,H)rep(j,W)rep(k,1<<(W-1)){
        bool ok=true;
        rep(l,W-2) if(((k>>l)&1)&&((k>>(l+1))&1)) ok=false;
        if(ok){
            if(j>=1&&((k>>(j-1))&1)){
                dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j-1]%=MOD;
            }else if(j<=W-2&&((k>>j)&1)){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=MOD;
            }else{
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=MOD;
            }
        }
        
    }
    cout1(dp[H][K-1])
}

Measured memory_bytes: 256
import math

n, h = map(int, input().split())

a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
m = max(a)
b.sort(reverse=True)

ans = 0
for i in range(n):
    if m <= b[i]:
        h -= b[i]
        ans += 1
        if h <= 0:
            print(ans)
            exit()

ans += math.ceil(h / m)
print(ans)


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	t.pop_back();
	cout<<(s==t?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
//就職させてください!!!!
signed main(){
    int a,b;cin>>a>>b;
    if(a+b==15)cout<<"+"<<endl;
    else if(a*b==15)cout<<"*"<<endl;
    else cout<<"x"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x)-1 for x in input()]

am = [a[i] % 2 for i in range(n)]

tmp = 0
ans = am[0] % 2

for i in range(1, n):
    ind = 0
    k = (n-i) & -(n-i)
    while k > 1:
        k = k // 2
        ind += 1
    kk = i & -i
    while kk > 1:
        kk = kk // 2
        ind -= 1
    tmp += ind
    if tmp == 0:
        ans += am[i]
        ans %= 2

if ans == 1:
    print(1)
    exit()

# あとは0か2かの判定！


if 1 in a:
    print(0)
else:
    b = [1 if a[i] == 2 else 0 for i in range(n)]
    tmp = 0
    ans = b[0] % 2
    for i in range(1, n):
        ind = 0
        k = (n-i) & -(n-i)
        while k > 1:
            k = k // 2
            ind += 1
        kk = i & -i
        while kk > 1:
            kk = kk // 2
            ind -= 1
        tmp += ind
        if tmp == 0:
            ans += b[i]
            ans %= 2
    if ans == 1:
        print(2)
    else:
        print(0)

Measured memory_bytes: 131124
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, xnow=0, ynow=0, tprev=0;

	bool flag=true;

	cin>>n;

	vector<int> t(n), x(n), y(n);

	rep(i, n) cin>>t[i]>>x[i]>>y[i];

	rep(i, n){
		int d=abs(x[i]-xnow)+abs(y[i]-ynow);
		//cout<<d<<endl;
		if(t[i]<d||(t[i]-tprev)%2!=d%2){
			flag=false; break;
		}
		xnow=x[i]; ynow=y[i]; tprev=t[i];
	}
	cout<<yn(flag)<<endl;
}

Measured memory_bytes: 1408
import sys

n, *a = map(int, sys.stdin.read().split())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    graph[a[i]-1].append(i)
def main():
    for i in range(n):
        print(len(graph[i]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 44040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            int[] d = new int[N];
            for(int n = 0; n<N; n++) { d[n] = sc.nextInt(); }

            int dan = 0;

            quickSort(d, 0, N-1);

            for(int i=0; i<N; i++) {
                if(i!=0) {
                    if(d[i-1] != d[i]) {
                        dan++;
                    }
                } else {
                    dan++;
                }
            }


            System.out.println(dan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void quickSort(int arr[], int begin, int end) {
        if (begin < end) {
            int partitionIndex = partition(arr, begin, end);
    
            quickSort(arr, begin, partitionIndex-1);
            quickSort(arr, partitionIndex+1, end);
        }
    }
    
    private int partition(int arr[], int begin, int end) {
        int pivot = arr[end];
        int i = (begin-1);
    
        for (int j = begin; j < end; j++) {
            if (arr[j]<= pivot) {
                i++;
    
                int swapTemp = arr[i];
                arr[i]= arr[j];
                arr[j]= swapTemp;
            }
        }
    
        int swapTemp = arr[i+1];
        arr[i+1]= arr[end];
        arr[end]= swapTemp;
    
        return i+1;
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

string s;
int n, k;

int to_a(char c) {
    return ('a' + 26 - c) % 26;
}

signed main() {
    cin >> s >> k;
    n = s.size();

    for(int i = 0; i < n - 1; i++) {
        if(k > 0 && to_a(s[i]) <= k) {
            k -= to_a(s[i]);
            s[i] = 'a';
        }
    }

    k %= 26;
    s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int ans = b / a;
    System.out.println(Math.min(ans,c));
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

ll thick[55];
ll patty[55];

ll dfs(int n, ll x) {
  if (n == 0) {
    return (x <= 0) ? 0 : 1;
  } else if (x <= thick[n - 1] + 1) {
    return dfs(n - 1, x - 1);
  } else if (x <= thick[n]) {
    return 1 + patty[n - 1] + dfs(n - 1, x - 2 - thick[n - 1]);
  } else {
    return patty[n];
  }
}

int main() {
  int n;
  ll x;
  cin >> n >> x;
  thick[0] = 1;
  patty[0] = 1;

  FOR(i, 1, n + 1) {
    thick[i] = 2 * thick[i - 1] + 3;
    patty[i] = 2 * patty[i - 1] + 1;
  }

  cout << dfs(n, x) << endl;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <tuple>

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;

  tuple<int,int,int> data[M];

  for(int i=0;i<M;i++){
    int p,y;
    cin>>p>>y;
    data[i]=make_tuple(y,p,i);
  }

  sort(data,data+M);
  int cnt[N+1];
  fill(cnt,cnt+N+1,0);

  pair<int,int> id[M];

  for(int i=0;i<M;i++){
    int y,p,idx;
    tie(y,p,idx)=data[i];
    cnt[p]+=1;
    id[idx]=make_pair(p,cnt[p]);
  }

  for(int i=0;i<M;i++){
    cout<<setw(6)<<setfill('0')<<id[i].first;
    cout<<setw(6)<<setfill('0')<<id[i].second<<endl;
  }

  return 0;
}


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

using namespace std;
typedef long long int lld;


int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	int tot = 0;
	for(int e=0;e<m;e++){
		int r;
		scanf("%d",&r);
		tot += r;
	}
	if(tot>n) printf("-1");
	else printf("%d\n",n-tot);
	return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] -= (i + 1);
  sort(A.begin(), A.end());

  int64_t answer = 0;
  int b = A[N / 2];
  for (int i = 0; i < N; i++) {
    answer += abs(A[i] - b);
  }
  printf("%ld\n", answer);

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;

int N, M;
int A[1010];
int B[1010];

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

    cin >> N >> M;
    REP(i, M) {
        int a; cin >> a;
        B[a] = 1;
    }

    int ans = 0;
    REP2(i, 1, M+1) ans += 1 - B[i];

    cout << ans << endl;
}



Measured memory_bytes: 3248
#include <iostream> // cin, cout
#include <algorithm> // sort
#include <vector> // vector
#include <cstdio> // printf
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

int		main(void)
{
	double r;
	cin >> r;
	printf("%f ", r * r * M_PI);
	printf("%f\n", (r + r) * M_PI);
	return (0);
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
long bs1(long x,const vector<long>& v){
  long l=-1,r=v.size();
  while(r-l>1){
    long z=(l+r)/2;
    if(v[z]>=x)r=z;
    else l=z;
  }
  return l;
}
long bs2(long x,const vector<long>& v){
  long l=-1,r=v.size();
  while(r-l>1){
    long z=(l+r)/2;
    if(v[z]>x)r=z;
    else l=z;
  }
  return l;
}
int main(){
  long N;cin>>N;
  vector<long>A(N),B(N),C(N);
  for(long i=0;i<N;i++)cin>>A[i];
  for(long i=0;i<N;i++)cin>>B[i];
  for(long i=0;i<N;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());
  long s=0;
  for(long i=0;i<N;i++){
    s+=(1+bs1(B[i],A))*(N-1-bs2(B[i],C));
  }cout<<s<<endl;
  
}

/*



*/

Measured memory_bytes: 5640
#include<stdio.h>
int main(void){
int i,m,n,t;
	int a[101];
		scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		a[i]=m;
	}
	for(i=0;i<n/2;i++){
			t=a[i];
			a[i]=a[(n-1)-i];
			a[(n-1)-i]=t;
	}
	for(i=0;i<n;i++){
		if(i==n-1){
			printf("%d",a[i]);
		}
		else{
			printf("%d ",a[i]);
		}
	}
	
	printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <cstdio>
char map[12][13];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void dfs(int x,int y) {
	for(int i=0;i<4;i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0>nx||nx>=12||0>ny||ny>=12)
			continue;
		if(map[ny][nx]=='1')
			map[ny][nx]='0',dfs(nx,ny);
	}
}
int main() {
	while(scanf("%s",map[0])!=EOF) {
		for(int i=1;i<12;i++)
			scanf("%s",map[i]);
		int ans=0;
		for(int y=0;y<12;y++) {
			for(int x=0;x<12;x++) {
				if(map[y][x]=='1') {
					map[y][x]='0';
					dfs(x,y);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  bool ans = true;
  
  for(int i = 0; i < N; i += 2){
    if(S.at(i) == 'L'){
      ans = false;
      break;
    }
  }
  
  for(int i = 1; i < N; i += 2){
    if(S.at(i) == 'R'){
      ans = false;
      break;
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int twake = 60 * h1 + m1;
    int tsleep = 60 * h2 + m2;

    cout << (tsleep - twake - k);

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  int a,e,k;
  cin >> a >> e >> e >> e >> e >> k;
  if(e-a>k) puts(":(");
  else puts("Yay!");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll sum=0,ma=-100000000,mi=100000000;
	rep(i,n)
	{
		cin >> a[i];
		sum += a[i];
		ma = max(ma,a[i]);
		mi = min(mi,a[i]);
	}
	cout<<mi<<' '<<ma<<' '<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3168
a=input().split()
N=int(a[0])
K=int(a[1])
count=int((1/2)*N*(N+1)*(N+1)-(N*(N+1)*(2*N+1))/6+N-(1/2)*(N+1)*K*(K-1)+(K*(K-1)*(2*K-1))/6-(K-1)+1)
print(count%(10**9+7))

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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
       int a1,a2,b1,b2;
    cin>>a1>>a2>>b1>>b2;

    int first=(a1+b2-1)/b2;
    int second=(b1+a2-1)/a2;
  //  cout<<first<<second<<endl;
    if(second<=first)
    {
      cout<<"Yes"<<endl;

    }
    else
      cout<<"No"<<endl;

return 0;

}

Measured memory_bytes: 3652
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

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

	if (n == 2 || a + 1 == b)
	{
		cout << "Borys";
		return 0;
	}

	while (1)
	{
		a++;
		if (a == b - 1)
		{
			cout << "Alice";
			return 0;
		}
		b--;
		if (b == a + 1)
		{
			cout << "Borys";
			return 0;
		}
	}
}

Measured memory_bytes: 3624
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int c =sc.nextInt();
        int[] data ={a ,b ,c ,};
        for (int i =0;i < data.length;i++){
            for (int n = data.length-1;n > i;n--){
                if (data[n - 1] > data[n]){
                    int box = data[n - 1];
                    data[n - 1] = data[n];
                    data[n] = box;
                }
            }
        }
        System.out.println(data[0]+" "+data[1]+" "+data[2]);
    }
}


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

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)


bool DP[2][17000];

int main(){
    string s; cin>>s;
    int x, y; cin>>x>>y;
    vector<int> list[2];
    int isYoko = 1;
    int accum = 0;
    
    for(char& c : s){
        if(c=='F'){
            accum++;
        }
        else{
            list[isYoko].push_back(accum);
            accum = 0;
            isYoko = (isYoko+1)%2;
        }
    }
    list[isYoko].push_back(accum);

    const int SAB = 8500;

    DP[0][0+SAB] = true;
    DP[1][0+SAB] = true;

    REP(bb,2){
        for(int ppos = 0;ppos<list[bb].size();ppos++){
            int x = list[bb][ppos];

            bool temp[17000];
            REP(i,17000){
                temp[i] = false;
            }
            REP(i,17000){
                if(DP[bb][i] == true){
                    if( bb== 1 && ppos == 0){
                        temp[i+x] = true;
                    }
                    else{
                        temp[i-x] = true;
                        temp[i+x] = true;
                    }
                }
            }
            memcpy(DP[bb], temp, sizeof(bool)*17000);
        }
    }
    if(DP[0][y+SAB] && DP[1][x+SAB]) cout << "Yes" << endl;
    else cout<< "No" << endl;

    return 0;
} 

Measured memory_bytes: 384