akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll minthis(ll a, ll b){return a<b?a:b;}
ll maxthis(ll a, ll b){return a>b?a:b;}
bool sortbysec(const pair<int, int>& a,const pair<int, int>& b){return (a.second < b.second);} 

const int MAX = 1000001;

// array to store prime factors
int factor[MAX] = { 0 };

// function to generate all prime factors
// of numbers from 1 to 10^6
void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (int i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}
 
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;

    // stores the smallest prime number
    // that divides n
    int dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    int c = 1;

    // reduces to the next number after prime
    // factorization of n
    int j = n / factor[n];

    // false when prime factorization is done
    while (j != 1) {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,
           then we again set c=1 and change dup to the new
           prime factor, and apply the formula explained
           above. */
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}
 
void solve(){
    generatePrimeFactors();
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1 ; i < n ; i++){
        ans +=  calculateNoOFactors(n-i);
    }
    cout << ans << "\n";
}
 
 
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
  return 0; 
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)

using ll = long long;
using namespace std;

int main(){
    int N,index;
    //char S[4010];
    int ans=0;
    //char s[200];
    //bool flag = false;
    //vector<int> a(N,0);

    cin >> N;
    vector<int> A(N,0);
    rep(i,N) cin >> A[i];

    vector<int>::iterator It = max_element(A.begin(),A.end());
    ans = *It;
    index = distance(A.begin(),It);

    sort(A.begin(),A.end(),std::greater<int>());

    rep(i,N){
        if(i!=index) cout << ans << endl;
        else cout << A[1] << endl;
    }
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100000

int h,t,A1[N];
char A2[N][10];

void enqueue(char *s, int w)
{
  int i = 0;

  if(isFull()){
    fprintf(stderr,"overflow!\n");
    exit(2);
  }

  A1[t] = w;
  strcpy(A2[t],s);
  if(t + 1 == N) t = 0;
  else t++;
}

int dequeue()
{
  int w;

  if(isEmpty()){
    fprintf(stderr,"underflow!\n");
    exit(1);
  }

  w = h;
  if(h + 1 == N) h = 0;
  else h++;
 
  return w;
}

int isEmpty()
{
  return h == t;

}

int isFull()
{
  return h == (t + 1) % N;
}

void roundschedule(int x, int y)
{
  int i,num,z;
  int total = 0;
  char argv[10];

  for(i=0;i<x;i++){
    scanf("%s%d",argv,&num);
    enqueue(argv,num);
  }

  while(!isEmpty()){
    num = dequeue();
    if(y>=A1[num]){
      total += A1[num];
      printf("%s %d\n",A2[num],total);
    }
    else{
      z = A1[num] - y;
      total += y;
      enqueue(A2[num],z);
    }
  }
}

int main()
{
  int x,y;
  scanf("%d%d",&x,&y);
  roundschedule(x,y);

  return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const double PI=3.14159265;
int main() {
  double r;
  cin >> r;
  cout << 2 * r * PI << endl;;
  return 0;
}

Measured memory_bytes: 3776
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s,t;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    cin>>s;
    cin>>t;

    fo(i,n)
    {
        cout<<s[i]<<t[i];
    }

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    string s;
    cin>>s;
    s[3] = '8';
    cout<<s<<endl;
}





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

int K, N;
#define MAXN 300000
int d[MAXN];

int main() {
  scanf("%d%d", &K, &N);
  if(K % 2 == 0) {
    printf("%d", K / 2);
    for(int i = 0; i < N - 1; ++i) printf(" %d", K);
    printf("\n");
  } else if(K == 1) {
    printf("1");
    for(int i = 0; i < (N + 1) / 2 - 1; ++i) printf(" %d", 1);
    printf("\n");
  } else {
    printf("%d", (K + 1) / 2);
    for(int i = 0; i < N - 1; ++i) d[i] = (K + 1) / 2;
    for(int rep = 0; rep < N / 2; ++rep) {
      for(int i = N - 2; ; --i) {
        if(d[i] > 0) {
          --d[i];
          if(d[i] > 0) {
            for(int j = i + 1; j < N - 1; ++j) d[j] = K;
          }
          break;
        }
      }
    }
    for(int i = 0; i < N - 1; ++i) {
      if(d[i] == 0) break;
      printf(" %d", d[i]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// s = "112223" -> [[1,2],[2,3],[3,1]]
vector<pair<int,int>> rle (vector<int> x) {
  vector<pair<int,int>> res;
  int n = (int)x.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && x[j] == x[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(x[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  map<int, int> mp;
  rep(i,n) mp[a[i]]++;

  int ans = 0;
  for (auto p : mp) {
    int x = p.fi;
    int n = p.se;
    if (n < x) ans += n;
    else ans += n - x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;

	while (scan.hasNext()) {
	    sum = scan.nextInt() + scan.nextInt();
	    System.out.println((sum+"").length());
	}
    }
}

Measured memory_bytes: 26420
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1301
Problem G: Malfatti Circles
"""
import math
def main():
    while True:
        x1, y1, x2, y2, x3, y3 = map(int,input().split())
        if  x1 == y1 == x2 == y2 == x3 == y3 == 0:
            break
        
        a = math.sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) # aの長さ
        b = math.sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) # bの長さ
        c = math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) # cの長さ

        cosA = round((b*b + c*c - a*a),10) / round(2*b*c,10) # 余弦定理
        cosB = round((a*a + c*c - b*b),10) / round(2*a*c,10) # 余弦定理
        cosC = round((a*a + b*b - c*c),6) / round(2*a*b,10) # 余弦定理
        
        A = math.degrees(math.acos(cosA)) # bcの角度
        B = math.degrees(math.acos(cosB)) # acの角度
        C = math.degrees(math.acos(cosC)) # abの角度
        
        S = 1/2*a*c*math.sin(math.radians(B)) # 三角形の面積
        r = 2*S / (a+b+c) # 内接円半径
        
        tanA4 = round(math.tan(math.radians(A)/4),10) # tan(A/4)
        tanB4 = round(math.tan(math.radians(B)/4),10) # tan(B/4)
        tanC4 = round(math.tan(math.radians(C)/4),10) # tan(C/4)
        
        r1 = ((1+tanB4)*(1+tanC4))/(2*(1+tanA4))*r
        r2 = ((1+tanC4)*(1+tanA4))/(2*(1+tanB4))*r
        r3 = ((1+tanA4)*(1+tanB4))/(2*(1+tanC4))*r
        
        print(r1, r2, r3)

if __name__ == "__main__":
    main()


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100000], b[3];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) {
		int c = 0;
		while(a[i] % 2 == 0) { a[i] /= 2; c++; }
		if(c >= 2) { c = 2; }
		b[c]++;
	}
	
	cout << ((b[1] == 0 && b[0] <= b[2] + 1) || (b[1] != 0 && b[0] <= b[2]) ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

#define SIZE 200000
#define MAXI 1200012

using namespace std;

int main() {
    long long int i,j,k,N,M,K,Q,X,B;
   long long int A[13][13];
   long long int C[13],T[13];
   cin >> N >> M >> X;

   for (i=1;i<=N;i++) {
     cin >> C[i];
     for (j=1;j<=M;j++)
      cin >> A[i][j];
   }

   long long int combi,combi2;

   long long int mincost,cost;
   int encore;

   mincost = MAXI;
   for (combi=0;combi<(1<<N);combi++) {
     // on teste tout le monde
      combi2 = combi;
      for (i=1;i<=M;i++) // algos
        T[i] = 0;
      cost = 0;
      for (i=1;i<=N;i++) {
          if (combi2 % 2) {
            cost += C[i];
            for (j=1;j<=M;j++)
              T[j] += A[i][j];
          }
          combi2 >>= 1;
      }

      encore = 1;
      for (i=1;(i<=M) && encore;i++)
        if (T[i] < X)
          encore = 0;
      if ((encore) && (cost < mincost))
        mincost = cost;
    }
    if (mincost >= (MAXI) )
      cout << "-1\n";
    else
        cout << mincost << endl;

  return 0;

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll x;
   cin>>x;
  ll y=100;
 
  int count = 0;
  
  while(y<x){
    y += y/100;
      count++ ;
    }
    
    cout<<count<<endl;
}
    
  
  


Measured memory_bytes: 3640
n, m = map(int, input().split())
ps = [(input().split()) for _ in range(m)]

wa = [0] * (n + 1)
ac = [0] * (n + 1)

for p, s in ps:
    i = int(p)
    if s == "WA":
        if ac[i] != 1:
            wa[i] += 1
    else:
        if ac[i] != 1:
            ac[i] = 1

print(sum(ac), sum(wa[i] * ac[i] for i in range(n + 1)))


Measured memory_bytes: 33684
import Data.List
main = do
  imput <- map (read::String->Int) . words <$> getLine
  putStrLn $ battle imput

battle [a,b,c,d] =
  if c-b <= 0
    then "Yes"
    else if a-d <= 0
      then "No"
      else battle [a-d,b,c-b,d]

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

int main() {
 int a;
 cin >> a;
 string A;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for(int i = 0; i < a; i++){
    cin >> A;
    if(A == "AC") ac++;
    if(A == "WA") wa++;
    if(A == "TLE") tle++;
    if(A == "RE") re++;
  }
  cout << "AC";
  cout << " ";
  cout << "x";
   cout << " ";
  cout << ac << endl;
   cout << "WA";
   cout << " ";
  cout << "x";
   cout << " ";
  cout << wa << endl;
   cout << "TLE";
   cout << " ";
  cout << "x";
   cout << " ";
  cout << tle << endl;
   cout << "RE";
   cout << " ";
  cout << "x";
   cout << " ";
  cout << re << endl;
  
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <stack>
#include <cstdio>
using namespace std;
static const int MAX = 100;

int adj[MAX][MAX] = {0};
int n;

enum Color {
  WHITE,
  GRAY,
  BLACK,
};

struct node {
  Color color;
  int begin;
  int end;
};

node nodes[MAX];

void paint(int id, Color c) {
  static int time = 1;
  nodes[id].color = c;
  if (c == GRAY)
    nodes[id].begin = time;
  else if (c == BLACK)
    nodes[id].end = time;
  time++;
}

int next(int id) {
  for (int i = 0; i < n; i++) {
    if (adj[id][i] == 1 && nodes[i].color == WHITE) {
      return i;
    }
  }
  return -1;
}

void visit(int id) {
  stack<int> S;
  S.push(id);
  paint(id, GRAY);

  while (!S.empty()) {
    int u = S.top();
    int v = next(u);
    if (v > -1) {
      paint(v, GRAY);
      S.push(v);
    } else {
      S.pop();
      paint(u, BLACK);
    }
  }
}

void dfs() {
  for (int i = 0; i < n; i++) {
    nodes[i].color = WHITE;
  }
  for (int i = 0; i < n; i++) {
    if (nodes[i].color == WHITE)
      visit(i);
  }
}

void printNode(int i) {
  printf("%d %d %d\n", i+1, nodes[i].begin, nodes[i].end);
}

int main() {
  cin >> n;
  int id, nn, x;
  for (int i = 0; i < n; i++) {
    cin >> id >> nn;
    id--; // 0-based
    for (int j = 0; j < nn; j++) {
      cin >> x;
      x--; // 0-based
      adj[id][x] = 1;
    }
  }

  dfs();

  for (int i = 0; i < n; i++) {
    printNode(i);
  }
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
    ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    string s[n];
    for (ll i=0;i<n;i++)cin >> s[i];
    ll nibuhan[n];
    fill(nibuhan,nibuhan+n,-1);
    nibuhan[0]=1;
    queue<ll> que;
    que.push(0);
    while(!que.empty()){
        ll p=que.front();
        que.pop();
        for (ll i=0;i<n;i++){
            if (s[p][i]=='1'){
                if(nibuhan[i]==-1){
                    que.push(i);
                    nibuhan[i]=(nibuhan[p]+1)%2;
                }else if (nibuhan[i]==(nibuhan[p]+1)%2){
                    continue;
                }else{
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    ll dist[n][n];
    for (ll i=0;i<n;i++){
        for (ll j=0;j<n;j++){
            if (i==j)dist[i][j]=0;
            else if (s[i][j]=='1')dist[i][j]=1;
            else dist[i][j]=INF;
        }
    }
    for (ll k=0;k<n;k++){
        for (ll i=0;i<n;i++){
            for (ll j=0;j<n;j++){
                chmin(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    ll ans=0;
    for (ll i=0;i<n;i++){
        for (ll j=0;j<n;j++){
            ans=max(ans,dist[i][j]);
        }
    }
    cout << ans+1 << endl;
    return 0;
}


Measured memory_bytes: 3976
N, K = gets.split(' ').map(&:to_i)
sushi = []
N.times do
  t = gets.split(' ').map(&:to_i)
  sushi.push(t)
end
sushi.sort_by!{|s| -s[1]}

eat = []
del = []
kind = Array.new(N+1, 0)
ks = 0
yum = 0
K.times do 
  n = sushi.shift
  yum += n[1]
  if kind[n[0]] == 0
	eat.push(n + [0])
    kind[n[0]] = 1
    ks += 1
  else
    del.push(n + [1])
  end
end
cand = [yum + ks ** 2]

while !sushi.empty? && !del.empty?
  n = sushi.shift
  if kind[n[0]] == 0
    yum = yum - del[-1][1] + n[1]
    del.pop
    eat.push(n + [1])
    kind[n[0]] = 1
    ks += 1
    cand.push(yum + ks ** 2)
  end
end

puts cand.max

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

long long a, b, c;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	if(a + b >= c){
		cout << b + c << "\n";
	}else{
		cout << a + b + 1 + b << "\n";
	}
}

Measured memory_bytes: 256
# どちらか必ずa_Nのカードを持つ

N,Z,W = map(int,input().split())
A = list(map(int,input().split()))
A.reverse()
A.append(W)

BOTTOM = A[0]

M = float('inf')
m = 0

for a in A[1:]:
  x = abs(BOTTOM-a)
  t = max(x,m)
  s = min(x,M)
  M = min(M,t)
  m = max(m,s)

print(t)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;


const int MAX_V = 101;

class Edge{
    public:
        //???????????????????????????????????????
        int to, cap, cost, rev;
};

vector<vector<Edge>> G(MAX_V);
int h[MAX_V]; //??????????????£???
int dist[MAX_V]; //???????????¢
int prev_v[MAX_V], prev_e[MAX_V]; //??´??????????????¨???

void addEdge(int from, int to, int cap, int cost){
    G[from].emplace_back(Edge{to, cap, cost, static_cast<int>(G[to].size())});
    G[to].emplace_back(Edge{from, 0, -cost, static_cast<int>(G[from].size() - 1)});
}

int minCostFlow(int v, int s, int t, int f){
    int res = 0;
    fill(h, h + v, 0);
    while(f > 0){
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
        fill(dist, dist + v, INF);
        dist[s] = 0;
        q.push(make_pair(0, s));
        while(not q.empty()){
            pair<int, int> p = q.top(); q.pop();
            int u = p.second;
            if(dist[u] < p.first) continue;
            rep(i,G[u].size()){
                Edge &e = G[u][i];
                if(e.cap > 0 && dist[e.to] > dist[u] + e.cost + h[u] - h[e.to]){
                    dist[e.to] = dist[u] + e.cost + h[u] - h[e.to];
                    prev_v[e.to] = u;
                    prev_e[e.to] = i;
                    q.push(make_pair(dist[e.to], e.to));
                }
            }
        }
        if(dist[t] == INF){
            return -1;
        }
        rep(i,v) h[i] += dist[i];

        int d = f;
        for(int u = t; u != s; u = prev_v[u]){
            d = min(d, G[prev_v[u]][prev_e[u]].cap);
        }
        f -= d;
        res += d * h[t];
        for(int u = t; u != s; u = prev_v[u]){
            Edge &e = G[prev_v[u]][prev_e[u]];
            e.cap -= d;
            G[u][e.rev].cap += d;
        }
    }
    return res;
}

int main(){
    int v, e, f;
    cin >> v >> e >> f;
    rep(i,e){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        addEdge(a,b,c,d);
    }
    cout << minCostFlow(v, 0, v - 1, f) << endl;
}

Measured memory_bytes: 3224
n, k, s = map(int, input().split())

ans = []

for _ in range(k):
    ans.append(s)

if s < 10 ** 9:
    for _ in range(n-k):
        ans.append(s+1)

elif s == 10 ** 9:
    for _ in range(n-k):
        ans.append(1)

print(*ans)


Measured memory_bytes: 9584
valuenum = int(input())
values = [int(value) for value in input().strip().split()]

exchange_count = 0

for i in range(valuenum):
  min_num = i
  for j in range(i + 1, valuenum):
    if values[j] < values[min_num]:
      min_num = j
  if values[i] > values[min_num]:
    values[i], values[min_num] = values[min_num], values[i]
    exchange_count += 1

ans = map(lambda value:str(value), values)

print(' '.join(ans).strip())
print(str(exchange_count))


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

int main(){
    char c[3]; cin>>c;

    for(int i=0; i<3; i++){
        if(c[i] == '1') c[i] = '9';

        else if(c[i] == '9') c[i] = '1';

        cout<<c[i];
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int menu_time[5];
    for (int i = 0; i < 5; i++)
    {
        scanf("%d", &menu_time[i]);
    }
    int difArray[5];
    for (int i = 0; i < 5; i++)
    {
        if(menu_time[i]%10)
        {
            difArray[i] = 10 - menu_time[i]%10;
        }
        else
        {
            difArray[i] = 0;
        }
    }
    for (int i = 0; i < 5; i++)
    {
        menu_time[i] += difArray[i];
    }

    int max = 0;
    for (int i = 0; i < 5; i++)
    {
        if (difArray[i] > max)
        {
            max = difArray[i];
        }
    }

    int sum = 0;
    for (int i = 0; i < 5; i++)
    {
        sum += menu_time[i];
    }
    printf("%d\n", sum - max);
    // printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	int ans = 0;
	string s;
	cin >> s;
	REP(i,s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'p')ans--;
		}
		else if (s[i] == 'g')ans++;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 512
<?php

	$x = trim(fgets(STDIN));
	$l = strlen($x);
	$s = 0;
	$t = 0;
	$ans = $l;
	
	for($i=0;$i<$l;$i++){
		if($x[$i] == 'S'){
		    $s++;
		} else {
		    if($s>0){
		        $s--;
		        $ans = $ans - 2;
		    } else $t++;
		}
	}
	
	echo $ans;
?>

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

int main(){
  string weather;
  string tomorrowWeather;

  cin >> weather;

  if (weather == "Sunny") {
    tomorrowWeather = "Cloudy";
  }
  else if (weather == "Cloudy") {
    tomorrowWeather = "Rainy";
  }
  else {
    tomorrowWeather = "Sunny";
  }

  cout << tomorrowWeather << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)
#define M_MAX 40
using namespace std;

/*
n m

n 10^5
m 10^9

out mod 10^9+7
 */
ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

int N,M;
int prime[100000];
int m[100000];
bool not_prime[1000000001];
ll dp[100001][M_MAX];
const ll MAX = pow(10,9)+7;

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

  if(M==1){
    cout << 1 << endl;
    return 0;
  }


  // factrization
  int s=0;
  FOR_IN(i,2,sqrt(M)+1){
    if(not_prime[i]) continue;
      
    int cnt = 0;
    while(!(M%i)){
      cnt++;
      M /= i;
    }
    if(cnt > 0){
      prime[s] = i;
      m[s] = cnt;
      s++;
    }

    for(int k=i; k<=sqrt(M)+1; k+=i)
      not_prime[k] = true;
  }

  if(M>1){
    prime[s] = M;
    m[s] = 1;
    s++;
  }

  // LOG("s=%d\n", s);
  // REP(j,s)
  //   LOG("m[%d]=%d\n", j, m[j]);

  // division
  REP(j,M_MAX)
    dp[1][j] = 1;

  FOR_IN(i,2,N+1){
    REP(j,M_MAX){
      REP(k,j+1){
        dp[i][j] += (dp[i-1][j-k]) % MAX;
        dp[i][j] %= MAX;
      }
    }
  }

  ll ans = 1;
  REP(j,s){
    ans *= (dp[N][m[j]])%MAX;
    ans %= MAX;
  }

  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 33024
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> mp(n);
    rep(_, k) {
        int d;
        std::cin >> d;
        rep(__, d) {
            int x;
            std::cin >> x;
            x--;
            mp[x]++;
        }
    }
    std::sort(mp.begin(), mp.end());
    std::cout << std::upper_bound(mp.begin(), mp.end(), 0) - std::lower_bound(mp.begin(), mp.end(), 0) << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    ll a[n];
    ll t=inf;
    rep(i,0,n){
        cin>>a[i];
        t=min(t,a[i]/2);
    }
    ll u=1;
    rep(i,0,n){
        ll y=gcd(u,a[i]/2);
        u/=y;
        u*=a[i]/2;
        if(u>m){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,0,n){
        ll r=u/(a[i]/2);
        if(r%2==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll e=m/u;
    if(e%2)cout<<(e+1)/2<<endl;
    else cout<<e/2<<endl;
}


Measured memory_bytes: 1024
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    // 2要素変換
    let element1: i32 = iter.next().unwrap().parse().unwrap();
    let element2: i32 = iter.next().unwrap().parse().unwrap();

    let d = element1 / element2;
    let r = element1 % element2;
    let f = element1 as f64 / element2 as f64;

    println!("{} {} {}", d, r, f);
}



Measured memory_bytes: 5040
n, m = gets.split.map {|item| item.to_i}
product = gets.split.map {|item| item.to_i}
total_vote = product.inject(:+)
is_choose = product.map {|item| item >= total_vote.to_f / (4 * m)}

if m <= is_choose.count(true) then
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);} int dummmmmmmmy

using namespace std;

int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;

    //west[i]はi~n - 1までにEの人数
    //east[i]は0~iまでにWの人数を示すようにする

    vector<int> west(n,0);
    vector<int> east(n,0);

    int tmp = 0;

    rep(i, n - 1){
        if(s[n - 1 - i] == 'E'){
            tmp++;
        }
        west[n - 1 - i] = tmp;
    }

    tmp = 0;

    rep(i, n - 1){
        if(s[i] == 'W'){
            tmp++;
        }
        east[i] = tmp;
    }

    int ans = min(west[1], east[n - 2]);

    for(int i = 1; i < n - 1; i++){
        tmp = east[i - 1] + west[i + 1];
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3076
from collections import defaultdict

N, M = map(int, input().split())
V = range(N+M)
E = defaultdict(list)
for i in range(N):
    _, *L, = map(int, input().split())
    for l in L:
        l -= 1
        E[i].append(l+N)
        E[l+N].append(i)
stack = [0]
visited = [False] * (N+M)
while stack:
    i = stack.pop()
    if visited[i]: continue
    visited[i] = True
    for j in E[i]:
        if not visited[j]:
            stack.append(j)
if sum(visited[:N]) == N:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 36180
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
		String b;
		String c[];
		while((b = a.readLine()) != null){
			c = b.split(" ");
			print_iu(c[1],c[2],c[0]);
		}
	}

	static void print_iu(String a, String b, String x){
		int i = 0,j = 0;
		boolean y;
		if(x.charAt(0) == 'i'){
			y = false;
		} else {
			y = true;
		}
		while(i < a.length() && j < b.length()){
			if(a.charAt(i) == b.charAt(j)){
				System.out.print(a.charAt(i));
				++i;
				++j;
			} else if(a.charAt(i) == '('){
				int c = 0;
				while(true){
					if(y){
						System.out.print(a.charAt(i));
					}
					if(a.charAt(i) == '('){
						++c;
					} else if(a.charAt(i) == ')'){
						--c;
						if(c == 0){
							++i;
							break;
						}
					}
					++i;
				}
			} else if(b.charAt(j) == '('){
				int c = 0;
				while(true){
					if(y){
						System.out.print(b.charAt(j));
					}
					if(b.charAt(j) == '('){
						++c;
					} else if(b.charAt(j) == ')'){
						--c;
						if(c == 0){
							++j;
							break;
						}
					}
					++j;
				}
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 10000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    if((100*r+10*g+b)%4==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    long long K;
    int A[2010];
    
    cin >> N;
    cin >> K;
    
    for (int i=0;i<N;i++) {
        cin >> A[i];
    }
    
    int count_1 = 0;
    int count_2 = 0;
    
    for (int i=0;i<N;i++) {
        for (int j=i+1;j<N;j++) {
            if (A[i]>A[j]) {
                count_1 += 1;
            }
        }
    }
    
    for (int i=0;i<N;i++) {
        for (int j=0;j<N;j++) {
            if (A[i]>A[j]) {
                count_2 += 1;
            }
        }
    }
    //cout << count_1 << endl;
    //cout << count_2 << endl;
    
    long long result = 0;
    result = K*(K-1)/2;
    result = result%1000000007;
    result *= count_2;
    result += count_1*K;
    //cout << result << endl;
    cout << result%1000000007 << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String text = "";
		int num[] = new int[26];

		while(sc.hasNext()) {  //hasNextメソッドはscannerの入力に別のトークンが残っている場合trueを返す
			text += sc.next();
		}

	    text = text.toLowerCase();  //大文字を小文字に変換する

	    for(int i = 0; i < text.length(); i++) {
	    	for(int j = 0; j < 26; j++) {
	    		if(text.charAt(i) == (char)(j+97)) {  //charAt(i)はテキストからi番目の文字を取り出す
	    			num[j]++;
	            }
	        }
		}

		for(int i = 0; i < 26; i++) {
			System.out.println((char)(i + 97) + " : " + num[i]);
		}
	}

}



Measured memory_bytes: 26724
q,h,s,d=map(int,input().split())
n=int(input())
 
l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print (int(l//2))
else:
    m=min(q*4,h*2,s)
    print(int(d*(n-1)//2)+m if n%2==1 else int(l//2))


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int i,n,x,max,min;
	long long int sum;
	scanf("%d",&n);
	max=-1000000;
	min=1000000;
	sum=0;
	for(i=1;i<=n;i++) {
		scanf("%d",&x);
		if(max<=x) {
			max=x;
		}
		if(x<=min) {
			min=x;
		}
		sum+=x;
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
typedef std::pair<int,int> Edge;

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

void unite(int* par, int x, int y)
{
	par[find(par, x)] = find(par, y);
}

bool isSame(int* par, int x, int y)
{
	return find(par, x) == find(par, y);
}

int main()
{
	int N, M;
	std::cin >> N >> M;
	Edge* edge_list = new Edge[M];
	for (int i=0; i<M; i++) {
		int a, b;
		std::cin >> a >> b;
		edge_list[i].first = a;
		edge_list[i].second = b;
	}
	int* par = new int[N+1];
	for (int i=1; i<=N; i++) par[i] = i;
	for (int i=0; i<M; i++) {
		int u, v;
		u = edge_list[i].first;
		v = edge_list[i].second;
		unite(par, u, v);
	}
	int* color_cnt = new int[N+1];
	for (int i=1; i<=N; i++) {
		color_cnt[i] = 0;
	}
	for (int i=1; i<=N; i++) {
		color_cnt[find(par, i)]++;
	}
	int max_size = 0;
	for (int i=1; i<=N; i++) {
		max_size = std::max(max_size, color_cnt[i]);
	}
	std::cout << max_size << std::endl;
	delete[] edge_list;
	delete[] par;
	delete[] color_cnt;
}


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    long long int max,min,tmp,res; 
    cin>>n;
    cin>>max;
    min=max;
    res=-1000000000;
    for(int i=1;i<n;i++){
        cin>>tmp;
        if(res<tmp-min) res=tmp-min;
        if(tmp<min) min=tmp;
        if(tmp>max) max=tmp;
    }

    cout<<res<<endl;
}


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

using namespace std;

int main(void) {

  int n, m;
  cin >> n >> m;
  
  vector<int> high(n);
  
  for (int i = 0;i < n;i++) {
    cin >> high[i];
  }
  
  int a, b;
  vector<bool> flags(n, true);
  for (int i = 0;i < m;i++) {
    cin >> a >> b;

    a--;
    b--;
    if (high[a] > high[b]) flags[b] = false;
    else if (high[a] < high[b]) flags[a] = false;
    else {
      flags[a] = false;
      flags[b] = false;
    }
  }
  
  int ans = 0;
  for (int i = 0;i < n;i++) {
    if (flags[i]) ans++;
  }
  
  cout << ans << endl;

  return 0;
}


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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
int read_int(){int c,r;while((c=getchar())<48);r=c-48;while((c=getchar())>47)r=r*10+c-48;return r;}
void write_int(int x){int b[10],*p=b;do*p++=48+x%10,x/=10;while(x);do putchar(*--p);while(p>b);}

template<class T, T Op(T, T), T E(), class U, T Ap(T, U), U Cp(U, U), U Id()>
struct SegmentTree {
  const int n;
  V<T> t;
  V<U> u;
  SegmentTree(int _n) : n(_n), t(2 * n, E()), u(n, Id()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() {
    for (int i = n - 1; i >= 1; --i) t[i] = Op(t[2 * i], t[2 * i + 1]);
  }
  void push() { for (int i = 1; i < n; ++i) push(i); }
  void apply(int i, U f) {
    t[i] = Ap(t[i], f);
    if (i < n) u[i] = Cp(u[i], f);
  }
  void push(int i) {
    if (u[i] == Id()) return;
    apply(2 * i, u[i]);
    apply(2 * i + 1, u[i]);
    u[i] = Id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = (l + n) >> hl, ar = (r - 1 + n) >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
  T acc(int l, int r) {
    push(l, r);
    T a = E(), b = E();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = Op(a, t[l++]);
      if (r & 1) b = Op(t[--r], b);
    }
    return Op(a, b);
  }
  T get(int i) { return acc(i, i + 1); }
  void act(int l, int r, U f) {
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(i++, f);
      if (j & 1) apply(--j, f);
    }
    l = (l + n) >> __builtin_ctz(l + n);
    while (l >>= 1) t[l] = Op(t[2 * l], t[2 * l + 1]);
    r = (r + n) >> __builtin_ctz(r + n);
    while (r >>= 1) t[r] = Op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, T a) {
    push(i, i + 1);
    t[i += n] = a;
    while (i >>= 1) t[i] = Op(t[2 * i], t[2 * i + 1]);
  }
};
int _min(int a, int b) { return b < a ? b : a; }
int inf() { return 0x7fffffff; }
int upd(int a, int f) { return f == -1 ? a : f; }
int id() { return -1; }

int main() {
  int n = read_int(), q = read_int();
  SegmentTree<int, _min, inf, int, upd, upd, id> st(n);
  while (q--) {
    int t = read_int(), l = read_int(), r = read_int() + 1;
    if (t == 0) {
      int x = read_int();
      st.act(l, r, x);
    } else {
      write_int(st.acc(l, r));
      putchar('\n');
    }
  }
}



Measured memory_bytes: 3772
d,g = map(int,input().split())
pc = [list(map(int,input().split()))for _ in[0]*d]
ans = []
for mask in range(1 << d):
    s = 0
    num = 0
    rest_max = -1
    for i in range(d):
        p,c = pc[i]
        if mask >> i & 1:
            s += p * 100 * (i + 1) + c
            num += p
        else:
            rest_max = i
    if s < g:
        s1 = 100 * (rest_max + 1)
        need = (g - s + s1 - 1) // s1
        if need >= pc[rest_max][0]:
            continue
        num += need
    ans.append(num)
print(min(ans))

Measured memory_bytes: 3064
INF = float('inf')

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

N=int(input())
h=LIST()

# DP配列を初期化
dp=[INF] * N

# 初期条件を入力
dp[0]=0

# テーブルを更新 もらうDP
for i in range(1,N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i >= 2:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int mod=1e9+7;
const int N=1e5+5;
int inf=1e9;
int main()
{
    int n,k,s;
    scanf("%d%d%d",&n,&k,&s);
    if(k!=0)printf("%d",s);
    for(int i=1;i<k;i++)
        printf(" %d",s);
    if(s==inf){
        for(int i=k;i<n;i++)
            printf("%s%d",((i!=0)?" ":""),s-1);
    }
    else{
        for(int i=k;i<n;i++)
            printf("%s%d",((i!=0)?" ":""),inf);
    }


    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int K, A, B;
  cin >> K >> A >> B;
  
  if (A%K==0 || B%K==0) {
    cout << "OK\n";
    return 0;
  }
  int a = (A / K);
  int b = (B / K);
  if (a == b) {
    cout << "NG\n";
  } else {
    cout << "OK\n";
  }
}


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

int main() {

	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	string s="APPROVED";

	rep(i, n)if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) s = "DENIED";

	cout << s << endl;

}

Measured memory_bytes: 256
loop{
  a,b,c = STDIN.gets.split
  a = a.to_i
  c = c.to_i
  cul = case b
        when "+" then
          a + c
        when "-" then
          a - c
        when "*" then
          a * c
        when "/" then
          a / c
        else
          break
        end
  puts cul
}

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

int selectionSort(int A[], int N){
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1 ; i++){
        minj = i;
        for (j = i; j < N; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        if (i != minj){
            sw ++;
        }
    }
    return sw;
}

int main(){
    int A[100], N, i, sw;
    cin >> N;
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    sw = selectionSort(A, N);
    
    for (i = 0; i<N; i++){
        if (i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, h[114];
	cin>>n;
	REP(i, n){
		cin>>h[i];
	}
	int ans=0;
	REP(i, 10001){
		int idx=0;
		while(idx<n && !h[idx]){
			++idx;
		}
		if(idx==n){
			cout<<i<<'\n';
			return 0;
		}
		while(h[idx]){
			--h[idx];
			++idx;
		}
	}
	return 0;
}


Measured memory_bytes: 256