akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int , int > P;
typedef int elem;


LL all(LL n)
{
    LL cnt=0;
    while(n)
    {
        if(n%10==7)
        {
            n/=10;
            cnt++;
        }
        else
            return 0;
    }
    return cnt;

}

int main()
{
   LL n;
   cin >> n;
   if((n%10)==5||((n%10)&1)==0)
   {
       cout << -1;
       return 0;
   }

   LL a=0;
   LL len=0;
    while(a<n)
    {
        a=a*10+7;
        len++;
    }
    while(1)
    {
        a%=n;
        if(!a)
            break;
        a=a*10+7;
        len++;
    }
    cout << len;
    return 0;



}


Measured memory_bytes: 3644
def makelist(n, m):
	return [[0 for i in range(m)] for j in range(n)]

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

c = makelist(H, W)

y = 0
x = 0
vol = 1
for i in range(N):
	now = i + 1
	cnt = a[i]
	for k in range(cnt):
		c[y][x] = now
		if vol == 1:
			if x == W-1:
				y += 1
				vol = -vol
			else:
				x += vol
		elif vol == -1:
			if x == 0:
				y += 1
				vol = -vol
			else:
				x += vol
for y in range(H):
	for x in range(W):
		if x == 0:
			print(c[y][x], end="")
		else:
			print(" " + str(c[y][x]), end="")
	print()


Measured memory_bytes: 44776
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	r := nextFloat64()
	fmt.Println(2 * r * math.Pi)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

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

  for(long b=K+1;b<=N;b++){
    long p=N/b;
    long r=N%b;
    ans += max(long(0),b-K)*(p);
    ans+= max(long(0),r-K+1);
    if(K==0) ans--;
  }


  cout<<ans<<endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const long double EPS = 1e-10;
const bool debug = 0;

int H, R;

int main() {
	cin >> H >> R;
	
	int ans;
	
	if (H < R) {
		if (H < -R) ans = -1;
		else if (H == -R) ans = 0;
		else ans = 1;
	}
	else ans = 1;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
struct unionfind{
    vector<int> par, sz; int cnt;
    unionfind() {}
    unionfind(int n):cnt(n), par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x]; cnt--;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
	int h, w;
	cin>>h>>w;
	string s[202];
	for(int i=0; i<h; i++) cin>>s[i];
	ll ans=1;
	if(h&1){
		string t=s[h/2];
		reverse(t.begin(), t.end());
		if(s[h/2]!=t) ans*=2;
	}
	if(w&1){
		string t, u;
		for(int i=0; i<h; i++) t+=s[i][w/2];
		u=t;
		reverse(u.begin(), u.end());
		if(t!=u) ans*=2;
	}
  unionfind uf(h/2+w/2);
	for(int i=0; i<h/2; i++){
		for(int j=0; j<w/2; j++){
			string t; int cnt[3]={};
			t+=s[i][j];
			t+=s[h-1-i][j];
			t+=s[i][w-1-j];
			t+=s[h-1-i][w-1-j];
			int ind[4]={0, 1, 2, 3};
			set<string> st[2];
			do{
				int c=0;
				for(int k=0; k<4; k++) for(int l=k+1; l<4; l++) if(ind[k]>ind[l]) c^=1;
				string u;
				for(int k=0; k<4; k++) u+=t[ind[k]];
				st[c].insert(u);
			}while(next_permutation(ind, ind+4));
          for(auto u:st[0]) if(st[1].find(u)!=st[1].end()) cnt[2]++;
          for(int k=0; k<2; k++) cnt[k]=st[k].size()-cnt[2];
          if(cnt[0]==0) (ans*=cnt[2])%=MOD;
          else (ans*=cnt[0])%=MOD, uf.unite(i, j+h/2);
		}
	}
  for(int i=0; i<h/2+w/2-uf.cnt; i++) (ans*=2)%=MOD;
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input().strip())

AB = [[int(i) for i in input().strip().split()] for _ in range(N)]
AB = sorted(AB, key=lambda a: a[1])

t = 0
for a, b in AB:
  t += a
  if t > b:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 42836
'use strict';
process.stdin.on('data', function(chunk) {
  var lines = chunk.toString().split('\n');
  var result = (function(sec) {
    var h = ~~(sec / 3600);
    var m = ~~((sec % 3600) / 60);
    var s = ~~(sec % 60);
    return [h,m,s].join(':');
  }(parseInt(lines[0],10)
  ));

  console.log(result);
});

process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 7648
n = int(input())
s = [input() for i in range(n)]

name = [0 for i in range(5)]
for i in range(n):
    if s[i][0] == "M":
        name[0] +=1
    elif s[i][0] == "A":
        name[1] +=1
    elif s[i][0] == "R":
        name[2] +=1
    elif s[i][0] == "C":
        name[3] +=1
    elif s[i][0] == "H":
        name[4] +=1
count = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            #print("({},{},{})".format(i,j,k))
            count += name[i]*name[j]*name[k]
print(count)


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

const int MOD = 998244353;

int to_int(string s) {
	int result = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '.')
			continue;
		result = result * 10 + (s[i] - '0');
	}
	return result;
}

void solve_test() {
	LL a;
	string b;
	cin >> a >> b;
	int B = to_int(b);

	cout << a * B / 100 << '\n';
}

int main() {
	int T;
	T = 1;
	for (int t = 1; t <= T; t++)
		solve_test();

	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



signed main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(0);

	int N;
	cin >> N;
	vector<int>a(N + 2, -1);
	rep(i, N)cin >> a[i + 1];

	int ans = 0;
	
	int count = 1;
	for (int i = 1; i <= N+1; ++i) {
		if (a[i] != a[i - 1]) {
			ans += count / 2;
			count = 1;
		}
		else count++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def is_a_mid(a, b, c):
    return (b <= a <= c) or (c <= a <= b)


def is_b_mid(a, b, c):
    return (a <= b <= c) or (c <= b <= a)


def solve(n, a):
    total = 0
    ans = []

    for i, j in zip(a, a[1:]):
        total += abs(j-i)

    for i, j, k in zip(a, a[1:], a[2:]):
        if is_a_mid(i, j, k):
            ans.append(total-2*(abs(j-i)))
        elif is_b_mid(i, j, k):
            ans.append(total)
        else:
            ans.append(total+abs(i-k) - abs(i-j) - abs(k-j))

    return ans


if __name__ == '__main__':
    n = int(input())
    a = [0] + list(map(int, input().split()))+[0]
    for i in solve(n, a):
        print(i)


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

#define ll long long
#define pll pair<ll,ll> 


ll M[100005][105];
ll func(ll W[],ll V[],ll w,ll x){
	if(w<0)
		return INT_MIN;
	if(x<0)
		return 0;
	if(M[w][x]==-1){
		ll ans=max(func(W,V,w-W[x],x-1)+V[x],func(W,V,w,x-1));
		M[w][x]=ans;
	}
	return M[w][x];
}

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

	ll n,w;
	cin>>n>>w;
	for(ll i=0;i<100005;i++)
		for(ll j=0;j<105;j++)
			M[i][j]=-1;
	ll W[n],V[n];
	for(ll i=0;i<n;i++)
		cin>>W[i]>>V[i];
	
	ll ans=func(W,V,w,n-1);
	cout<<ans;

}


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

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

    long long i,j,k,l,m,n,o,q;

    while(cin>>n)
    {
        j=0;k=0;
        if(n%2==0)cout<<"-1"<<endl;
         else{
        while(1){k++;
        j%=n;
            j*=10;
            j+=7;
            if(j%n==0){
                cout<<k<<endl;
                break;
            }
            if(k>n){
                cout<<"-1"<<endl;
                break;
            }

        }
         }
    }
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
const int MOD = 1000000007;
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C;
    cin >> A >> B >> C;
    bool yes = false;
    if (A < B)
    {
        if (A < C && C < B) yes = true;
    }
    else
    {
        if (A > C && C > B) yes = true;
    }
    cout << (yes ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include<iomanip>

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,n) for(int i=1,i##_len=(n);i<=i##_len;++i)
#define rrep(i,n) for(int i=((int)((n)-1));i>=0;--i)
#define rreps(i,n) for(int i=((int)(n));i>0;--i)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 4545
#endif

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define int long long int
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

const lli MOD = 1000000007LL;

inline lli mod_add(lli x, lli y) {
    return (x + y) % MOD;
}

inline lli mod_mul(lli x, lli y) {
    return (x * y) % MOD;
}

inline lli mod_sub(lli x, lli y) {
    return x - y >= 0 ? (x - y) % MOD : (x - y + MOD) % MOD;
}

inline lli mod_pow(lli x, lli y) {
    lli ret = 1;
    while (y > 0) {
        if (y & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        y = y >> 1;
    }
    return ret;
}

inline lli mod_inv(lli x) {
    return mod_pow(x, MOD - 2);
}

inline lli mod_div(lli x, lli y) {
    return x * mod_inv(y) % MOD;
}

#define MAX_FAC 200001
lli fac[MAX_FAC], finv[MAX_FAC];
void init_fac() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX_FAC; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        finv[i] = finv[i - 1] * mod_inv(i) % MOD;
    }
}
inline lli com(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main() {
    int N, M, K; cin >> N >> M >> K;
    init_fac();

    int combi = com(mod_mul(N, M) - 2, K - 2);
    int ans = 0;
    // X座標から求める
    reps(d, M - 1) {
        int xCombi = mod_mul(mod_mul(M - d, N), N);
        ans = mod_add(ans, mod_mul(d, xCombi));
    }
    // Y座標から求める
    reps(dy, N - 1) {
        int yCombi = mod_mul(mod_mul(N - dy, M), M);
        ans = mod_add(ans, mod_mul(dy, yCombi));
    }

    cout << mod_mul(ans, combi) << endl;
    return 0;
}


Measured memory_bytes: 3328
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();
 
      if(C<=B/A){
	System.out.println(C);
      }else{
	System.out.println(B/A);
    }
      }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;

ll min1(ll a, ll b){
	if(a > b){
		return b;
	}else{
		return a;
	}
}

int main(){
	ll A,B,N;cin >>A >> B >> N;
	ll x = min1(B-1, N);
	ll ans = (A*x)/B - A*(x/B);
	
	cout << ans << endl;

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(k >= s.length())
		cout<<s;
	else
	{
		s = string(s.begin(), s.begin() + k);
	cout<<s<<"...";
	}

}

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

int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 1; i <= N; i += 2) {
		int tmp = 0;
		for (int j = 1; j <= N; j++) {
			if (!(i%j))
				tmp++;
		}
		if (tmp == 8)
			sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;

int main(){
	IOS
	char a;
	cin >> a;
	a++;
	cout << a << '\n';
}


Measured memory_bytes: 3612
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]


ans = -float("inf")

for i in range(2**10):
  cnt = [0] * N
  for j in range(10):
    if (i>>j) & 1:
      for k in range(N):
        if F[k][j] == 1:
          cnt[k] += 1
  
  tmp = 0
  valid = False
  for i in range(N):
    if cnt[i] > 0:
      valid = True
    tmp += P[i][cnt[i]]

  if valid:
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N, M; cin >> N >> M;
    int Q; cin >> Q;
    vec a(Q); readi(a);

    vec order(M, -1), count(M, 0), v(0);
    int n = 0;
    IREP(i, Q){
        if(order[a[i]] == -1){
            order[a[i]] = n;
            count[n]++;
            n++;
            v.push_back(a[i]);
        }else if(order[a[i]] == 0){
            count[0]++;
        }else if(count[order[a[i]]] < count[order[a[i]] - 1]){
            count[order[a[i]]]++;
        }
    }

    vector<bool> used(M, false);
    REP(i, M){
        if(count[i] >= N) used[v[i]] = true;
        else break;
    }
    bool f = true;
    int mval = -1;
    IREP(i, Q){
        if(!used[a[i]]){
            if(a[i] < mval && mval != -1) f = false;
            used[a[i]] = true;
            mval = a[i];
        }
    }
    IREP(i, M) if(i < mval && !used[i]) f = false;
    if(f) cout << "Yes";
    else cout << "No"; 

    return 0;
}

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

int main(){
  long long N,X,M;
  cin >> N >> X >> M;
  vector<long long> V(M,-1);
  
  long long sum = 0;
  for(int i=0;i<N;i++){
    if(V[X]==-1){
      V[X] = i;
      sum += X;
      X *= X;
      X %= M;
    }
    else{
      long long k = i - V[X], Ws = 0;
      vector<long long> W(k);
      for(long long j=0;j<M;j++){
        if(V[X]<=V[j] && V[j]<i){
          W[V[j]-V[X]] = j;
          Ws += j;
        }
      }
      
      sum += Ws * ((N-i)/k);
      for(int j=0;j<(N-i)%k;j++){
        sum += W[j];
      }
      break;
    }
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4160
n = int(input())
li = list(map(int,input().split()))
color = [0]*8
x = 0

for i in li:
    if i < 400:
        color[0] += 1
    elif i < 800:
        color[1] += 1
    elif i < 1200:
        color[2] += 1
    elif i < 1600:
        color[3] += 1
    elif i < 2000:
        color[4] += 1
    elif i < 2400:
        color[5] += 1
    elif i < 2800:
        color[6] += 1
    elif i < 3200:
        color[7] += 1
    else:
        x += 1

ans = 8-color.count(0)
x += ans
if ans == 0:
    ans += 1
print(ans, x)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    // 整数の入力とカウンターの設定
    long long N;
  	cin >> N;
  	vector<long long> A(N);
  	for(long long i = 0; i<N; i++){
      cin >> A.at(i);
    }
	long long ans=0;
  
	for(long long i = 1; i<N; i++){
      if(A.at(i)<A.at(i-1)){
        ans += A.at(i-1) - A.at(i);
        A.at(i) += A.at(i-1) - A.at(i);
      }
    }
  
    // 出力
  	cout << ans << endl;
  
    return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	string s;
	cin>>n>>s;
	int cnt =0;
	for(int i = 1; i < n; i++){
		if(s[i]!=s[i-1])cnt++;
	}	
	cout<<cnt+1;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P; 
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;
const double mi=0.0000005;
int main(){
  ll n,k;cin>>n>>k;
  vi v(n),x(n);
  rep(i,n)cin>>v[i];
  rep(i,n)cin>>x[i];
  sort(all(v));sort(all(x));
  reverse(all(x));
  ll lb=0,ub=(1001001001001);
  while(ub!=lb){
    ll ans=0,t=(lb+ub)/2;
    bool b=false;
    rep(i,n){
      ans+=max((ll)(0),v[i]-t/x[i]);
      if(ans>k){
        b=true;
        break;
      }
    }
    if(b)lb=t+1;
    else ub=t;
  }
  /*ll ans=0,t=(lb+ub)/2;
    bool b=false;
    rep(i,n){
      ans+=max(0,v[i]-t/x[i]);
      if(ans>k){
        b=true;
        break;
      }
    }
    if(b)cout<<ub<<endl;
    else cout<<lb<<endl;*/
  cout<<ub<<endl;
}


Measured memory_bytes: 3456
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
    int n = scn.nextInt();
    HashMap<String, Integer> map = new HashMap<>();
    for(int i = 0; i < n; i++){
      char[] a = scn.next().toCharArray();
      Arrays.sort(a);
      map.merge(new String(a), 1, Integer::sum);
    }
    
    long x = 0;
    for(String s : map.keySet()){
      long v = map.get(s);
      x += v * (v - 1) / 2;
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 55052
def main():
    S = input()
    memo = dict()

    def helper(S, i):
        # i is the starting index
        if i == len(S): return [0, 1]
        if i == len(S)-1: return [int(S[i]), 1]

        if i not in memo:
            memo[i] = [0, 0]
            for j in range(i+1, len(S)+1):
                if j not in memo:
                    memo[j] = helper(S, j)
                memo[i][0] += int(S[i:j])*memo[j][1] + memo[j][0]
                memo[i][1] += memo[j][1]
            # print(memo)
        return memo[i]

    return helper(S, 0)[0]

if __name__ == '__main__':

    print(main())

Measured memory_bytes: 3064
/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/

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

/*******************Debugging defines*************************/

#define ok_dump() cerr<<"OK\n"
#define var_dump(x) cerr<<#x": "<<x<<'\n'
#define arr_dump(x, n) do{cerr<<#x"[]: ";\
     for(int _=0;_<n;++_) cerr<<x[_]<<" ";cerr<<'\n';}while(0)

/*************************************************************/

const int kMaxN = 500000;

int di[] = {0, 1, 0, -1},
	dj[] = {1, 0, -1, 0};

int n, m;
bool Viz[505][505];
bool B[505][505], R[505][505];

bool Advance(int &i, int &j, int &d, bool W[505][505]) {
	int cnt = 0;
	while(true) {
		i += di[d],
		j += dj[d];

		if(Viz[i][j]) break;

		Viz[i][j] = 1;
		W[i][j] = 1;
		cnt += 1;
	}

	i -= di[d];
	j -= dj[d];
	d = (d + 1) % 4;
	return cnt != 0;
}


char Map[505][505];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;

	int d1 = 0, d2 = 2;
	int i1 = 1, j1 = 0, i2 = n, j2 = m + 1;

	for(int i = 0; i <= n + 1; ++i) Viz[i][0] = Viz[i][m + 1] = 1;
	for(int i = 0; i <= m + 1; ++i) Viz[0][i] = Viz[n + 1][i] = 1;

	while(true) {
		bool a = Advance(i1, j1, d1, R);
		bool b = Advance(i2, j2, d2, B);

		if(!a && !b) break;
	}

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

	for(int i = 1; i <= n; ++i, cout << '\n')
		for(int j = 1; j <= m; ++j)
			if(R[i][j] || Map[i][j] == '#')
				cout << '#';
			else cout << '.';

	cout << endl;

	for(int i = 1; i <= n; ++i, cout << '\n')
		for(int j = 1; j <= m; ++j)
			if(B[i][j] || Map[i][j] == '#')
				cout << '#';
			else cout << '.';


	return 0;
}

/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(ll,a,b,c);
    Yes(4*a*b<c*c-2*c*(a+b)+a*a+2*a*b+b*b&&c>a+b);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	Scanner sc = new Scanner(System.in);

	public void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			System.out.println(solve(n));
		}
	}

	
	int solve(int n){
		int r = 0;
		for(int j = 2,i = 1,s = 3;j<n;s += (s < n)?++j:-i++)
			if(s == n) r++;
		return r;
	}
}

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

int main() {
  string s;
  cin>>s;
  int a=0, b=0;
  rep(i, 3) {
    if (s[i] == 'a') a++;
    else if (s[i] == 'b') b++;
  }
  cout<<(a==1 && b==1 ? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]

b12 = c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]
b13 = c[0][2] - c[0][0] == c[1][2] - c[1][0] == c[2][2] - c[2][0]
a12 = c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]
a13 = c[2][0] - c[0][0] == c[2][1] - c[0][1] == c[2][2] - c[0][2]

print("Yes" if b12 and b13 and a12 and a13 else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a==3){
    cout<<"YES"<<'\n';
  }
  else if(a==5){
    cout<<"YES"<<'\n';
  }
  else if(a==7){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int L, R;
  cin >> L >> R;

  int left, right;
  if (L + 2019 <= R) {
    left = 0;
    right = 2019 + 2019;
  }
  else {
    left = L % 2019;
    right = R % 2019;
    if (left > right) right += 2019;
  }

  int minimum = 1000000007;
  for (int i = left; i < right; i++) {
    for (int j = i+1; j <= right; j++) {
      int x = (i * j) % 2019;
      if (x < minimum) minimum = x;
    }
  }

  cout << minimum << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = (N * (N + 1)) // 2
t, f, ft = N // 3, N // 5, N // 15
S -= 3 * ((t * (t + 1)) // 2) + 5 * ((f * (f + 1)) // 2)
S += 15 * ((ft * (ft + 1)) // 2)
print(S)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int first = 0, end = 0;
    string S;
    cin >> S;

    for (int i = 0; i < 7; i++){
        if (i == 0 && S.at(i) != 'k'){
            break;
        }
        if (i == 1 && S.at(i) != 'e'){
            break;
        }
        if (i == 2 && S.at(i) != 'y'){
            break;
        }
        if (i == 3 && S.at(i) != 'e'){
            break;
        }
        if (i == 4 && S.at(i) != 'n'){
            break;
        }
        if (i == 5 && S.at(i) != 'c'){
            break;
        }
        if (i == 6 && S.at(i) != 'e'){
            break;
        }
        first++;
    }
    reverse(ALL(S));
    for (int i = 0; i < 7; i++){
        if (i == 0 && S.at(i) != 'e'){
            break;
        }
        if (i == 1 && S.at(i) != 'c'){
            break;
        }
        if (i == 2 && S.at(i) != 'n'){
            break;
        }
        if (i == 3 && S.at(i) != 'e'){
            break;
        }
        if (i == 4 && S.at(i) != 'y'){
            break;
        }
        if (i == 5 && S.at(i) != 'e'){
            break;
        }
        if (i == 6 && S.at(i) != 'k'){
            break;
        }
        end++;
    }
    if (first + end >= 7){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		for (var i = a.Length - 2; i >= 0; i--)
		{
			var d = a[i] - a[i + 1];
			if (d > 1)
			{
				Console.WriteLine("No");
				return;
			}
			if (d == 1) a[i]--;
		}
		Console.WriteLine("Yes");
	}
}


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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;
using mpii = map<int, int>;
using mpci = map<char, int>;
using mpsi = map<string, int>;
using si = set<int>;
using sll = set<ll>;

#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

bool custom1 (pii a, pii b) {
  return (a.first < b.first);
}

bool custom2 (pii a, pii b) {
  return (a.second < b.second);
}

int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    cout << "x";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 1LL<<50

void turn(vector<vector<pii> > &line , vector<pii> p){
    line.pb(p);
    vector<pii> tmp;
    rep(i,p.size()){
        tmp.pb(pii( p[i].first*-1 , p[i].second*-1 ));
    }
    line.pb(tmp);
    tmp.clear();

    
    rep(i,p.size()){
        tmp.pb(pii( p[i].second*-1 , p[i].first ));
    }
    line.pb(tmp);
    tmp.clear();

    
    rep(i,p.size()){
        tmp.pb(pii( p[i].second , p[i].first*-1 ));
    }
    line.pb(tmp);
    tmp.clear();
}


void pre(vector<vector<pii> > &line , vector<pii> p){
    int y,x;
    y=p[0].first,x=p[0].second;
    vector<pii> tmp;
    rep(i,p.size())tmp.pb(pii( p[i].first-y , p[i].second-x ));
    turn(line,tmp);

    reverse(all(p));
    y=p[0].first,x=p[0].second;
    tmp.clear();
    rep(i,p.size())tmp.pb(pii( p[i].first-y , p[i].second-x ));
    turn(line,tmp);
}

bool same(vector<pii> line,vector<pii> a){
    if(a.size()!=line.size())return false;
    rep(i,a.size()){
        if(line[i].first!=a[i].first)return false;
        if(line[i].second!=a[i].second)return false;
    }
    return true;
}

bool is(vector<vector<pii> > line , int t){
    for(int i=t*8;i<t*8+8;i++){
        if(same(line[i],line[0])){
            return true;
        }
    }
    return false;
}


int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<vector<pii> > line;
        rep(i,n+1){
            int m;
            cin>>m;
            vector<pii> tmp;
            rep(j,m){
                int x,y;
                cin>>x>>y;
                tmp.pb(pii(y,x));
            }
            pre(line,tmp);
        }
        
        for(int i=1;i<n+1;i++){
            if(is(line,i)){
                cout<<i<<endl;
            }
        }
        cout<<"+++++"<<endl;
    }
}

Measured memory_bytes: 1300
#include<stdio.h>
#include<string.h>
int main()
{
  int a,b,c;
  char cc;
  scanf("%d %c %d",&a,&cc,&b);
  if(cc=='+')printf("%d\n",a+b);
  else if(cc=='-') printf("%d\n",a-b);







 return 0;
}

Measured memory_bytes: 128
from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
    n=int(stdin.readline());p=1
    # n,k=map(int,stdin.readline().split())
    a=list(map(int,stdin.readline().split()))
    if 0 in a:
        print(0)
        exit(0)
    for v in a:
        p*=v
        if p>(10**18):
            p=-1
            break
    print(p)

Measured memory_bytes: 21768
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if(s[2] == 'o') ans += 100;
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#define INF (1<<21)
using namespace std;

int n,t[20],mi,a[20];

void rec(int p){
  int a1,a2;
  if(p == n){
    a1 = 0;
    a2 = 0;
    for(int i=0;i<n;i++){
      if(t[i] == 1) a1 += a[i];
      else a2 += a[i];
    }
    if(a1 - a2 >= 0 && a1 - a2 < mi) mi = a1 - a2;
    else if(a2 - a1 > 0 && a2 - a1 < mi) mi = a2 - a1;
    return;
  }

  for(int k=1;k<=2;k++){
  t[p] = k;
  rec(p+1);
  }
}

int main(){
  int i,j;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
      t[i] = 0;
    }

    mi = INF;
    rec(0);
    cout << mi << endl;

  }
  return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    ll ret = 0;
    n= s.size();
    for(i=0;i<n-1;i++){
        if(s[i]!=s[i+1])ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

			int n = sc.nextInt();
			
			for(int i = 1 ; i < 10 ; i++ ) {
				for(int j = 1 ; j < 10 ; j++ ) {
					if ( n == i*j) {
						System.out.println("Yes");
						return;
					}
				}
			}
			
			System.out.println("No");
			
			
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  unordered_set<string> hash;
  int n; cin >> n;
  rep(i, n) {
    string tmp; cin >> tmp;
    hash.insert(tmp);
  }

  cout << hash.size() << endl;
}


Measured memory_bytes: 17692
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int,int>
#define scl(n) scanf("%d",&n);
#define pcl(n) printf("%d\n", n)
#define pcl1(n) printf("%lld ", n)
#define FastRead                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
bool comp(ppi a,ppi b)
{
	return a.first<b.first;
}

int main()
{
	ll ans;
	for(ll i=1;i<=5;i++)
	{
		ll x;
		cin>>x;
		if(x==0LL) ans=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
ABCD = [int(i) for i in input().split()]
if ABCD[0] + ABCD[1] > ABCD[2] + ABCD[3]:
    print("Left")
elif ABCD[0] + ABCD[1] < ABCD[2] + ABCD[3]:
    print("Right")
else:
    print("Balanced")


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cstring>


using namespace std;
int n;
int d[4];
int u[4],ru[4];
int mo[4]={10,50,100,500};
int res;


void check(int v){
	if(v==4){
		int coin=0,nowm=0;
		for(int i=0;i<4;i++){
			nowm+=u[i]*mo[i];
			coin+=(d[i]-u[i]);
		}
		nowm-=n;
		if(nowm<0)return;
		int j=3;
		while(nowm>0){
			while(nowm<mo[j])j--;
			if(u[j]>0)return;
			nowm-=mo[j];
			coin++;
		}
		if(res>coin){
			res=coin;
			for(int i=0;i<=3;i++){
				ru[i]=u[i];
			}
		}
	}else{
		for(int i=0;i<=d[v];i++){
			u[v]=i;
			check(v+1);
			u[v]=0;
		}
	}
}

int main(void){
	int ddd=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		if(ddd!=0){
			printf("\n");
		}else ddd++;
		for(int i=0;i<4;i++){
			scanf("%d",&d[i]);
		}
		res=114514;
		check(0);
		for(int i=0;i<=3;i++){
			if(ru[i]>0){
				printf("%d %d\n",mo[i],ru[i]);
			}
		}
	}
	return 0;
}

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

#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
//UnionFind

int main(){
  set<ll> st;
  int N;
  cin >> N;
  vector<ll> vec(N);
  rep(i,N) cin >> vec[i];
  rep(i,N){
    if(st.find(vec[i]) != st.end()){
      st.erase(vec[i]);
    }else{
      st.insert(vec[i]);
    }
  }
  cout << st.size() << endl;

  
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>

using namespace std;

typedef long long ll;

#define MAX 101

int main() {
    int N;
    int d[MAX];
    bool inverse[MAX];
    
    cin >> N;
    fill(inverse, inverse + MAX, false);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
        inverse[d[i]] = true;
    }
    
    int ans = 0;
    for (int i = 0; i < MAX; ++i) {
        if (inverse[i]) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[310][310];

int main(){
  int h,w; cin >> h >> w;
  rep(i,10)rep(j,10) cin >> dp[i][j];
  vector<vector<int> > g(h,vector<int>(w));
  rep(i,h)rep(j,w){
    cin >> g[i][j];
  }
  rep(k,10)rep(i,10)rep(j,10) chmin(dp[i][j],dp[i][k]+dp[k][j]);
  ll ans=0;
  rep(i,h)rep(j,w){
    if(g[i][j]!=-1) ans+=dp[g[i][j]][1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
X = sorted([[x,i] for i, x in enumerate(map(int,input().split()))])
med1,med2 = X[(N-1)//2][0], X[(N-1)//2+1][0]
ans = []
for idx1, x in enumerate(X):
  if idx1 <= (N-1)//2: ans.append([x[1],med2])
  else: ans.append([x[1],med1])
  #print(i)
[print(med) for i, med in sorted(ans)]

Measured memory_bytes: 128084
/*  ****************************

        Author: Devanshu Chaudhari  

        Institution: Indian Institute of Technology Roorkee
    
    ********************************/  
       #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int t;
        
    	cin>>t;
    	vector<int> arr(t);
    	for(int i =0;i<t;i++)
    		cin>>arr[i];
    		int counter = 1;
    	int resmin = arr[0];
    	
    	for(int i =1;i<t;i++)
    	{
    		if(arr[i]<resmin)
    		{
    			counter++;
    			resmin=arr[i];
    		}
    	}
    	cout<<counter<<'\n';
    }

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

vvint G;
vll sum;

void propagate(int u, int p) {
	for (auto &v : G[u]) {
		if (v == p) continue;
		sum[v] += sum[u];
		propagate(v, u);
	}
}

void Main() {
	int N, Q; cin >> N >> Q;
	G = vvint(N);
	sum = vll(N, 0);
	for (int i = 0; i < N-1; i++) {
		int a, b; cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	while (Q--) {
		ll p, x; cin >> p >> x; --p;
		sum[p] += x;
	}
	
	propagate(0, -1);
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 25028
//dont try to understand my code i really dont understand it 
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<vector>
#include <queue>
#include <stack>
#include<algorithm>
#include<memory.h>
using namespace std;
typedef long long ll;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef pair<int, int> ii;
const double PI = acos(-1.0);
//const ll oo = 1000000000000030200;
//const ll F = LLONG_MIN;	
const int A = 1234567;
typedef long long ll;
// write what you need here : ... 

map<char, char> c;
map<string, int > out;
map<string, int> ::iterator it;
vector<pair<string, int>>v;
int main()
{
	int a;
	cin >> a;
	cout << "ABC" << a << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;

    vector<vector<int> > index;
    for(int i=0;i<26;i++){
        vector<int> temp;
        index.push_back(temp);
    }

    for(int i=0;i<s.size();i++){
        index[s[i]-'a'].push_back(i);
    }

    int cnt = 0;
    for(int i=0;i<26;i++){
        vector<string> subset;
        for(int j=0;j<index[i].size();j++){
            int s_idx = index[i][j];
            for(int k=1;k<=K;k++){
                if(s_idx+k > s.size())
                    break;

                string sub_str = s.substr(s_idx, k);
                subset.push_back(sub_str);
            }
        }

        sort(subset.begin(), subset.end());
        subset.erase(unique(subset.begin(), subset.end()), subset.end());

        if(subset.size() < K-cnt){
            cnt = cnt + subset.size();
        }
        else{
            cout << subset[K-cnt-1] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
n = gets.to_i
a = gets.split.map(&:to_i)

m = Array.new(n, 0)
pms = Array.new(n+1)
mps = Array.new(n+1)

pms[0] = mps[0] = 0
for i in 1..n
  if i % 2 == 1
    pms[i] = pms[i-1] + a[i-1]
    mps[i] = mps[i-1] - a[i-1]
  else
    pms[i] = pms[i-1] - a[i-1]
    mps[i] = mps[i-1] + a[i-1]
  end
end

for i in 0..(n-1)
  if i == 0
    m[i] = pms[n]
  elsif i % 2 == 1
    m[i] = pms[i] + (mps[n] - mps[i])
  else
    m[i] = mps[i] + (pms[n] - pms[i])
  end
end
puts m.join(" ")

Measured memory_bytes: 15628