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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >>n>>m;
  int mi=0,ma=n;
  rep(i,m){
    int s,b;
    cin >>s>>b;
    mi = max(mi,s);
    ma = min(ma,b);
  }
  cout <<max(0,ma-mi+1);
}

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] NCK = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int N = NCK[0], C = NCK[1], K = NCK[2];
			int[] T = new int[N];
			for (int i = 0; i < N; i++)
			{
				T[i] = int.Parse(Console.ReadLine());
			}
			var ordered = T.OrderBy(item => item);
			int bus = 0, time = int.MinValue, passenger = 0;
			foreach (var item in ordered)
			{
				if (time + K < item)
				{
					bus++;
					passenger = 0;
					time = item;
				}
				if (++passenger > C)
				{
					passenger = 1;
					time = item;
					bus++;
				}
			}
			Console.WriteLine(bus);
		}
	}
}


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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i=0; i<3; i++)
        for (int j=0; j<3; j++)
            cin >> c[i][j];

    vector<int> a(3);
    vector<int> b(3);

    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];

    a[0] = 0;
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool ok = true;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            if (c[i][j] != a[i] + b[j]) {
                ok = false;
                break;
            }
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import collections


class Solution:
    def solve(self, S: str) -> int:

        c = collections.Counter(S + "01")
        zeros = c["0"] - 1
        ones = c["1"] - 1

        return 2 * min(zeros, ones)


if __name__ == '__main__':

    # standard input
    S = input()

    # solve
    solution = Solution()
    print(solution.solve(S))


Measured memory_bytes: 3444
#include<iostream>
#include<cmath>
using namespace std;
int n,w[105],minn,k,g1,g2=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>w[i];
		g2+=w[i];
	}
	g1=0;
	minn=g2;
	for(int i=1;i<=n;i++){
		g1+=w[i];
		g2-=w[i];
		minn=min(minn,abs(g2-g1));
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
flag = False
for i in range(n) :
  if a[i] > b[i] :
    a[i] -= b[i]
    cnt += b[i]
    b[i] = 0
  elif a[i] == b[i]:
    cnt += b[i]
    b[i] = 0
    a[i] = 0
  else :
    b[i] -= a[i]
    cnt += a[i]
    a[i] = 0
    flag = True

  if flag :
    if a[i+1] > b[i] :
      a[i+1] -= b[i]
      cnt += b[i]
      b[i] = 0
    elif a[i+1] == b[i]:
      cnt += b[i]
      b[i] = 0
      a[i+1] = 0
    else :
      b[i] -= a[i+1]
      cnt += a[i+1]
      a[i+1] = 0
    flag = False

print(cnt)


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

# check
numbers = sorted(
    [{"number": ind + 1, "A": a} for ind, a in enumerate(A)],
    key=lambda x: x["A"]
)

# output
op = ""
for n in numbers:
    op += str(n["number"])
    op += " "
print(op[:-1])

Measured memory_bytes: 43364
// he's not even trying
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef gp_hash_table<ll,ll,chash> gash;
vl w;
int bru(int u) {
	int res = 0;
	while(u) {
		res += u&1;
		u >>= 1;
	}
	return res;
}
ll dp[55][55];
ll cho(int n, int k) {
	if(k < 0 || k > n) {return 0;}
	if(k == 0 || k == n) {return 1;}
	if(dp[n][k] != -1) {return dp[n][k];}
	return dp[n][k] = cho(n-1,k-1)+cho(n-1,k);
}
ll calc(ll res, ll ks) {
	if(res <= ks) {
		return (1LL<<res)-1;
	} else {
		ll wa = 0;
		for(int i=1;i<=ks;i++) {
			wa += cho(res,i);
		}
		return wa;
	}
}
int main() {
	ios::sync_with_stdio(0);cout.precision(20);cout.tie(0);cin.tie(0);
	ll n,ks,as,ot;
	cin >> n >> ks >> as >> ot;
	memset(dp,-1,sizeof(dp));
	if((as&ot) != as) {
		cout << 0 << '\n';
		return 0;
	}
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		w.push_back(t);
	}
	ll tob = 0;
	ll ko = 0;
	for(int i=0;i<20;i++) {
		if(((as>>i)&1) == ((ot>>i)&1)) {
			int bo = (as>>i)&1;
			vl we;
			for(int j=0;j<w.size();j++) {
				if(((w[j]>>i)&1) == bo) {
					we.push_back(w[j]);
				}
			}
			w = we;
		} else {
			ko++;
			tob |= (1<<i);
		}
	}
	as = 0;
	ot = (1<<ko)-1;
	n = w.size();
	for(int i=0;i<n;i++) {
		ll ru = 0;
		ll rb = 0;
		for(int j=0;j<20;j++) {
			if((tob>>j)&1) {
				ru |= (((w[i]>>j)&1)<<rb);
			rb++;
			}
		}
		w[i] = ru;
	}
	ll ans = 0;
	for(int i=0;i<=ot;i++) {
		int sg = 1-((bru(i)&1)*2);
		gash lol;
		for(int j=0;j<n;j++) {
			lol[i&w[j]]++;
		}
		ll res = 0;
		for(auto& it: lol) {
			res += calc(it.second,ks);
		}
		ans += sg*res;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3688
S = input()
N = int('10' + S, 2)

def make_alternate_binary(S):
    a = 0
    b = 0
    a += 1 << S + 1
    b += 1 << S + 1
    
    for i in range(S):
        a += (i % 2) << i
        b += ((i + 1) % 2) << i
    return a, b

co1, co2 = make_alternate_binary(len(S))
print(min(bin(N ^ co1).count('1'), bin(N ^ co2).count('1')))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll n;
string s[210];
vector<int> G[210];
bool nibu = 1;
int a[210];
int dp[210][210];

void input() {
    cin >> n;
    REP(i,n) cin >> s[i];
    REP(i,n) REP(j,n) {
        dp[i][j] = inf;
        if (i == j) dp[i][j] = 0;
    }
    REP(i,n) REP(j,n) {
        if (s[i][j] == '1') {
            G[i].pb(j);
            dp[i][j] = 1;
        }
    }
}

void solve() {
    //二部グラフ判定
    REP(i,n) a[i] = -1;
    queue<pair<int,bool>> que;
    que.push({0,0});
    while (!que.empty()) {
        pair<int,bool> tp = que.front();
        que.pop();
        if (a[tp.fi] != -1) {
            if (tp.se == a[tp.fi]) continue;
            else nibu = 0;
            break;
        }
        a[tp.fi] = tp.se;
        REP(i,sz(G[tp.fi])) {
            que.push({G[tp.fi][i],!tp.se});
        }
    }
    if (!nibu) {
        cout << -1 << endl;
        return;
    }
    int ans = 0;
    REP(k,n) REP(j,n) REP(i,n) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }
    REP(i,n) REP(j,n) ans = max(ans,dp[i][j] + 1);
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1024
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define INF INT_MAX/3

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

struct dataset {
  int req;
  int coin010;
  int coin050;
  int coin100;
  int coin500;
};

int load(dataset* d) {
  int r;
  scanf("%d", &r);
  if( !r ) return 0;
  d->req = r;
  scanf("%d %d %d %d",
        &(d->coin010),
        &(d->coin050),
        &(d->coin100),
        &(d->coin500));
  return 1;
}

void solve(dataset* d) {
  int change = -(d->req);
  change += d->coin010 * 10;
  change += d->coin050 * 50;
  change += d->coin100 * 100;
  change += d->coin500 * 500;

  int r010, r050, r100, r500;

  r500 = change / 500;
  change %= 500;

  r100 = change / 100;
  change %= 100;

  r050 = change / 50;
  change %= 50;

  r010 = change / 10;
  change %= 10;

  if( r010 < d->coin010 ) {
    printf("10 %d\n", d->coin010 - r010);
  }
  if( r050 < d->coin050 ) {
    printf("50 %d\n", d->coin050 - r050);
  }
  if( r100 < d->coin100 ) {
    printf("100 %d\n", d->coin100 - r100);
  }
  if( r500 < d->coin500 ) {
    printf("500 %d\n", d->coin500 - r500);
  }
}

int main() {
  struct dataset ds;
  int needEmptyLine = 0;
  while( load(&ds) ) {
    if( needEmptyLine ) printf("\n");
    solve(&ds);
    needEmptyLine = 1;
  }
  return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  int ans=0;
  cin>>s;
  if(s.size()%2==0){
    s.pop_back();
    s.pop_back();
  }else{
    s.pop_back();
  }
  while(true){
    ans=0;
  for(int i=0;i<(s.size()/2);i++){
    if(s[i]==s[i+(s.size()/2)]){
      ans++;
    }else{
      break;
    }
  }
    if(ans==s.size()/2){
      cout<<s.size()<<endl;
      return 0;
    }else{
      s.pop_back();
      s.pop_back();
    }
  }
  
}
///////////////////////////



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int cnt = 0;
    repi(i, n+1) {
        int v = 0;
        int t = i;
        while (t > 0) {
            v += t % 10;
            t /= 10;
        }
        if (a <= v && v <= b) {
            cnt += i;
        }
    }
    put(cnt)
    return 0;
}

Measured memory_bytes: 3624
chars = 'abcdefghijklmnopqrstuvwxyz'
s = input()
t = input()
l = len(s)

ds = {c: 0 for c in chars}
dt = {c: 0 for c in chars}

ans = 'Yes'
for cs, ct in zip(s, t):
    ds[cs] += 1
    dt[ct] += 1
    if ds[cs] != dt[ct]:
        ans = 'No'
        break
print(ans)

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

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

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  int odd = 0, div2 = 0, div4 = 0;
  rep(i, n) {
    if(a[i]%4 != 0 && a[i]%2 == 0) div2++;
    if(a[i]%4 == 0) div4++;
    if(a[i]&1) odd++;
  }

  int foundDiv2 = 0;
  if(div2 == 0) foundDiv2++;
  cout << (div4+foundDiv2 >= odd ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 1024
// AOJ 0505: Questionnaire
// 2017.8.30 bal4u@uu
// 2017.11.18

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

typedef struct { int m, c; } T;
T tbl[1002];
int c[102];
char buf[202], *p;

int cmp(T *a, T *b) { if (b->c - a->c) return b->c - a->c; return a->m - b->m; }

int main()
{
	int n, m, i;

	while (fgets(buf, 20, stdin) && *buf != '0') {
		sscanf(buf, "%d%d", &n, &m);
		memset(c, 0, sizeof(c));
		while (n--) {
			fgets(p=buf, 202, stdin);
			for (i = 1; i <= m; i++) c[i] += *p & 1, p+=2;
		}
		for (i = 1; i <= m; i++) tbl[i].m = i, tbl[i].c = c[i];
		qsort(tbl+1, m, sizeof(T), cmp);
		printf("%d", tbl[1].m);
		for (i = 2; i <= m; i++) printf(" %d", tbl[i].m);
		putchar('\n');
	}
	return 0;
}

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

N, Q = map(int, input().split())
S = input()

S = S.replace("AC", "-+")
Sl = [0]
Sr = [0]
l = 0
r = 0
for i in range(N):
    if S[i] == "-":
        l += 1
    if S[i] == "+":
        r += 1
    Sl.append(l)
    Sr.append(r)

for _ in range(Q):
    l, r = map(int, input().split())
    print(Sr[r] - Sl[l - 1])


Measured memory_bytes: 8632
S = input()

ind = len(S)
flg = True
while ind > 0:
    if S[ind-7:ind] in ["dreamer"]:
        ind -= 7
    elif S[ind-6:ind] in ["eraser"]:
        ind -= 6
    elif S[ind-5:ind] in ["dream", "erase"]:
        ind -= 5
    else:
        flg = False
        break

if flg:
    print('YES')
else:
    print('NO')

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

int main() {
  int n;
  cin >> n;
  queue<string> w;
  w.push("a");
  while(w.front().size()<n) {
    char maxchar='a';
    for(int i=1;i<w.front().size();i++) maxchar=max(maxchar,w.front().at(i));
    maxchar++;
    for(char charplus='a';charplus<=maxchar;charplus++) w.push(w.front()+charplus);
    w.pop();
  }
  while(w.size()!=0) {
    cout << w.front() << endl;
    w.pop();
  }
}

Measured memory_bytes: 9728
#include <stdio.h>
#define MIN -1000000000
int heapsize=0,A[2000000001];
void maxHeapify(int );
void insert(int );
void helpIncreaseKey(int ,int );
int heapExtractMax(int );


int main(void){
  int key;
  char command[7];
  while(1){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(command[0]=='e'){
      if(command[1]=='n')
        break;
      else if(command[1]=='x')
        printf("%d\n",helpExtractMax());
    }
  }
  
  return 0;
}

int helpExtractMax(int element){
  int max;
  if(heapsize<1)
    return ;
  max=A[1];
  A[1]=A[heapsize];
  heapsize--;
  maxHeapify(1);
  return max;
}

void helpIncreaseKey(int element,int key){
  int temp;
  if(key < A[element])return ;
  A[element]=key;
  while(element>1 && A[element/2] < A[element]){
    //compare parent's key with child's key
    temp=A[element];
    A[element]=A[element/2];
    A[element/2]=temp;
    element/=2;
  }
}

void insert(int key){
  heapsize++;
  A[heapsize]=MIN;
  //set key to A[heapsize]
  helpIncreaseKey(heapsize,key);
}
void maxHeapify(int parent){
  int left,right,maxnode,temp;
  left=2*parent;
  right=left+1;

  if(left<=heapsize && A[left] > A[parent])
    maxnode=left;
  else
    maxnode=parent;
  if(right<=heapsize && A[right] > A[maxnode])
    maxnode=right;

  if(maxnode!=parent){
    //need to swap node
    temp=A[maxnode];
    A[maxnode]=A[parent];
    A[parent]=temp;

    if(maxnode*2<=heapsize)
      //there is child of maxnode
      maxHeapify(maxnode);
  }
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    vector<int> f(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            int fi; cin >> fi;
            f[i] |= (fi << j);
        }
    }
    vector<vector<int>> p(n, vector<int>(11));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++)
            cin >> p[i][j];
    }

    int ans = -inf;
    for (int bits = 1; bits < (1 << 10); bits++) {
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += p[i][__builtin_popcount(f[i] & bits)];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using B = std::bitset<4000001>;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    
    B dp;
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        dp |= dp << a[i];
    }
    
    for (int i = std::accumulate(a.begin(), a.end(), 1) / 2; ; i++) {
        if (dp[i]) {
            std::cout << i << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
import scala.io.StdIn

object Main extends App {
  // val Array(h,w) = StdIn.readLine.split(" ").map(_.toInt)
  StdIn.readLine

  val sqr = Iterator.continually(StdIn.readLine)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .toArray
    .foreach(ch => println(ch.mkString))
}

Measured memory_bytes: 29156
N = int(input())

s = 0
ans = []
for i in range(1, N + 1):
    s += i
    if s >= N:
        for n in range(i, 0, -1):
            if N - n >= 0:
                ans.append(n)
                N -= n
        break

for i in ans:
    print(i)


Measured memory_bytes: 3444
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
        var y = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
        x.Add(inp[2]);
        y.Add(inp[3]);
        x = x.OrderBy(f => f).ToList();
        y = y.OrderBy(f => f).ToList();
        Console.WriteLine(x.Last() < y.First() ? "No War" : "War");
    }
}

Measured memory_bytes: 11348
//	C++ (Clang3.8.0)
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int aNum, bNum, mNum;
	int *a, *b;
	int *x, *y, *c;
	int aMin = 999999;
	int bMin = 999999;
	int ans;
	
	cin >> aNum >> bNum >> mNum;
	
	a = new int[aNum];
	b = new int[bNum];
	x = new int[mNum];
	y = new int[mNum];
	c = new int[mNum];
	
	for(int i=0; i<aNum; ++i){
		cin >> a[i];
		if(aMin > a[i]){
			aMin = a[i];
		}
	}
	
	for(int i=0; i<bNum; ++i){
		cin >> b[i];
		if(bMin > b[i]){
			bMin = b[i];
		}
	}
	ans = aMin + bMin;
	
	for(int i=0; i<mNum; ++i){
		cin >> x[i] >> y[i] >> c[i];
		if(a[x[i]-1] + b[y[i]-1]-c[i] < ans){
			ans = a[x[i]-1] + b[y[i]-1]-c[i];
		}
	}
	
	cout << ans;
	
	delete[] a;
	delete[] b;
	delete[] x;
	delete[] y;
	delete[] c;
	
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void){

	int a, b, c, d, n, count;

	while(scanf("%d", &n) != EOF){
		count = 0;
		for(a = 0; a <= 9; a++){
			for(b = 0; b <= 9; b++){
				for(c = 0; c <= 9; c++){
					for(d = 0; d <= 9; d++){
						if(n == a + b + c + d){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=INT_MAX;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

void dijkstra(li start)
{
    dis[start]=0;

    multiset<pair<li,li>> s;

    s.insert({0,start});

    while(!s.empty())
    {
        pair<li,li> tp=*s.B;
        s.erase(s.begin());

        li p=tp.S;

        if(!vis[p]) 
        {
            vis[p]=1;

            for(pair<li,li> v:wgraph[p])
            {
                if(dis[p]+v.S<dis[v.F])
                {
                    dis[v.F]=dis[p]+v.S;
                    s.insert({dis[v.F],v.F});
                }
            }
        }
    }
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    li tp=floor(log2(n))+1;

    li ans=((li)pow(2,tp)-1);

    cout<<ans;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <set>
#include<bits/stdc++.h>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
bool dp[100005 ] = {0};
int main(){
    int n , k;
    cin>>n>>k;
    vector <int> a;
    for(int i = 0;i<n;i++){
        int z;
        cin>>z;
        a.push_back(z);
    }
    for(int i = 1 ; i<=k;i++){
        for(int j = 0;j<n;j++){
            if(i >=a[j] ){
                if(dp[i - a[j] ] ==0 ){
                    dp[i] = 1;break;
                }
            }
        }
    }
    if(dp[k]==1 ){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}


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

int main(){
  long long n = 0;
  cin >> n;
  long long ans = n - 1;
  for (long long i = 1; i*i <= n; i++){
    if (n % i == 0){
      ans = i + n/i - 2;
      }
    }
  cout << ans << endl;
  }

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

const static int Null = -1;

const static int mod = 1e9+7;

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

  vector<int> a(n + 1, 0);

  vector<int> dp(n + 1, 0);

  for (int i = 1; i <= m; i++) {
    int b;
    cin >> b;
    a[b] = -1;
  }

  bool flag = true;

  if (a[1] == -1) {
    dp[1] = Null;
  } else dp[1] = 1;
  if (a[2] == -1 && a[1] == -1) {
    cout << 0 << endl;
    return 0;
  } else if (a[2] != -1 && a[1] == -1) {
    dp[2] = 1;
  } else if (a[2] == -1 && a[1] != -1) {
    a[2] = Null;
  } else if (a[2] != -1 && a[1] != -1) {
    dp[2] = 2;
  }



  for (int i = 3; i <= n; i++) {
    if (a[i] == -1) {
      dp[i] = Null;
    } else {
      if (dp[i - 1] != Null && dp[i - 2] != Null) {
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
      } else if (dp[i - 1] == Null && dp[i - 2] != Null) {
        dp[i] = dp[i - 2] % mod;
      } else if (dp[i - 1] != Null && dp[i - 2] == Null) {
        dp[i] = dp[i - 1] % mod;
      } else if (dp[i - 1] != Null && dp[i - 2] != Null) {
        flag = false;
        break;
      }
    }
  }

  if (!flag) {
    cout << 0 << endl;
    return 0;
  }

  cout << dp[n] << endl;

};


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if (a>=13){
        cout << b << endl;
    }
    else if(a<=12&&a>=6){
        cout << b/2 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int w,h;
  while(cin >> w >> h, w+h) {
    bool ba[w][h];
    memset(ba,0,sizeof(ba));
    int n;
    cin >> n;
    while(n--) {
      int a,b;
      cin >> a >> b;
      ba[a-1][b-1] = 1;
    }
    int dp[w][h];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
      
    REP(i,w) {
      REP(j,h) {
        if (ba[i][j]) continue;
        if (i>0)
          dp[i][j] += dp[i-1][j];
        if (j>0)
          dp[i][j] += dp[i][j-1];
      }
    }
    cout << dp[w-1][h-1] << endl;
  }
}

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

int N, K;

int main() {
    cin >> N >> K;
    int l = 1, h = N;

    long double ans = 0;
    for (int i = 1; i <= N; i++) {
        int n = i;
        long double r = 1;
        while (n < K) {
            r /= 2; n*= 2;
        }
        ans += r;
    }
    cout << std::setprecision(20) << ans / N << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      Scanner sc = new Scanner(System.in);
      while(sc.hasNext()){
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = a + b;
        int cnt = 0;
        
        while (true) {
          sum /= 10;
          cnt++;
          if (sum == 0) {
            break;
          }
        }
        
        out.println(cnt);
      }
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 26528
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    s = int(input())

    if s <= 10**9:
        print(0,0,1,0,0,s)
    elif s == 10**18:
        print(0,0,10**9,0,0,10**9)
    else:
        c = s // (10**9)
        b = c+1
        a = s % 10**9
        print(0,c,a,0,10**9,b)
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 7768
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int[] arr = new int[n];

		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}

		int current = 1;
		int broken = 0;

		for (int i = 0; i < n; i++) {
			if (arr[i] == current) {
				current++;
			} else {
				broken++;
			}
		}

		if (current == 1) {
			System.out.println("-1");
		} else {
			System.out.println(broken);
		}

		sc.close();
	}

}


Measured memory_bytes: 79204
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next(); 
		int[] arr = new int[s.length()];
		for (int i = 0; i < s.length(); i++) {
			arr[i] = s.charAt(i) - '0';
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + 2 < s.length(); i++) {
			int value = abc(arr[i], arr[i + 1], arr[i + 2]);
			if (min >= value) {
				min = value;
			}
		}
		System.out.println(min);
		
	}
	
	public static int abc(int a, int b, int c) {
		int value = a * 100 + b * 10 + c;
		value -= 753;
		if (value >= 0) {
			return value;
		} else {
			return value * -1;
		}
	}
	
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 24;

#define F first
#define S second

int main(void){
    for(int n, m; cin >> n >> m, n;){
        int s, z; cin >> s >> z; s--, z--;

        // (距離, 制限速度)
        vector<vector<pair<int, pii>>> edge(n);
        rep(i, m){
            int x, y, d, c; cin >> x >> y >> d >> c; x--, y--;

            edge[x].pb(mp(y, mp(d, c)));
            edge[y].pb(mp(x, mp(d, c)));
        }

        constexpr int kMaxSpeed = 30;

        // (コスト, (今いる都市, 速度, 1個前の都市))
        typedef pair<double, pair<int, pii>> State;

        vector<vector<vector<double>>> minDist(n, vector<vector<double>>(kMaxSpeed + 1, vector<double>(n, (double)inf)));
        priority_queue<State, vector<State>, greater<State>> q;

        q.push(mp(0.0, mp(s, mp(0, s))));

        while(!q.empty()){
            double cur_cost = q.top().F;
            int cur_v = q.top().S.F;
            int cur_speed = q.top().S.S.F;
            int cur_prev = q.top().S.S.S;
            q.pop();

            if(minDist[cur_v][cur_speed][cur_prev] < inf - eps) continue;

            minDist[cur_v][cur_speed][cur_prev] = cur_cost;

            int next_prev = cur_v;
            range(next_speed, cur_speed - 1, cur_speed + 2){
                if(next_speed <= 0) continue;

                for(auto && ee : edge[cur_v]){
                    if(ee.S.S < next_speed || ee.F == cur_prev) continue;

                    int next_v = ee.F;
                    double next_cost = cur_cost + (double)ee.S.F / next_speed;

                    if(minDist[next_v][next_speed][next_prev] < inf - eps) continue;

                    q.push(mp(next_cost, mp(next_v, mp(next_speed, next_prev))));
                }
            }
        }

        double res = *min_element(all(minDist[z][1]));
        if(res < inf - eps) printf("%.6f\n", res);
        else cout << "unreachable" << endl;
    }

	return 0;
}

Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int nn=n;
    int sum=0;
    while(nn>0)
    {
        sum+=nn%10;
        nn=nn/10;
    }
    if(n%sum==0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <iomanip>
#include <cassert>
using namespace std;

const int INF = 1<<29;

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

int main(){
    int N;
    int x[200], y[200];
    while(true){
        scanf("%d", &N);
        if(N == 0) break;
        x[0] = y[0] = 0;
        for(int i = 1; i < N; i++){
            int n, d;
            scanf("%d%d", &n, &d);
            x[i] = x[n] + dx[d];
            y[i] = y[n] + dy[d];
        }
        int min_x = INF, max_x = -INF;
        int min_y = INF, max_y = -INF;
        for(int i = 0; i < N; i++){
            min_x = min(min_x, x[i]);
            max_x = max(max_x, x[i]);
            min_y = min(min_y, y[i]);
            max_y = max(max_y, y[i]);
        }
        printf("%d %d\n", max_y - min_y + 1, max_x - min_x + 1);
    }
    return 0;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	set<int> st;
	
	rep(i,n){
		int a;
		cin >>a;
		if(st.count(a)) st.erase(a);
		else st.insert(a);
	
	}
	
	cout << sz(st) <<"\n";
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//long long MOD = 1e9 + 7;

long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;


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

    ll n;
    string s;
    cin >> n >> s;
    
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string pre = s.substr(0, n / 2);
    string lat = s.substr(n / 2, n / 2);
    if (pre == lat) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if ( a==b && a!=c ) {
    cout << "Yes" << endl;
  }
  else if ( a==c && a!=b ) {
    cout << "Yes" << endl;
  }
  else if ( c==b && a!=c ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int gohyakuen = Integer.parseInt(sc.nextLine());
        int hyakuen = Integer.parseInt(sc.nextLine());
        int gojuen = Integer.parseInt(sc.nextLine());
        int x = Integer.parseInt(sc.nextLine());
        sc.close();
        for (int i = 0; i <= gohyakuen; i++) {
            if (i * 500 > x) {
                continue;
            }
            for (int j = 0; j <= hyakuen; j++) {
                if (i * 500 + j * 100 > x) {
                    continue;
                }
                for (int k = 0; k <= gojuen; k++) {
                    if (i * 500 + j * 100 + k * 50 == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


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

int main(){
  unsigned long int A, B, N;

  cin>>N>>A>>B;
  if (A > B){
    cout<<0<<endl;
    return 0;
  }
  
  if (A == B && N < 2){
    cout << 1 << endl;
    return 0;
  }

  if (N < 2){
    cout<<0<<endl;
    return 0;
  }
  
  unsigned long int max = A + B + 1;
  unsigned long int min = A + B;
  
  for (int i = 0; i < N - 2; i++){
    max += B;
    min += A;
  }

  cout<<max - min <<endl;
 
   return 0;
}


Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    s = input()
    if s[-1]=='s':
        print(s+'es')
    else:
        print(s+'s')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0,big=0;
	cin>>n;
	int a[n];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]>big){
			big=a[i];
		}
	}
	for(int i=1;i<=n;i++){
			sum+=a[i];
	}
	sum-=big/2;
	cout<<sum;
	return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll mods = 1000000007;
const double pi = 3.14159265358979;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double ax,ay,bx,by;
    ax = a * cos(-2*pi*((h+9+m/60)/12));
    ay = a * sin(-2*pi*((h+9+m/60)/12));
    bx = b * cos(-2*pi*(m+45)/60);
    by = b * sin(-2*pi*(m+45)/60);

    print(fixed << setprecision(10) << sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)));
    return 0;
}

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

int main() {
	int n;cin>>n;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	vector<vector<int>> count(n,vector<int>(27,0));
//	cout<<'A';
	for(int i=0;i<n;i++){
		for(int j=0;j<s[i].size();j++){
			int ch=s[i][j]-'a';
			count[i][ch]++;
		}
//		cout<<endl;
	}
//	for(int i=0;i<n;i++){
//		for(int j=0;j<27;j++){
//			cout<<count[i][j];
//		}
//		cout<<endl;
//	}
	vector<int> min(27,100);
	for(int i=0;i<n;i++){
		for(int j=0;j<27;j++){
			if(min[j]>count[i][j]){
				min[j]=count[i][j];
			}
		}
	}
//	for(int i=0;i<27;i++){
//		cout<<min[i];
//	}
//	cout<<endl;


	for(int i=0;i<27;i++){
		for(int j=0;j<min[i];j++){
			cout<<char('a'+i);
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;
typedef tuple< ll, int, int > dist;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< dist > d;
  ll d_min[n][n], d_true[n][n];
  ll inf = 10000000000000;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      ll a;
      cin >> a;
      if (i<j) d.push_back(make_tuple(a, i, j));
      d_min[i][j] = inf;
      d_true[i][j] = a;
    }
  }
  sort(d.begin(), d.end());
  ll ans = 0;
  for (auto w : d) {
    ll a = get<0>(w);
    int from = get<1>(w), to = get<2>(w);
    if (d_min[from][to] < a) {cout << -1 << endl; return 0;}
    if (d_min[from][to] > a) {
      d_min[from][to] = a; d_min[to][from] = a;
      ans += a;
    }
    for (int i = 0; i < n; ++i) {
      if (i==from) continue;
      d_min[i][from] = min(d_min[i][from], d_min[i][to] + d_min[to][from]);
      d_min[from][i] = d_min[i][from];
    }
    for (int i = 0; i < n; ++i) {
      if (i==to) continue;
      d_min[i][to] = min(d_min[i][to], d_min[i][from] + d_min[to][from]);
      d_min[to][i] = d_min[i][to];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i==j) {
        if (d_true[i][j] != 0) {cout << -1 << endl; return 0;}
        continue;
      }
      if (d_min[i][j] != d_true[i][j]) {
        cout << -1 << endl; return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2548
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
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; }
const int MAX_N = 3030;
const int MAX_T = 3030;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> time(N), value(N);
    for (int i = 0; i < N; i++) cin >> time[i] >> value[i];
    
    int dp1[MAX_N][MAX_T] = {0}; // 区間[1, i]の食べ物を j 分以内に食べるときの最大値 
    int dp2[MAX_N][MAX_T] = {0}; // 区間[i, N]の食べ物を j 分以内に食べるときの最大値
    
    for (int i = 0; i < N; i++) {
        for (int t = 0; t < MAX_T; t++) {
            chmax(dp1[i+1][t], dp1[i][t]);
            if (0 <= t - time[i]) chmax(dp1[i+1][t], dp1[i][t-time[i]]+value[i]);
        }
    }
    
    for (int i = N; i > 0; i--) {
        for (int t = 0; t < MAX_T; t++) {
            chmax(dp2[i-1][t], dp2[i][t]);
            if (0 <= t - time[i-1]) chmax(dp2[i-1][t], dp2[i][t-time[i-1]]+value[i-1]);
        }
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int t = 0; t < T; t++) {
            int res = dp1[i][t] + dp2[i+1][T-1-t] + value[i];
            chmax(ans, res);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 71936
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	for(int i = 1; i <= 360; ++i){
		if((i*x)%360 == 0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, x;
	cin >> n >> m >> x;
	int l = 0, r = 0;
	rep(i,m){
		int a;
		cin >> a;
		if(a < x) ++l;
		else ++r;
	}
	int ans = min(l, r);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[110];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%s",ss+1);int len=strlen(ss+1);
	int m=read();
	int s1=1;
	for(int i=2;i<=len;i++)
	{
		if(ss[i]==ss[i-1])s1++;
		else break;
	}
	if(s1==len){printf("%lld\n",1LL*len*m/2);return 0;}
	int s2=1;
	for(int i=len-1;i>=1;i--)
	{
		if(ss[i]==ss[i+1])s2++;
		else break;
	}
	int tot=0,d=0;
	for(int i=s1+1;i<=len-s2+1;i++)
	{
		if(ss[i]!=ss[i-1])tot+=d/2,d=1;
		else d++;
	}
	int sum=s1/2+tot+s2/2;
	if(ss[1]==ss[len])printf("%lld\n",1LL*((s1+s2)/2+tot)*(m-1)+sum);
	else printf("%lld\n",1LL*sum*m);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String str = sc.next();
   int count = 0;
   int countmem = 0;
 for (int i = 0; i < str.length(); i++) {
	if(str.charAt(i) == 'A' || str.charAt(i) == 'T' ||
       str.charAt(i) == 'C' || str.charAt(i) == 'G'){
       count++;
    }else{
      if(countmem < count){
      countmem = count;
      }
      count = 0;
    }
   if(i == str.length()-1 && countmem < count){
      countmem = count;      
   }
  }
    System.out.print(countmem);
 }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int a[100010],b[100010];
int main()
{
	int k,n,i,x=0,y=0,t;
	long long s=1e18,h;
	scanf("%d%d",&n,&k);
	for(i=1; i<=n; i++)
	{
		scanf("%d",&t);
		if(t==0) k--;
		else if(t<0) a[++x]=-t;
		else if(t>0) b[++y]=t;
	}
	if(k==0||k==-1)
	{
		printf("0");
		return 0;
	}
	sort(a+1,a+1+x);
	sort(b+1,b+1+y);
	a[0]=b[0]=0;

	for(i=0; i<=k&&i<=x; i++)
	{
		if(k-i>y) continue;
		h=a[i]+b[k-i];
		if(i!=0&&i!=k) h=h+min(a[i],b[k-i]);
		s=min(s,h);
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 640