akhauriyash/Code-Regression huggingface dataset:
import sys
import math
def koratsu(n,i):
    if(n==1):
        return i
    elif(n%2==0):
        n=n//2
        i=i+1
        return koratsu(n,i)
    else:
        n=3*n+1
        i=i+1
        return koratsu(n,i)
i=0
while i<50:
    n=int(input())
    if(n==0):
        break
    kaisu=koratsu(n,i)
    print(str(kaisu))


Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n=5;
  vector<int>v(5);
  for(int i=0;i<n;i++)
  {
  cin >> v[i];
    if(v[i]==0)
    {
      cout << i+1;
      return 0;
  }}
}

Measured memory_bytes: 3592
# doc: git.io/vy4co
def graph(inp):
    nodes = dict()
    N = None
    for line in inp.splitlines():
        if N is None:
            N = int(line.strip())
            for k in range(1, N + 1):
                nodes[k] = set()
            continue
        i, k = map(int, line.split())
        nodes[i].add(k)
        nodes[k].add(i)
    return nodes

def trace(nodes, start, exclude=None):
    return (start,) + max([trace(nodes, n, exclude=start) for n in nodes[start] if n != exclude], key=len, default=())

def tree(nodes, start, exclude=None):
    return tup([tree(nodes, n, exclude=start) for n in nodes[start] if n != exclude])

class tup(tuple):
    def __new__(cls, arg=()):
        rv = super().__new__(cls, arg)
        rv.height = (1 + min((t.height[0] for t in rv), default=-1),
                     1 + max((t.height[1] for t in rv), default=-1))
        rv.edges = len(rv) + sum(t.edges for t in rv)
        return rv

def combinations(nodes):
    path = trace(nodes, trace(nodes, next(iter(nodes)))[-1])
    D = len(path)
    C = D // 2
    root = path[D // 2]
    if D % 2:
        thetree = tree(nodes, root)
        return sum(enum(limits, thetree) for limits in zip(range(C + 1), reversed(range(C + 1))))
    else:
        left = path[D // 2 - 1]
        left_tree = tup([tree(nodes, left, exclude=root)])
        right_tree = tree(nodes, root, exclude=left)
        lg = [i // 2 for i in range(1, C * 2 + 2)]
        ll = list(zip(lg, reversed(lg)))
        rg = [i // 2 for i in range(C * 2 + 1)]
        rl = list(zip(rg, reversed(rg)))
        tot = 0
        for i in range(len(ll)):
            left_limits = ll[i]
            right_limits = rl[i]
            lrv = enum(left_limits, left_tree) - sum(enum(ne, left_tree) for ne in ll[i - 1: i] + ll[i + 1: i + 2])\
                if sum(left_limits) > C else enum(left_limits, left_tree)
            rrv = enum(right_limits, right_tree)
            tot += lrv * rrv
        return tot

def enum(limits, shape, _cache=dict()):
    limits = tuple(sorted(limits))
    r, b = limits
    low, high = shape.height

    if r >= high:
        return 2 ** shape.edges

    if 0 in limits:
        return 1

    key = hash((r, b, shape))
    if key not in _cache:
        tot = 1
        for subtree in shape:
            acc = 0
            for sublimit in ((r - 1, b), (r, b - 1)):
                acc += enum(sublimit, subtree)
            tot *= acc
        _cache[key] = tot
    return _cache[key]

import sys
sys.setrecursionlimit(99999)
g = graph(sys.stdin.read())
rv = combinations(g)
print(rv % (10 ** 9 + 7))

Measured memory_bytes: 24176
#include<stdio.h>
#include<limits.h>

int main()
{
	int a,max1,max2,max3;
	max1=max2=max3=INT_MIN;
	while(~scanf("%d",&a)){
		if(a>max1){
			max3=max2;
			max2=max1;
			max1=a;
		}else if(a>max2){
			max3=max2;
			max2=a;
		}else if(a>max3){
			max3=a;
		}
	}
	printf("%d\n%d\n%d\n",max1,max2,max3);
	return 0;
}


Measured memory_bytes: 2032
#include<stdio.h>

int main(){
    long int i,n,number[10000],min,max,sum;
    scanf("%ld",&n);
    
    for (i=0; i<n; i++){
        scanf("%ld",&number[i]);
    }

    int temp, j, k;
    for (j = 0; j < n; ++j)
    {
      for (k = j + 1; k < n; ++k)
      {
         if (number[j] < number[k])
         {
            temp = number[j];
            number[j] = number[k];
            number[k] = temp;
         }
      }
    }

    min=number[n-1];
    max=number[0];

    int o;
    sum=0;
    for (o=0; o<n; o++){
        sum=sum+number[o];
    }

    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}


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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int a,b,x;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> a >> b >> x;
	if (2*x>=a*a*b)
    {
        ld tem= atan(((ld)(2*b)-(((ld)(2*x))/((ld)(a*a))))/((ld)(a)));
        cout << fixed << setprecision(10) << 180.0*tem/acos(-1);
    } else
    {
        ld tem=atan ((ld)(2*x)/((ld)(a*b*b)));
        cout << fixed << setprecision(10) << (90.0-180*tem/acos(-1));
    }
}


Measured memory_bytes: 256
def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [list(input().split()) for i in range(M)]
    was = [0] * N
    acs = [0] * N
    penaltyCount = 0
    for sp in SP:
        if acs[int(sp[0])-1] == 1:
            continue
        if acs[int(sp[0])-1] == 0 and sp[1] == "WA":
            was[int(sp[0])-1] += 1
        elif acs[int(sp[0])-1] == 0 and sp[1] == "AC":
            acs[int(sp[0])-1] = 1
            penaltyCount += was[int(sp[0])-1]

    print(sum(acs), penaltyCount)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27416
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    vector<int> c(26);
 
    for(int i=0;i<s.size();i++){
        c.at((int)s.at(i)-(int)'a')++;
    }

    string ans = "None";

    for(int i=0;i<26;i++){
        if(c.at(i)==0){
            ans = (char)((int)'a'+i);
            break;
        }
    }

    cout << ans <<endl;
}

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

int main(){
    int m;
    cin >>  m;
    int d;
    cin >>  d;
    int d10=d/10;
    int d2=d%10,ans=0;
    
    for(int i=2;i<=d10-1;i++){
        for(int j=2;j<10;j++){
            if(i*j<=m){
                ans++;
            }
        }
    }

    for(int i=2;i<=d2;i++){
        if(i*d10<=m){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
from itertools import combinations
from math import sqrt
n=int(input())

k=int(sqrt(2*n))+1

if(k*(k-1)==2*n):
    res=[[0 for _ in range(k-1)] for _ in range(k)]
    num=[0 for _ in range(k)]
    for i,pair in enumerate(combinations(range(k),2)):
        for a in pair:
            res[a][num[a]]=i+1
            num[a]+=1

    print('Yes')
    print(k)
    for row in res:
        print(k-1,end=' ')
        for e in row:
            print(e,end=' ')
        print('')
else:
    print('No')

Measured memory_bytes: 12496
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int K,A,B;
int b;

signed main(){

    in(K,A,B);
    if(K-A+1<2){
        out(K+1);
        return 0;
    }
    int Kleft=K-A+1;
    // show(Kleft);
    b=A;
    if(B-A>2){
        b+=(Kleft/2)*(B-A);
        if(Kleft&1) b++;
    }else{
        b+=Kleft;
    }

    out(b);

    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi A(N);rep(i,N)cin>>A[i];
  ll ans=1000000;
  for(int i=-100;i <=100;i++){
    ll tot =0; 
    for(int j=0;j<N;j++){
      tot+=(i-A[j])*(i-A[j]);
    }
    ans =min(ans,tot );
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

ll TEN(int n) {
    if(n == 0) {
        return 1;
    }
    return 10LL * TEN(n - 1);
}

P transfar(string s) {
    int n = s.size();
    int id = 0;
    for(; id < n; id++) {
        if(s[id] == '.') {
            break;
        }
    }
    if(id == n) {
        return P(stoll(s), 1LL);
    }
    string t = s.substr(0, id) + s.substr(id + 1, n - id);
    debug("t", t);
    ll a = stoll(t);
    ll b = TEN(n - id - 1);
    ll g = gcd(a, b);
    a /= g;
    b /= g;
    return P(a, b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<P> v(N);
    map<pair<int, int>, ll> fraction;
    auto hoge = [](ll n) -> pair<int, int> {
        int two = 0, five = 0;
        while(n % 2 == 0) {
            n /= 2;
            two++;
        }
        while(n % 5 == 0) {
            n /= 5;
            five++;
        }
        return make_pair(two, five);
    };
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        v[i] = transfar(s);
        debug("v[i]", v[i].first, v[i].second);
        auto a = hoge(v[i].first);
        auto b = hoge(v[i].second);
        debug("a", a.first, a.second);
        debug("b", b.first, b.second);
        fraction[P(a.first - b.first, a.second - b.second)]++;
    }
    for(auto p1 : fraction) {
        for(auto p2 : fraction) {
            if(p1.first.first + p2.first.first >= 0 &&
               p1.first.second + p2.first.second >= 0) {
                if(p1.first < p2.first) {
                    ans += p1.second * p2.second;
                } else if(p1.first == p2.first) {
                    ans += p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n,a,b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  REP(i,n)cin >> v[i];
  vector<ll> dist(n);
  REP(i,n-1)dist[i] = v[i+1]-v[i];
  ll res = 0;
  REP(i,n-1)dist[i]*a <= b ? res += dist[i]*a : res += b;
  cout << res << endl;



  

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final int N = stdin.nextInt();
	final int K = stdin.nextInt();

	final long[][] rects = new long[ N ][ 6 ];
	for ( int i = 0; i < N; i++ ) {
	    for ( int j = 0; j < 6; j++ ) {
		rects[ i ][ j ] = stdin.nextLong();
	    }
	}
	final ArrayList<Long> xs = new ArrayList<Long>();
	final ArrayList<Long> ys = new ArrayList<Long>();
	final ArrayList<Long> zs = new ArrayList<Long>();

	for ( int i = 0; i < N; i++ ) {
	    if ( !xs.contains( rects[ i ][ 0 ] ) ) {
		xs.add( rects[ i ][ 0 ] );
	    }
	    if ( !xs.contains( rects[ i ][ 3 ] ) ) {
		xs.add( rects[ i ][ 3 ] );
	    }
	    if ( !ys.contains( rects[ i ][ 1 ] ) ) {
		ys.add( rects[ i ][ 1 ] );
	    }
	    if ( !ys.contains( rects[ i ][ 4 ] ) ) {
		ys.add( rects[ i ][ 4 ] );
	    }
	    if ( !zs.contains( rects[ i ][ 2 ] ) ) {
		zs.add( rects[ i ][ 2 ] );
	    }
	    if ( !zs.contains( rects[ i ][ 5 ] ) ) {
		zs.add( rects[ i ][ 5 ] );
	    }
	}
	Collections.sort( xs );
	Collections.sort( ys );
	Collections.sort( zs );

	final int[][][] compressedRect = new int[ xs.size() ][ ys.size() ][ zs.size() ];

	for ( int i = 0; i < N; i++ ) {
	    final int fromX = Collections.binarySearch( xs, rects[ i ][ 0 ] );
	    final int toX = Collections.binarySearch( xs, rects[ i ][ 3 ] );
	    final int fromY = Collections.binarySearch( ys, rects[ i ][ 1 ] );
	    final int toY = Collections.binarySearch( ys, rects[ i ][ 4 ] );
	    final int fromZ = Collections.binarySearch( zs, rects[ i ][ 2 ] );
	    final int toZ = Collections.binarySearch( zs, rects[ i ][ 5 ] );

	    for ( int x = fromX; x < toX; x++ ) {
		for ( int y = fromY; y < toY; y++ ) {
		    for ( int z = fromZ; z < toZ; z++ ) {
			compressedRect[ x ][ y ][ z ]++;
		    }
		}
	    }
	}

	long volume = 0L;
	for ( int x = 0; x < compressedRect.length - 1; x++ ) {
	    for ( int y = 0; y < compressedRect[ x ].length - 1; y++ ) {
		for ( int z = 0; z < compressedRect[ x ][ y ].length - 1; z++ ) {
		    if ( compressedRect[ x ][ y ][ z ] >= K ) {
			volume += ( xs.get( x + 1 ) - xs.get( x ) ) *
			    ( ys.get( y + 1 ) - ys.get( y ) ) *
			    ( zs.get( z + 1 ) - zs.get( z ) );
		    }
		}
	    }
	}
	System.out.println( volume );
    }    
}

Measured memory_bytes: 28552
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int cnt=0;
    rep(i,n){
        if(a[i]==i+1) cnt++;
    }
    rep(i,n-1){
        if(a[i]==i+1&&a[i+1]==i+2){
            cnt--;
            i++;
        }
    }
    cout<<cnt<<endl;
    
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;

int dp[6600][3300];
vector<bool> G;

int mod = 924844033;

int recur(int i, int n) {
    if (n == 0)return 1;
    if (i >= G.size())return 0;
    if (dp[i][n] != -1)return dp[i][n];
    if (G[i])return dp[i][n] = (recur(i + 1, n) + recur(i + 2, n - 1)) % mod;
    return dp[i][n] = (recur(i + 1, n) + recur(i + 1, n - 1)) % mod;
}

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000], inv[1100000];
int mod_fact(int n, int m) {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        fact[i] = fact[i - 1] * i % m;
        inv[i] = m - inv[m % i] * (m / i) % m;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % m;
    }
}

signed main() {
    cin >> N >> K;
    int L = 2 * K;
    for (int i = 1; i <= L; i++) {
        for (int j = i; j <= N; j += L) {
            if (j + K <= N)G.push_back(true);
            if (j - K >= 1)G.push_back(true);
        }
        G[G.size() - 1] = false;
    }
    mod_fact(3300, mod);
    for (int i = 0; i < 6600; i++)for (int j = 0; j < 3300; j++)dp[i][j] = -1;
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        (ans += recur(0, i) % mod * fact[N - i] % mod * (i % 2 == 0 ? 1 : -1) + mod) %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 175872
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    string ans ="NO";
    if(a+b+c==17){
        if(a==7){
            if(b==c){
                ans="YES";
            }
        }else if(b==7){
            if(c==a){
                ans="YES";
            }
        }else if(c==7){
            if(a==b){
                ans="YES";
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

const int MOD = (int)1e9+7;

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

	int x1=0;
	for(int i=0;i<S.size();i++){
		if(i%2==0 && S.at(i)=='0')	x1++;
		if(i%2==1 && S.at(i)=='1')	x1++;
	}
	int x2=0;
	for(int i=0;i<S.size();i++){
		if(i%2==0 && S.at(i)=='1')	x2++;
		if(i%2==1 && S.at(i)=='0')	x2++;
	}
	cout << min(x1,x2) << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int main(void){
	long long h, w;
	scanf("%lld %lld", &h, &w);
	if(h == 1 || w == 1)
		printf("1");
	else
		printf("%lld", ((h * w) % 2 == 1) ? h * w / 2 + 1 :  h * w / 2);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define SORT(x) sort((x).begin(),(x).end())
#define MEMSET(x,y) memset((x),(y),sizeof(x))
#define P pair<int,int>

typedef long long ll;
using namespace std;

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

  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    string s; cin >> s;
    int a=s[0];
    int ans=0;    
    for(int i=1;i<s.length();i++){
        if(i%2==0){
            if(s[i]!=a){
                ans++;
            }
        }else{
            if(s[i]==a){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
n, y = map(int, input().split())
res10000, res5000, res1000 = -1, -1, -1
for i in range(n+1):
  if res10000 != -1:
    break
  for j in range(n-i+1):
    a = i
    b = j
    c = n - a - b
    total = 10000*a + 5000*b + 1000*c
    if total == y:
      res10000, res5000, res1000 = a, b, c
     
    if res10000 != -1:
      break

print(str(res10000) + " " + str(res5000) + " " + str(res1000))

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

using ll = long long;
#define rep(i, j) for(ll i=0; i < (ll)(j); i++)

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

class Solver {
  public:
    bool solve() {
        string s; cin >> s;
        reverse(all(s));
        ll sum = 0;        
        rep(bit, (1 << (s.size() - 1))) {
            ll keta = 1;
            rep(i, s.size()) {
                sum += (s[i] - '0') * keta;
                keta *= 10;
                if(bit & (1 << i)) {
                    keta = 1;
                }
            }
        }        
        cout << sum << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

int main()
{
	int N,T,A;
	cin >> N;
	cin >> T >> A;
	int tmp,ans;
	double t;
	double min = 100000;
	for(int i(0);i<N;++i){
		cin >> tmp;
		t = double(T)-tmp*0.006-double(A);
		if(t<0){
			t = -t;
		}
		if(t<min){
			min = t;
			ans = i+1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,n;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl; 
        return 0; 
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1) 
    {
        n=1;
    }
    cout<<((a-b)/(b-c)+n)*2+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int P, Q, R;

    scanf("%d %d %d", &P, &Q, &R);

    if(P<=R && Q<=R){
        printf("%d", P+Q);
    }else if(R<=P && Q<= P){
        printf("%d", R+Q);
    }else{
        printf("%d", P+R);
    }

    return 0;
}

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

#define MAX_N 200000
#define MAX_K 100000
#define MAX_L 100000



class UnionFind {
    int par[MAX_N];  // 親
    int my_rank[MAX_N]; // 木の深さ

public:
    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            my_rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (my_rank[x] < my_rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (my_rank[x] == my_rank[y]) my_rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

// int N = 4;
// int K = 3;
// int L = 1;
// int p[] = {1, 2, 3};
// int q[] = {2, 3, 4};
// int r[] = {2};
// int s[] = {3};

int N, K, L;
int p[MAX_K], q[MAX_K], r[MAX_L], s[MAX_L];

typedef pair<int, int> P;
map<P, int> mp;

int main() {
    cin >> N >> K >> L;
    UnionFind uf, train;
    uf.init(N);
    train.init(N);

    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        uf.unite(p - 1, q - 1);
    }

    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        train.unite(r - 1, s - 1);
    }

    for (int i = 0; i < N; i++) {
        mp[P(uf.find(i), train.find(i))]++;
    }

    for (int i = 0; i < N; i++) {
        cout << mp[P(uf.find(i), train.find(i))] << " ";
    }
    printf("\n");
}

Measured memory_bytes: 15104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

int n, m;
int field[100][100] = {0};
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

int solve_dfs(int x, int y, int t)
{
	int res = 0;
	
	if(!( x < 0 || x >= m || y < 0 || y >= n || field[y][x] == 0 ))
	{
		res = t;
		field[y][x] = 0;
		
		FOR(k, 0, 4)
		{
			if( field[y+dy[k]][x+dx[k]] )
				res = max(res, solve_dfs(x+dx[k], y+dy[k], t+1));
		}
		
		field[y][x] = 1;
	}
	
	return res;
}
	
int solve()
{
	int res = 0;
	
	FOR(j, 0, n)
		FOR(i, 0, m)
		{
			res = max(res, solve_dfs(i, j, 1));
		}
		
	return res;
}
	
int main()
{
	while(cin >> m >> n, (n||m))
	{
		FOR(j, 0, n)
			FOR(i, 0, m)
			{
				cin >> field[j][i];
			}
			
		cout << solve() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<vector<mint> > dp;
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    ll m = s.length();
    dp.resize(n+2, vector<mint> (n+2, 0));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
    	dp[i][0] = dp[i-1][1] + dp[i-1][0];
    	for(int j=1;j<=n;j++){
    		dp[i][j] = dp[i-1][j+1] + dp[i-1][j-1] * 2;
    	}
    }
    cout << dp[n][m] / mint(2).pow(m) << endl;
    return 0;
}


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

struct _six {
    int f1;
    int f2;
    int f3;
    int f4;
    int f5;
    int f6;
} six;

char cmd[105];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    scanf("%d", &six.f1);
    scanf("%d", &six.f2);
    scanf("%d", &six.f3);
    scanf("%d", &six.f4);
    scanf("%d", &six.f5);
    scanf("%d", &six.f6);
    scanf("%s", cmd);
    int len = strlen(cmd);
    int n1, n2, n3, n4, n5, n6;
    for (int i = 0; i < len; ++i) {
        n1 = six.f1;
        n2 = six.f2;
        n3 = six.f3;
        n4 = six.f4;
        n5 = six.f5;
        n6 = six.f6;
        switch (cmd[i]) {
            case 'S':
                six.f1 = n5;
                six.f2 = n1;
                six.f3 = n3;
                six.f4 = n4;
                six.f5 = n6;
                six.f6 = n2;
                break;
            case 'E':
                six.f1 = n4;
                six.f2 = n2;
                six.f3 = n1;
                six.f4 = n6;
                six.f5 = n5;
                six.f6 = n3;
                break;
            case 'N':
                six.f1 = n2;
                six.f2 = n6;
                six.f3 = n3;
                six.f4 = n4;
                six.f5 = n1;
                six.f6 = n5;
                break;
            case 'W':
                six.f1 = n3;
                six.f2 = n2;
                six.f3 = n6;
                six.f4 = n1;
                six.f5 = n5;
                six.f6 = n4;
                break;
        }
    }
    printf("%d\n", six.f1);

    return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <list>
#include <algorithm>
#include <climits>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m,a,b,c,mi,ret;
	int info[100][100];

	while(cin >> n && n){
		cin >> m;
		ret = 0;
		rep(i,100)rep(j,100)info[i][j] = INT_MAX;

		rep(i,m){
			scanf("%d,%d,%d\n",&a,&b,&c);
			info[a][b] = info[b][a] = (c/100)-1;
		}

		list<int> X,Y;
		X.push_back(0);
		for(int i=1;i<n;i++){
			Y.push_back(i);
		}

		while(!Y.empty()){
			mi = INT_MAX;
			for(list<int>::iterator it = X.begin(); it != X.end(); ++it){
				rep(i,n){
					if( count(Y.begin(),Y.end(),i) ){
						if(info[*it][i]<mi){
							a = i;
							mi = info[*it][i];
						}
					}
				}
			}
			X.push_back(a);
			for(list<int>::iterator it = Y.begin(); it != Y.end(); ++it){
				if((*it)==a){
					Y.erase(it);
					break;
				}
			}
			ret+=mi;
		}
		cout << ret << endl;
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

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

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    cout << (a == (b.substr(0, a.size())) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3640
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
x = []
for i, v in cnt.items():
    x.append([i, v])
x.sort()
left = 0
right = len(x) - 1
ans = 0
while left < right:
    if x[left][1] == 1:
        left += 1
    elif x[right][1] == 1:
        right -= 1
    else:
        x[left][1] -= 1
        x[right][1] -= 1
        ans += 2
if x[left][1] == 1:
    pass
else:
    if x[left][1] % 2 == 0:
        ans += x[left][1]
    else:
        ans += x[left][1]-1
print(n - ans)


Measured memory_bytes: 23644
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, k;
    cin >> a >> b >> k;
    rep(i, k)
    {
        if (i % 2 == 0)
        {
            a -= a % 2;
            b += a / 2;
            a /= 2;
        }
        else
        {
            b -= b % 2;
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int solve(){
  int n,m;
  int a[SIZE] ={} ,b[SIZE] = {};
  map<int,int> mm;

  scanf("%d%d",&n,&m);

  if(n==0) return false;
  
  for(int i=1;i<=n;i++){
    scanf("%d",a+i);
  }
  for(int i=0;i<n;i++){
    a[i+1] += a[i];
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<=n;j++){
      mm[a[j]-a[i]]++;
    }
  }

  for(int i=1;i<=m;i++){
    scanf("%d",b+i);
  }
  for(int i=0;i<m;i++){
    b[i+1] += b[i];
  }

  ll ans = 0;
  
  for(int i=0;i<m;i++){
    for(int j=i+1;j<=m;j++){
      ans += mm[b[j]-b[i]];
    }
  }

  printf("%lld\n",ans);
  
  
  return true;
}

int main(){
  while(solve());

  return 0;
}

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

#define MAX 25
#define NIL -1

struct Node {
    int parent;
    int left;   //一番左の子を入れる　NIL(-1)なら子がいない
    int right;  //再帰的に子を入れる
} info[MAX];


int depth[MAX];
int height[MAX];

void print(int node){

    cout << "node " << node;
    cout << ": parent = " << info[node].parent;
    
    cout << ", sibling = ";
    if(info[node].parent == NIL){
        cout << -1;
    }
    else if(info[info[node].parent].left == node){
        cout << info[info[node].parent].right;
    }
    else if(info[info[node].parent].right == node){
        cout << info[info[node].parent].left;
    }

    
    cout << ", degree = ";
    int deg = 0;
    if(info[node].left != NIL){
        deg++;
    }
    if(info[node].right != NIL){
        deg++;
    }
    cout << deg;
    
    cout << ", depth = " << depth[node];
    cout << ", height = " << height[node] << ", ";

    if(info[node].parent == NIL){
        cout << "root";
    }
    else if(info[node].left == NIL && info[node].right == NIL){
        cout << "leaf";
    }
    else{
        cout << "internal node";
    }

    cout << "\n";
}

void setDepth(int node, int dep){
    depth[node] = dep;
    if(info[node].right != NIL){
        setDepth(info[node].right, dep+1);
    }
    if(info[node].left != NIL){
        setDepth(info[node].left, dep+1);
    }
}

/*ここ分からなかった*/
int setHeight(int node){
    int h1 = 0, h2 = 0;
    if(info[node].left != NIL){
        h1 = setHeight(info[node].left) + 1;
    }
    if(info[node].right != NIL){
        h2 = setHeight(info[node].right) + 1;
    }

    return height[node] = max(h1, h2);
}

int main() {

    int n;
    cin >> n;
    rep(i, n){ //初期化
        info[i].parent = NIL;
    }

    int node, left, right;
    rep(i, n){
        cin >> node >> left >> right;
        info[node].left = left;
        info[node].right = right;
        if(left != NIL){
            info[left].parent = node;
        }
        if(right != NIL){
            info[right].parent = node;
        }
    }

    int root;
    rep(i, n){
        if(info[i].parent == NIL){
            root = i;
        }
    }

    setDepth(root, 0);
    setHeight(root);

    rep(i, n){
        print(i);
    }

    return 0;
}


Measured memory_bytes: 3080
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
struct sushi
{
    ll id,t,d;
};
sushi sushis[100010];

bool comp(const sushi &a,const sushi &b){
    if(a.d!=b.d){
        return a.d >= b.d;
    }else{
        return a.t > b.t;
    }
}

int main() {
    ll n,k;
    std::cin >> n>>k;
    for (int i = 0; i < n; i++) {
        ll tmp1,tmp2;
        std::cin >> tmp1>>tmp2;
        sushis[i].id = i;
        sushis[i].t = tmp1;
        sushis[i].d = tmp2;
    }
    sort(sushis,sushis+n,comp);
    ll val = 0;
    ll now = 0;

    set<ll> kinds;
    priority_queue<ll, vector<ll>, greater<ll> > que;
    
    for (int i = 0; i < k; i++) {
        if(kinds.count(sushis[i].t) == 1){
            que.push(sushis[i].d);
        }
        val += sushis[i].d;
        kinds.insert(sushis[i].t);
        now = i;
    }
    ll f[100010];
    Fill(f,(ll)-1e15);
    f[kinds.size()] = val;
    ll si = kinds.size();

    for (int i = si+1; i <= k; i++) {
        if(!que.empty()){
            ll current = que.top();
            que.pop();

            for (int j = now+1; j < n; j++) {
                if(kinds.count(sushis[j].t)==0){
                    kinds.insert(sushis[j].t);
                    f[i] = f[i-1]-current+sushis[j].d;
                    now = j;
                    break;
                }else{
                    now = j;
                    continue;
                }
            }
            
        }else{
            break;
        }
    }
    ll ans = 0;
    for (int i = si; i <= k; i++) {
        ans = max(ans,f[i]+(ll)i*i);
        // cout<<ans<<" "<<i<<endl;
        
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 6648
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;


int main(void)
{
    /*
    ABC 103 D, 2018_07_21
    https://atcoder.jp/contests/abc103/tasks/abc103_d
    貪欲法, 区間スケジューリング
    */
    int N, a;
    cin >> N;

    int sum =0;
    for(int i=0; i<N; i++)
    {
        cin >> a;
        sum += a-1;
    }

    cout << sum << endl;



    return 0;
}


Measured memory_bytes: 3636
//cwystc <--> 陈威宇是天才  --by cwy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<48||ch>57)&&ch!=45)ch=getchar();
	if (ch==45)f=-1,ch=getchar();
	while (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();
	x*=f;
}

//-------------------------------------------------head-------------------------------------------------

#define maxn 200005
int n,a[maxn];
int _abs(int x){
	return (x<0)?-x:x;
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	ll res=0;
	rep(i,1,n)res+=_abs(a[i]-(a[(n+1)/2]));
	printf("%lld\n",res);return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> p;
    int god=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<3200){
        p[a[i]/400]++;
        }
        else{
            god++;
        }
    } 
    if(p.size()==0){
        cout<<1<<" "<<god<<endl;
    }
    else{
    cout<<p.size()<<" "<<p.size()+god<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    //ans = max({a,b,c});
    ans = max({
            10*a+b+c,
            a+10*b+c,
            a+b+10*c
            });
    cout << ans << endl;
}




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

int main(){
	int ans=0,mx=0;
	for(int i=0;i<5;++i){
		int a; cin>>a;
		if(a%10!=0)mx=max(mx,10-a%10),a=(a/10+1)*10;
		ans+=a;
	}
	cout<<ans-mx<<"\n"s;
}


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

int main () {
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans;
}
      


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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(){ 
    int n, m; cin >> n >> m;
    vector<int> price(m);
    vector<vector<int>> numbers(m, vector<int>(n, 0));
    rep(i, m){
        int b; cin >> price[i] >> b;
        rep(j, b){
            int c; cin >> c; c--;
            numbers[i][c] = 1;
        }
    }

    vector<int> dp(pow(2, n), INF);
    dp[0] = 0;
    rep(i, m){
        int num = 0;
        rep(j, n){
           if(numbers[i][j] == 1) num += pow(2, j); 
        }
        for(int bit=0; bit < (1<<n) - 1; bit++){
            if(dp[bit] == INF) continue;
            int next = bit | num;
            chmin(dp[next], dp[bit] + price[i]);
        }
    }
    int res = dp[pow(2, n)-1];
    if(res == INF) res = -1;
    cout << res << ln;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

string box[6]={"357","375","537","573","735","753"};
ll n = 0;

bool ck(string num){
	bool a=false,b=false,c=false;
	rep(i,num.size()){
		if(a&&b&&c)return true;
		switch(num[i]){
			case '3':
				a = true;
				break;
			case '5':
				b = true;
				break;
			case '7':
				c = true;
				break;
		};
	}
	return a&&b&&c;
}

ll dfs(ll num){
	if(num>n)return 0;
	ll ans = 0;
	if(ck(to_string(num)))ans++;
	rep(i,3){
		ans += dfs(num*10+3+2*i);
	}
	return ans;
}


int main(){
	cin>>n;
	cout<<dfs(0)<<endl;
	return 0;
}

Measured memory_bytes: 256