akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  vector<int> a(N);
  vector<int> s(N+1);
rep(i, N){
    if(S[i] == 'W'){
      a[i] = 0;
    }else{
      a[i] = 1;
    }
  }
  s[0] = 0;
  //s_1, s_2, ..., s_Nに、それまでの和を格納
  rep(i, N){
    s[i+1] = s[i] + a[i];
  }
  int ans = 999999;
  for(int i = 1; i <= N; i++){
    int right = s[N] - s[i];
    int left = (i-1) - s[i-1];
    if(i == 1){
      ans = min(ans, right);
    }else if(i == N){
      ans = min(ans, left);
    }else{
      ans = min(ans, left + right);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char s[201],p[101],t[101];
    scanf("%s%s",s,p);
    strcpy(t,s);
    strcat(s,t);
    if(strstr(s,p)==NULL)puts("No");
    else puts("Yes");
    return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{

	char ch; cin >> ch;
	if ( ch >= 'a' and ch <= 'z' ) cout << 'a';
	else cout << 'A';
}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}






























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


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+23;
int a[maxn];

int main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		ans+=max(a[i-1]-a[i],0);
		a[i]=max(a[i],a[i-1]);
	}
	cout<<ans;
}

Measured memory_bytes: 4468
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    string s;cin>>s;
    
    int count;
    int minimum = INT_MAX;
    for(auto c = 'a'; c<='z';c++){
        count = 0;
        string t(s);
        bool flag;
        while(1){
            flag = false;
            for(auto i = 0;i<s.size() - count;i++){
                if (t[i] != c) flag = true;
            }
            
            if(!flag)break;
            
            for(auto i = 0;i<s.size()-1 - count;i++){
                if (t[i] == c) continue;
                if (t[i] != c && t[i+1]==c){ t[i] = c; continue;}
            }
            count++;
        }
        
        minimum = min(minimum,count);
        
    }
    
    cout<<minimum<<endl;
    
    
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;

int n, a[MAXN];

int gcd(int x, int y)
{
	return x == 0 ? y : gcd(y % x, x);
}

bool check()
{
	// cerr << "!" << endl;
	if(n == 1 && a[1] == 1)
		return false;
	int even = 0, odd = 0;
	for(int i = 1; i <= n; i++)
		(a[i] & 1 ? odd : even)++;
	if(even & 1)
		return true;
	if((~even & 1) && odd >= 2)
		return false;
	int g = 0;
	for(int i = 1; i <= n; i++)
	{
		if(a[i] & 1)
		{
			if(a[i] == 1) return false;
			else a[i]--;
		}
		g = gcd(g, a[i]);
	}
	// cerr << g << endl;
	for(int i = 1; i <= n; i++)
		a[i] /= g;
	return !check();
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	bool ans = check();
	cout << (ans ? "First" : "Second") << endl;


	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a - c) * (b - d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  unsigned N, K;
  cin >> N;
  cin >> K;

  unsigned distance = 0;
  
  for (unsigned n=0; n<N; ++n) {
	unsigned x;
	cin >> x;
	distance += 2*min(x,K-x);
  }

  cout << distance << endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    a = []
    for i in range(2):
        a.append(read_int(n))
    return a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    x_range = len(a[0])
    y_range = len(a)
    subtotal = [[0 for x in range(x_range)] for y in range(y_range)]
    for y in range(y_range):
        for x in range(x_range):
            if y == 0:
                if x == 0:
                    subtotal[y][x] = a[y][x]
                else:
                    subtotal[y][x] = a[y][x] + subtotal[y][x - 1]
            else:
                if x == 0:
                    subtotal[y][x] = a[y][x] + subtotal[y - 1][x]
                else:
                    subtotal[y][x] = a[y][x] + max(subtotal[y][x - 1], subtotal[y - 1][x])
    return subtotal[y_range - 1][x_range - 1]


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    if((a == b && b != c) || (b == c && c != a) || (c == a && a != b)){
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	vector<long long> list(N);
	vector<long long> sorted(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> list[i];
		sorted[i] = list[i];
	}

	sort(sorted.begin(), sorted.end(), greater<long long>());
	map<long long, int> m;
	auto maxDiff = -1ll;
	auto count = 0;
	auto index = 0;
	for (auto i = 0; i < N - 1; ++i)
	{
		while (true)
		{
			auto it = m.find(sorted[index]);
			if (it == m.end())
			{
				break;
			}
			--(it->second);
			if (it->second == 0)
			{
				m.erase(it);
			}
			++index;
		}

		if (sorted[index] == list[i])
		{
			++index;
			continue;
		}

		auto diff = sorted[index] - list[i];
		if (diff > maxDiff)
		{
			maxDiff = diff;
			count = 1;
		}
		else if (diff == maxDiff)
		{
			++count;
		}
		
		auto temp = m.find(list[i]);
		if (temp != m.end())
		{
			++(temp->second);
		}
		else
		{
			m[list[i]] = 1;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 10112
#include<stdio.h>

int main()
{
	int N, T, Min = 1001, i;
	scanf("%d%d", &N, &T);
	int cost_Ary[N], time_Ary[N];
	for(i = 0; i < N; ++i){
		scanf("%d %d", &(cost_Ary[i]), &(time_Ary[i]));
		if(time_Ary[i] <= T && cost_Ary[i] < Min) Min = cost_Ary[i];
	}
	if(Min == 1001) printf("TLE\n");
	else printf("%d\n", Min);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    z = find_root(root,y)
    root[x] = z
    return z
 
def merge(root,size,x,y):
    x = find_root(root,x)
    y = find_root(root,y)
    if x == y:
        return
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    
def UF_check(root,x,y):
    if find_root(root,x) == find_root(root,y):
        return True
    else:
        return False
    
def UF_make(graph,n):  #グラフと最大項を与えると、塊ごとにグルーピングする
    Root=list(range(n+1))
    Size=[1] * (n+1)
    for i in range(len(graph)):
        merge(Root,Size,graph[i][0],graph[i][1])
    for i in range(n+1):  #これを入れれば、UF_checkを使わずに一塊になる
        Root[i] = find_root(Root,i)
    Root.pop(0)  #
    return Root

N,M=map(int,input().split())
P=list(map(int,input().split()))
XY=[list(map(int,input().split())) for i in range(M)]

UF=UF_make(XY,N)
#print(UF)

groups=[[] for i in range(N+1)]
for i in range(N):
    groups[UF[i]].append(P[i])

for i in range(N+1):
    groups[i].sort()

import bisect
ans=0
for i in range(N):
    num=bisect.bisect_left(groups[UF[i]],i+1)
    if num!=len(groups[UF[i]]) and groups[UF[i]][num]==i+1:
        ans+=1

print(ans)

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    int ans=(1<<30)-1;
    vector<int> v(101);
    for (int i = 0; i < n;i++){
        int x;
        cin >> x;
        for (int j = 1; j < 101;j++){
            v[j] += pow(x - j, 2);
        }
    }
    for (int i = 1; i < 101; i++){
        ans = min(ans, v[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int x, a, b; cin >> x >> a >> b;
  int n; cin >> n;
  while (n--) {
    string s; cin >> s;
    if (s[0] == 'n') {
      x = max(x + a, 0);
    } else if (s[0] == 't') {
      x = max(x + b, 0);
    } else {
      x = 0;
    }
  }
  cout << x << '\n';
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <utility>
#include <stdlib.h>

using namespace std;

int main(void)
{
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    int r;
    cin >> r;
    int time[r], pc[r], stu[r], log[r];
    

    for (size_t i = 0; i < r; i++) {
      cin >> time[i] >> pc[i] >> stu[i] >> log[i];   
    }
    int que;
    cin >> que;
    int ts[que], te[que], qm[que];
    for (size_t i = 0; i < que; i++) {
      cin >> ts[i] >> te[i] >> qm[i];
    }
    //??\??????

    for (size_t k = 0; k < que; k++) {

      int start = ts[k];
      int end = te[k];
      int diff = end - start;
      int student = qm[k];
      vector<int> timecount;
      timecount.resize(diff);
      for (size_t i = 0; i < diff; i++)
	timecount[i] = 0;

      for (size_t i = 0; i < r; i++) {
	int intime, outtime;

	//question????????????recode ??????????????°????????????
	if (student == stu[i] && log[i]) {
	  intime = time[i];
	  //pc????????§???
	  int pcnum = pc[i]; 
	  int j = i + 1;
	  //?????°??¢???????¨?????????¢???
	  while (true) {
	    if(student == stu[j] && pcnum == pc[j]) {
	      outtime = time[j];

	      if (intime < start) intime = start;
	      if (outtime > end) outtime = end;
	      intime -= start;
	      outtime -= start;

	         
	      for (int l = intime; l < outtime; l++)
		timecount[l] = 1;
	      break;
	    }
	    j++;
	    if (j > r)
	      break;
	  }
	}
      }
      int cnt = 0;
      for (size_t i = 0; i < diff; i++){
	if (timecount[i])
	  cnt++;
      }
      cout << cnt << endl;
     

    }
  }
  
  
  return 0;
  
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
int ans;
int main(int argc, char* argv[]){
  char s[10];
  int a=0;
  scanf("%s",s);
  for (int i = 0; i < strlen(s); i++,i++) {
    if (s[i]!='h'||s[i+1]!='i') {
      a=1;
    }
  }
  if (a==0) {
    printf("Yes" );
  }else{
    printf("No");
  }

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  co((a-1)*(b-1));
  return 0;
}


Measured memory_bytes: 256
N=int(input()) % 26
L=input()
ALP=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',
     'S','T','U','V','W','X','Y','Z']
NUM=range(0,len(ALP))
ALP_NO = dict(zip(ALP,NUM))
PLUS_ALP=ALP[N:] + ALP[:N]
ANS=''
for s in L:
  NUM = ALP_NO[s]
  ANS += PLUS_ALP[NUM]
print(ANS)


Measured memory_bytes: 3064
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;

  int n; rd(n);
  auto data=new int[][](3, 0);
  foreach(i; 0..3) data[i]=readln.split.to!(int[]);

  auto a=new Tuple!(int, int)[](0);
  foreach(i; 0..3){
    foreach(e; data[i]) a~=Tuple!(int, int)(e, i);
  }
  sort(a);
  // writeln(a);
  alias P=Tuple!(int, int, int);
  auto b=new P[](0);
  for(auto i=0; i<a.length;){
    auto e=a[i];
    int[3] cnt;
    foreach(j; 0..3){
      while(i<a.length && e[0]==a[i][0] && j==a[i][1]) cnt[j]++, i++; 
    }
    b~=P(cnt[0], cnt[1], cnt[2]);
  }
  // writeln(b);
  long x=0, y=0, z=0;
  foreach(e; b){
    z+=y*e[2];
    y+=x*e[1];
    x+=e[0];
  }
  writeln(z);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 20052
# -*- coding:utf-8 -*-

def main():
    LIST=[]

    while True:
        try:
            N=int(input())
            flag=True
            for item in LIST:
                if item[0]==N:
                    index=LIST.index(item)
                    flag=False

            if flag:
                LIST.append([N,1])
            else:
                LIST[index][1]+=1


        except:
            break
    m=0
    for i in LIST:
        m=max(m,i[1])
    ans=sorted([x for x in LIST if x[1]==m],key=lambda x:x[0])
    for i in ans:
        print(i[0])

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }
#define pb push_back
#define vi vector<int>
#define vii vector<<int>>
#define mii map<int, int>
#define pii pair<int, int>
#define qii priority_que<int, vector<int>, greater<int>>				
#define For(i, n) for(int i = 0; i < n; ++i)
#define For1(i, n) for(int i = 1; i <= n; ++i)
#define Forlr(i, l, r) for(int i = l; i <= r; ++i)
#define Forrl(i, r, l) for(int i = r; i >= l; --i)
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int nax = 1e5 + 5;
void solve() {
	vi a(5);
	For(i, 5) cin >> a[i];
	For(i, 5) if(a[i] == 0){
		cout << i + 1 <<"\n";
		return;
	}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    N % 2 == 0 ? cout << N : cout << N * 2;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;


int main(){
	double a,l,x;
	
	while(~scanf("%lf %lf %lf",&a,&l,&x)){
		double s = (a+l+l)/2.0;
		double ca = sqrt(s*(s-a)*(s-l)*(s-l));

		double res = 0.0;
		
		for(double scale = 0.00001; scale < 1.0; scale += 0.00001){
			double e1 = scale * (l+x);
			double e2 = (1.0-scale) * (l+x);

			double s2 = (e1+e2+l)/2.0;
			if(s2*(s2-e1)*(s2-e2)*(s2-l) < 0) continue;

			double ca2 = sqrt(s2*(s2-e1)*(s2-e2)*(s2-l));

			res=max(ca+ca2+ca2,res);
		}

		printf("%lf\n",res);
	}
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,Max,pos,tot,ans[N],a[N];
vector<int> vec;
typedef long long ll;
ll sum1,sum2;

int main()
{
   scanf("%d",&n);Max=-1e9-1;
   for (int i=1;i<=n;i++) 
   {
      scanf("%d",&a[i]);if (a[i]>Max) Max=a[i],pos=i;
      if (i&1) sum1+=(a[i]>0)?a[i]:0;
      else sum2+=(a[i]>0)?a[i]:0;
   }
   if (Max<0) 
   {
     printf("%d\n%d\n",Max,n-1);
     for (int i=n;i>pos;i--) printf("%d\n",i);
     for (int i=1;i<pos;i++) puts("1");
     return 0;
   }
   for (int i=(sum1>sum2?1:2);i<=n;i+=2) if (a[i]>0) vec.push_back(i);
   printf("%lld\n",max(sum1,sum2));
   for (int i=n;i>vec[vec.size()-1];i--) ans[++tot]=i;
   for (int i=vec.size()-1;i>=1;i--)
   {
     int t=(vec[i]-vec[i-1])/2-1;
     while (t--) ans[++tot]=vec[i-1]+2;
     ans[++tot]=vec[i-1]+1;
   }
   for (int i=1;i<vec[0];i++) ans[++tot]=1;
   printf("%d\n",tot);
   for (int i=1;i<=tot;i++) printf("%d\n",ans[i]);
   return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;

    for (int i = 1; i <= N; i++) {
        if (i % 2 == 0) continue;
        int yakusu = 0;
        for (int k = 1; k <= i; k++) {
            if (i % k == 0) yakusu++;
        }
        if (yakusu == 8) ans++;
    }
    cout << ans << endl;
}

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

int main() {
  unsigned N;
  long long A, B, C, D;
  std::cin >> N >> A >> B >> C >> D;
  long long diff = std::abs(A - B);
  long long min = C * (N - 1);
  long long max = D * (N - 1);
  for (unsigned i = 0; i < N; ++i) {
    if (min <= diff && diff <= max) {
      std::cout << "YES" << std::endl;
      return 0;
    }
    min -= C + D;
    max -= C + D;
  }
  std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 888
#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;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=205,L=1e7+5;
bool mark[L],prime[L];
namespace match
{
  const int N=205;
  int l[N],r[N],n,m;
  bool a[N][N],seen[N];
  bool findmatch(int i)
  {
    rep(j,0,m)
      {
	if(a[i][j] && !seen[j])
	  {
	    seen[j]=true;
	    if(r[j]<0 || findmatch(r[j]))
	      {
		l[i]=j; r[j]=i;
		return true;
	      }
	  }
      }
    return false;
  }
  int bipartitematch()
  {
    int cnt=0;
    rep(i,0,n) l[i]=-1;
    rep(i,0,m) r[i]=-1;
    rep(i,0,n)
      {
	rep(j,0,m) seen[j]=false;
	if(findmatch(i)) cnt++;
      }
    return cnt;
  }
};
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  memset(prime,true,sizeof(prime));
  prime[0]=prime[1]=false;
  rep(i,2,L)
    {
      if(!prime[i]) continue;
      for(int j=2*i;j<L;j+=i)
	prime[j]=false;
    }
  prime[2]=false;
  int n,x;
  cin>>n;
  rep(i,1,n+1)
    {
      cin>>x;
      mark[x]=true;
    }
  vi arr;
  int odd=0,even=0;
  rep(i,1,L-1)
    if(mark[i]!=mark[i-1])
      {
	arr.pb(i);
	if(i&1) odd++;
	else even++;
      }
  match::n=match::m=sz(arr);
  rep(i,0,sz(arr))
    rep(j,0,sz(arr))
    {
      if(arr[i]&1 && prime[abs(arr[i]-arr[j])]) match::a[i][j]=1;
      else match::a[i][j]=0;
    }
  int k=match::bipartitematch();
  assert((even-odd)%2==0);
  even-=k; odd-=k;
  int ans=k+(even/2+odd/2)*2+(even&1)*3;
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 18816
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 2e5+5;

void solve(){
	string s,t;
	cin>>s>>t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	for(int i=0;i<min(sz(s),sz(t));++i){
		if(s[i]<t[i]){
			cout<<"Yes";
			return;
		}
		if(s[i]>t[i]){
			cout<<"No";
			return;
		}
	}
	if(sz(t)>sz(s))cout<<"Yes";
	else cout<<"No";

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3644
// Cake 123.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long X[1001], Y[1001], Z[1001];
int main()
{
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	for (int i = 0; i != x; i++)
	{
		cin >> X[i];
	}
	for (int i = 0; i != y; i++)
	{
		cin >> Y[i];
	}
	for (int i = 0; i != z; i++)
	{
		cin >> Z[i];
	}
	sort(X, X + x, greater<long long>());
	sort(Y, Y + y, greater<long long>());
	sort(Z, Z + z, greater<long long>());
	int xn = 1, yn = 1, zn = 1;
	while (xn * yn * zn < k)
	{
		if (xn < x)xn++;
		if (yn < y)yn++;
		if (zn < z)zn++;
	}
	vector<long long> v;
	for (int xi = 0; xi < xn; xi++)
	{
		for (int yi = 0; yi < yn; yi++)
		{
			for (int zi = 0; zi < zn; zi++)
			{
				v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	long long minimum = (long long)X[xn - 1] + Y[yn - 1] + Z[zn - 1];
	for (int xi = 0; xi < xn; xi++)
	{
		for (int yi = 0; yi < yn; yi++)
		{
			for (int zi = zn; zi < z; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	for (int xi = 0; xi < xn; xi++)
	{
		for (int yi = yn; yi < y; yi++)
		{
			for (int zi = 0; zi < zn; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	for (int xi = xn; xi < x; xi++)
	{
		for (int yi = 0; yi < yn; yi++)
		{
			for (int zi = 0; zi < zn; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	for (int xi = 0; xi < xn; xi++)
	{
		for (int yi = yn; yi < y; yi++)
		{
			for (int zi = zn; zi < z; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	for (int xi = xn; xi < x; xi++)
	{
		for (int yi = 0; yi < yn; yi++)
		{
			for (int zi = zn; zi < z; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	for (int xi = xn; xi < x; xi++)
	{
		for (int yi = yn; yi < y; yi++)
		{
			for (int zi = 0; zi < zn; zi++)
			{
				long long res = (long long)X[xi] + Y[yi] + Z[zi];
				if (res > minimum)
					v.push_back((long long)X[xi] + Y[yi] + Z[zi]);
			}
		}
	}
	sort(v.begin(), v.end(), greater<long long>());
	for (int i = 0; i < k; i++)
	{
		cout << v[i] << endl;
	}
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 525268
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
//			re%=mod;
		}
		a=(a*a);
//		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		ll a[n+1];
		FOR(i,0,n+1)
		cin>>a[i];
		ll mi[n+1],ma[n+1];
		ma[n]=a[n];
		mi[n]=a[n];
//		cout<<mi[n];
//		bool f=1;
		FORD(i,n,0)
		{
			ma[i]=ma[i+1]+a[i];
			mi[i]=((mi[i+1]+1)/2)+a[i];
			if(i<50)
			{
				ma[i]=min(ma[i],po(2,i));
			}
			if(mi[i]>ma[i])
			{
				cout<<-1;
				return 0;
			}
		}
		ll ans=0;
		ll no=1;
		FOR(i,0,n+1)
		{	
			no=min(no,ma[i]);
//			cout<<ma[i]<<' '<<mi[i]<<'\n';
			ans+=no;
			no-=a[i];
			no*=2;
		}
		if(no!=0)
		cout<<-1;
		else
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 5948
N,M,Q=map(int,input().split())

ABCD=[[0]]*Q
i=0
while i<Q:
    ABCD[i]=list(map(int,input().split()))
    i+=1

import itertools
seq=list(range(1,M+1))
AN=list(itertools.combinations_with_replacement(seq,N))

ans=0
for Aj in AN:
    count=0
    for A,B,C,D in ABCD:
        if Aj[B-1]-Aj[A-1]==C:
            count+=D
    ans=max(ans,count)

print(ans)

Measured memory_bytes: 21500
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 105, M = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, W, w[N], v[N];
ll dp[N][M];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> W;
 	for(int i=1; i<=n; i++) cin >> w[i] >> v[i];
 	for(int i=0; i<=n; i++)
 		for(int j=1; j<M; j++)
 			dp[i][j] = INF;
 	for(int i=1; i<=n; i++)
 	{
 		for(int j=0; j<M; j++)
 			dp[i][j] = dp[i-1][j];
	 	for(int j=v[i]; j<M; j++)
		 	dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);	
	}
 	ll ans = M - 1;
 	while(dp[n][ans]>W) ans--;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 80128
#include <cstdio>
#include <algorithm>
using namespace std;
int a[4];
int main() {
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n", a[2]*10+a[1]+a[0]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;
const int N=100000;

struct data {
    char name[20];
    LL ss, tt;
    void init(char _name[], LL _ss, LL _tt) {
        strcpy(name, _name);
        ss=_ss, tt=_tt;
    }
} A[N];

int n, m;

int main() {
//freopen("/home/lovezzt/桌面/in.txt", "r", stdin);
    while(~scanf("%d%d", &n, &m)) {
        if(n == 0 && m == 0){
            break;
        }
        for(int i=0; i<n; i++) {
            char name[20];
            LL y1, y2;
            scanf("%s%lld%lld", name, &y1, &y2);
           // cout << y1 << " " << y2 << endl;
            A[i].init(name, y2-y1+1, y2);
        }
        while(m--) {
            LL y;
            scanf("%lld", &y);
            bool flag=1;
            for(int i=0; i<n; i++) {
                if(A[i].ss<=y && A[i].tt>=y) {
                    printf("%s %lld\n", A[i].name, (y-A[i].ss)+1);
                    flag=0;
                    break;
                }
            }
            if(flag) printf("Unknown\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1244
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    static double num = 380000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0 ; i < arr.length ; i++){
            arr[i] = sc.nextInt();
        }
        int odd[] = new int[(int)1e5 + 1];
        int even[] = new int[(int)1e5 + 1];
        int totalOdd = 0,totalEven = 0;
        for(int i = 0 ; i < arr.length ; i+=2){
            odd[arr[i]]++;
            totalOdd++;
        }
        ArrayList<Node> oddFreq = new ArrayList<>();
        for(int i = 0 ; i < odd.length ; i++){
            if(odd[i] > 0){
                oddFreq.add(new Node(i,odd[i]));
            }
        }
        for(int i = 1; i < arr.length ; i+=2){
            even[arr[i]]++;
            totalEven++;
        }
        ArrayList<Node> evenFreq = new ArrayList<>();
        for(int i = 0 ; i < even.length ; i++){
            if(even[i] > 0){
                evenFreq.add(new Node(i,even[i]));
            }
        }
        Collections.sort(oddFreq);
        Collections.sort(evenFreq);
        int oddNum = 0;
        int evenNum = 0;
        if(oddFreq.get(0).num == evenFreq.get(0).num){
            int firstOdd = oddFreq.get(0).count;
            int secondOdd = oddFreq.size() > 1 ? oddFreq.get(1).count : 0;
            int firstEven = evenFreq.get(0).count;
            int secondEven = evenFreq.size() > 1 ? evenFreq.get(1).count : 0;

            int ans1 = totalEven+totalOdd - firstOdd - secondEven;
            int ans2 = totalEven + totalOdd - firstEven - secondOdd;
            System.out.println(Math.min(ans1,ans2));
            return;
        } else {
            oddNum = oddFreq.get(0).count;
            evenNum = evenFreq.get(0).count;
        }
        System.out.println(totalEven+totalOdd-oddNum-evenNum);
    }
    static class Node implements Comparable<Node>{
        int num,count;
        Node(int num , int count){
            this.num = num;
            this.count = count;
        }
        public int compareTo(Node node){
            return node.count - this.count;
        }
    }
}

Measured memory_bytes: 50892
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $r);
// fscanf(STDIN, "%d", $b);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// $arr = array("SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN");
// for ($i = 0; $i <= count($arr); $i++) {
//   if ($arr[$i] == $s) {
//     break;
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "win";
// if ($a + $b + $c >= 22) {
//   $r = "bust
// ";
// }
// $arr = array(1, 2, 3);
// unset($arr[$a - 1]);
// unset($arr[$b - 1]);
// $arr = array_values($arr);
if ($n < 10 && $m < 10) {
  $r = $n * $m;
} else {
  $r = -1;
}

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $arr[0] . "\n";
// echo $i + 1 . "\n";
echo $r . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
// echo $t . $s . "\n";


Measured memory_bytes: 16292
t = int(input())

ans = [0 for i in range(t)]

for _ in range(t):
    n, k = map(int, input().split())
    
    li = list(map(int, input().split()))

    if n <= k:
        continue
    dis = []
    for i in range(n-1):
        dis.append(li[i+1]-li[i])
    dis.sort()
    ans[_] = (sum(dis[:n-k]))

for a in ans:
    print(a)


Measured memory_bytes: 21304
#ABC161B_PopularVote.rb
n,m = gets.split.map(&:to_i)
vote = gets.split.map(&:to_i)
sum = vote.inject(:+)
std = sum.to_f/(4.0*m.to_f)
count = 0

vote.each do |i|
  if i >= std
    count += 1
  end
end

if count >= m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#pragma once
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> W.at(i);
        sum += W.at(i);
    }
    int min_diff = 100000;
    int tmp = 0;
    for(int i = 0; i < N; i++){
        tmp += W.at(i);
        min_diff = min(min_diff, abs(sum - 2 * tmp));
    }
    cout << min_diff << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)

using namespace std;

int main()
{
	//input_output;
	the_flash;
	int a, b, c, k;
    int cnt = 0 ;
    cin >> a >> b >> c >> k;
    while(b <= a)
    {
        b *= 2 ;
        cnt++ ;
        if(cnt > k) 
        break ;
    }
    while(c <= b)
    {
        c *= 2 ;
        cnt++ ;
        if(cnt > k) 
			break ;
    }
    if(cnt > k)
    {
        cout <<"No" << endl;
    }
    else 
		cout<<"Yes" << endl;
}


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

using namespace std;

int main()
{
  while(1){
    int A,B;
    cin>>A;
    cin>>B;

    if(A == 0 && B == 0){
      break;
    }

    int money = B - A;
    int thousand = 0;
    int fhundred = 0;
    int hundred = 0;

    if(money >= 1000){
      while(1){
        ++thousand; 
        money = money - 1000;
        if(money < 1000){
          break;
        }
      }
    }

    if(money >= 500){
      while(1){
        ++fhundred; 
        money = money - 500;
        if(money < 500){
          break;
        }
      }
    }

    if(money >= 100){
      while(1){
        ++hundred; 
        money = money - 100;
        if(money < 100){
          break;
        }
      }
    }

    cout<<hundred<<" "<<fhundred<<" "<<thousand<<endl;
  }

  return 0;
}


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

using namespace std;

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

int main(){
  int n;
  cin >> n;
  vector<lli> vec(n);
  rep0(i,n){
          cin >> vec[i];
  }
  sort(all(vec));

  lli ans=0;
  int temp;
  rep0(i,n){
    rep0(j,i){
     temp = lower_bound(all(vec),vec[i]+vec[j]) - vec.begin() - i - 1;                                       ans += max(temp,0);
                                                             }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1174();
	}
	class AOJ1174{
		AOJ1174(){
			while(sc.hasNext()){
				H=sc.nextInt();
				W=sc.nextInt();
				C=sc.nextInt();
				if((H|(W|C))==0)	break;
				solve();
			}
		}
		int H,W,C;
		int[][][] b;
		final int[] vx={0,-1,0,1},vy={-1,0,1,0};
		void solve(){
			b=new int[6][W][H];
			for(int h=0; h<H; ++h)for(int w=0; w<W; ++w)	b[0][w][h]=sc.nextInt();
			System.out.println(dfs(b,0,b[0][0][0]));
		}
		int dfs(int[][][] b,int depth,int last){
			if(depth>=4)	return cnt(change(depth, C));
			int ret=0;
			for(int c=1; c<=6; ++c){
				if(c==last)	continue;
				change(depth, c);
				ret=max(ret, dfs(b, depth+1, c));
			}
			return ret;
		}
		int[][] change(int d,int target){
			for(int w=0; w<W; ++w)for(int h=0; h<H; ++h)	b[d+1][w][h]=b[d][w][h];
			LinkedList<Pair> open=new LinkedList<Pair>();
			open.add(new Pair(0,0));
			boolean[][] closed=new boolean[W][H];
			closed[0][0]=true;
			b[d+1][0][0]=target;
			while(!open.isEmpty()){
				Pair now=open.poll();
				for(int v=0; v<4; ++v){
					int xx=now.x+vx[v], yy=now.y+vy[v];
					if(!(0<=xx&&xx<W && 0<=yy&&yy<H))	continue;
					if(b[d][xx][yy]!=b[d][0][0])	continue;
					if(b[d+1][xx][yy]==target)	continue;
					if(closed[xx][yy])	continue;
					b[d+1][xx][yy]=target;
					open.add(new Pair(xx,yy));
					closed[xx][yy]=true;
				}
			}
			return b[d+1];
		}
		int cnt(int[][] a){
			LinkedList<Pair> open=new LinkedList<Pair>();
			open.add(new Pair(0,0));
			boolean[][] closed=new boolean[W][H];
			closed[0][0]=true;
			int cnt=1;
			while(!open.isEmpty()){
				Pair now=open.poll();
				for(int v=0; v<4; ++v){
					int xx=now.x+vx[v], yy=now.y+vy[v];
					if(!(0<=xx&&xx<W && 0<=yy&&yy<H))	continue;
					if(a[xx][yy]!=a[0][0])	continue;
					if(closed[xx][yy])	continue;
					open.add(new Pair(xx,yy));
					closed[xx][yy]=true;
					++cnt;
				}
			}
//			for(int h=0; h<H; ++h){
//				for(int w=0; w<W; ++w)	System.out.print(a[w][h]+" ");
//				System.out.println();
//			}
//			System.out.println(cnt);
//			System.out.println();
			return cnt;
		}
		class Pair{
			int x,y;
			Pair(int x,int y){
				this.x=x;
				this.y=y;
			}
		}
	}
}

Measured memory_bytes: 158420
#include<bits/stdc++.h>
using namespace std;
string S;
int main()
{
	int N;
	cin >> S;
	N=(int)S.length();
	int ans=0;
	for(int i=0;i<N-1;i++){
		if(S[i]!=S[i+1])ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

long long euler_phi(long long n) {
    /* Euler's phi (totient) function */
    long long res=n;
    for (long long p=2; p*p<=n; ++p)
        if (n%p == 0) {
            while (n%p == 0)
                n /= p;

            res -= res / p;
        }

    if (n > 1)
        res -= res / n;

    return res;
}

int main() {
    long long n;
    scanf("%lld", &n);

    printf("%lld\n", euler_phi(n));
    return 0;
}

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

using ll = long long;

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

Measured memory_bytes: 256
def main():
    from sys import stdin
    input=stdin.readline
    from itertools import accumulate as ac

    n, k = map(int, input().split())
    a = [int(input())-k for _ in [0]*n]

    # bit木を作る
    bit = [0]*(n+2)

    # aにwを足す
    def add(a, w):
        x = a
        while x < n+2:
            # print(x)
            bit[x] += w
            x += x & (-x)

    # aまでの和をとる
    def sum_(a):
        ret = 0
        x = a
        while x > 0:
            ret += bit[x]
            x -= x & (-x)
        return ret

    aca = [0]+list(ac(a))
    aca = sorted([(i, j) for i, j in enumerate(aca)],
                 key=lambda x: -x[1])+[(0, 10**20)]
    temp = []
    temp2 = [aca[0][0]]
    for i in range(1, n+2):
        if aca[i][1] == aca[i-1][1]:
            temp2.append(aca[i][0])
        else:
            temp.append(temp2)
            temp2 = [aca[i][0]]
    ans = 0
    for temp2 in temp:
        l=len(temp2)
        ans += l*(l-1)//2
        for i in temp2:
            ans += sum_(n+1)-sum_(i)
        for i in temp2:
            add(i+1, 1)
    print(ans)


main()

Measured memory_bytes: 63884
#include "bits/stdc++.h"5 7 5
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    ns = list(map(int, sys.stdin.readline().strip()))
    ns.reverse()
    ns.append(0)

    ans = 0
    lastpay = 0

    for i in range(len(ns)):
        if lastpay == 0:
            if ns[i] <= 4 or (ns[i] == 5 and ns[i + 1] <= 4):
                ans += ns[i]
                lastpay = 0
            else:
                ans += 1 + (10 - ns[i])
                lastpay = 1
        else:
            if lastpay + ns[i] <= 4 or (lastpay + ns[i] == 5 and ns[i + 1] <= 4):
                ans += ns[i]
                lastpay = 0
            else:
                ans += 1 - 1 + (9 - ns[i])
                lastpay = 1
    print(ans)

if __name__ == '__main__':
    main()

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

using ll=long long;
ll temp_mod=pow(10,9)+7;

ll Kaijou(ll x) {
  ll ret_val=1;
  for (ll i=1;i<=x;i++) ret_val=((ret_val*i)%temp_mod);
  return ret_val;
}

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

  int temp=abs(N-M);

  if (0==temp) {
    int ans=((2*Kaijou(N)*Kaijou(M))%temp_mod);
    cout <<ans <<endl;
    return 0;
  }else if (1==temp) {
    int ans=((Kaijou(N)*Kaijou(M))%temp_mod);
    cout <<ans <<endl;
    return 0;
  } else {
    cout <<0 <<endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
//const LLONG MOD = 1000000007;
const LLONG MOD = 998244353;
const double PI = 3.14159265359;

LLONG dp[3001][3001];

int main()
{
    LLONG a, b, c, d; cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for (LLONG x = a + 1; x <= c; ++x)
    {
        dp[x][b] = (dp[x - 1][b] * b) % MOD;
    }
    for (LLONG y = b + 1; y <= d; ++y)
    {
        dp[a][y] = (dp[a][y - 1] * a) % MOD;
    }
    for (LLONG x = a + 1; x <= c; ++x)
    {
        for (LLONG y = b + 1; y <= d; ++y)
        {
            dp[x][y] = (dp[x - 1][y] * y + dp[x][y - 1] * x
                - dp[x - 1][y - 1] * (x - 1) * (y - 1)) % MOD;
            if (dp[x][y] < 0) dp[x][y] += MOD;
        }
    }
    cout << dp[c][d] << endl;
}


Measured memory_bytes: 73932