akhauriyash/Code-Regression huggingface dataset:
from collections import deque
S = deque(input())
Q = int(input())

dir = 1
for q in range(Q):
    Query = list(map(str, input().split()))
    if Query[0] == '1':
        #反転
        dir *= -1
    else:   #Query[0]==2
        if Query[1] == '1':
            #先頭追加
            if dir > 0:
                #Sの先頭追加
                S.appendleft(Query[2])
            else:   #dir < 0
                #Sの末尾追加
                S.append(Query[2])
        else:   #Query[1] ==2
            #末尾追加
            if dir > 0:
                #Sの末尾追加
                S.append(Query[2])
            else:   #dir < 0
                #Sの先頭追加
                S.appendleft(Query[2])

if dir < 0:
    S.reverse()
else:   #dir > 0
    pass

print(''.join(S))





Measured memory_bytes: 8692
import numpy as np
import sys
from bisect import bisect_right, bisect_left

readline = sys.stdin.readline

# 入力にかかる最大計算量O(NlogN)：クイックソート
N = int(input())
A = np.array(readline().split(), np.int64)
num_array = np.zeros(10**5, np.int64)
for n in A:
    num_array[n-1] += 1

# A_sort = np.sort(A)
A_sum = sum(A)
Q = int(input())
BC = np.array([np.array(readline().split(), np.int64) for n in range(Q)], np.int64)
# BC[N][0,1]

# ここの計算量O(N(logN + logN))
for q in range(Q):
    # A = [BC[q][1] if x==BC[q][0] else x for x in A]
    # A[bisect.bisect_left(A, BC[q][0]):bisect.bisect_right(A, BC[q][0])] = BC[q][1]
    '''
    plus_num = BC[q][1] - BC[q][0]
    left = bisect_left(A_sort, BC[q][0])
    right = bisect_right(A_sort, BC[q][0])
    plus_multiple = right - left
    A_sort[left:right] = BC[q][1]
    A_sort = np.sort(A_sort)
    '''

    '''
    plus_num = BC[q][1] - BC[q][0]
    plus_multiple = np.count_nonzero(A == BC[q][0])
    A[A==BC[q][0]] = BC[q][1]
    '''

    plus_num = BC[q][1] - BC[q][0]
    plus_multiple = num_array[BC[q][0] - 1]
    # リスト内の要素数の更新
    num_array[BC[q][1]- 1] += num_array[BC[q][0] - 1]
    num_array[BC[q][0] - 1] = 0

    A_sum = A_sum + plus_num*plus_multiple
    print(A_sum)



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

int main() {
	double v;
	while(cin>>v){
		double t=v/9.8;
		double y=4.9*t*t;
		for(int i=1;;i++){
			if(y>5*(i-1)-5&&y<5*i-5){ 
				cout<<i<<endl; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(A),
    get_number(B),
    get_number(C),
    X is A + B + C - max(max(A, B), C),
    writeln(X).


Measured memory_bytes: 8172
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    bool[8][8] G;
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        G[a - 1][b - 1] = G[b - 1][a - 1] = true;
    }
    // writeln(G);
    auto ary = [1, 2, 3, 4, 5, 6, 7].take(N - 1).array;
    long cnt;
    do
    {
        // writeln(ary);
        bool b = G[0][ary[0]];
        foreach (i; 0 .. N - 2)
            b = b && G[ary[i]][ary[i + 1]];

        cnt += b;
    }
    while (nextPermutation(ary));
    writeln(cnt);
}


Measured memory_bytes: 256
#include <stdio.h>

const long long mod = 1000000007;
long long inv[5050] = { 0,1 }, fact[5050] = { 1,1 }, ifact[5050] = { 1,1 };

int N, dir[5050];

int par[5050], sz[5050];
int find(int x)
{
	if (par[x] != x) par[x] = find(par[x]);
	return par[x];
}

long long mult[5050];

int main()
{
	for (int i = 2; i < 5050; i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i - 1] * i % mod;
		ifact[i] = ifact[i - 1] * inv[i] % mod;
	}

	scanf ("%d", &N);
	for (int i = 1; i <= N; i++){
		scanf ("%d", &dir[i]);
		par[i] = i;
	}

	long long ans = 0;
	int pick = 0;
	for (int i = 1; i <= N; i++){
		if (dir[i] != -1){
			int x = find(dir[i]);
			int y = find(i);
			if (x != y){
				par[x] = y;
				ans++;
			}
		}
		else pick++;
	}

	mult[0] = 1;
	for (int i = 1; i <= N; i++) sz[find(i)]++;
	for (int i = 1; i <= N; i++) if (dir[i] == -1){
		int x = find(i);
		ans = (ans + (N - sz[x]) * inv[N - 1]) % mod;
		for (int j = pick - 1; j >= 0; j--){
			mult[j + 1] = (mult[j + 1] + mult[j] * sz[x] % mod * inv[N-1]) % mod;
		}
	}

	for (int i = 2; i <= pick; i++){
		ans = (ans + mod - fact[i - 1] % mod * mult[i] % mod) % mod;
	}

	for (int i = 0; i < pick; i++) ans = ans * (N - 1) % mod;
	printf ("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <map>
#include <set>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  a[0] -= 32;
  b[0] -= 32;
  c[0] -= 32;
  cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

typedef pll P;

pll operator - (pll A,pll B){A.F-=B.F; A.S-=B.S; return A;}
pll operator + (pll A,pll B){A.F+=B.F; A.S+=B.S; return A;}

ll cross(pll a,pll b){return a.F*b.S-a.S*b.F;}

ll dot(pll a,pll b){return a.F*b.F+a.S*b.S;}

vector<P> convexhull(vector<P> pts){
  vector<P> ret;
  sort(pts.begin(),pts.end());
  pts.erase(unique(pts.begin(),pts.end()),pts.end());
  auto fnc=[&](){
             for(auto &I:pts){
               if(!ret.empty() && I==ret.back()){continue;}
               while(ret.size()>=2){
                 pll A=ret.back()-ret[ret.size()-2];
                 pll B=I-ret.back();
                 if(cross(A,B)<0){ret.pop_back(); continue;}
                 //if(cross(A,B)==0 && dot(A,B)>0){ret.pop_back(); continue;}
                 break;
               }
               ret.push_back(I);
             }
           };
  fnc();
  reverse(pts.begin(),pts.end());
  fnc();
  if(ret[0]==ret.back() && ret.size()>1){ret.pop_back();}
  return ret;
}


int main(){
  ll N;
  cin>>N;
  vector<pll> A(N);
  cin>>A;
  vector<pll> con={{0,0}};
  vector<pll> nx;
  for(auto &I:A){
    nx=con;
    for(auto &J:con){
      nx.push_back(J+I);
    }
    con=convexhull(nx);
  }
  D ans=0;
  for(auto &I:con){
    ans=max<D>(ans,sqrt(I.F*I.F+I.S*I.S));
  }
  cout<<fixed<<setprecision(20)<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 28632
s = []
count = 0

while true
    input = STDIN.gets.chomp()
    if input == "-" then
        break
    else
        m = STDIN.gets.chomp().to_i
        h = []
        for i in 0..m - 1 do
            _h = STDIN.gets.chomp().to_i
            h << _h
        end
        s[count] = { string:input, m:m, h:h}
        # p s[count]
    end
    count += 1
end

for i in 0..s.length - 1 do
    str = s[i][:string]
    for j in 0..s[i][:m] - 1 do
        # puts str
        num = s[i][:h][j]
        substr = str.slice(num .. str.length - 1)
        str = substr + str.slice(0 .. s[i][:h][j] - 1)
    end
    puts str
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
using namespace atcoder;


void solve(){
  int n,q;
  cin>>n>>q;
  fenwick_tree<ll>bit(n);
  rep(i,n){
    ll a;
    cin>>a;
    bit.add(i,a);
  }
  while(q--){
    int que;
    ll x,y;
    cin>>que>>x>>y;
    if(que==0)bit.add(x,y);
    else {
			cout<<bit.sum(x,y)<<"\n";
		}
  }
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

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

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

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

int a;

signed main(){
    io();
    cin>>a;
    if(a<1200){
        cout<<"ABC"<<endl;
    }else if(a<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define test() ll tc;cin>>tc;while(tc--)

using namespace std;

/*ll fact(ll n);

ll comb(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = ((res%mod * i%mod)%mod)%mod;
    return res;
}


ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

*/



int main()
{
        fast();
        ll n,i,j;
        cin>>n;
        ll a[n][3];
        f(i,0,n)
        {
            f(j,0,3)
            {
                cin>>a[i][j];
            }
        }
        ll maxx;
        f(i,1,n)
        {
            f(j,0,3)
            {
                if(j==0)
                {
                    maxx=max(a[i-1][1],a[i-1][2]);
                    a[i][j]+=maxx;
                }
                else if(j==1)
                {
                    maxx=max(a[i-1][0],a[i-1][2]);
                    a[i][j]+=maxx;
                }
                else{
                    maxx=max(a[i-1][1],a[i-1][0]);
                    a[i][j]+=maxx;
                }
            }
        }
        ll ans=INT_MIN;
        for(j=0;j<3;j++)
        {
            ans=max(ans,a[n-1][j]);
        }
        cout<<ans;
        return 0;
}


Measured memory_bytes: 2560
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;

int s, t;

struct edge {
	int a, b, c, f;
	ll w;
};

const int N = 3000;

vector<edge> ed;
vector<int> eds[N];

void add_edge(int a, int b, int c, ll w) {
	edge x;
	x.a = a, x.b = b, x.c = c, x.f = 0, x.w = w;
	eds[a].push_back(ed.size());
	ed.push_back(x);
	swap(x.a, x.b), x.c = 0, x.w = -w;
	eds[b].push_back(ed.size());
	ed.push_back(x);
}

const ll INF = 1e18;

ll dd[N];
int go[N];
int en[N];

queue<int> qu;


ll flow() {
	ll ans = 0;
	while (true) {
		fill(dd, dd + t + 1, INF);
		fill(en, en + t + 1, 0);
		dd[s] = 0;
		qu.push(s);
		en[s] = 1;
		while (!qu.empty()) {
			int x = qu.front();
			qu.pop();
			en[x] = 0;
			for (int e: eds[x]) {
				if (ed[e].c == ed[e].f)
					continue;
				int u = ed[e].b;
				if (dd[u] > dd[x] + ed[e].w) {
					dd[u] = dd[x] + ed[e].w;
					go[u] = e;
					if (!en[u])
						en[u] = 1, qu.push(u);
				}
			}
		}
		if (dd[t] >= INF)
			break;
		int mn = 100;
		int now = t;
		while (now != s) {
			int e = go[now];
			mn = min(mn, ed[e].c - ed[e].f);
			now = ed[e].a;
		}
		ans += mn * dd[t];
		now = t;
		while (now != s) {
			int e = go[now];
			ed[e].f += mn;
			ed[e ^ 1].f -= mn;
			now = ed[e].a;
		}
	}
	return ans;
}


int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	s = 2 * n + 4;
	t = s + 1;
	for (int i = 0; i < n; ++i) {
		int x, y, c;
		cin >> x >> y >> c;
		add_edge(s, i, c, 0);
		add_edge(i, 2 * n, c, x + y);
		add_edge(i, 2 * n + 1, c, -x + y);
		add_edge(i, 2 * n + 2, c, x - y);
		add_edge(i, 2 * n + 3, c, -x - y);
	}
	for (int i = 0; i < n; ++i) {
		int x, y, c;
		cin >> x >> y >> c;
		add_edge(n + i, t, c, 0);
		add_edge(2 * n + 3, n + i, c, x + y);
		add_edge(2 * n + 2, n + i, c, -x + y);
		add_edge( 2 * n + 1, n + i, c, x - y);
		add_edge(2 * n + 0, n + i, c, -x - y);
	}
	cout << -flow() << "\n";
	return 0;
}




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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    VV g(n);
    rep(i,n){
        ll u,k;
        cin>>u>>k;
        u--;
        rep(j,k){
            ll x;
            cin>>x;
            x--;
            g[u].pb(x);
        }
    }

    Vec d(n,-1);
    Vec f(n,-1);
    ll time = 0;
    auto dfs = [&](auto dfs,ll v)->void{
        Each(x,g[v]){
            if(d[x]==-1){
                time++;
                d[x] = time;
                dfs(dfs,x);
            }
        }
        if(f[v]==-1){
            time++;
            f[v] = time;
        }
    };
    rep(i,n){
        if(d[i]==-1){
            time++;
            d[i] = time;
        }
        dfs(dfs,i);
    }
    rep(i,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return  0;
}



Measured memory_bytes: 3216
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M, K = (int(i) for i in input().split())
    par = [i for i in range(N)]
    rank = [0 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    fre = [set() for _ in range(N)]
    blo = [set() for _ in range(N)]
    mem = {i for i in range(N)}
    for i in [0]*M:
        a, b = (int(i) for i in input().split())
        fre[a-1].add(b-1)
        fre[b-1].add(a-1)
        unite(a-1, b-1)
    cur = [-1]*N
    from collections import Counter
    for i, x in enumerate(par):
        unite(i, x)
    c = Counter(par)
    # print(par, is_same_group(5, 7))
    for i in [0]*K:
        a, b = (int(i) for i in input().split())
        if is_same_group(a-1, b-1):
            blo[a-1].add(b-1)
            blo[b-1].add(a-1)
    for i in range(N):
        cur = c[par[i]] - len(fre[i]) - len(blo[i]) - 1
        print(cur, end=" ")
    print()


if __name__ == '__main__':
    main()


Measured memory_bytes: 126624
#include <stdio.h>
 
int main(void)
{
    int m, f, r, sum;
 
    while(1)
	{
        scanf("%d%d%d", &m, &f, &r);
        
		sum = m+f;
        
		if(m==-1 && f==-1 && r==-1)
        {
			break;
		}
        
		if(m==-1 || f==-1)
        {
			printf("F\n");
		}
        
		else if(sum  >= 80)
        {
			printf("A\n");
		}
        
		else if(sum >= 65)
        {
			printf("B\n");
		}
        
		else if(sum >= 50)
        {
			printf("C\n");
		}
        
		else if(sum >= 30)
        {
			if(r >= 50)
            {
				printf("C\n");
			}
            
			else
            {
				printf("D\n");
			}
		}
        
		else
        {	
			printf("F\n");
		}
    }
    
	return 0;
}

Measured memory_bytes: 584
while 1:
    t = int(input())
    if t == 0:
        break
  
    n = int(input())
  
    ans = 0
    for _ in range(n):
        s, f = map(int, input().split())
        ans += f - s
  
    if ans >= t:
        print("OK")
    else:
        print(t - ans)


Measured memory_bytes: 5596
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
	int ans = 0;
	string S;
//	scanf("%s",&S);
	cin >> S;
	for (int i = 0; i < S.size(); ++i) {
		if(S[S.size()-1-i] == 'Z'){
			ans = S.size()-i;
			break;
		}
	}
	for (int i = 0; i < S.size(); ++i) {
		if(S[i] == 'A'){
			ans -= i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
"use strict"
function main(arg) {
    arg = arg.trim().split("\n")
    var nm = arg.shift().split(" ").map(Number)
    var n = nm[0]
    var m = nm[1]
    var p = arg.pop().split(" ").map(Number)
    // var k = []
    var s = []
    for (var i = 0; i < arg.length; i++) {
        var tmp = arg[i].split(" ").map(e => Number(e) - 1)
        tmp.shift()
        s.push(tmp)
    }
    var maps = getOnOffMap(n)
    var switchies_history = []
    var result = 0
    for (var i = 0; i < maps.length; i++) {
        var rule = maps[i]
        var switchies_history_row = []
        for (var j = 0; j < s.length; j++) {
            var count = 0
            for (var k = 0; k < s[j].length; k++) {
                var sw = s[j][k]
                if (rule[sw]) {
                    count++
                }
            }
            // 点灯するか?
            if (count % 2 === p[j]) {
                switchies_history_row.push(true)
            } else {
                switchies_history_row.push(false)
            }
        }
        // switchies_history.push(switchies_history_row)
        // console.log(switchies_history_row)
        var tmp_result_flg = true
        for (var j = 0; j < switchies_history_row.length; j++) {
            if (!switchies_history_row[j]) {
                tmp_result_flg = false
            }
        }
        if (tmp_result_flg) {
            result++
        }
    }
    console.log(result)
    // console.log(JSON.stringify(maps,null,"\t"))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

//0:on, 1:off
function getOnOffMap(s) {
    var maxLength = (Math.pow(2, s) - 1).toString(2).length
    var result = []
    for (var i = 0; i < Math.pow(2, s); i++) {
        var row = i.toString(2)
        var prefix = ''
        for (var j = row.length; j < maxLength; j++) {
            prefix += '0'
        }
        result.push((prefix + row).split("").map(e => {
            if (e === '0') return true
            if (e === '1') return false
        }))
    }
    return result
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n;
    scn(n);

    vector<int>dp(n+3,0);
    int a[n+1];

    for(int i=1; i<=n; i++)scn(a[i]);

    for(int i=2; i<=n; i++){
        dp[i] = abs(a[i]-a[i-1]) + dp[i-1];
        if(i>2) dp[i] = min(dp[i] , abs(a[i]-a[i-2]) + dp[i-2]);
    }
    cout<<dp[n];
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI3(a, b, h);
  print((a + b) * h / 2);
  return 0;
}

Measured memory_bytes: 256
import java.lang.Math.*


fun main(args: Array<String>) {
    val n = readLongList().first()
    val a = mutableListOf<Long>()

    var max1 = 0L
    var max2 = 0L
    n.rep {
        val _a = readLongList().first()
        a.add(_a)
        if (max1 < _a) {
            max2 = max1
            max1 = _a
        } else if (max2 < _a) {
            max2 = _a
        }
    }

    n.rep {
        if (a[it.toInt()] == max1) {
            println(max2)
        } else {
            println(max1)
        }
    }
}


fun readList() = readLine()!!.split(' ')
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

Measured memory_bytes: 79580
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int S;
    cin >> S;
    while (S--)
    {
        ll mask = 0, K;
        vector<ll> v(8);
        string s;
        for (int i = 0; i < 8; i++)
        {
            cin >> s;
            v[i] = stol(s, nullptr, 16);
        }
        cin >> s;
        K = stol(s, nullptr, 16);
        for (int i = 0; i < 32; i++)
        {
            ll tmp = 0;
            for (int j = 0; j < 8; j++)
            {
                tmp += v[j] ^ mask;
            }
            if ((tmp & ((1LL << (i + 1)) - 1)) == ((K ^ mask) & ((1LL << (i + 1)) - 1)))
            {
                continue;
            }
            mask |= (1LL << i);
        }
        cout << hex << mask << endl;
    }
}



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

int main() {
  string str;
  cin >> str;
  
  int cnt = 0;
  for(int i = 0; i < str.length()/2; i++) {
  	if(str[i] != str[str.length()-1-i]) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

/*
 size < 26,
 append the smallest remaining

 size = 26
 find first out of order one, replace that with the first one
 */
int const MaxSize = 1e5 + 5;
string S;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> S;

	set<char> seen;

	LP(i, 0, S.size())
	{
		seen.insert(S[i]);
	}

	if (S.size() < 26) {

		LP(i, 0, 26)
		{
			char c = 'a' + i;

			if (seen.count(c)) {

			} else {
				cout << S;
				cout << c;
				return 0;
			}
		}
	} else {
		for (int i = S.size() - 2; i >= 0; i--) {
			if (S[i] < S[i + 1]) {

				LP(j, 0, i)
				{
					cout << S[j];
				}

				for (int j = S.size() - 1; j >= i; j--) {
					if (S[j] > S[i]) {
						cout << S[j];
						return 0;
					}

				}
			}
		}

		cout << -1;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    if(N < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 5*1e5 + 10;
// make sure N size is correctttt!!!!!!!!!

const int T = 55;

ll G[T][T], Z = 55, k, n;
void multiply(ll F[T][T], ll F2[T][T]){
   ll res[T][T];

   for (int i = 0; i < Z ; ++i){//row
      for (int j = 0; j < Z ; ++j){//column
         res[i][j] = 0;
         for (int k = 0; k < Z ; ++k){
            res[i][j] += (F[i][k] * F2[k][j]) % mod;
            while(res[i][j] >= mod)res[i][j] -= mod;
         }
      }
   }

   for (ll i = 0; i <Z ; ++i)
      for (ll j = 0; j <Z ; ++j){
         F[i][j] = res[i][j];
         if(F[i][j] >= mod)F[i][j] -= mod;
      }
}

void findnth(ll F[T][T], ll n){
   if(n == 0 or n == 1)
      return;

   ll M[T][T];

   for (int i = 0; i < Z; ++i)
   {
      for (int j = 0; j < Z; ++j)
      {
         M[i][j] = G[i][j];
      }
   }

   findnth(F, n/2);
   multiply(F, F);
   if(n&1)multiply(F, M);
}

int32_t main(){_

   cin>>n>>k;
   Z = n;

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < n; ++j)
      {
         cin>>G[i][j];
      }
   }
      
   findnth(G, k);

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < n; ++j)
      {
         ans += G[i][j];
         ans %= mod;
      }
   }

   cout<<ans;
   return 0;
}

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

const int MAX_DIGIT = 50;//50桁と仮定
ll dp[100][2];//dp[上からi桁目まで][smaller]

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    memset(dp,-1,sizeof(dp));//dp配列を-1で初期化
    dp[0][0] = 0;//初期条件
    //配るdp
    rep(d,MAX_DIGIT){
        ll mask = 1LL<<(MAX_DIGIT - d - 1);

        //Aで元々d桁目にビットが立っているものの個数
        int num = 0;
        rep(i,N)if(A[i]&mask)++num;

        //xのd桁目を0,1にしたときのコスト
        ll cost0 = mask * num;
        ll cost1 = mask *(N-num);

        //smaller -> smaler
        if(dp[d][1] != -1){
            chmax(dp[d+1][1],dp[d][1] + max(cost0,cost1));//0でも1でも大きい方
        }
        //exact->smaller
        if(dp[d][0] != -1){
            if(K&mask){//Kのd桁目が1だったらxのd桁目は0にする
                chmax(dp[d+1][1],dp[d][0]+cost0);
            }
        }
        //exact -> exact(Kにぴったり合わせる)
        if(dp[d][0]!= -1){
            if(K&mask)chmax(dp[d+1][0],dp[d][0]+cost1);
            else chmax(dp[d+1][0],dp[d][0]+cost0);
        }

    }
    cout << max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1]) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

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

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    rep(i, h) cin >> a[i];

    rep(i, w + 2) cout << '#'; cout << "\n";
    rep(i, h) cout << '#' << a[i] << '#' << endl;
    rep(i, w + 2) cout << '#'; cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = max(a * c, max(a * d, max(b * c, b * d)));
  if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) {
    ans = max(ans, 0LL);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LL long long
#define LD long double
#define FOR(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RFOR(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define int LL
using namespace std;

typedef pair<int,int> PII;
typedef pair<int,PII> PIII;
typedef vector<int> VI;

const int MX = 1e5+1;

signed main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    if(k>(n+1)/2)
    	cout<<"NO";
    else
    	cout<<"YES";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main(void) {
  char n[20];
  scanf("%s", n);
  int ans = strlen(n) * 9 - 9;
  //printf("%d ", ans);
  ans += (int)n[0] - 1;
  ans -= '0';
  int s = 0;
  for(int i = 1; i < strlen(n); ++i) if(n[i] != '9'){s = 1; break;}
  if(!s)++ans;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e18 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	int a, b;
	cin >> a >> b;
	ll a1 = a + b;
	ll a2 = a - b;
	ll a3 = a * b;
	cout << max(max(a1, a2), a3) << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  vector<int> H(N+1);
  H.at(0)=0;
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    H.at(i+1)=h.at(i);
  }
  int ans=0;
  int s=-1;
  int g=0;
  for (int i = 0; i < N; i++) {
    if(H.at(i)<=H.at(i+1)){
      g++;
    }    
    else{
      s++;
      ans+=H.at(g)-H.at(s);
      s=i;
      g=i+1; 
    }
  }  
  s++;
  ans+=H.at(g)-H.at(s);
    cout<<ans<<endl;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> A(N) ; 
  for(int i = 0 ; i < N ; i++) cin >> A.at(i) ; 
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end()) ;
  
  int SUM_L = 0 ; 
  for(int i = 1 ; i < N ; i++) SUM_L += A.at(i) ; 
  
  if(SUM_L > A.at(0)){
    cout << "Yes" << endl ;
  }
  else{
    cout << "No" << endl ; 
  }
}

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

int main(){
  long long n, k;
  cin >> n >> k;

  if(k == 0){
    cout << n*n << endl;
    return 0;
  }


  long long ans = 0;
  long long tmp;

  for(int i = 1;i <= n;i++){
    tmp = (i-k);
    if(tmp > 0){
      ans += (n/i)*(tmp);
      if(n%i >= k){
        ans += n%i-(k-1);
      }
    }
  }

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



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


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

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

	long long c[10] = {};
	c[0] = (long long)(h - 2)*(w - 2);
	set<pair<int, int>> s;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		int f[5][5];
		for (int t = -2; t <= 2; t++) {
			for (int l = -2; l <= 2; l++) {
				f[t + 2][l + 2] = s.count(make_pair(t + a, l + b));
			}
		}


		for (int t = -2; t <= 0; t++) {
			for (int l = -2; l <= 0; l++) {
				if (!(0 < a + t && 0 < b + l && a + t + 2 <= h && b + l + 2 <= w))continue;
				int cnt = 0;
				rep(dy,3)rep(dx,3) {
					cnt += f[2 + t + dy][2 + l + dx];
				}
				c[cnt]--;
				c[cnt + 1]++;
			}
		}
		s.insert(make_pair(a, b));
	}
	rep(i, 10)cout << c[i] << endl;

	return 0;
}

Measured memory_bytes: 4992
package main

import (
	"fmt"
	"sort"
	"strings"
)

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}

func main() {
	// Code for A - abc of ABC
	var S string
	fmt.Scanf("%s", &S)
	S = sortString(S)

	if S == "abc" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

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

    return 0;
    
}

Measured memory_bytes: 256
n,m,l = gets.split(" ").map(&:to_i)
a = []
b = []
c = Array.new(n).map{Array.new(l,0)}
n.times do
  a<<gets.split(" ").map(&:to_i)
end
m.times do
  b<<gets.split(" ").map(&:to_i)
end
bt = b.transpose
n.times do |i|
  l.times do |j|
    c[i][j] = [a[i],bt[j]].transpose.map{|t| t.inject(:*)}.inject(:+)
  end
end
puts c.map{|r| r.join(" ")}

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

//int _; 

long long n,a[200020],ans=0;
map<int,int> mp; 

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans += mp[i-a[i]];
		mp[i+a[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22060
from itertools import product as p
n,k=map(int,input().split())
a=list(map(int,input().split()))
an=float("INF")
for i in p([0,1],repeat=n):
    s=0
    c=a[::]
    p=0
    q=0
    for j in range(n):
        if i[j]:
            if s<c[j]:
                p+=1
                s=c[j]
            else:
                q+=s+1-c[j]
                c[j]=s+1
                p+=1
                s+=1
        else:
            if s<c[j]:
                p+=1
                s=c[j]
    if p>=k:
        an=min(q,an)
print(an)

Measured memory_bytes: 3064
object Main{
  def main(args:Array[String]) = {
    val lines = for{
      in <-scala.io.Source.stdin.getLines()
    }yield if(isPrime(in.toInt)) in else -1

    println(lines.filter(_ != -1).length)
  }
  def isPrime(n : Int) : Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)
}

Measured memory_bytes: 101412
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

bool solve() {
    int l = s.size();
    int i = 0;
    while (i < l) {
        if (s.substr(i, 5) == "dream") {
            i += 5;
            if (i < l && s.substr(i, 5) != "erase" && s.substr(i, 2) == "er") {
                i += 2;
            }
        } else if (s.substr(i, 5) == "erase") {
            i += 5;
            if (i < l && s[i] == 'r') i++;
        } else {
            return false;
        }
    }
    return true;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	string a, b;
	cin >> a;
	int cnt = 0;
	b = "CODEFESTIVAL2016";
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int sum = 0, temp = n;
    while (temp > 0)
    {
        sum += temp % 10;
        temp /= 10;
    }
    if (n % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;
    ll k;
    cin>>n>>k;
    vl a(n),f(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>f[i];

    sort(all(a));
    sort(all(f),greater<ll>());

    ll tmpk=k,ans=0;
    rep(i,n){
        if(a[i]<=tmpk){
            tmpk-=a[i];
        }else{
            maxs(ans,a[i]*f[i]);
        }
    }

    ll l=0,r=ans;
    while(l!=r){
        ll i=(l+r)/2;
        int frag=0;
        tmpk=k;
        rep(j,n){
            if(a[j]*f[j]>i){
                tmpk-=((f[j]-1+a[j]*f[j]-i)/f[j]);
            }
            if(tmpk<0){
                l=i+1;
                frag=1;
                break;
            }
        }
        if(frag==0)r=i;
    }

    cout<<r<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{

	long double A,B,H,M;
	cin>>A>>B>>H>>M;
	long double hourangle=0.5*(H*60+M);
	long double minangle=6*M;
	long double angle=abs(hourangle-minangle);
	angle=min(360-angle,angle);
    long double result=cos(angle*3.141592653589793/180);
    long double y=A*A+B*B-2*A*B*result;
     long double dist=sqrt(y);
cout<<fixed<<setprecision(10);
     cout<<dist;
 }

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

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

using namespace std;
using ll = long long;
const ll INF = 100000000;


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int cnt = 0;
    while (b <= a) {
        b = b * 2;
        cnt++;
        if (cnt > k) {
            cout << "No";
            return 0;
        }
    }
    while (c <= b) {
        c = c * 2;
        cnt++;
        if (cnt > k) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3580