akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> sieves_nonprime(int n) {
    /* sieve of Eratosthenes */
    // returns is_prime([0, n))
    if (n <= 2)
        return vector<int>(n, false);

    vector<int> is_prime(n, true); is_prime[0]=is_prime[1]=false;

    for (long long i=2; i*i<n; ++i)
        if (is_prime[i])
            for (long long j=i*i; j<n; j+=i)
                is_prime[j] = false;

    return is_prime;
}

int main() {
    size_t n=1e6;
    vector<int> is_prime=sieves_nonprime(n);
    for (size_t i=1; i<n; ++i)
        is_prime[i] += is_prime[i-1];

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

        printf("%d\n", is_prime[n]);
    }

    return 0;
}

Measured memory_bytes: 6136
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	int i(0),c(0);
	vector<int>clist;
	while (i<n-1) {
		if (h[i] >= h[i + 1]) {
			++c;
		}
		else {
			clist.push_back(c);
			c = 0;
		}
		++i;
		//cout << c << endl;
	}
	clist.push_back(c);
	//cout << 99 << endl;
	sort(clist.rbegin(), clist.rend());
	
	

	cout << clist[0];
	return 0;
}

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

int main() {
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3; 

    if (A1+A2+A3>=22) {
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
from queue import deque

n, m = map(int, input().split())
links = [None] + [set() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    links[a].add(b)
    links[b].add(a)

s = 1
path = deque([s])
visited = {s}

while True:
    s_remains = links[s] - visited
    if s_remains:
        s = s_remains.pop()
        path.appendleft(s)
        visited.add(s)
    else:
        break

t = 1

while True:
    t_remains = links[t] - visited
    if t_remains:
        t = t_remains.pop()
        path.append(t)
        visited.add(t)
    else:
        break

print(len(path))
print(*path)


Measured memory_bytes: 38164
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n, x, t;
    cin >> n >> x >> t;
    int mul = (n + x - 1) / x;
    cout << mul *t;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
	int x,a,b,c,d=0;
		scanf("%d %d %d",&a,&b,&c);
		for(x=a;x<=b;x++){
			if(c%x==0){
				d=d+1;
			}
		}
		
		printf("%d\n",d);
		
	
	return 0;
}

		

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;
const ll N = 1000010;

int main()
{
    ll n;
    cin >> n;
    if (n == 1) cout << "1\n";
    else {
        ll p = 1;
        while (p <= n){
            p *= 2;
        }
        cout << p / 2 << "\n";
    }

    return 0;
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		200010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int DP[MAX];
VV g;

void bfs(int p,int x){
	DP[p] += x;
	for(int itr : g[p]){
		bfs(itr,DP[p]);
	}
}

//
int main(){
	int N,Q;cin>>N>>Q;

	g.resize(N);
	REP(i,N-1){
		int a,b;cin>>a>>b;a--;b--;
		g[a].push_back(b);
	}

	REP(i,Q){
		int p,x;cin>>p>>x;--p;
		DP[p] += x;
	}

	bfs(0,0);

	REP(i,N)cout << DP[i] << " " ;
	cout << endl;

	return 0;
}




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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s = in();
    s.pop_back();
    while (s.size() > 0)
    {
        if (s.size() % 2 == 1)
        {
            s.pop_back();
            continue;
        }
        if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2))
        {
            break;
        }
        s.pop_back();
    }
    cout << s.size() << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func rotateDice(dice []string, direction string) []string {
	var result []string
	if direction == "N" {
		result = []string{dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]}
	} else if direction == "E" {
		result = []string{dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]}
	} else if direction == "W" {
		result = []string{dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]}
	} else if direction == "S" {
		result = []string{dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]}
	}
	return result
}

func main() {
	var input string
	var dice []string
	i := 0
	for sc.Scan() {
		if i == 0 {
			dice = strings.Split(sc.Text(), " ")
		} else if i == 1 {
			input = sc.Text()
		}
		i++
	}

	for _, i := range strings.Split(input, "") {
		dice = rotateDice(dice, i)
	}

	fmt.Printf("%s\n", dice[0])

}



Measured memory_bytes: 1112
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var dict = new Dictionary<string, int>();
            Calc(N, true, dict);

            var M = int.Parse(Console.ReadLine());
            Calc(M, false, dict);

            var max = dict.Values.Max();

            Console.WriteLine(max < 0 ? 0 : max);
        }

        static void Calc(int n, bool red, Dictionary<string, int> dict)
        {
            for (var i = 0; i < n; i++)
            {
                var tmp = Console.ReadLine();
                if (dict.ContainsKey(tmp))
                {
                    if (red)
                        dict[tmp]++;
                    else
                        dict[tmp]--;
                }
                else
                {
                    if (red)
                        dict[tmp] = 1;
                    else
                        dict[tmp] = 0;
                }
            }
        }
    }
}


Measured memory_bytes: 13152
n = int(input())
t = 0
x = 0
y = 0
judge = True

for i in range(n):
    t1, x1, y1 = map(int, input().split())
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        judge = False
    x = x1
    y = y1
    t = t1

if judge == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll H, W;
bool c[100][100];
bool seen[510][510];
const int dx[8] = {0, 0, -1, 1, -1, 1, 1, -1};
const int dy[8] = {1, -1, 0, 0, 1, 1, -1, -1}; 

void dfs(ll h, ll w){
    seen[h][w] = true;

    ll nh, nw;
    rep(i, 0, 8){
        nh = h + dy[i];
        nw = w + dx[i];

        if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if(seen[nh][nw]) continue;

        if(c[nh][nw]) dfs(nh, nw);
    }
}

void solve() {
    while(cin >> W >> H){
        if(W == 0 && H == 0) break;

        rep(h, 0, H) rep(w, 0, W) cin >> c[h][w];
        rep(h, 0, H) rep(w, 0, W) seen[h][w] = 0;

        ll ans = 0;
        rep(h, 0, H) rep(w, 0, W) { 
            if(c[h][w] && !(seen[h][w])){
                dfs(h, w);
                ans++;
            }
        }
        
        cout << ans << endl;
    }

    return;
}

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

    solve();
    return 0;
}



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

#define rep(i, l, r) for (__typeof(l) i = (l), _##i##_ = (r); i < _##i##_; ++i)
#define rof(i, l, r) for (__typeof(l) i = (l) - 1, _##i##_ = (r); i >= _##i##_; --i)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
template<typename T> bool chkMax(T &x, const T& y) {return x < y ? (x = y), 1 : 0;}
template<typename T> bool chkMin(T &x, const T& y) {return x > y ? (x = y), 1 : 0;}
typedef long long ll;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG debug("passing %d in %s\n", __LINE__, __FUNCTION__)

const int MAXN = 500000 + 5;

char Str[MAXN];
int N;

bool check(int x) {
	static int A[MAXN];
	int len = N - 1, sum = 0;
	rep(i, 0, N) {
		A[i] = (Str[i] - '0') * 9;
	}
	A[0] += 9 * x;
	for(int i = 0; i <= len; ++i) {
		if(i == len && A[i] > 9) {
			A[++len] = 0;
		}
		A[i + 1] += A[i] / 10;
		A[i] %= 10; 
		sum += A[i];
	}
	return sum <= 9 * x;
}

int main() {
	scanf("%s", Str);
	N = strlen(Str);
	std::reverse(Str, Str + N);
	int l = 1, r = N;
	int ans = 0;
	while(l <= r) {
		int m = (l + r) >> 1;
		if(check(m)) {
			ans = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, m;
long long dp[111111];

long long yuka(int n);

int main(){

  for(int i = 0; i < 111111; i++) {
    dp[i] = -1;
  }

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

  cout << yuka(n) << endl;

  return 0;
}

long long yuka(int n) {
  if(n == 0) return 1;
  if( dp[n] != -1 ) return dp[n];
  return dp[n] = (yuka(n-1) + yuka(n-2)) % 1000000007;
}

Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
using namespace std;

unsigned long long grundy(unsigned long long x) {
	return ((x+1)^x) & (x+1);
}

class Trie {
public:
	Trie *zero;
	Trie *one;
	Trie() {
		zero = NULL;
		one = NULL;
	}
};
int ind = 0;
Trie buf[100000];

void AddString(Trie *t, char s[], int len, int i = 0) {
	if(i >= len) return;
	if(s[i] == '0') {
		if(t->zero == NULL) t->zero = &buf[ind++];
		AddString(t->zero, s, len, i+1);
	} else {
		if(t->one == NULL) t->one = &buf[ind++];
		AddString(t->one, s, len, i+1);
	}
}
unsigned long long Grundy(Trie *t, unsigned long long l) {
	unsigned long long g = 0;
	if(t->zero == NULL && t->one == NULL) return 0;
	g ^= t->zero == NULL ? grundy(l-1) : Grundy(t->zero, l-1);
	g ^= t->one == NULL ? grundy(l-1) : Grundy(t->one, l-1);
	return g;
}

int main() {
	int n;
	unsigned long long l;
	char s[100000+1];
	Trie t;
	scanf("%d %llu", &n, &l);
	for(int i=0;i<n;i++) {
		scanf("%100000s", s);
		AddString(&t, s, strlen(s));
	}
	printf("%s\n", Grundy(&t, l) != 0 ? "Alice" : "Bob");
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int inf=1e7+9;
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int a,b,c,x;
	int ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				{
					int q=500*i,w=100*j,e=50*k;
					if(q+w+e==x)
					ans++;
				}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	string s;
	cin >> n >> k >> s;
	s[k-1]= s[k-1]-'A'+'a';
	cout << s << endl;
	
}

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

int main(void) {
  int D;
  cin >> D;
  if(D==25){
    cout << "Christmas" << endl;
  } else if(D==24){
    cout << "Christmas Eve" << endl;
  }else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }else if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


Measured memory_bytes: 256
import heapq
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a = [(-x,x) for x in a]
heapq.heapify(a)
for i in range(m):
    new = a[0][1]//2
    heapq.heappop(a)
    heapq.heappush(a,(-new,new))
a = [a[i][1] for i in range(len(a))]
print(sum(a))

Measured memory_bytes: 17424
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, k;
int64 f[N], s[N], suf, ans;
int main()
{
    n = read(), k = read();
    for(int i = 1; i <= n; ++i) 
        s[i] = s[i-1]+read(), 
        f[i] = f[i-1]+max(s[i]-s[i-1], 0ll);
    for(int i = n; i >= k; --i) 
        ans = max(f[i-k]+suf+max(s[i]-s[i-k], 0ll), ans),
        suf += max(s[i]-s[i-1], 0ll);
    printf("%lld\n", ans);
    return 0;
}
/* 
6 5
5 -4 -5 -8 -4 4
*/

Measured memory_bytes: 1664
n = int(input())
ali = list(map(int,input().split()))
bli = list(map(int,input().split()))
cli = list(map(int,input().split()))
total = 0
for i in range(n):
    total += bli[ali[i]-1]
    if i != n-1:
        if ali[i] == ali[i+1] - 1:
            total += cli[ali[i]-1]
print(total)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<llint>X;
vector<vector<int>>go;
pair<vector<llint>,llint>dfs(int ter,int per){
	llint ofset=X[ter];
	vector<llint>ans(2);
	int i,j;
	for(auto it:go[ter]){
		if(it==per){continue;}
		auto ret=dfs(it,ter);
		ofset+=ret.sec;
		//ここでマージする、本当は凸性を使ったマージができるが、O(n^2)が間に合うし、凸性使ってもO(n^2)ので使わない
		vector<llint>iti(ans.size()+ret.fir.size()-1,big);
		for(i=0;i<ans.size();i++){
			for(j=0;j<ret.fir.size();j++){
				mineq(iti[i+j],ans[i]+ret.fir[j]);
			}
		}
		ans=move(iti);
	}
	for(i=0;i<ans.size();i++){ans[i]+=abs(ofset-i);}
	return mp(ans,ofset);
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	X.res(n);
	go.res(n);
	llint wa=0;
	for(i=0;i<n;i++){cin>>X[i];wa+=X[i];}
	for(i=0;i<n;i++){X[i]-=wa/n;}
	for(i=0;i<n-1;i++){
		int u,v;cin>>u>>v;u--;v--;
		go[u].pub(v);
		go[v].pub(u);
	}
	cout<<dfs(0,-1).fir[wa%n]<<endl;
	return 0;
}


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

int main(){
    int N,M; cin >> N >> M;
    vector<int> P(M),Y(M);
    for(int i = 0; i < M; i++) cin >> P[i] >> Y[i], P[i]--;
    vector<vector<int>> vals(N);
    for(int i = 0; i < M; i++) vals[P[i]].push_back(Y[i]);
    for(int v = 0; v < N; v++){
        sort(vals[v].begin(),vals[v].end());
        vals[v].erase(unique(vals[v].begin(),vals[v].end()),vals[v].end());
    }
    for(int i = 0; i < M; i++){
        int v = P[i];
        printf("%06d",v+1);
        int id = lower_bound(vals[v].begin(),vals[v].end(),Y[i]) - vals[v].begin();
        printf("%06d\n",id + 1);
        
    }
    
    
}


Measured memory_bytes: 9512
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
A = []
B = []
for i in range(n):
    a,b = map(int,readline().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
#奇数であると前提してまずは実装しきっちゃう
if not even(n):
    lower = A[n//2]
    upper = B[n//2]
    print(upper-lower+1)
else:
    l1 = A[n//2-1]
    l2 = A[n//2]
    u2 = B[n//2]
    u1 = B[n//2-1]

    a = u1-l1+1
    b = abs(u2-l2)+1
    print(a+b-1)



Measured memory_bytes: 88240
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
S = sum(A)
if S % 10 != 0:
  print(S)
else:
  x = 10000
  for a in A:
    if a % 10 != 0:
      x = min(x, a)
  if x == 10000:
    print(0)
  else:
    print(S - x)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> cnt(26);
    vector<string> s(n);
    for(int i = 0;i < n;i ++){
        vector<int> cnts(26);
        cin >> s[i];
        for(int j = 0;j < s[i].size();j ++){
            cnts[s[i][j]-'a'] ++;
        }
        for(int j = 0;j < 26;j ++){
            if(i==0) cnt[j] = cnts[j];
            else cnt[j] = min(cnt[j],cnts[j]);
        }
    }
    string ans = "";
    for(int i = 0;i < 26;i ++){
        for(int j = 0;j < cnt[i];j ++){
            ans += i+'a';
        }
    }
    cout << ans << endl;
    return 0;
}

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

int h, w;
int T[1401][1401];

struct Rect	{
	int height, prepos;
};

class Tile {
public:
	Tile() {
		for (int i = 0; i < h; i++)	{
			T[i][w] = 0;
			for (int j = 0; j < w; j++) {
				if (!i) T[i][j] = (T[i][j] + 1) % 2;
				else {
					T[i][j] = T[i][j] ? 0 : T[i - 1][j] + 1;
				}
			}
		}
	}

	int largestRectangle(int row) { //???????????°????????¨????????????
		int maxR = 0;
		stack<Rect> R;
		
		for (int j = 0; j <= w; j++) {
			Rect rect;
			rect.height = T[row][j];
			rect.prepos = j;
			if (R.empty()) {
				R.push(rect);
			} else {
				if (rect.height > R.top().height) {
					R.push(rect);
				} else if (rect.height < R.top().height) {
					int target = j; //???????????????index????§?????????????
					while (!R.empty() && rect.height <= R.top().height) { //???????????????????????±????????????????¶??????????????¨???°????\???????????????????
						maxR = max(maxR, R.top().height * (j - R.top().prepos));
						target = R.top().prepos;
						R.pop();
					}
					rect.prepos = target;
					R.push(rect);
				}
			}
		}
		return maxR;
	}

	int largestRectangle() {
		int maxS = 0;
		for (int i = 0; i < h; i++) {
			maxS = max(maxS, largestRectangle(i));
		}
		return maxS;
	}

	

};

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)	{
		for (int j = 0; j < w; j++) {
			cin >> T[i][j];
		}
	}

	Tile t = Tile();

	cout << t.largestRectangle() << endl;
	return 0;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (auto&& e : d) {
    cin >> e;
  }
  sort(begin(d), end(d));

  int res = 0;
  int prev = -1;
  for (const auto& e : d) {
    if (e != prev) {
      res++;
    }
    prev = e;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int F[100][10];
ll P[100][11];
int cnt[10];
ll ans = -mod*mod;
ll sum;


int main(){
    
    cin>>N;
    REP( i, N ){
        REP( j, 10 ){
            cin>>F[i][j];
        }
    }
    
    REP( i, N ){
        REP( j, 11 ){
            cin>>P[i][j];
        }
    }
    
    int s = 1<<10;
    
    while( s > 1 ){
        s--;
        sum = 0;
        REP( i, N ) cnt[i] = 0;
        REP( i, N ){
            REP( j, 10 ){
                if( s&(1<<j) && F[i][j] ) cnt[i]++;
            }
        }
        REP( i, N ) sum += P[i][cnt[i]];
        ans = max( ans, sum );
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    ll N,sum=0;
    double ans=0;
    cin >> N;

    vector<long long> a(N),b(N+1,0),c(N+1,0);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        b.at(a.at(i))++;
    }
    for (int i = 0; i <= N; i++) {
        ll num = b.at(i)*(b.at(i)-1)/2;
        c.at(i)=num;
        sum+=c.at(i);
    }
    for (int i = 0; i < N; i++) {
        ll res = c.at(a.at(i))-(b.at(a.at(i))-1);
        //cout << sum << endl;
        res += (sum - c.at(a.at(i)));
        cout << res << endl;
    }

}

Measured memory_bytes: 7296
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if K >= sum(A) + sum(B):
    print(M + N)
    exit()
acc = 0
ans = 0
for j, b in enumerate(B):
    acc += b
    if K >= acc:
        ans = j + 1
for i in range(N):
    acc += A[i]
    if K >= acc:
        ans = max(ans, i + j + 2)
        continue
    else:
        while (K < acc) & (j > -1):
            acc -= B[j]
            j -= 1
        if K >= acc:
            ans = max(ans, i + j + 2)
print(ans)


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

int main() {
  int N;
  int a, b, c, d;

  cin >> N; // 1234
  
  a = N / 1000; // 1 
  b = (N / 100) - (10 * a);  // 12
  c = (N / 10) - (10 * (N / 100));   // 123
  d = N - (10 * (N / 10));

  if ( (a == b) && (b == c) ) {
      cout << "Yes" << endl;
  }
  else if ( (b == c) && (c == d) ) {
      cout << "Yes" << endl;
  }
  else
  {
      cout << "No" << endl;
  }
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n, h;
    cin >> n >> h;
    vector<pair<int,int>> a(n);
    for (auto &p : a) {cin >> p.first >> p.second;}
    sort(a.rbegin(), a.rend());
    int ans = int(2e9);
    vector<int> b;
    rep(i, 0, n) b.push_back(a[i].second);
    sort(b.rbegin(), b.rend());
    int sum = 0;
    rep(i, 0, n) {
        ans = min(ans, i + (h - sum + a[0].first - 1) / a[0].first);
        // cout << sum << ' ' << b[i] << ' ' << ans << endl;
        sum += b[i];
        if (sum >= h) {
            ans = min(ans, i + 1);
            break;
        }
    }
    if (sum <= h) ans = min(ans, n + (h - sum + a[0].first - 1) / a[0].first);
    cout << ans << '\n';
}

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

#define int long long
typedef long long ll;
typedef long long ll; 
typedef vector<ll> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef vector<vi> vvi;
#define sz(a) int((a).size())
#define F first
#define S second
#define pb emplace_back
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for(int i = a; i<= b; i++)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())

int dp[101][100001];

main() {
    IOS;

    int n, W;
    cin >> n >> W;

    int V = 1e5;
    int val[n+1], w[n+1];

    fr (i,1,n) {
        cin >> w[i] >> val[i];
    }

    for (int i = 0; i <= n; i++) {
        for (int v = 1; v <= V; v++) {
            dp[i][v] = 1e18;
        }
    }

    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int v = 1; v <= 1e5; v++) {
            if (dp[i-1][v] != 1e18)
                dp[i][v] = dp[i-1][v];
            if (v >= val[i])
                dp[i][v] = min(dp[i][v], dp[i-1][v - val[i]] + w[i]);
        }
    }

    for (int i = 1e5; i >= 1; i--) {
        if (dp[n][i] <= W) {
            cout << i << endl;
            break;
        }
    }
}

/*  Check for base cases such as n == 1
    and cases like it where code can fail */

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int i = 1; i <= N; i++) {
        double tmp = 1.0 / N;
        int k = i;
        while(k < K) {
            k *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		String str = fs.next();
		
		int[] leaderImosuArr = new int[n];
		for(int i = 0; i < n; i++) {
			char eOrW = str.charAt(i);
			if(eOrW == 'E') {
				leaderImosuArr[i]++;
			}else {
				leaderImosuArr[0]++;
				if(i < n-1) {
					leaderImosuArr[i+1]--;
				}
			}
		}
		
//		System.out.println(Arrays.toString(leaderImosuArr));
		
		int imosuValue = 0;
		int maxImosuValue = 0;
		for(int i = 0; i < n; i++) {
			imosuValue += leaderImosuArr[i];
			maxImosuValue = Math.max(imosuValue, maxImosuValue);
		}
		
		System.out.println(n - maxImosuValue);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

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

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

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 27896
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int a[100000+10];
int _next[100000+10],before[100000+10];
int flag[100000+10];
int res=0;
int main(){
	int n;
	scanf("%d",&n);
	rb(i,1,n){
		scanf("%d",&a[i]);
	}
	multiset<int> last;
	multiset<int> :: IT ite;
	rb(i,1,n){
		if(!last.empty()){
		ite=last.lower_bound(a[i]);
		if(ite!=last.begin()){
			ite--;
			last.erase(ite);
			last.insert(a[i]);
		}
		else{
			res++;
			last.insert(a[i]);
		}	
		}
		else{
			res++;
			last.insert(a[i]);
		}
	}
	cout<<res<<endl; 
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
int n, c[N], cnt[N], siz[N];
ll cal(int x) {
	return 1ll * x*(x - 1) / 2 + x;
}
ll ans[N];
vector<int>G[N];
	void dfs(int v, int fa) {
		int tmp = cnt[c[v]];
		siz[v] = 1;
		for(int u:G[v]) {
			if(u==fa) continue;
			cnt[c[v]] = 0;
			dfs(u, v);
			siz[v] += siz[u];
			ans[c[v]]+=cal(siz[u]-cnt[c[v]]);
		}
		cnt[c[v]] = tmp + siz[v];
	}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%d", &c[i]);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%lld\n", cal(n) - ans[i] - cal(n - cnt[i]));
	}
	return 0;
}


Measured memory_bytes: 34228
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    int ans = INF;
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) {
            int tmp = y * j - x * i;
            tmp = (tmp >= 0) ? tmp : INF;
            tmp += 2 - (2 + i + j) / 2;
            ans = min(tmp, ans);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2])){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
  N, M = read_int_list()
  A = [0] * M
  B = [0] * M
  v = [set() for i in range(N)] 
  for i in range(M):
    A[i], B[i] = read_int_list()
    v[A[i] - 1].add(B[i])
    v[B[i] - 1].add(A[i])

  res = [0] * (N - 1)
  done = set()
  l = set([1])
  for i in range(N):
    l2 = set()
    for t in l:
      for r in v[t - 1]:
        if r not in l and r not in done:
          l2.add(r) 
          res[r - 2] = t

    # done = done.union(set(l))
    done.update(l)
    l = l2

  return res


def solve0():
  N, M = read_int_list()
  A = [0] * M
  B = [0] * M
  v = [set()] * N
  for i in range(M):
    A[i], B[i] = read_int_list()
    v[A[i] - 1].add(B[i])
    v[A[i] - 1].add(B[i])

  res = [0] * (N - 1)
  done = set()
  l = set([1])
  for i in range(N):
    l2 = set()
    for k in range(M):
      for t in l:
        if t == A[k]:
          if B[k] not in l and B[k] not in done:
            l2.add(B[k]) 
            res[B[k] - 2] = A[k]

        if t == B[k]:
          if A[k] not in l and A[k] not in done:
            l2.add(A[k])
            res[A[k] - 2] = B[k]

    # done = done.union(set(l))
    done.update(l)
    l = l2

  return res


def main():
    res = solve()
    print('Yes', *res, sep='\n')


main()


Measured memory_bytes: 74800
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N,K;
    cin >>N>>K;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll b=1,a=1;
    repd(i,K,N){
        if(A[i-K]<A[i])cout<<"Yes"<<'\n';
        else cout<<"No"<<'\n';
    }


    return (0);
}

Measured memory_bytes: 4776
n = int(input())
A = list(map(int,input().split()))
q = int(input())
total = sum(A)

l = [[i, 0] for i in range(10**5+1)]
for _ in range(n):
    l[A[_]][1] += 1
#print(l)

for i in range(q):
    b, c = map(int,input().split())
    total -= (l[b][0] * l[b][1])
    tmp = (l[c][0] * (l[c][1] + l[b][1]))
    total -= (l[c][0] * l[c][1])
    total += tmp
    print(total)
    l[c][1] += l[b][1]
    l[b][1] = 0
#    print(l)


Measured memory_bytes: 25284
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int p[22];

bool isSecond(int i)
{
	if ((p[i - 1] < p[i]) && (p[i] < p[i + 1]))	//是排列，没有相等的情况 
		return true;
		
	if ((p[i - 1] > p[i]) && (p[i] > p[i + 1]))	//是排列，没有相等的情况 
		return true;
		
	return false;
}


int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(p[i]));
		
	int count = 0;
	for (int i = 1 ; i < n - 1 ; i++){
		if (isSecond(i))
			count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}



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

int main(){
  int k;
  cin >> k;
  for(int i=0;i<k;i++){
    int gx,gy;
    cin >> gx >> gy;
    int p;
    cin >> p;
    int A[16][16][16][16]={};
    for (int j=0;j<p;j++){
      int a,b,c,d;
      cin >> a >> b>>c>>d;
      A[a][b][c][d] = 1;
    }
    int B[16][16]={};
    B[0][0] = 1;
    for(int t= 0;t<=gx;t++){
      for(int j=0;j<=gy;j++){
	if(j==0){
	  if(t!=0){
	    if(A[t-1][0][t][0]==0&&A[t][0][t-1][0]==0){
	      B[t][0] = B[t-1][0];
	    }
	  }
	}else{
	  if(t==0){
	    if(A[0][j-1][0][j]==0&&A[0][j][0][j-1]==0){
	      B[0][j]=B[0][j-1];
	    }
	  }else{
	    if(A[t][j-1][t][j]==0&&A[t][j][t][j-1]==0){
	      B[t][j]+=B[t][j-1];
	    }
	    if(A[t-1][j][t][j]==0&&A[t][j][t-1][j]==0){
	      B[t][j]+=B[t-1][j];
	    }
	  }
	} 
      }
    }
    if(B[gx][gy]==0){
      cout<<"Miserable Hokusai!" <<endl;
    }else{
      cout << B[gx][gy] << endl;
    }
  }
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main()
{
  int N, M;
  while(cin >> N >> M,N || M) {
    int mas[1005];
    int q[1005];
    Rep(i,N)cin >> mas[i];
    Rep(i,M)cin >> q[i];
    int p = 0;
    Rep(i,M) {
      (p += q[i]) += mas[p];
      if(p >= N - 1) {
	cout << i + 1 << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3048
package main

import "fmt"
//import "sort"
func main() {
    
    const n = 1              
    a := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Scan(&a[i])
    }
    // sort.Ints(a)
    fmt.Println(a[0] * (a[0] + 1) / 2)
    //fmt.Println( (a[0] + a[1]) * a[2] / float64(2) )
    
}

Measured memory_bytes: 512
#include <stdio.h>


using namespace std;



int main(){
	
	int n;
	int R[200000];
	int max;
	int gain;
	int ans;

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d", &R[i]);
	}

	max = R[n - 1];
	ans = R[n - 1] - R[n - 2];
	for (int i = n - 2; i >= 0; i--){
		gain = max - R[i];
		if (gain > ans) ans = gain;
		if (R[i] > max)	max = R[i];
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1808
N = int(input())
m = s = 1
while s < N:
    m += 1
    s += m

ans = [m]
rem = N-m
if rem:
    for n in range(m-1,0,-1):
        if n <= rem:
            ans.append(n)
            rem -= n
            if rem==0: break

print(*reversed(ans), sep='\n')

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll A, ll B) {
    int N = 99;
    char c[100][100] = {};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i % 2 == 0) {
                c[i][j] = '#';
            } else {
                c[i][j] = '.';
            }
        }
    }
    for (int i = 0; i < N; i++)
        c[i][N - 1] = '#';
    for (int i = 1; i < N - 1; i++)
        c[i][0] = '.';


    A -= 1;
    B -= 1;
    for (int i = 1; i < N; i += 2) {
        for (int j = 2; j < N - 1; j += 2) {
            if (A == 0) break;
            c[i][j] = '#';
            A--;
        }
    }
    for (int i = N - 3; i >= 2; i -= 2) {
        for (int j = N - 2; j >= 2; j -= 2) {
            if (B == 0) break;
            c[i][j] = '.';
            B--;
        }
    }

    cout << N << " " << N << endl;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << c[i][j];
        }
        cout << endl;
    }
}


void main_(istream &cin) {
    ll A;
    ll B;
    cin >> A;
    cin >> B;
    solve(A, B);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SONI ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn=5e5+15;
const int maxm=5000+15;
const int mod=1e9+9;
const int inf=0x3f3f3f3f;
const int MOD=1000000007;

int main()
{
    SONI;
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<bool> dp(1+k);
    
    for(int stones=0; stones<=k ; stones++)
    {
        for(int x:a)
        {
            if(stones>=x && !(dp[stones-x]))
            {
                dp[stones] = true;
            }
        }
    }
    
    if(dp[k]==true)
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
    return 0;
}

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()
using ll = int64_t;
using p = pair<int, int>;
using pp = pair<p, int>;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int INF = 100000000;
const bool DEBUG = true;

int h, w, result = 0;
vector<vector<bool>> grid(1500, vector<bool>(1500));

void input() {
    char c;
    cin >> h >> w;
    rep(i, h) { rep(j, w) {
        cin >> c;
        grid[i][j] = c == '#';
    }}
}

void solve() {
    queue<pp> q;
    rep(i, h) { rep(j, w) {
        if(grid[i][j]) {
            q.push(pp(p(i, j), 0));
        }
    }}

    while(!q.empty()) {
        pp target = q.front(); q.pop();
        int tx = target.first.first;
        int ty = target.first.second;
        int id = target.second;
        result = max(id, result);
        rep(i, 4) {
            int nx = tx + dx[i];
            int ny = ty + dy[i];
            if(0>nx || nx>=h) continue;
            if(0>ny || ny>=w) continue;
            if(grid[nx][ny]) continue;
            grid[nx][ny] = true;
            q.push(pp(p(nx, ny), id+1));
        }
    }
}

void Main() {
    input();
    solve();
    cout << result << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12688
n, k = map(int, input().split())
hs = list(map(int, input().split()))

dp = [0] + [float("inf") for _ in range(n - 1)]

for i in range(1, n):
    for j in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(hs[i - j] - hs[i]))
print(dp[i])

Measured memory_bytes: 57184
#include<stdio.h>

int main(void)
{
	int max, dur, min;
	int temp;

	scanf("%d %d %d", &max, &dur, &min);

	if (min > dur){
		temp = min;
		min = dur;
		dur = temp;
	}
	if (min > max){
		temp = min;
		min = max;
		max = temp;
	}
	if (dur > max){
		temp = max;
		max = dur;
		dur = temp;
	}

	printf("%d %d %d", min, dur, max);

	putchar('\n');

	return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n, k; sc(n), sc(k);
    ll ans = 0, cnt = 0, tmp = 0;
    string s, tmps; cin >> s;
    tmps = s[0];
    rep(i, 1, s.size()){
        if (s[i]==tmps[0]) tmp += 1;
        else {
            cnt += 1;
            ans += tmp;
            tmp = 0;
            tmps = s[i];
        }
    }
    ans += tmp;
    rep(i, 0, k){
        if (cnt<=0) break;
        else if (cnt==1) ans += 1;
        else ans += 2;
        cnt -= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int total = 0;
		for (int i = 0;i< n.length();i++) {
			total += Integer.parseInt(Character.toString(n.charAt(i)));
		}
		if(total % 9 ==0) {
			System.out.print("Yes");
		}else {

			System.out.print("No");
		}
		
	}

}

Measured memory_bytes: 50480
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for (int i = 0; i < length; i++) {
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch) == true){
                    ch=Character.toUpperCase(ch);
                    answer+=ch;
                }else{
                    ch=Character.toLowerCase(ch);
                    answer+=ch;
                }
            }
            System.out.println(answer);
        }
    }
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x, a; cin >> x >> a;
  cout << (x < a ? 0 : 10);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		double r = 0;;
		if((a * a * b) / 2 >= x) {
			r = Math.atan((2 * x)/(a * b * b));
		}else {
			r = Math.atan((a * a * a)/(2 * (a * a * b - x)));
		}
		r = Math.toDegrees(r);
		System.out.println(90 -r);
	}

}


Measured memory_bytes: 23508