akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long  ll;
int main()
{
    double a,b,h,m,du,H,M;
    double ans;
    cin>>a>>b>>h>>m;
    H=h*30+m*0.5;
    M=m*6;
    du=max(H,M)-min(H,M);
    if(du>180) du=360-du;
    if(du==90){
        ans=a*a+b*b;
        printf("%.20lf",sqrt(ans));
        return 0;
    }
    du=du*PI/180.0;
    ans=a*a+b*b-(2*a*b*cos(du));
    printf("%.20lf",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4196
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    ss = input()
    s = [i for i in ss]
    n = len(s)
    print("Yes" if (s[:(n-1)//2] == s[:(n-1)//2][::-1] and s[(n+3)//2:] == s[(n+3)//2:] and s == s[::-1]) else "No")
        
if __name__ == "__main__":
    main() #endline===============================================

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

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

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

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

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

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

int main() {
	int H, W; cin >> H >> W;
	vector<string> S(H); cin >> S;
	vector<vint> diff(H, vint(W));
	vector<vint> sum(H, vint(W, 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W-1; j++) {
			diff[i][j] = S[i][j+1] != S[i][j];
		}
	}

	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W-1; j++) {
			if (diff[i-1][j] == diff[i][j]) sum[i][j] += sum[i-1][j];
		}
		sum[i][W-1] = 0;
	}
	sum[0][W-1] = 0;

	int maxv = max(W, H);
	for (int i = 0; i < H; i++) {
		//longest area rectangle
		stack<Pi> st;
		for (int j = 0; j < W; j++) {
			int minv = j;
			while (!st.empty() && st.top().first > sum[i][j]) {
				auto dat = st.top(); st.pop();
				chmax(maxv, dat.first * (j - dat.second + 1));
				chmin(minv, dat.second);
			}
			st.emplace(sum[i][j], minv);
		}
	}
	cout << maxv << endl;


	return (0);
}

Measured memory_bytes: 35840
#include<stdio.h>

int main(void){
  int i=0,j;
  unsigned long int x,s=100;
  
  scanf("%ld",&x);
  
  while(x>s){
    s=s+s/100;
    i++;
  }
  printf("%d\n",i);
  
  return 0;

}

Measured memory_bytes: 1732
L = input()
mod = 10**9 + 7
ans_last = [2, 0, 1]  #upper, 1, 0

for l in L[1:]:
    ans = [0, 0, 0]
    if l == "1":
        ans[0] = ans_last[0] * 2 % mod
        ans[1] = (ans_last[1] * 2 + ans_last[2] * 2) % mod
        ans[2] = (ans_last[0] + ans_last[1] + ans_last[2]) % mod
    else:
        ans[0] = ans_last[0]
        ans[1] = (ans_last[1] * 2 + ans_last[2] * 2) % mod
        ans[2] = (ans_last[1] + ans_last[2]) % mod
    ans_last = ans
print(sum(ans_last) % mod)


Measured memory_bytes: 41964
#include<stdio.h>
int main(){
  int n,j,i,a[50001]={},t2;


  a[2]=1;
  a[3]=1;
  
  for(i=1;i<=50000;i++){
    for(j=2;j<=i/2;j++){
      if(i%j==0)
	break;
      if(j==i/2 && i%j!=0)
	a[i]=1;
    }
  }
  
  while(1){
   
    t2=0;
    
  scanf("%d",&n);
  
  if(n==0) break;

    for(i=1;i<=n/2;i++){
      if(a[i]==1 && a[n-i]==1)
	  t2++;	
      }
    
      printf("%d\n",t2);
  }
  return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w, n; cin >> h >> w >> n;

    map<pi, int> mp;

    rep(k,0,n){
        int y, x; cin >> y >> x;

        rep(i,-1, 2){
            rep(j,-1, 2){
                int dx = x + j; int dy = y + i;
                mp[make_pair(dy, dx)]++;
            }
        }
    }



    int ans[10]; memset(ans, 0, sizeof(ans));

    int z = 0;
    each(mp, itr){
        pi cell = itr -> first;
        if(1 < cell.first && cell.first < h && 1 < cell.second && cell.second < w){
            ans[mp[cell]]++;
            z++;
        }
    }


    print((w - 2) * (h - 2) - z);
    rep(i,1,10){
        print(ans[i]);
    }



    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 56576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  int a[200009];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  int now=1,ans=0;
  rep(i,n){
    if(a[i]==now){
      now++;
    }
    else{
      ans++;
    }
  }
  if(ans==n){
    cout<<-1<<endl;
  }
  else{
    cout<<ans<<endl;
  }
  return(0);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int& x : a) cin >> x;
    vector<int> w(n, 0);
    function<i64(int, int)> merge = [&](int l, int r) {
        if(l + 1 >= r) return 0LL;
        if(l + 2 == r) return a[l] > a[l + 1] ? swap(a[l], a[l + 1]), 1LL : 0LL;
        int mid = (l + r) >> 1;
        i64 cl = merge(l, mid), cr = merge(mid, r), cnt = 0LL;
        int i = l, j = mid, k = l;
        while(i < mid && j < r) {
            if(a[i] <= a[j]) {
                w[k++] = a[i++];
            }
            else {
                w[k++] = a[j++];
                cnt += mid - i;
            }
        }
        while(i < mid) w[k++] = a[i++];
        while(j < r) w[k++] = a[j++];
        assert(k == r);
        copy(w.begin() + l, w.begin() + r, a.begin() + l);
        return cl + cr + cnt;
    };
    cout << merge(0, n) << endl;
}

Measured memory_bytes: 4260
n = input()
s = map(int, raw_input().split())
ans = s[-1]
dp = [[0] * 21 for i in range(n)]
dp[0][s[0]] = 1
for i in range(1, n-1):
    for j in range(21):
        if dp[i-1][j] == 0: continue
        vp = j + s[i]
        vm = j - s[i]
        if vp <= 20:
            dp[i][vp] += dp[i-1][j]
        if 0 <= vm:
            dp[i][vm] += dp[i-1][j]
print dp[n-2][ans]

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

using namespace std;

#define DPRINTF(...) printf(__VA_ARGS__)
#define FOR0(i, n) for(int i=0;i<n;i++)
#define ALL(c) (begin(c)), (end(c))
#define fst(t) get<0>(t)
#define snd(t) get<1>(t)
#define thd(t) get<2>(t)

typedef tuple<int,int> P;
typedef long long ll;

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

  int N, L;
  cin >> N >> L;

  string S[100];
  FOR0(i, N){
      cin >> S[i];
  }

  sort(S, S+N);

  FOR0(i, N){
      cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
N, way = map(int, input().split())
high = list(map(int, input().split()))
ans = [1]*N

for _ in range(way):
  a, b = map(int, input().split())
  if high[a-1] < high[b-1]:
    ans[a-1] = 0
  elif  high[a-1] > high[b-1]:
    ans[b-1] = 0
  else:
    ans[a-1], ans[b-1] = 0, 0
  
print(sum(ans))

Measured memory_bytes: 20072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    
    long double a,b,c;
    cin>>a>>b>>c;
    if((a+b-c+2*sqrt(a*b))<0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
const MOD: i64 = 1_000_000_007;

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let pow = |mut a: i64, mut n: usize| -> i64 {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 {
                res = res * a % MOD;
            }
            a = a * a % MOD;
            n >>= 1;
        }
        res
    };

    let mut ans = pow(10, n);
    ans = (ans + MOD - pow(9, n)) % MOD;
    ans = (ans + MOD - pow(9, n)) % MOD;
    ans = (ans + pow(8, n)) % MOD;
    println!("{}", ans);
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(ll i=ll(x);i<(ll)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<ll,ll>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;

bool f(P a,P b){
    if(a.first!=b.first){
        return a.first<b.first;
    }
    else{
        return a.second<b.second;
    }
}

int main(){
    ll n,m;
    cin>>n>>m;
    map<ll,ll>mp;
    vector<P>p(m);
    rep(i,m){
        ll d,y;
        cin>>d>>y;
        p[i].first=d;
        p[i].second=y;
        mp[i]=y;
    }
    sort(p.begin(),p.end(),f);
    map<ll,ll>ans;
    ll index=1,now;
    for(auto x:p){
        ll num;
        if(x.first!=now)index=1;
        now=x.first;
        num=x.first*pow(10,6)+index;
        ans[x.second]=num;
        index++;

    }
    rep(i,m){
        printf("%012lld\n",ans[mp[i]]);
    }
    return 0;
}

Measured memory_bytes: 15616
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
LL dp[101010][13];
const LL mod = 1e9 + 7;

int main(){
    cin >> s;
    dp[0][0] = 1;
    REP(i, (int)s.size()){
        if(s[i] == '?'){
            REP(j, 13)REP(k, 10){
                (dp[i + 1][(j * 10 + k)%13] += dp[i][j]) %= mod;
            }
        }else{
            int num = s[i] - '0';
            REP(j, 13)(dp[i + 1][(j * 10 + num)%13] += dp[i][j]) %= mod;
        }
    }
    cout << dp[(int)s.size()][5] << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = unsigned long long;
using G   = vector<vector<int>>;

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    LL k;cin >> k;
    vector<int> cnt(40, 0);
    vector<LL> a(n);
    inc(i, 0, n){
        cin >> a[i];
        dec(j, 0, 40){
            if((a[i] >> j)%2 > 0){
                cnt[j]++;
            }
        }
    }
    bool flag = true;
    LL x = 0;
    dec(i, 0, 40){
        int bit = (k >> i)%2;
        if(flag){
            if(bit == 0){
                x <<= 1;
            }else{
                if(cnt[i] >= (n+1)/2){
                    x <<= 1;
                    flag = false;
                }else{
                    x <<= 1;
                    x += 1;
                }
            }
        }else{
            if(cnt[i] >= (n+1)/2){
                x <<= 1;
            }else{
                x <<= 1;
                x += 1;
            }
        }
    }
    LL ans = 0;
    inc(i, 0, n){
        ans += (x ^ a[i]);
    }
    printf("%lld\n", ans);
    //cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
#define inf 1<<25
#define min(a,b)((a)<=(b)?(a):(b))
#define rep(i,n)for(int i=0;i<n;i++)
int n,a,b,c;
int cost[10][10];
bool use[10];
int main() {
	while(scanf("%d",&n),n) {
		fill(use,use+10,false);
		fill(cost[0],cost[0]+10*10,inf);
		rep(i,n) {
			scanf("%d %d %d",&a,&b,&c);
			cost[a][b]=cost[b][a]=c;
			use[a]=use[b]=true;
		}
		rep(k,10)rep(i,10)rep(j,10) {
			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		}
		int to,cs=inf;
		rep(i,10) {
			if(!use[i])continue;
			int sum=0;
			rep(j,10)if(i!=j&&cost[i][j]<inf)sum+=cost[i][j];
			if(cs>sum)to=i,cs=sum;
		}
		printf("%d %d\n",to,cs);
	}
}

Measured memory_bytes: 1028
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = (int)(s.length());
    for (int i=1; i<n/2; i++) {
        string sub = s.substr(0, n/2-i);
        sub += sub;
        if (s.find(sub) != string::npos) {
            cout << n-2*i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3560
n,d=map(int,input().split())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
ans=0
for i in range(n):
  if x[i]**2+y[i]**2<=d**2:
    ans+=1

print(ans)

Measured memory_bytes: 24700
import java.util.Scanner;
class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int counter = 0;
    int sum = 0;
    double min;
    int[] a = new int[n];
    
    for(int i = 0;i < n;i++){
	  a[i] = scan.nextInt();
      sum += a[i];
    }
    
    min = sum / (4*(double)m);
    
    for(int i = 0;i < n;i++){
      if(a[i] >= min)counter++;
    }
    
    if(counter >= m){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b<10)
    {
        cout <<a+b<<endl;
    }    
    else
    {
        cout <<"error"<<endl;
    }   

    return 0;
}

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

int main() {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  long long x, t;
  cin >> x >> t;

  if ((x - t) < 0){
    cout << 0 << endl;
  }
  else {
    cout << x - t << endl;
  }

  return 0;
}


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

struct neta {
	long long pos;
	long long cal;
};

neta sushi[100002];
neta sum_lt[100002];
neta sum_rt[100002];


int main()
{
	int N;
	long long C;
	cin >> N >> C;

	sushi[0].cal = 0;
	sushi[0].pos = 0;
	sum_lt[0].cal = 0;
	sum_lt[0].pos = 0;
	sum_rt[0].cal = 0;
	sum_rt[0].pos = 0;
	sushi[N+1].cal = 0;
	sushi[N+1].pos = C;
	sum_lt[N+1].cal = 0;
	sum_lt[N+1].pos = 0;
	sum_rt[N+1].cal = 0;
	sum_rt[N+1].pos = 0;

	long long cal_sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> sushi[i].pos >> sushi[i].cal;
		cal_sum += (sushi[i].cal - (sushi[i].pos - sushi[i-1].pos));
		if (cal_sum > sum_lt[i-1].cal) {
			sum_lt[i].cal = cal_sum;
			sum_lt[i].pos = sushi[i].pos;
		} else {
			sum_lt[i] = sum_lt[i-1];
		}
	}

	cal_sum = 0;
	for (int i = N; i >= 1; i--) {
		cal_sum += (sushi[i].cal - (sushi[i+1].pos - sushi[i].pos));
		if (cal_sum > sum_rt[i+1].cal) {
			sum_rt[i].cal = cal_sum;
			sum_rt[i].pos = C - sushi[i].pos;
		} else {
			sum_rt[i] = sum_rt[i+1];
		}
	}

	long long ans = 0;
	// clockwise
	for (int i = 0; i <= N; i++) {
		long long get_calorie = 0;
		get_calorie += sum_lt[i].cal;
		ans = max(ans, get_calorie);

		get_calorie -= (sum_lt[i].pos);
		get_calorie += sum_rt[i+1].cal;

		ans = max(ans, get_calorie);
	}

	// counter clockwise
	for (int i = N+1; i >= 1; i--) {
		long long get_calorie = 0;

		get_calorie += sum_rt[i].cal;
		ans = max(ans, get_calorie);

		get_calorie -= (sum_rt[i].pos);
		get_calorie += sum_lt[i-1].cal;

		ans = max(ans, get_calorie);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
	int n,l[10],t,s,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&l[i]);
	t=l[0];
	s=l[0];
	for(i=1;i<n;i++){
		if(t<l[i])
			t=l[i];
		s+=l[i];
	}
	printf("%s",(s-t>t)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

llong mod = 1000000007;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
  int N;cin>>N;
  int K;cin>>K;
  int X;cin>>X;
  int Y;cin>>Y;
  int c;
  if(N < K){
    cout << N * X<< endl;
  }else{
    cout << K *X + (N-K)*Y<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, a;
ll dp[51][51][50*50+1];//i番目までにj個選んで合計がk
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a;
    vector<ll> x;
    ll maxa;
    for (int i = 0; i < n; i++)
    {
        ll tempx;
        cin >>tempx;
        maxa=max(maxa,tempx);
        x.push_back(tempx);
    }
    for(int i=0;i<=50;i++){
        for(int j=0;j<=50;j++){
            for(int k=0;k<=50*50;k++)
                    dp[i][j][k]=0;
        }
    }
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n*50;k++){
                if(k-x[i-1]>=0&&j>0)
                dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];
                dp[i][j][k]+=dp[i-1][j][k];
                //cout<<dp[i][j][k]<<"\n";
            }
        }
    }

    ll ans=0;
    for(int j=1;j<=n;j++){
        for(int k=1;k<=n*maxa;k++){
            if(k/j==a&&k%j==0)
            ans+=dp[n][j][k];
        }
    }
    cout<<ans<<"\n";
}


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

int main() {
  string s; cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n) rep(j,n-i) {
    string ss = s.substr(i, j+1);
    bool isACGT = false;
    int sn = ss.size();
    rep(k, sn) {
      if (ss[k] == 'A' || 
          ss[k] == 'C' ||
          ss[k] == 'G' ||
          ss[k] == 'T') { isACGT = true; }
      else { isACGT = false; break; }
    }
    if (isACGT) ans = max(ans, sn);
  }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000],n,m,t,p;
int main(){
    cin>>n>>m>>t;
    for(int i=0;i<n;i++){cin>>p;a[p-m]++;a[p+m]--;}
    for(int i=1;i<t;i++)a[i]+=a[i-1];
    int cnt=0;for(int i=0;i<t;i++){if(a[i]==0)cnt++;}
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define INF 0x7fffffff
typedef long long ll;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define enter printf("\n");
#define outn(x) std::cout<<(x)<<"\n";

#define Mem(x) memset(x,0,sizeof(x));

#define fori(x) for (int i = 0; i < (x); i++)
#define fori1(x) for (int i = 1; i <= (x); i++)
#define forj(x) for (int j = 0; j < (x); j++)
#define fork(x) for (int k = 0; k < (x); k++)
#define in(x) scanf("%d",&(x));
#define outc(x) printf("%c",(x));
#ifndef ONLINE_JUDGE
	#define out(x) std::cout<<#x" = "<<(x)<<std::endl;
	#define out2(x,y) std::cout<<#x" = "<<(x)<<" "<<#y" = "<<(y)<<std::endl;
	#define outset(x) for(auto ii8i: (x)) cout<<(ii8i)<<" ";outc(10);
	#define outarr(x,fir) for(int ii9i=0;ii9i<fir;ii9i++) cout<<(x)[ii9i]<<" ";outc(10)
	#define out2arr(x,fir,sec) fori(fir){ outarr((x)[i],sec) outc(10)}
#endif // ONLINE_JUDGE

#define outline(x) printf("%d%c",(x),i==N-1?10:32);
#define REP(i,a,b) for(register int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(register int i=(a),_end_=(b);i>=_end_;i--)
const double eps = 1e-9;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
using namespace std;
const int maxn=10+200000;
int T,l,N,M,x,y,t1,t2,t;
int a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	int m=max(max(a,b),c);
	printf("%d",m*(1<<k)+b+c+a-m);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <map>
#include <ctime>
#include <list>
#include <bitset>
#include <algorithm>

#define ll long long
#define fo(i, c) for (int i = 0; i != c; i++)

using namespace std;

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int> h(n);
	for (auto& it : h)
		cin >> it;
	vector<int> dsu(n);
	dsu[0] = 0, dsu[1] = abs(h[0] - h[1]);
	for (int i = 2; i != n; i++)
		dsu[i] = min(dsu[i - 1] + abs(h[i] - h[i - 1]), dsu[i - 2] + abs(h[i] - h[i - 2]));
	cout << dsu[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N; cin >> N;
    ll X; cin >> X;
    vel x(N); rep(i,N) cin >> x[i];

    rep(i,N) x[i] = abs(X - x[i]);
    ll gcd = x[0];
    rep(i,N-1) {
        ll temp = __gcd(x[i], x[i+1]);
        gcd = __gcd(gcd, temp);
    }
    cout << gcd << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
      	int c = scn.nextInt();
      	int check = 0;
      	if(a<=c && c<=b){
          check = 1;
        }
      	if(a>=c && c>=b){
          check = 1;
        }
      	if(check==1){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35848
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int ans;

main(){
	int n,k;
	cin>>n>>k;
	dump(max(0ll,n-k+1ll));
}





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

//?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c???                       
void shuffle(vector<int> &yama, int n, int p, int c);


int main(){
  int n, r;
  int p, c;
  vector<int> yama, v;

  cin >> n;
  cin >> r;

  while(n != 0 && r != 0){
    //?±±??????????????????                                                            
    yama.clear();
    for(int i = 0, j = n; i < n; i++, j--){
      yama.push_back(j);
    }
    //?????£?????????                                                                
    for (int i = 0; i < r; i++){
      cin >> p;
      cin >> c;
      shuffle(yama, n, p, c);
    }
    //???????????????????¨????                                                          
    v.push_back(yama.front());

    cin >> n;
    cin >> r;
  }
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << endl;
  }
}

void shuffle(vector<int> &yama, int n, int p, int c){
  int tmp;

  for(int i = 0;i < c; i++){
    tmp = yama[p-1+c-1];
    yama.erase(yama.begin()+p-1+c-1);
    yama.insert(yama.begin(), tmp);

  }
}

Measured memory_bytes: 3064
import numpy as np

n, k = map(int, input().split())

n_count = np.zeros(n, dtype = np.int)
# print(n_count)

for i in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  # print(a)
  for j in range(d):
    n_count[a[j]-1] += 1

# print(n_count)
print(np.count_nonzero(n_count == 0))

Measured memory_bytes: 27204
#include<stdio.h>

int max(int x,int y){
	if(x>y)return x;
	return y;
}


int main(){
	int A,B,K,i;
	scanf("%d%d%d",&A,&B,&K);
	for(i=A;i<=B && i<A+K;i++)printf("%d\n",i);
	for(i=max(i,B-K+1);i<=B;i++)printf("%d\n",i);
	return 0;
}

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

int main(void){
    int N,i;
    cin>>N;
    string s1,s2;
    cin>>s1>>s2;
    ll res=1;
    if(s1[0]==s2[0]){
        res=3;
        i=0;
    }else{
        res=6;
        i=1;
    }
    while(i<N-1){
        if(s1[i]==s2[i]){
            if(s1[i+1]==s2[i+1]){
                res=(res*2)%M;
                i+=1;
            }else{
                res=(res*2)%M;
                i+=2;
            }
        }else{
            if(s1[i+1]==s2[i+1]){
                i+=1;
            }else{
                res=(res*3)%M;
                i+=2;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveIntArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];

			//答えの出力
			var ans = getAns(N);
			var sb = new StringBuilder();
			foreach (var mojiretu in ans) {
				sb.Append(mojiretu);
				sb.Append("\n");

			}
			Console.Write(sb);
		}

		/// <summary>
		/// 答えを求める
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static string[] getAns(int N) {

			string[] characters= { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
			var ansStructs = new List<AnsStruct> {
				new AnsStruct{str="a",level=1 }
			};
			for (int i = 1; i < N; i++) {
				var newAns = new List<AnsStruct>();
				foreach (var ans in ansStructs) {
					for (int n = 0; n <= ans.level; n++) {

						//すでに自分の持っている文字を付け足す場合
						if(n < ans.level) {
							var mojiretsu = ans.str + characters[n];
							newAns.Add(new AnsStruct { str = mojiretsu, level = ans.level });
						}
						else {//新しい文字を足す場合
							var mojiretsu = ans.str + characters[n];
							newAns.Add(new AnsStruct { str = mojiretsu, level = ans.level+1 });
						}
					}
				}
				ansStructs = newAns;
			}
			return ansStructs.Select(ans => ans.str).ToArray();
		}



		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static int[] retreiveIntArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var intArray = inputArray.Select(s => int.Parse(s));
			return intArray.ToArray();
		}
		
	}

	/// <summary>
	/// 答えを管理するクラス
	/// </summary>
	public class AnsStruct {
		/// <summary>
		/// 答えの文字列
		/// </summary>
		public string str { get; set; }

		/// <summary>
		/// 何個の種類の文字を持っているか
		/// </summary>
		public int level { get; set; }
	}


}


Measured memory_bytes: 37920
s=input()
k=int(input())
n=len(s)
num=[0]*n
for i in range(n):
    if s[i]!="a":
        num[i]=123-ord(s[i])
if sum(num)>=k:
    ans=""
    for i in range(n-1):
        if k>=num[i]:
            k-=num[i]
            ans+="a"
        else:
            ans+=s[i]
    if k>=num[-1]:
        ans+="a"
    else:
        ans+=chr(97+((ord(s[-1])-97+k)%26))
else:
    k-=sum(num)
    ans="a"*(n-1)
    ans+=chr(97+(k%26))
print(ans)


Measured memory_bytes: 10100
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>  
#include <iostream>  
#include <cstdlib>  
#include <cstring>  
#include <string>
#include <cstdio>  
#include <climits>
#include <cmath> 
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <sstream>
#define INF 0x3f3f3f3f
#define LL long long
#define fora(i,a,n) for(int i=a;i<=n;i++)
#define fors(i,n,a) for(int i=n;i>=a;i--)
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define MAXN 100024
const double eps = 1e-8;
using namespace std;

int main() {
#ifdef DID
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
	int w, a, b;
	cin >> w >> a >> b;
	if (a + w < b) cout << b - a - w << endl;
	else if (b + w < a) cout << a - b - w << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=abs(a-b),e=abs(b-c),f=abs(c-a);
	cout<<d+e+f-max(d,max(e,f));
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<pair<ll,ll>>x;
  for(int i=0;i<n;i++){
  	ll a,b;
  	cin>>a>>b;
  	x.push_back(make_pair(b,a));
  }
  sort(x.begin(),x.end());
  bool possible=true;
  ll time = 0;
  for(int i=0;i<n;i++){
  	time+=x[i].second;
  	if(time>x[i].first){
  		possible=false;
  	}
  }
  if(possible){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }
}  


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;

    for(int i=0;i<S.size();i++){
        int cost = 26 - (int)(S[i] - 'a');
        if (S[i] != 'a' && cost <= K){
            S[i] = 'a';
            K -= cost;
        }
    }

    if (K >= 26) K %= 26;
    S[S.size() - 1] = (char)(S[S.size() - 1] + K);
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
 
#define M 1046527
#define L 14
 
char H[M][L];
 
int char2int(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
 
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * char2int(str[i]);
    p *= 5;
  }
  return ret;
}
 
int h1(int key) {
  return key % M;
}
 
int h2(int key) {
  return 1 + (key % (M - 1));
}
 
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
 
int insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
 
int main(void) {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
 
    if(cmd[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 16104
#include<stdio.h>
#define INFINITY (1<<21)
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX]/*へんの重みを保存した隣接行列*/;

int prim(){
  int i,u,minv,v,sum=0;
  int d[MAX]/*Tに属する頂点とV-Tに属する頂点を繋ぐへんの中で最小の重みを記録*/,p[MAX]/*それぞれの親を記録*/,color[MAX];
  for(i=0;i<n;i++){/*dをinfinity pを−１colorを白に初期化*/
    d[i] = INFINITY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0]=0;/*d[0]を０にする*/

  while(1){
    minv=INFINITY;
    u = -1;
    for(i=0;i<n;i++){/*minvにブラック以外の頂点から最小のおもみをいれる*/
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v] != INFINITY){
        if(d[v] > M[u][v]){
          d[v]= M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e == -1)M[i][j]=INFINITY;
      else M[i][j]=e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2044
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long a = in.nextLong();
        long b = in.nextLong();
        out.println(lcm(a,b));
        out.close();
    }
    private static long lcm(long a, long b){
        return a * b / gcd(a,b);
    }
    private static long gcd(long a, long b){
        if(b==0){
            return a;
        }
        return gcd(b, a%b);
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 32948
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
m_list = []
for _ in range(m):
    b, c = map(int, input().split())
    m_list.append([c, b])
m_list.sort(reverse=True)
cnt = 0
tmp_list = []
for c, b in m_list:
    if cnt < n:
        tmp_list += [c]*b
    else:
        break
    cnt += b
a_list.extend(tmp_list)
a_list.sort(reverse=True)
print(sum(a_list[:n]))


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

struct A {
    int64_t a, b, c, d;
};

int64_t f(int64_t TT[10], const std::vector<A>& AA)
{
    int64_t s = 0;
    for (auto& a : AA) {
        if (TT[a.b - 1] - TT[a.a - 1] == a.c)
        {
            s += a.d;
        }
    }
    return s;
}

int main()
{
    size_t N,M,Q;
    std::cin >> N >> M >> Q;

    std::vector<A> t;
    for (size_t q = 0; q < Q; ++q)
    {
        A a;

        std::cin >> a.a >> a.b >> a.c >> a.d;

        t.push_back(a);
    }

    int64_t TT[10] = {1, 1, 1, 1, 1, 1, 1,  1, 1, 1};
    int64_t max = 0;

    while (true) {
        max = std::max(max, f(TT, t));

        if (TT[0] == M) {
            break;
        }

        for (size_t i = 0; i < N; ++i)
        {
            if (TT[N - 1 - i] != M) {
                ++TT[N - 1 - i];
                for (size_t j = N - 1 - i + 1; j < N; ++j) {
                    TT[j] = TT[N - 1 - i];
                }
                break;
            }
        }
    }
    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 3612
from collections import defaultdict


def main():
    N, M, *AB = map(int, open(0).read().split())
    cnt = defaultdict(int)
    for a, b in zip(*[iter(AB)] * 2):
        cnt[a] += 1
        cnt[b] += 1
    ans = []
    for i in range(1, N + 1):
        ans.append(cnt[i])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::collections::BTreeSet;

fn main() {
    let s = str2vec(&input_line_str());
    let mut map = "abcdefghijklmnopqrstuvwxyz"
        .chars()
        .into_iter()
        .collect::<BTreeSet<_>>();

    for z in s {
        let mut map2 = BTreeSet::new();
        map2.insert(z);
        map = &map - &map2;
    }
    let mut it = map.iter();
    let ans = match it.next() {
        None => String::from("None"),
        Some(e) => e.to_string(),
    };
    p(ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#define rep(i,rept) for (int i = 0; i < rept; i++)

int main() {
	int n = 0, a[100] = {};
	int count = 0, ans = 0;
	std::cin >> n;
	rep(i, n) {
		std::cin >> a[i];
	}
	rep(i, n) {
		if (a[i] == 1) {
			count++;
		}
		else {
			count = 0;
		}
		ans = std::max(ans, count);
	}
		std::cout << ans + 1 << std::endl;
}


Measured memory_bytes: 3068